diff --git a/packages/ripple-binary-codec/src/enums/definitions.json b/packages/ripple-binary-codec/src/enums/definitions.json index 15900a21..83c78626 100644 --- a/packages/ripple-binary-codec/src/enums/definitions.json +++ b/packages/ripple-binary-codec/src/enums/definitions.json @@ -1426,6 +1426,26 @@ "isSigningField": true, "type": "UInt32" } + ], + [ + "SettleDelay", + { + "nth": 39, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "Channel", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } ] ], "TRANSACTION_RESULTS": { @@ -1539,6 +1559,9 @@ "SuspendedPaymentCreate": 1, "SuspendedPaymentFinish": 2, "SuspendedPaymentCancel": 4, + "PaymentChannelCreate": 13, + "PaymentChannelFund": 14, + "PaymentChannelClaim": 15, "Invalid": -1 } } diff --git a/packages/ripple-binary-codec/test/binary-serializer-test.js b/packages/ripple-binary-codec/test/binary-serializer-test.js index 3764fed5..c0023b09 100644 --- a/packages/ripple-binary-codec/test/binary-serializer-test.js +++ b/packages/ripple-binary-codec/test/binary-serializer-test.js @@ -15,6 +15,20 @@ const SignerListSet = { binary: require('./fixtures/signerlistset-tx-binary.json'), meta: require('./fixtures/signerlistset-tx-meta-binary.json') }; +const PaymentChannel = { + create: { + tx: require('./fixtures/payment-channel-create-tx.json'), + binary: require('./fixtures/payment-channel-create-binary.json') + }, + fund: { + tx: require('./fixtures/payment-channel-fund-tx.json'), + binary: require('./fixtures/payment-channel-fund-binary.json') + }, + claim: { + tx: require('./fixtures/payment-channel-claim-tx.json'), + binary: require('./fixtures/payment-channel-claim-binary.json') + } +} function bytesListTest() { const list = new BytesList().put([0]).put([2, 3]).put([4, 5]); @@ -106,6 +120,21 @@ function SignerListSetTest() { }); } +function PaymentChannelTest() { + it('can serialize PaymentChannelCreate', () => { + assert.strictEqual(encode(PaymentChannel.create.tx), + PaymentChannel.create.binary); + }); + it('can serialize PaymentChannelFund', () => { + assert.strictEqual(encode(PaymentChannel.fund.tx), + PaymentChannel.fund.binary); + }); + it('can serialize PaymentChannelClaim', () => { + assert.strictEqual(encode(PaymentChannel.claim.tx), + PaymentChannel.claim.binary); + }); +} + describe('Binary Serialization', function() { describe.skip('parseLedger4320278', parseLedger4320278); describe('nestedObjectTests', nestedObjectTests); @@ -113,4 +142,5 @@ describe('Binary Serialization', function() { describe('BytesList', bytesListTest); describe('DeliverMin', deliverMinTest); describe('SignerListSet', SignerListSetTest); + describe('PaymentChannel', PaymentChannelTest); }); diff --git a/packages/ripple-binary-codec/test/fixtures/payment-channel-claim-binary.json b/packages/ripple-binary-codec/test/fixtures/payment-channel-claim-binary.json new file mode 100644 index 00000000..e6d86042 --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/payment-channel-claim-binary.json @@ -0,0 +1 @@ +"12000F5016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA61986140000000000F42406240000000000F4240712132D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A764630440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B" diff --git a/packages/ripple-binary-codec/test/fixtures/payment-channel-claim-tx.json b/packages/ripple-binary-codec/test/fixtures/payment-channel-claim-tx.json new file mode 100644 index 00000000..7c6a165d --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/payment-channel-claim-tx.json @@ -0,0 +1,8 @@ +{ + "TransactionType": "PaymentChannelClaim", + "Channel": "C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198", + "Balance": "1000000", + "Amount": "1000000", + "Signature": "30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B", + "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A" +} diff --git a/packages/ripple-binary-codec/test/fixtures/payment-channel-create-binary.json b/packages/ripple-binary-codec/test/fixtures/payment-channel-create-binary.json new file mode 100644 index 00000000..24ac25df --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/payment-channel-create-binary.json @@ -0,0 +1 @@ +"12000D2300002DE32E00005BB820241FC78D66202700015180614000000000002710712132D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A81144B4E9C06F24296074F7BC48F92A97916C6DC5EA98314204288D2E47F8EF6C99BCC457966320D12409711" diff --git a/packages/ripple-binary-codec/test/fixtures/payment-channel-create-tx.json b/packages/ripple-binary-codec/test/fixtures/payment-channel-create-tx.json new file mode 100644 index 00000000..c886fdee --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/payment-channel-create-tx.json @@ -0,0 +1,11 @@ +{ + "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "TransactionType": "PaymentChannelCreate", + "Amount": "10000", + "Destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW", + "SettleDelay": 86400, + "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A", + "CancelAfter": 533171558, + "DestinationTag": 23480, + "SourceTag": 11747 +} diff --git a/packages/ripple-binary-codec/test/fixtures/payment-channel-fund-binary.json b/packages/ripple-binary-codec/test/fixtures/payment-channel-fund-binary.json new file mode 100644 index 00000000..4c813e12 --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/payment-channel-fund-binary.json @@ -0,0 +1 @@ +"12000E2A206023E65016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198614000000000030D4081144B4E9C06F24296074F7BC48F92A97916C6DC5EA9" diff --git a/packages/ripple-binary-codec/test/fixtures/payment-channel-fund-tx.json b/packages/ripple-binary-codec/test/fixtures/payment-channel-fund-tx.json new file mode 100644 index 00000000..5fb94b7a --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/payment-channel-fund-tx.json @@ -0,0 +1,7 @@ +{ + "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", + "TransactionType": "PaymentChannelFund", + "Channel": "C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198", + "Amount": "200000", + "Expiration": 543171558 +}