Add escrow support

This commit is contained in:
wilsonianb
2017-03-20 15:30:48 -07:00
parent e897daf443
commit 9ddb6498b0
9 changed files with 87 additions and 12 deletions

View File

@@ -30,10 +30,11 @@
"AccountRoot": 97,
"RippleState": 114,
"FeeSettings": 115,
"SuspendedPayment": 117,
"Escrow": 117,
"DirectoryNode": 100,
"GeneratorMap": 103,
"Contract": 99,
"PayChannel": 120,
"Invalid": -1
},
"FIELDS": [
@@ -988,7 +989,17 @@
}
],
[
"Proof",
"Fulfillment",
{
"nth": 16,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Blob"
}
],
[
"Condition",
{
"nth": 17,
"isVLEncoded": true,
@@ -1556,9 +1567,9 @@
"OfferCreate": 7,
"SignerListSet": 12,
"Contract": 9,
"SuspendedPaymentCreate": 1,
"SuspendedPaymentFinish": 2,
"SuspendedPaymentCancel": 4,
"EscrowCreate": 1,
"EscrowFinish": 2,
"EscrowCancel": 4,
"PaymentChannelCreate": 13,
"PaymentChannelFund": 14,
"PaymentChannelClaim": 15,

View File

@@ -15,6 +15,20 @@ const SignerListSet = {
binary: require('./fixtures/signerlistset-tx-binary.json'),
meta: require('./fixtures/signerlistset-tx-meta-binary.json')
};
const Escrow = {
create: {
tx: require('./fixtures/escrow-create-tx.json'),
binary: require('./fixtures/escrow-create-binary.json')
},
finish: {
tx: require('./fixtures/escrow-finish-tx.json'),
binary: require('./fixtures/escrow-finish-binary.json')
},
cancel: {
tx: require('./fixtures/escrow-cancel-tx.json'),
binary: require('./fixtures/escrow-cancel-binary.json')
}
}
const PaymentChannel = {
create: {
tx: require('./fixtures/payment-channel-create-tx.json'),
@@ -120,6 +134,21 @@ function SignerListSetTest() {
});
}
function EscrowTest() {
it('can serialize EscrowCreate', () => {
assert.strictEqual(encode(Escrow.create.tx),
Escrow.create.binary);
});
it('can serialize EscrowFinish', () => {
assert.strictEqual(encode(Escrow.finish.tx),
Escrow.finish.binary);
});
it('can serialize EscrowCancel', () => {
assert.strictEqual(encode(Escrow.cancel.tx),
Escrow.cancel.binary);
});
}
function PaymentChannelTest() {
it('can serialize PaymentChannelCreate', () => {
assert.strictEqual(encode(PaymentChannel.create.tx),
@@ -142,5 +171,6 @@ describe('Binary Serialization', function() {
describe('BytesList', bytesListTest);
describe('DeliverMin', deliverMinTest);
describe('SignerListSet', SignerListSetTest);
describe('Escrow', EscrowTest);
describe('PaymentChannel', PaymentChannelTest);
});

View File

@@ -681,7 +681,14 @@
},
{
"type_name": "Blob",
"name": "Proof",
"name": "Fulfillment",
"nth_of_type": 16,
"type": 7,
"expected_hex": "7010"
},
{
"type_name": "Blob",
"name": "Condition",
"nth_of_type": 17,
"type": 7,
"expected_hex": "7011"
@@ -2924,7 +2931,7 @@
"expected_hex": "0000"
},
{
"test_json": "SuspendedPaymentCreate",
"test_json": "EscrowCreate",
"type_id": 1,
"type_specialisation_field": "TransactionType",
"type": "UInt16",
@@ -2932,14 +2939,14 @@
},
{
"test_json": 1,
"canonical_json": "SuspendedPaymentCreate",
"canonical_json": "EscrowCreate",
"type_id": 1,
"type_specialisation_field": "TransactionType",
"type": "UInt16",
"expected_hex": "0001"
},
{
"test_json": "SuspendedPaymentFinish",
"test_json": "EscrowFinish",
"type_id": 1,
"type_specialisation_field": "TransactionType",
"type": "UInt16",
@@ -2947,7 +2954,7 @@
},
{
"test_json": 2,
"canonical_json": "SuspendedPaymentFinish",
"canonical_json": "EscrowFinish",
"type_id": 1,
"type_specialisation_field": "TransactionType",
"type": "UInt16",
@@ -2969,7 +2976,7 @@
"expected_hex": "0003"
},
{
"test_json": "SuspendedPaymentCancel",
"test_json": "EscrowCancel",
"type_id": 1,
"type_specialisation_field": "TransactionType",
"type": "UInt16",
@@ -2977,7 +2984,7 @@
},
{
"test_json": 4,
"canonical_json": "SuspendedPaymentCancel",
"canonical_json": "EscrowCancel",
"type_id": 1,
"type_specialisation_field": "TransactionType",
"type": "UInt16",

View File

@@ -0,0 +1 @@
"1200042019000000198114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8214EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA"

View File

@@ -0,0 +1,6 @@
{
"Account" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
"OfferSequence" : 25,
"Owner" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
"TransactionType" : "EscrowCancel"
}

View File

@@ -0,0 +1 @@
"1200012E00005BB82024258D09812025258D0980614000000000000064701127A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B8558101008114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8314B5F762798A53D543A014CAF8B297CFF8F2F937E8"

View File

@@ -0,0 +1,10 @@
{
"Account" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
"Amount" : "100",
"CancelAfter" : 630000001,
"Condition" : "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
"Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"DestinationTag" : 23480,
"FinishAfter" : 630000000,
"TransactionType": "EscrowCreate"
}

View File

@@ -0,0 +1 @@
"120002201900000007701004A0028000701127A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B8558101008114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8214EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA"

View File

@@ -0,0 +1,8 @@
{
"Account" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
"Condition" : "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
"Fulfillment" : "A0028000",
"OfferSequence" : 7,
"Owner" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
"TransactionType" : "EscrowFinish"
}