在 Ripple 中發送交叉貨幣
我一直在使用 Ripple JSON RPC 面臨這個問題,實際上我正在為跨境交易開發 PoC,作為我的案例的一部分,我需要以 NGN 發送交易並以美元/歐元接收。
我已經閱讀了您的 David Schwartz 回复<https://forum.ripple.com/viewtopic.php?f=2&t=15980>和<https://forum.ripple.com/viewtopic.php?f=2&t=8079>但仍然交易有問題
這是我的要求
{ "method": "submit", "params": [ { "offline": false, "secret": "sssssssssssssssssssssss", "tx_json": { "SendMax" : { "currency" : "USD", "value" : "200", "issuer" : "rU3BENzHa5SeB2HnwzovG5wdk7v8ChxXrc" }, "Account": "rU3BENzHa5SeB2HnwzovG5wdk7v8ChxXrc", "Amount":{ "value": "100", "issuer": "rK6qNr9HV62gJPRvKGNen1qHi2LYyHSDvj", "currency": "NGN" }, "Destination": "rK6qNr9HV62gJPRvKGNen1qHi2LYyHSDvj", "TransactionType": "Payment" }, "fee_mult_max": 10000 } ] }
我得到了這個作為我的回應
{ "result": { "engine_result": "tecPATH_PARTIAL", "engine_result_code": 101, "engine_result_message": "Path could not send full amount.", "status": "success", "tx_blob": "1200002280000000240000005661D5038D7EA4C680000000000000000000000000004E474E0000000000CD2B28791E0BEB754A75AF8DB99BDEF21DD8D4A968400000000000000A69D5071AFD498D000000000000000000000000000055534400000000007A04D90FD6B8D1400B5CD796391444090AF06C1F7321031810282977B92281325F0AC5DAF4AB7EDB3FBBE5404A38D657E327B1A46B7897744730450221008269F1C23E2C719A73F7F41D484C0577C1EBF496D8BD6009AA975A852C627E7202207FBD5CBA3EF5F5BE7696FAF5C45F2E22BDCEA7FD48BA99D75897BF58C474BD0D81147A04D90FD6B8D1400B5CD796391444090AF06C1F8314CD2B28791E0BEB754A75AF8DB99BDEF21DD8D4A9", "tx_json": { "Account": "rU3BENzHa5SeB2HnwzovG5wdk7v8ChxXrc", "Amount": { "currency": "NGN", "issuer": "rK6qNr9HV62gJPRvKGNen1qHi2LYyHSDvj", "value": "100" }, "Destination": "rK6qNr9HV62gJPRvKGNen1qHi2LYyHSDvj", "Fee": "10", "Flags": 2147483648, "SendMax": { "currency": "USD", "issuer": "rU3BENzHa5SeB2HnwzovG5wdk7v8ChxXrc", "value": "200" }, "Sequence": 86, "SigningPubKey": "031810282977B92281325F0AC5DAF4AB7EDB3FBBE5404A38D657E327B1A46B7897", "TransactionType": "Payment", "TxnSignature": "30450221008269F1C23E2C719A73F7F41D484C0577C1EBF496D8BD6009AA975A852C627E7202207FBD5CBA3EF5F5BE7696FAF5C45F2E22BDCEA7FD48BA99D75897BF58C474BD0D", "hash": "A658DE84ABFED32E0E52FBF02E60FBC81E32C5E6186427C33AEBD938188FE4BB" } } }
我了解 tecPATH_PARTIAL 表示交易失敗,因為提供的路徑沒有足夠的流動性來發送全部金額。
但是我沒有指定路徑 bcos 我理解最好在波紋選擇路徑時。
我將不勝感激任何正確方向的幫助
<https://bitcoin.stackexchange.com/users/85/david-schwartz>
所以,經過很多天,我能夠解決這個問題。我能夠將交易從一位擁有 (NGN) 的客戶發送給另一位以 (USD) 收到交易的客戶。
對於將來可能面臨類似問題的其他人,這是我為解決此問題而採取的步驟。
第1步
我為所有貨幣創建了報價。請參閱下面的範例請求和響應
{ "method": "submit", "params": [ { "offline": false, "secret": "snYothV5CFDMpMYStmL5VwMHzxHFr", "fee_mult_max": 1000, "tx_json": { "TakerGets": { "currency": "EUR", "value": "0.94", "issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk" }, "TakerPays": { "currency": "USD", "value": "1", "issuer": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ" }, "Account": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk", "TransactionType": "OfferCreate", "Fee": "12", "Flags": "65536" } } ] }
和样本響應
{ "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": "1200072200010000240000001764D4838D7EA4C68000000000000000000000000000555344000000000045249D498FF76EF67DACD0958930DB02EE4A9D4465D46165400CE380000000000000000000000000004555520000000000C260B3831882A44608EE81C2F3726AA72D11CA9568400000000000000C732102272E391673B735C9D96435DAFF89F9EA7B4EC285C39643A754848EDE19A6542674473045022100CD7511B302ED7D0C299C0F2C1014EA5AA62F7584B361B940C0E8A98FBA04EDE10220047590E7A678818000B5B221EBBC3D21AB1FCE5C003F8F02AAC41F96D054F90A8114C260B3831882A44608EE81C2F3726AA72D11CA95", "tx_json": { "Account": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk", "Fee": "12", "Flags": 65536, "Sequence": 23, "SigningPubKey": "02272E391673B735C9D96435DAFF89F9EA7B4EC285C39643A754848EDE19A65426", "TakerGets": { "currency": "EUR", "issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk", "value": "0.94" }, "TakerPays": { "currency": "USD", "issuer": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "value": "1" }, "TransactionType": "OfferCreate", "TxnSignature": "3045022100CD7511B302ED7D0C299C0F2C1014EA5AA62F7584B361B940C0E8A98FBA04EDE10220047590E7A678818000B5B221EBBC3D21AB1FCE5C003F8F02AAC41F96D054F90A", "hash": "C35F98185CEBD03EEBCBDB6BB4364288DD8A0EDCF6FE137E9E3950524353AC8B" } } }
第 2 步 我根據之前在第 1 步中創建的報價,做了一個查找路徑來獲取用於發送交易的路徑
{ "method": "ripple_path_find", "params": [ { "source_account": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "source_currencies": [ { "currency": "XRP" }, { "currency": "USD" } ], "destination_amount": { "currency": "NGN", "value": "305", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD" }, "destination_account": "rwRRz7yt7GXe2NjZjB9ruLs7r71fi1WNpQ", "SendMax": { "currency": "USD", "value": "1", "issuer": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ" } } ] }
樣本響應
{ "result": { "alternatives": [ { "paths_canonical": [], "paths_computed": [ [ { "account": "rntHFZfVgoCeBNYDxSejkPewViFow1Sz6r", "type": 1, "type_hex": "0000000000000001" }, { "account": "rJHPyhod8HuZhps6Gerf7t3yLfinpVLXNT", "type": 1, "type_hex": "0000000000000001" }, { "currency": "NGN", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD", "type": 48, "type_hex": "0000000000000030" } ], [ { "currency": "EUR", "issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk", "type": 48, "type_hex": "0000000000000030" }, { "currency": "NGN", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD", "type": 48, "type_hex": "0000000000000030" } ] ], "source_amount": { "currency": "USD", "issuer": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "value": "1" } } ], "destination_account": "rwRRz7yt7GXe2NjZjB9ruLs7r71fi1WNpQ", "destination_amount": { "currency": "NGN", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD", "value": "305" }, "destination_currencies": [ "NGN", "XRP" ], "full_reply": true, "ledger_current_index": 3, "source_account": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "status": "success", "validated": false } }
第 3 步 我使用上述響應中返回的路徑之一發送付款請求。
樣品請求
{ "method": "submit", "params": [ { "offline": false, "secret": "sn1GPS42vNZXg6GYrsSXxYv2VrbkG", "fee_mult_max": 100000, "tx_json": { "Amount": { "currency": "NGN", "value": "305", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD" }, "Account": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "Destination": "rwRRz7yt7GXe2NjZjB9ruLs7r71fi1WNpQ", "TransactionType": "Payment", "Fee": "10", "Flags": "0", "Paths": [ [ { "type_hex": "0000000000000030", "issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk", "type": "48", "currency": "EUR" }, { "type_hex": "0000000000000030", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD", "type": "48", "currency": "NGN" } ] ], "SendMax": { "currency": "USD", "value": "1", "issuer": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ" } } } ] }
樣本響應
{ "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": "1200002200000000240000000461D50AD5F57690A0000000000000000000000000004E474E00000000009B0C47828166D6258E8E7F0AA3B464FEA9C17E6668400000000000000A69D4838D7EA4C68000000000000000000000000000555344000000000045249D498FF76EF67DACD0958930DB02EE4A9D4473210336DF52033C6AE8F955A8AE89CE32793C0DB54A3DA2477A0F769EA9A4320D754D74463044022019DBE3D2C7ADF58AD35F1924889B8612EC46E8421492BDC591D50EEABCBC0BA9022046F9D34D8DAF24698B3B5A973AB575E5901A1C14EB80E8ABDC25B0D8010F0983811445249D498FF76EF67DACD0958930DB02EE4A9D4483146757FA04E0212B971F7F76E3E4A85A1B280EAE770112300000000000000000000000004555520000000000C260B3831882A44608EE81C2F3726AA72D11CA95300000000000000000000000004E474E00000000009B0C47828166D6258E8E7F0AA3B464FEA9C17E6600", "tx_json": { "Account": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "Amount": { "currency": "NGN", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD", "value": "305" }, "Destination": "rwRRz7yt7GXe2NjZjB9ruLs7r71fi1WNpQ", "Fee": "10", "Flags": 0, "Paths": [ [ { "currency": "EUR", "issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk", "type": 48, "type_hex": "0000000000000030" }, { "currency": "NGN", "issuer": "rE3FSvB4Q59WZUXcDyB8tgAFBTZMwCJ1FD", "type": 48, "type_hex": "0000000000000030" } ] ], "SendMax": { "currency": "USD", "issuer": "rfJbVE7tTrkbmuqTBvhdYDRExp9oamTzrQ", "value": "1" }, "Sequence": 4, "SigningPubKey": "0336DF52033C6AE8F955A8AE89CE32793C0DB54A3DA2477A0F769EA9A4320D754D", "TransactionType": "Payment", "TxnSignature": "3044022019DBE3D2C7ADF58AD35F1924889B8612EC46E8421492BDC591D50EEABCBC0BA9022046F9D34D8DAF24698B3B5A973AB575E5901A1C14EB80E8ABDC25B0D8010F0983", "hash": "58906C7DEFCF60ED6AC55A646BE3BF50E32F7B633AC6CD62E1AA6799888AA5EA" } } }