7 月 272018
 

托管交易字段构造

{
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"TransactionType": "EscrowCreate",
"Amount": "10000",
"Destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"CancelAfter": 533257958,
"FinishAfter": 533171558,
"Condition": "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
"DestinationTag": 23480,
"SourceTag": 11747
}

交易字段CancelAfter和FinishAfter必须指定,且FinishAfter指定的时间点必须早于CancelAfter指定的时间点。
在修正案fix1571(于1.0.0版本引入)(当前已生效)中要求,必须指定FinishAfter字段和Condition字段中的一个或全部。
时间戳指定的时间点,必须是自Ripple Epoch(Ripple纪元)(January 1, 2000 00:00 UTC)起所经历的秒数,且该值在交易提交后不可改变。

1)提交一笔基于时间的托管交易,等待托管过期,并取消交易

当前时间
[root@rippled ~]# date
Fri Jul 13 12:18:36 UTC 2018
在此时间后可取消交易
CancelAfter:2018-07-16 00:00
1531699200-946684800=585014400
在此时间后可提取资金
FinishAfter: 2018-07-14 00:00
1531526400-946684800=584841600

提交交易及交易返回(占用1个单位储备金额度,消耗10Drops,托管1XRP)

curl -k -H 'Content-Type: application/json' -X POST -d '
{
"method": "sign",
"params": [
{
"tx_json" : {
"TransactionType" : "EscrowCreate",
"Account" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"Destination" : "rPMDsqFDs8YGgfRvvEViC9Xbezw4hGsUgi",
"Amount" : 1000000,
"CancelAfter": 585014400,
"FinishAfter": 584841600
},
"secret" : "###",
"offline": false,
"fee_mult_max": 10
}
]
}' localhost:5005

F8937D49ABA8C3F616789FB9EB13DF42F6A6F863787E49C05C458480BB9A0489

托管未在有效期内提取,在达到可取消时间后,取消该笔托管交易,返还资金给付款方

curl -k -H 'Content-Type: application/json' -X POST -d '
{
"method": "sign",
"params": [
{
"tx_json" : {
"TransactionType" : "EscrowCancel",
"Account" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"Owner" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"OfferSequence": 34
},
"secret" : "###",
"offline": false,
"fee_mult_max": 10
}
]
}' localhost:5005

8AB365CD1A14B775CDB2CE1002BE5522B4064031EF1624393D5C66A64CEDDE11

2)提交一笔基于时间的托管交易,在托管提取有效期内提取资金

当前时间
[root@rippled ~]# date
Thu Jul 19 09:25:34 UTC 2018
基本时间计算
[root@rippled ~]# date -d ‘2018-07-19 10:00:00’ +%s
1531994400
[root@rippled ~]# date -d ‘2018-07-19 10:15:00’ +%s
1531995300
[root@rippled ~]#
在此时间后可取消交易
CancelAfter:2018-07-19 10:15:00
1531995300-946684800= 585310500
在此时间后可提取资金
FinishAfter: 2018-07-19 10:00:00
1531994400-946684800= 585309600

提交托管交易

curl -k -H 'Content-Type: application/json' -X POST -d '
{
"method": "sign",
"params": [
{
"tx_json" : {
"TransactionType" : "EscrowCreate",
"Account" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"Destination" : "rPMDsqFDs8YGgfRvvEViC9Xbezw4hGsUgi",
"Amount" : 1000000,
"CancelAfter": 585310500,
"FinishAfter": 585309600
},
"secret" : "###",
"offline": false,
"fee_mult_max": 10
}
]
}' localhost:5005

0939A6DD03C52812304B8D136A8E8A4410857454443D8870E1F16C409171A661

提取托管资金

