Add support for PaymentChannel transactions

This commit is contained in:
Ben Sharafian
2017-02-17 16:29:17 +01:00
parent c516ed4972
commit 5cf4301fd0
8 changed files with 82 additions and 0 deletions

View File

@@ -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
}
}

View File

@@ -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);
});

View File

@@ -0,0 +1 @@
"12000F5016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA61986140000000000F42406240000000000F4240712132D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A764630440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B"

View File

@@ -0,0 +1,8 @@
{
"TransactionType": "PaymentChannelClaim",
"Channel": "C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
"Balance": "1000000",
"Amount": "1000000",
"Signature": "30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B",
"PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A"
}

View File

@@ -0,0 +1 @@
"12000D2300002DE32E00005BB820241FC78D66202700015180614000000000002710712132D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A81144B4E9C06F24296074F7BC48F92A97916C6DC5EA98314204288D2E47F8EF6C99BCC457966320D12409711"

View File

@@ -0,0 +1,11 @@
{
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"TransactionType": "PaymentChannelCreate",
"Amount": "10000",
"Destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"SettleDelay": 86400,
"PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A",
"CancelAfter": 533171558,
"DestinationTag": 23480,
"SourceTag": 11747
}

View File

@@ -0,0 +1 @@
"12000E2A206023E65016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198614000000000030D4081144B4E9C06F24296074F7BC48F92A97916C6DC5EA9"

View File

@@ -0,0 +1,7 @@
{
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"TransactionType": "PaymentChannelFund",
"Channel": "C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
"Amount": "200000",
"Expiration": 543171558
}