curl -k -H 'Content-Type: application/json' -X POST -d '
{
"method": "sign",
"params": [
{
"tx_json" : {
"TransactionType" : "EscrowFinish",
"Account" : "rPMDsqFDs8YGgfRvvEViC9Xbezw4hGsUgi",
"Owner" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"OfferSequence": 36
},
"secret" : "###",
"offline": false,
"fee_mult_max": 10
}
]
}' localhost:5005

未到可提取时间点时提取的交易返回

[root@rippled ~]# date
Thu Jul 19 09:37:12 UTC 2018
[root@rippled ~]#

{
"result" : {
"engine_result" : "tecNO_PERMISSION",
"engine_result_code" : 139,
"engine_result_message" : "No permission to perform requested operation.",
"status" : "success",
"tx_blob" : "1200022280000000240000001520190000002468400000000000000A732103F9B92F34FC2C0E873543D18B6B792F2325D3D592F4BF99F1905151C7A0538A1A744730450221009BFCAA9C24E2522A5BB5FB58C286D45B9D4C54AAC86A5E6B08DE87DFAC14778602200EE80148B6EE354F8B7AE2A3BD290A328AFEFF50D91D879827CD4DF9D77AF4488114F52524FC1F994334DDE86CC633E2383928B67A5582140ED68995C96301AF05997C7242D6F75371F3587F",
"tx_json" : {
"Account" : "rPMDsqFDs8YGgfRvvEViC9Xbezw4hGsUgi",
"Fee" : "10",
"Flags" : 2147483648,
"OfferSequence" : 36,
"Owner" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"Sequence" : 21,
"SigningPubKey" : "03F9B92F34FC2C0E873543D18B6B792F2325D3D592F4BF99F1905151C7A0538A1A",
"TransactionType" : "EscrowFinish",
"TxnSignature" : "30450221009BFCAA9C24E2522A5BB5FB58C286D45B9D4C54AAC86A5E6B08DE87DFAC14778602200EE80148B6EE354F8B7AE2A3BD290A328AFEFF50D91D879827CD4DF9D77AF448",
"hash" : "3C84D69EFAE8C4C607B072E04D1EC22227BB2554FB5EB1AD93EFE5F049557B7F"
}
}
}

到达可提取时间点后提取的交易返回

[root@rippled ~]# date
Thu Jul 19 10:00:20 UTC 2018
[root@rippled ~]#

{
"result" : {
"engine_result" : "tesSUCCESS",
"engine_result_code" : 0,
"engine_result_message" : "The transaction was applied. Only final in a validated ledger.",
"status" : "success",
"tx_blob" : "1200022280000000240000001620190000002468400000000000000A732103F9B92F34FC2C0E873543D18B6B792F2325D3D592F4BF99F1905151C7A0538A1A7446304402205BBE5FDD7A67AB638016CAFA2513E472E510E6B7976607385617E3A9E1FF6E0702201216F0FC3C3B6BBA8249EE9828666E47CAB553AF25CBAA76E1484C00582AB4EC8114F52524FC1F994334DDE86CC633E2383928B67A5582140ED68995C96301AF05997C7242D6F75371F3587F",
"tx_json" : {
"Account" : "rPMDsqFDs8YGgfRvvEViC9Xbezw4hGsUgi",
"Fee" : "10",
"Flags" : 2147483648,
"OfferSequence" : 36,
"Owner" : "rpMT7rVHb9wskPVZHycRqXjrHH6Jc9dDv5",
"Sequence" : 22,
"SigningPubKey" : "03F9B92F34FC2C0E873543D18B6B792F2325D3D592F4BF99F1905151C7A0538A1A",
"TransactionType" : "EscrowFinish",
"TxnSignature" : "304402205BBE5FDD7A67AB638016CAFA2513E472E510E6B7976607385617E3A9E1FF6E0702201216F0FC3C3B6BBA8249EE9828666E47CAB553AF25CBAA76E1484C00582AB4EC",
"hash" : "64EFAE4DB75B69627F3EBF7D4850655AC18350A997985BBB9B68A7742C26A7F2"
}
}
}

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据