diff --git a/content/code_samples/checks/cli/account_objects-resp-clean.txt b/content/code_samples/checks/cli/account_objects-resp-clean.txt new file mode 100644 index 0000000000..19ad3afcae --- /dev/null +++ b/content/code_samples/checks/cli/account_objects-resp-clean.txt @@ -0,0 +1,100 @@ +{ + "result": { + "account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "account_objects": [ + { + "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "37D90463CDE0497DB12F18099296DA0E1E52334A785710B5F56BC9637F62429C", + "PreviousTxnLgrSeq": 8003261, + "SendMax": "999999000000", + "Sequence": 5, + "index": "2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2" + }, + { + "Balance": { + "currency": "BAR", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "0" + }, + "Flags": 1179648, + "HighLimit": { + "currency": "BAR", + "issuer": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "value": "1234567890123450e79" + }, + "HighNode": "0000000000000000", + "LedgerEntryType": "RippleState", + "LowLimit": { + "currency": "BAR", + "issuer": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "value": "0" + }, + "LowNode": "0000000000000000", + "PreviousTxnID": "D7687E275546322995764632799040CF5BDB597691683DE7C532A60BA64E5414", + "PreviousTxnLgrSeq": 8003321, + "index": "5A157543E6A19F14E559A3BE14876B48103502F3258893D4F6DF83E61884F20E" + }, + { + "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode": "0000000000000000", + "DestinationTag": 1, + "Flags": 0, + "InvoiceID": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "09D992D4C89E2A24D4BA9BB57ED81C7003815940F39B7C87ADBF2E49034380BB", + "PreviousTxnLgrSeq": 7841263, + "SendMax": "100000000", + "Sequence": 4, + "index": "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9" + }, + { + "Balance": { + "currency": "FOO", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "0" + }, + "Flags": 2162688, + "HighLimit": { + "currency": "FOO", + "issuer": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "value": "0" + }, + "HighNode": "0000000000000000", + "LedgerEntryType": "RippleState", + "LowLimit": { + "currency": "FOO", + "issuer": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "value": "10000" + }, + "LowNode": "0000000000000000", + "PreviousTxnID": "119400AC7A5B8BD3CC98265D0AB89FC59E6469ED64917425AEA52D40D83164A7", + "PreviousTxnLgrSeq": 8003297, + "index": "88003CF8348313E5CD720FBCCFADF4C4CE6C2C7F4093C943A3E01E8F547DBCAF" + }, + { + "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "C0B27D20669BAB837B3CDF4B8148B988F17CE1EF8EDF48C806AE9BF69E16F441", + "PreviousTxnLgrSeq": 7835887, + "SendMax": "100000000", + "Sequence": 2, + "index": "CEA5F0BD7B2B5C85A70AE735E4CE722C43C86410A79AB87C11938AA13A11DBF9" + } + ], + "ledger_hash": "386FE87ED505E28134AC7171A0B690BA87112334B22DD83194A4C7C3C9810E84", + "ledger_index": 8003351, + "status": "success", + "validated": true + } +} diff --git a/content/code_samples/checks/cli/account_objects-resp.txt b/content/code_samples/checks/cli/account_objects-resp.txt new file mode 100644 index 0000000000..925df85179 --- /dev/null +++ b/content/code_samples/checks/cli/account_objects-resp.txt @@ -0,0 +1,100 @@ +{ + "result" : { + "account" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "account_objects" : [ + { + "Account" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode" : "0000000000000000", + "Flags" : 0, + "LedgerEntryType" : "Check", + "OwnerNode" : "0000000000000000", + "PreviousTxnID" : "37D90463CDE0497DB12F18099296DA0E1E52334A785710B5F56BC9637F62429C", + "PreviousTxnLgrSeq" : 8003261, + "SendMax" : "999999000000", + "Sequence" : 5, + "index" : "2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2" + }, + { + "Balance" : { + "currency" : "BAR", + "issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value" : "0" + }, + "Flags" : 1179648, + "HighLimit" : { + "currency" : "BAR", + "issuer" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "value" : "1234567890123450e79" + }, + "HighNode" : "0000000000000000", + "LedgerEntryType" : "RippleState", + "LowLimit" : { + "currency" : "BAR", + "issuer" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "value" : "0" + }, + "LowNode" : "0000000000000000", + "PreviousTxnID" : "D7687E275546322995764632799040CF5BDB597691683DE7C532A60BA64E5414", + "PreviousTxnLgrSeq" : 8003321, + "index" : "5A157543E6A19F14E559A3BE14876B48103502F3258893D4F6DF83E61884F20E" + }, + { + "Account" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode" : "0000000000000000", + "DestinationTag" : 1, + "Flags" : 0, + "InvoiceID" : "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", + "LedgerEntryType" : "Check", + "OwnerNode" : "0000000000000000", + "PreviousTxnID" : "09D992D4C89E2A24D4BA9BB57ED81C7003815940F39B7C87ADBF2E49034380BB", + "PreviousTxnLgrSeq" : 7841263, + "SendMax" : "100000000", + "Sequence" : 4, + "index" : "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9" + }, + { + "Balance" : { + "currency" : "FOO", + "issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value" : "0" + }, + "Flags" : 2162688, + "HighLimit" : { + "currency" : "FOO", + "issuer" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "value" : "0" + }, + "HighNode" : "0000000000000000", + "LedgerEntryType" : "RippleState", + "LowLimit" : { + "currency" : "FOO", + "issuer" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "value" : "10000" + }, + "LowNode" : "0000000000000000", + "PreviousTxnID" : "119400AC7A5B8BD3CC98265D0AB89FC59E6469ED64917425AEA52D40D83164A7", + "PreviousTxnLgrSeq" : 8003297, + "index" : "88003CF8348313E5CD720FBCCFADF4C4CE6C2C7F4093C943A3E01E8F547DBCAF" + }, + { + "Account" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode" : "0000000000000000", + "Flags" : 0, + "LedgerEntryType" : "Check", + "OwnerNode" : "0000000000000000", + "PreviousTxnID" : "C0B27D20669BAB837B3CDF4B8148B988F17CE1EF8EDF48C806AE9BF69E16F441", + "PreviousTxnLgrSeq" : 7835887, + "SendMax" : "100000000", + "Sequence" : 2, + "index" : "CEA5F0BD7B2B5C85A70AE735E4CE722C43C86410A79AB87C11938AA13A11DBF9" + } + ], + "ledger_hash" : "386FE87ED505E28134AC7171A0B690BA87112334B22DD83194A4C7C3C9810E84", + "ledger_index" : 8003351, + "status" : "success", + "validated" : true + } +} diff --git a/content/code_samples/checks/cli/sign-cancel-req.sh b/content/code_samples/checks/cli/sign-cancel-req.sh new file mode 100644 index 0000000000..de3ec280fc --- /dev/null +++ b/content/code_samples/checks/cli/sign-cancel-req.sh @@ -0,0 +1,6 @@ +rippled sign s████████████████████████████ '{ + "TransactionType": "CheckCancel", + "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "CheckID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + "Fee": "12" +}' diff --git a/content/code_samples/checks/cli/sign-cancel-resp.txt b/content/code_samples/checks/cli/sign-cancel-resp.txt new file mode 100644 index 0000000000..6c16904a31 --- /dev/null +++ b/content/code_samples/checks/cli/sign-cancel-resp.txt @@ -0,0 +1,20 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Jan-24 01:11:07 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "result" : { + "status" : "success", + "tx_blob" : "12001222800000002400000003501849647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB068400000000000000C7321022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78744630440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A181147990EC5D1D8DF69E070A968D4B186986FDF06ED0", + "tx_json" : { + "Account" : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "CheckID" : "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + "Fee" : "12", + "Flags" : 2147483648, + "Sequence" : 3, + "SigningPubKey" : "022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78", + "TransactionType" : "CheckCancel", + "TxnSignature" : "30440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A1", + "hash" : "414558223CA8595916BB1FEF238B3BB601B7C0E52659292251CE613E6B4370F9" + } + } +} diff --git a/content/code_samples/checks/cli/sign-cash-exact-req.sh b/content/code_samples/checks/cli/sign-cash-exact-req.sh new file mode 100644 index 0000000000..855d9d701f --- /dev/null +++ b/content/code_samples/checks/cli/sign-cash-exact-req.sh @@ -0,0 +1,7 @@ +rippled sign s████████████████████████████ '{ + "Account": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "TransactionType": "CheckCash", + "Amount": "100000000", + "CheckID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", + "Fee": "12" +}' diff --git a/content/code_samples/checks/cli/sign-cash-exact-resp.txt b/content/code_samples/checks/cli/sign-cash-exact-resp.txt new file mode 100644 index 0000000000..4abc4f46c0 --- /dev/null +++ b/content/code_samples/checks/cli/sign-cash-exact-resp.txt @@ -0,0 +1,21 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Jan-24 01:17:54 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "result" : { + "status" : "success", + "tx_blob" : "120011228000000024000000015018838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334614000000005F5E10068400000000000000C732102F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED74473045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C811449FF0C73CA6AF9733DA805F76CA2C37776B7C46B", + "tx_json" : { + "Account" : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "Amount" : "100000000", + "CheckID" : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", + "Fee" : "12", + "Flags" : 2147483648, + "Sequence" : 1, + "SigningPubKey" : "02F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED", + "TransactionType" : "CheckCash", + "TxnSignature" : "3045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C", + "hash" : "0521707D510858BC8AF69D2227E1D1ADA7DB7C5B4B74115BCD0D91B62AFA8EDC" + } + } +} diff --git a/content/code_samples/checks/cli/sign-cash-flex-req.sh b/content/code_samples/checks/cli/sign-cash-flex-req.sh new file mode 100644 index 0000000000..801b63a729 --- /dev/null +++ b/content/code_samples/checks/cli/sign-cash-flex-req.sh @@ -0,0 +1,6 @@ +rippled sign s████████████████████████████ '{ + "Account": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "TransactionType": "CheckCash", + "DeliverMin": "95000000", + "CheckID": "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9" +}' diff --git a/content/code_samples/checks/cli/sign-cash-flex-resp.txt b/content/code_samples/checks/cli/sign-cash-flex-resp.txt new file mode 100644 index 0000000000..3dca889785 --- /dev/null +++ b/content/code_samples/checks/cli/sign-cash-flex-resp.txt @@ -0,0 +1,21 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Apr-03 00:09:53 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "result" : { + "status" : "success", + "tx_blob" : "12001122800000002400000004501884C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD968400000000000000A6A4000000005A995C073210361ACFCB478BCAE01451F95060AF94F70365BF00D7B4661EC2C69EA383762516C7446304402203D7EC220D48AA040D6915C160275D202F7F808E2B58F11B1AB05FB5E5CFCC6C00220304BBD3AD32E13150E0ED7247F2ADFAE83D0ECE329E20CFE0F8DF352934DD2FC8114A8B6B9FF3246856CADC4A0106198C066EA1F9C39", + "tx_json" : { + "Account" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "CheckID" : "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9", + "DeliverMin" : "95000000", + "Fee" : "10", + "Flags" : 2147483648, + "Sequence" : 4, + "SigningPubKey" : "0361ACFCB478BCAE01451F95060AF94F70365BF00D7B4661EC2C69EA383762516C", + "TransactionType" : "CheckCash", + "TxnSignature" : "304402203D7EC220D48AA040D6915C160275D202F7F808E2B58F11B1AB05FB5E5CFCC6C00220304BBD3AD32E13150E0ED7247F2ADFAE83D0ECE329E20CFE0F8DF352934DD2FC", + "hash" : "A0AFE572E4736CBF49FF4D0D3FF8FDB0C4D31BD10CB4EB542230F85F0F2DD222" + } + } +} diff --git a/content/code_samples/checks/cli/submit-cancel-req.sh b/content/code_samples/checks/cli/submit-cancel-req.sh new file mode 100644 index 0000000000..47ac200b0e --- /dev/null +++ b/content/code_samples/checks/cli/submit-cancel-req.sh @@ -0,0 +1 @@ +rippled submit 12001222800000002400000003501849647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB068400000000000000C7321022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78744630440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A181147990EC5D1D8DF69E070A968D4B186986FDF06ED0 diff --git a/content/code_samples/checks/cli/submit-cancel-resp.txt b/content/code_samples/checks/cli/submit-cancel-resp.txt new file mode 100644 index 0000000000..19b0cd8265 --- /dev/null +++ b/content/code_samples/checks/cli/submit-cancel-resp.txt @@ -0,0 +1,23 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Jan-24 01:11:07 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "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" : "12001222800000002400000003501849647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB068400000000000000C7321022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78744630440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A181147990EC5D1D8DF69E070A968D4B186986FDF06ED0", + "tx_json" : { + "Account" : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "CheckID" : "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + "Fee" : "12", + "Flags" : 2147483648, + "Sequence" : 3, + "SigningPubKey" : "022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78", + "TransactionType" : "CheckCancel", + "TxnSignature" : "30440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A1", + "hash" : "414558223CA8595916BB1FEF238B3BB601B7C0E52659292251CE613E6B4370F9" + } + } +} diff --git a/content/code_samples/checks/cli/submit-cash-exact-req.sh b/content/code_samples/checks/cli/submit-cash-exact-req.sh new file mode 100644 index 0000000000..e5705f26e1 --- /dev/null +++ b/content/code_samples/checks/cli/submit-cash-exact-req.sh @@ -0,0 +1 @@ +rippled submit 120011228000000024000000015018838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334614000000005F5E10068400000000000000C732102F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED74473045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C811449FF0C73CA6AF9733DA805F76CA2C37776B7C46B diff --git a/content/code_samples/checks/cli/submit-cash-exact-resp.txt b/content/code_samples/checks/cli/submit-cash-exact-resp.txt new file mode 100644 index 0000000000..5d7796a1ce --- /dev/null +++ b/content/code_samples/checks/cli/submit-cash-exact-resp.txt @@ -0,0 +1,24 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Jan-24 01:17:54 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "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" : "120011228000000024000000015018838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334614000000005F5E10068400000000000000C732102F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED74473045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C811449FF0C73CA6AF9733DA805F76CA2C37776B7C46B", + "tx_json" : { + "Account" : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "Amount" : "100000000", + "CheckID" : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", + "Fee" : "12", + "Flags" : 2147483648, + "Sequence" : 1, + "SigningPubKey" : "02F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED", + "TransactionType" : "CheckCash", + "TxnSignature" : "3045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C", + "hash" : "0521707D510858BC8AF69D2227E1D1ADA7DB7C5B4B74115BCD0D91B62AFA8EDC" + } + } +} diff --git a/content/code_samples/checks/cli/submit-cash-flex-req.sh b/content/code_samples/checks/cli/submit-cash-flex-req.sh new file mode 100644 index 0000000000..e010e19070 --- /dev/null +++ b/content/code_samples/checks/cli/submit-cash-flex-req.sh @@ -0,0 +1 @@ +rippled submit 12001122800000002400000004501884C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD968400000000000000A6A4000000005A995C073210361ACFCB478BCAE01451F95060AF94F70365BF00D7B4661EC2C69EA383762516C7446304402203D7EC220D48AA040D6915C160275D202F7F808E2B58F11B1AB05FB5E5CFCC6C00220304BBD3AD32E13150E0ED7247F2ADFAE83D0ECE329E20CFE0F8DF352934DD2FC8114A8B6B9FF3246856CADC4A0106198C066EA1F9C39 diff --git a/content/code_samples/checks/cli/submit-cash-flex-resp.txt b/content/code_samples/checks/cli/submit-cash-flex-resp.txt new file mode 100644 index 0000000000..5c5c3a2985 --- /dev/null +++ b/content/code_samples/checks/cli/submit-cash-flex-resp.txt @@ -0,0 +1,24 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Apr-03 00:10:30 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "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" : "12001122800000002400000004501884C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD968400000000000000A6A4000000005A995C073210361ACFCB478BCAE01451F95060AF94F70365BF00D7B4661EC2C69EA383762516C7446304402203D7EC220D48AA040D6915C160275D202F7F808E2B58F11B1AB05FB5E5CFCC6C00220304BBD3AD32E13150E0ED7247F2ADFAE83D0ECE329E20CFE0F8DF352934DD2FC8114A8B6B9FF3246856CADC4A0106198C066EA1F9C39", + "tx_json" : { + "Account" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "CheckID" : "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9", + "DeliverMin" : "95000000", + "Fee" : "10", + "Flags" : 2147483648, + "Sequence" : 4, + "SigningPubKey" : "0361ACFCB478BCAE01451F95060AF94F70365BF00D7B4661EC2C69EA383762516C", + "TransactionType" : "CheckCash", + "TxnSignature" : "304402203D7EC220D48AA040D6915C160275D202F7F808E2B58F11B1AB05FB5E5CFCC6C00220304BBD3AD32E13150E0ED7247F2ADFAE83D0ECE329E20CFE0F8DF352934DD2FC", + "hash" : "A0AFE572E4736CBF49FF4D0D3FF8FDB0C4D31BD10CB4EB542230F85F0F2DD222" + } + } +} diff --git a/content/code_samples/checks/cli/submit-create-resp.txt b/content/code_samples/checks/cli/submit-create-resp.txt index 3dc0c8b68e..6f7f1a12e0 100644 --- a/content/code_samples/checks/cli/submit-create-resp.txt +++ b/content/code_samples/checks/cli/submit-create-resp.txt @@ -2,11 +2,11 @@ Loading: "/home/mduo13/.config/ripple/rippled.cfg" 2018-Mar-28 01:52:49 HTTPClient:NFO Connecting to 127.0.0.1:5005 { - "id": "submit_req_1", "result": { "engine_result": "terQUEUED", "engine_result_code": -89, "engine_result_message": "Held until escalated fee drops.", + "status" : "success", "tx_blob": "120010228000000024000000042E00000001501146060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE29168400000000000000C694000000005F5E100732103B6FCD7FAC4F665FE92415DD6E8450AD90F7D6B3D45A6CFCF2E359045FF4BB40074463044022071A341F911A8EF3B68399487CAF5BA3B59C6FE476B626698AEF044B8183721BC0220166053A859BD907251DFCCF34DD71202180EBABAE7098BB5903D16EBFC993C408114735FF88E5269C80CD7F7AF10530DAB840BBF6FDF8314A8B6B9FF3246856CADC4A0106198C066EA1F9C39", "tx_json": { "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", @@ -22,7 +22,5 @@ Loading: "/home/mduo13/.config/ripple/rippled.cfg" "TxnSignature": "3044022071A341F911A8EF3B68399487CAF5BA3B59C6FE476B626698AEF044B8183721BC0220166053A859BD907251DFCCF34DD71202180EBABAE7098BB5903D16EBFC993C40", "hash": "09D992D4C89E2A24D4BA9BB57ED81C7003815940F39B7C87ADBF2E49034380BB" } - }, - "status": "success", - "type": "response" + } } diff --git a/content/code_samples/checks/cli/tx-cash-fixed-req.sh b/content/code_samples/checks/cli/tx-cash-exact-req.sh similarity index 100% rename from content/code_samples/checks/cli/tx-cash-fixed-req.sh rename to content/code_samples/checks/cli/tx-cash-exact-req.sh diff --git a/content/code_samples/checks/cli/tx-cash-fixed-resp.txt b/content/code_samples/checks/cli/tx-cash-exact-resp.txt similarity index 100% rename from content/code_samples/checks/cli/tx-cash-fixed-resp.txt rename to content/code_samples/checks/cli/tx-cash-exact-resp.txt diff --git a/content/code_samples/checks/cli/tx-cash-flex-req.sh b/content/code_samples/checks/cli/tx-cash-flex-req.sh new file mode 100644 index 0000000000..4b4ed6be9b --- /dev/null +++ b/content/code_samples/checks/cli/tx-cash-flex-req.sh @@ -0,0 +1 @@ +rippled tx A0AFE572E4736CBF49FF4D0D3FF8FDB0C4D31BD10CB4EB542230F85F0F2DD222 diff --git a/content/code_samples/checks/cli/tx-cash-flex-resp.txt b/content/code_samples/checks/cli/tx-cash-flex-resp.txt new file mode 100644 index 0000000000..a3cae3aa33 --- /dev/null +++ b/content/code_samples/checks/cli/tx-cash-flex-resp.txt @@ -0,0 +1,107 @@ +Loading: "/home/mduo13/.config/ripple/rippled.cfg" +2018-Apr-03 00:11:17 HTTPClient:NFO Connecting to 127.0.0.1:5005 + +{ + "result" : { + "Account" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "CheckID" : "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9", + "DeliverMin" : "95000000", + "Fee" : "10", + "Flags" : 2147483648, + "Sequence" : 4, + "SigningPubKey" : "0361ACFCB478BCAE01451F95060AF94F70365BF00D7B4661EC2C69EA383762516C", + "TransactionType" : "CheckCash", + "TxnSignature" : "304402203D7EC220D48AA040D6915C160275D202F7F808E2B58F11B1AB05FB5E5CFCC6C00220304BBD3AD32E13150E0ED7247F2ADFAE83D0ECE329E20CFE0F8DF352934DD2FC", + "date" : 576029432, + "hash" : "A0AFE572E4736CBF49FF4D0D3FF8FDB0C4D31BD10CB4EB542230F85F0F2DD222", + "inLedger" : 8005386, + "ledger_index" : 8005386, + "meta" : { + "AffectedNodes" : [ + { + "ModifiedNode" : { + "FinalFields" : { + "Flags" : 0, + "Owner" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "RootIndex" : "3F248A0715ECCAFC3BEE0C63C8F429ACE54ABC403AAF5F2885C2B65D62D1FAC1" + }, + "LedgerEntryType" : "DirectoryNode", + "LedgerIndex" : "3F248A0715ECCAFC3BEE0C63C8F429ACE54ABC403AAF5F2885C2B65D62D1FAC1" + } + }, + { + "ModifiedNode" : { + "FinalFields" : { + "Account" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "Balance" : "10099999960", + "Flags" : 0, + "OwnerCount" : 2, + "Sequence" : 5 + }, + "LedgerEntryType" : "AccountRoot", + "LedgerIndex" : "7939126A732EBBDEC715FD3CCB056EB31E65228CA17E3B2901E7D30B90FD03D3", + "PreviousFields" : { + "Balance" : "9999999970", + "Sequence" : 4 + }, + "PreviousTxnID" : "0283465F0D21BE6B1E91ABDE17266C24C1B4915BAAA9A88CC098A98D5ECD3E9E", + "PreviousTxnLgrSeq" : 8005334 + } + }, + { + "DeletedNode" : { + "FinalFields" : { + "Account" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode" : "0000000000000000", + "DestinationTag" : 1, + "Flags" : 0, + "InvoiceID" : "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", + "OwnerNode" : "0000000000000000", + "PreviousTxnID" : "09D992D4C89E2A24D4BA9BB57ED81C7003815940F39B7C87ADBF2E49034380BB", + "PreviousTxnLgrSeq" : 7841263, + "SendMax" : "100000000", + "Sequence" : 4 + }, + "LedgerEntryType" : "Check", + "LedgerIndex" : "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9" + } + }, + { + "ModifiedNode" : { + "FinalFields" : { + "Account" : "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Balance" : "9899999920", + "Flags" : 0, + "OwnerCount" : 2, + "Sequence" : 8 + }, + "LedgerEntryType" : "AccountRoot", + "LedgerIndex" : "A9A591BA661F69433D5BEAA49F10BA2B8DEA5183EF414B9130BFE5E0328FE875", + "PreviousFields" : { + "Balance" : "9999999920", + "OwnerCount" : 3 + }, + "PreviousTxnID" : "54A7A917BE9AC13962251BCF1D09803C7BBE75882B8BFC987B5933A566A48215", + "PreviousTxnLgrSeq" : 8004870 + } + }, + { + "ModifiedNode" : { + "FinalFields" : { + "Flags" : 0, + "Owner" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "RootIndex" : "C6A30AD85346718C7148D161663F84A96A4F0CE7F4D68C3C74D176A6C50BA6B9" + }, + "LedgerEntryType" : "DirectoryNode", + "LedgerIndex" : "C6A30AD85346718C7148D161663F84A96A4F0CE7F4D68C3C74D176A6C50BA6B9" + } + } + ], + "TransactionIndex" : 4, + "TransactionResult" : "tesSUCCESS" + }, + "status" : "success", + "validated" : true + } +} diff --git a/content/code_samples/checks/js/get-cancel-tx-resp.txt b/content/code_samples/checks/js/get-cancel-tx-resp.txt new file mode 100644 index 0000000000..6ab79c48d8 --- /dev/null +++ b/content/code_samples/checks/js/get-cancel-tx-resp.txt @@ -0,0 +1,16 @@ +Connected +Final transaction result: { type: 'checkCancel', + address: 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za', + sequence: 7, + id: '54A7A917BE9AC13962251BCF1D09803C7BBE75882B8BFC987B5933A566A48215', + specification: + { checkID: '2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2' }, + outcome: + { result: 'tesSUCCESS', + timestamp: '2018-04-02T23:42:22.000Z', + fee: '0.000012', + balanceChanges: { rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za: [Array] }, + orderbookChanges: {}, + ledgerVersion: 8004870, + indexInLedger: 3 } } +Disconnected diff --git a/content/code_samples/checks/js/get-checks-resp.txt b/content/code_samples/checks/js/get-checks-resp.txt new file mode 100644 index 0000000000..fbc967b489 --- /dev/null +++ b/content/code_samples/checks/js/get-checks-resp.txt @@ -0,0 +1,53 @@ +Connected +account_objects response: { account: 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za', + account_objects: + [ { Account: 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za', + Destination: 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis', + DestinationNode: '0000000000000000', + Flags: 0, + LedgerEntryType: 'Check', + OwnerNode: '0000000000000000', + PreviousTxnID: '37D90463CDE0497DB12F18099296DA0E1E52334A785710B5F56BC9637F62429C', + PreviousTxnLgrSeq: 8003261, + SendMax: '999999000000', + Sequence: 5, + index: '2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2' }, + { Account: 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis', + Destination: 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za', + DestinationNode: '0000000000000000', + Flags: 0, + LedgerEntryType: 'Check', + OwnerNode: '0000000000000000', + PreviousTxnID: 'EF462F1D004E97850AECFB8EC4836DA57706FAFADF8E0914010853C1EC7F2055', + PreviousTxnLgrSeq: 8003480, + SendMax: [Object], + Sequence: 2, + index: '323CE1D169135513085268EF81ED40775725C97E7922DBABCCE48FE3FD138861' }, + { Account: 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za', + Destination: 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis', + DestinationNode: '0000000000000000', + DestinationTag: 1, + Flags: 0, + InvoiceID: '46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291', + LedgerEntryType: 'Check', + OwnerNode: '0000000000000000', + PreviousTxnID: '09D992D4C89E2A24D4BA9BB57ED81C7003815940F39B7C87ADBF2E49034380BB', + PreviousTxnLgrSeq: 7841263, + SendMax: '100000000', + Sequence: 4, + index: '84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9' }, + { Account: 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za', + Destination: 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis', + DestinationNode: '0000000000000000', + Flags: 0, + LedgerEntryType: 'Check', + OwnerNode: '0000000000000000', + PreviousTxnID: 'C0B27D20669BAB837B3CDF4B8148B988F17CE1EF8EDF48C806AE9BF69E16F441', + PreviousTxnLgrSeq: 7835887, + SendMax: '100000000', + Sequence: 2, + index: 'CEA5F0BD7B2B5C85A70AE735E4CE722C43C86410A79AB87C11938AA13A11DBF9' } ], + ledger_hash: 'DD577D96A1064E16A5DB64C3C25BFF5EF0D8E36A18E4540B162731FA6320C46D', + ledger_index: 8004101, + validated: true } +Disconnected diff --git a/content/code_samples/checks/js/get-create-tx-resp.txt b/content/code_samples/checks/js/get-create-tx-resp.txt index ff599727e9..9da84d5f48 100644 --- a/content/code_samples/checks/js/get-create-tx-resp.txt +++ b/content/code_samples/checks/js/get-create-tx-resp.txt @@ -14,4 +14,5 @@ Final transaction result: { type: 'checkCreate', orderbookChanges: {}, ledgerVersion: 7835887, indexInLedger: 0 } } +Calculated checkID: CEA5F0BD7B2B5C85A70AE735E4CE722C43C86410A79AB87C11938AA13A11DBF9 Disconnected diff --git a/content/code_samples/checks/js/getCancelTx.js b/content/code_samples/checks/js/getCancelTx.js new file mode 100644 index 0000000000..61d5055237 --- /dev/null +++ b/content/code_samples/checks/js/getCancelTx.js @@ -0,0 +1,21 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// This example connects to a public Test Net server +const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) +api.connect().then(() => { + console.log('Connected') + + const tx_hash = "54A7A917BE9AC13962251BCF1D09803C7BBE75882B8BFC987B5933A566A48215" + + return api.getTransaction(tx_hash) +}).then(response => { + console.log("Final transaction result:", response) + +// Disconnect and return +}).then(() => { + api.disconnect().then(() => { + console.log('Disconnected') + process.exit() + }) +}).catch(console.error) diff --git a/content/code_samples/checks/js/getChecks.js b/content/code_samples/checks/js/getChecks.js new file mode 100644 index 0000000000..fe674bb02c --- /dev/null +++ b/content/code_samples/checks/js/getChecks.js @@ -0,0 +1,26 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// This example connects to a public Test Net server +const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) +api.connect().then(() => { + console.log('Connected') + + const account_objects_request = { + command: "account_objects", + account: "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + ledger_index: "validated", + type: "check" + } + + return api.connection.request(account_objects_request) +}).then(response => { + console.log("account_objects response:", response) + +// Disconnect and return +}).then(() => { + api.disconnect().then(() => { + console.log('Disconnected') + process.exit() + }) +}).catch(console.error) diff --git a/content/code_samples/checks/js/getCreateTx.js b/content/code_samples/checks/js/getCreateTx.js index b70fb8f162..816e4232ac 100644 --- a/content/code_samples/checks/js/getCreateTx.js +++ b/content/code_samples/checks/js/getCreateTx.js @@ -1,5 +1,7 @@ 'use strict' const RippleAPI = require('ripple-lib').RippleAPI +const decodeAddress = require('ripple-address-codec').decodeAddress; +const createHash = require('crypto').createHash; // This example connects to a public Test Net server const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) @@ -12,6 +14,16 @@ api.connect().then(() => { }).then(response => { console.log("Final transaction result:", response) + // Re-calculate checkID to work around issue ripple-lib#876 + const checkIDhasher = createHash('sha512') + checkIDhasher.update(Buffer.from('0043', 'hex')) + checkIDhasher.update(new Buffer(decodeAddress(response.address))) + const seqBuf = Buffer.alloc(4) + seqBuf.writeUInt32BE(response.sequence, 0) + checkIDhasher.update(seqBuf) + const checkID = checkIDhasher.digest('hex').slice(0,64).toUpperCase() + console.log("Calculated checkID:", checkID) + // Disconnect and return }).then(() => { api.disconnect().then(() => { diff --git a/content/code_samples/checks/js/prepareCancel.js b/content/code_samples/checks/js/prepareCancel.js new file mode 100644 index 0000000000..82fc070079 --- /dev/null +++ b/content/code_samples/checks/js/prepareCancel.js @@ -0,0 +1,41 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// This example connects to a public Test Net server +const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) +api.connect().then(() => { + console.log('Connected') + + const sender = 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za' + const options = { + // Allow up to 60 ledger versions (~5 min) instead of the default 3 versions + // before this transaction fails permanently. + "maxLedgerVersionOffset": 60 + } + return api.prepareCheckCancel(sender, { + "checkID": "2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2" + }, options) + +}).then(prepared => { + console.log("txJSON:", prepared.txJSON); + +// Disconnect and return +}).then(() => { + api.disconnect().then(() => { + console.log('Disconnected') + process.exit() + }) +}).catch(console.error) + + +// Example output: +// +// Connected +// txJSON: {"Account":"rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", +// "TransactionType":"CheckCancel", +// "CheckID":"2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2", +// "Flags":2147483648, +// "LastLedgerSequence":8004884, +// "Fee":"12", +// "Sequence":7} +// Disconnected diff --git a/content/code_samples/checks/js/prepareCashExact.js b/content/code_samples/checks/js/prepareCashExact.js new file mode 100644 index 0000000000..6cb612366a --- /dev/null +++ b/content/code_samples/checks/js/prepareCashExact.js @@ -0,0 +1,45 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// This example connects to a public Test Net server +const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) +api.connect().then(() => { + console.log('Connected') + + const sender = 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis' + const options = { + // Allow up to 60 ledger versions (~5 min) instead of the default 3 versions + // before this transaction fails permanently. + "maxLedgerVersionOffset": 60 + } + return api.prepareCheckCash(sender, { + "checkID": "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9", + "amount": { + "currency": "XRP", + "value": "95" // Cash for exactly 95 XRP + } + }, options) + +}).then(prepared => { + console.log("txJSON:", prepared.txJSON); + +// Disconnect and return +}).then(() => { + api.disconnect().then(() => { + console.log('Disconnected') + process.exit() + }) +}).catch(console.error) + + +// Example output: +// +// Connected +// txJSON: {"Account":"rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", +// "TransactionType":"CheckCancel", +// "CheckID":"2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2", +// "Flags":2147483648, +// "LastLedgerSequence":8004884, +// "Fee":"12", +// "Sequence":7} +// Disconnected diff --git a/content/code_samples/checks/js/prepareCashFlex.js b/content/code_samples/checks/js/prepareCashFlex.js new file mode 100644 index 0000000000..4aad7dd30d --- /dev/null +++ b/content/code_samples/checks/js/prepareCashFlex.js @@ -0,0 +1,45 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// This example connects to a public Test Net server +const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) +api.connect().then(() => { + console.log('Connected') + + const sender = 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis' + const options = { + // Allow up to 60 ledger versions (~5 min) instead of the default 3 versions + // before this transaction fails permanently. + "maxLedgerVersionOffset": 60 + } + return api.prepareCheckCash(sender, { + "checkID": "C0B27D20669BAB837B3CDF4B8148B988F17CE1EF8EDF48C806AE9BF69E16F441", + "deliverMin": { + "currency": "XRP", + "value": "95" // Cash for at least 95 XRP + } + }, options) + +}).then(prepared => { + console.log("txJSON:", prepared.txJSON); + +// Disconnect and return +}).then(() => { + api.disconnect().then(() => { + console.log('Disconnected') + process.exit() + }) +}).catch(console.error) + + +// Example output: +// +// Connected +// txJSON: {"Account":"rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", +// "TransactionType":"CheckCancel", +// "CheckID":"2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2", +// "Flags":2147483648, +// "LastLedgerSequence":8004884, +// "Fee":"12", +// "Sequence":7} +// Disconnected diff --git a/content/code_samples/checks/js/sign-cancel-resp.txt b/content/code_samples/checks/js/sign-cancel-resp.txt new file mode 100644 index 0000000000..59e907b474 --- /dev/null +++ b/content/code_samples/checks/js/sign-cancel-resp.txt @@ -0,0 +1,2 @@ +tx_blob is: 12001222800000002400000007201B007A251450182E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C268400000000000000C732103B6FCD7FAC4F665FE92415DD6E8450AD90F7D6B3D45A6CFCF2E359045FF4BB4007446304402205D77451B0D7BCDA1FE5B98763C5B3B2837453371FE93C2B86157C44B1867AE36022003800273848BC2F8E1C6EC7EE4B0CB2425A888AE80E586886C306C796B25678B8114735FF88E5269C80CD7F7AF10530DAB840BBF6FDF +tx hash is: 54A7A917BE9AC13962251BCF1D09803C7BBE75882B8BFC987B5933A566A48215 diff --git a/content/code_samples/checks/js/signCancel.js b/content/code_samples/checks/js/signCancel.js new file mode 100644 index 0000000000..d44872e4d1 --- /dev/null +++ b/content/code_samples/checks/js/signCancel.js @@ -0,0 +1,15 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// Can sign offline if the txJSON has all required fields +const api = new RippleAPI() + +const txJSON = '{"Account":"rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za","TransactionType":"CheckCancel","CheckID":"2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2","Flags":2147483648,"LastLedgerSequence":8004884,"Fee":"12","Sequence":7}' + +// Be careful where you store your real secret. +const secret = 's████████████████████████████' + +const signed = api.sign(txJSON, secret) + +console.log("tx_blob is:", signed.signedTransaction) +console.log("tx hash is:", signed.id) diff --git a/content/code_samples/checks/js/submit-cancel-resp.txt b/content/code_samples/checks/js/submit-cancel-resp.txt new file mode 100644 index 0000000000..42c23508fc --- /dev/null +++ b/content/code_samples/checks/js/submit-cancel-resp.txt @@ -0,0 +1,3 @@ +Connected +Preliminary transaction result: tesSUCCESS +Disconnected diff --git a/content/code_samples/checks/js/submitCancel.js b/content/code_samples/checks/js/submitCancel.js new file mode 100644 index 0000000000..cd93e78816 --- /dev/null +++ b/content/code_samples/checks/js/submitCancel.js @@ -0,0 +1,21 @@ +'use strict' +const RippleAPI = require('ripple-lib').RippleAPI + +// This example connects to a public Test Net server +const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'}) +api.connect().then(() => { + console.log('Connected') + + const tx_blob = "12001222800000002400000007201B007A251450182E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C268400000000000000C732103B6FCD7FAC4F665FE92415DD6E8450AD90F7D6B3D45A6CFCF2E359045FF4BB4007446304402205D77451B0D7BCDA1FE5B98763C5B3B2837453371FE93C2B86157C44B1867AE36022003800273848BC2F8E1C6EC7EE4B0CB2425A888AE80E586886C306C796B25678B8114735FF88E5269C80CD7F7AF10530DAB840BBF6FDF" + + return api.submit(tx_blob) +}).then(response => { + console.log("Preliminary transaction result:", response.resultCode) + +// Disconnect and return +}).then(() => { + api.disconnect().then(() => { + console.log('Disconnected') + process.exit() + }) +}).catch(console.error) diff --git a/content/code_samples/checks/json-rpc/account_objects-req.json b/content/code_samples/checks/json-rpc/account_objects-req.json new file mode 100644 index 0000000000..0cc9146f71 --- /dev/null +++ b/content/code_samples/checks/json-rpc/account_objects-req.json @@ -0,0 +1,10 @@ +{ + "method": "account_objects", + "params": [ + { + "account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "ledger_index": "validated", + "type": "check" + } + ] +} diff --git a/content/code_samples/checks/json-rpc/account_objects-resp.json b/content/code_samples/checks/json-rpc/account_objects-resp.json new file mode 100644 index 0000000000..932f604e37 --- /dev/null +++ b/content/code_samples/checks/json-rpc/account_objects-resp.json @@ -0,0 +1,69 @@ +{ + "result": { + "account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "account_objects": [ + { + "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "37D90463CDE0497DB12F18099296DA0E1E52334A785710B5F56BC9637F62429C", + "PreviousTxnLgrSeq": 8003261, + "SendMax": "999999000000", + "Sequence": 5, + "index": "2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2" + }, + { + "Account": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "Destination": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "EF462F1D004E97850AECFB8EC4836DA57706FAFADF8E0914010853C1EC7F2055", + "PreviousTxnLgrSeq": 8003480, + "SendMax": { + "currency": "BAR", + "issuer": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "value": "1000000000000000e-66" + }, + "Sequence": 2, + "index": "323CE1D169135513085268EF81ED40775725C97E7922DBABCCE48FE3FD138861" + }, + { + "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode": "0000000000000000", + "DestinationTag": 1, + "Flags": 0, + "InvoiceID": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291", + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "09D992D4C89E2A24D4BA9BB57ED81C7003815940F39B7C87ADBF2E49034380BB", + "PreviousTxnLgrSeq": 7841263, + "SendMax": "100000000", + "Sequence": 4, + "index": "84C61BE9B39B2C4A2267F67504404F1EC76678806C1B901EA781D1E3B4CE0CD9" + }, + { + "Account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za", + "Destination": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "DestinationNode": "0000000000000000", + "Flags": 0, + "LedgerEntryType": "Check", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "C0B27D20669BAB837B3CDF4B8148B988F17CE1EF8EDF48C806AE9BF69E16F441", + "PreviousTxnLgrSeq": 7835887, + "SendMax": "100000000", + "Sequence": 2, + "index": "CEA5F0BD7B2B5C85A70AE735E4CE722C43C86410A79AB87C11938AA13A11DBF9" + } + ], + "ledger_hash": "4002E4E84CABAAF1BDD5636097F3042547EBAE2DEE647E1036E64AA9FDA2A10C", + "ledger_index": 8004173, + "status": "success", + "validated": true + } +} diff --git a/content/snippets/tutorial-sign-step.md b/content/snippets/tutorial-sign-step.md new file mode 100644 index 0000000000..ac25e719dc --- /dev/null +++ b/content/snippets/tutorial-sign-step.md @@ -0,0 +1,3 @@ +The most secure way to sign a transaction is to do it locally with a signing library, such as [RippleAPI](reference-rippleapi.html). Alternatively, you can sign the transaction using the [`sign`](reference-rippled.html#sign) command, but this must be done through a trusted and encrypted connection, or through a local connection, and only to a server you control. + +In all cases, note the signed transaction's identifying hash for later. diff --git a/content/snippets/tutorial-submit-step.md b/content/snippets/tutorial-submit-step.md new file mode 100644 index 0000000000..3f408d3aa4 --- /dev/null +++ b/content/snippets/tutorial-submit-step.md @@ -0,0 +1,3 @@ +Take the signed transaction blob from the previous step and submit it to a `rippled` server. You can do this safely even if you do not operate the `rippled` server. The response contains a provisional result, which should be `tesSUCCESS`, but this result is [usually not final](reference-transaction-format.html#finality-of-results). A provisional response of `terQUEUED` is also OK, since [queued transactions](concept-transaction-cost.html#queued-transactions) are generally included in the next open ledger version (usually about 10 seconds after submission). + +**Tip:** If the preliminary result is `tefMAX_LEDGER`, the transaction has failed permanently because its `LastLedgerSequence` parameter is lower than the current ledger. This happens when you take longer than the expected number of ledger versions between preparing and submitting the transaction. If this occurs, [start over from step 1]({{step_1_link}}) with a higher `LastLedgerSequence` value. diff --git a/content/tutorial-checks.md b/content/tutorial-checks.md index 65a2ea64d4..5b389f70b9 100644 --- a/content/tutorial-checks.md +++ b/content/tutorial-checks.md @@ -1,10 +1,10 @@ -for Checks# Checks Tutorials +# Checks Tutorials Checks in the XRP Ledger are similar to paper personal checks. This tutorial steps through the following processes for using Checks: - [Send a Check](#send-a-check) -- Look for incoming Checks -- Look for outgoing Checks +- [Look up Checks by sender address](#look-up-checks-by-sender-address) +- [Look up Checks by recipient address](#look-up-checks-by-recipient-address) - [Cash a Check for an exact amount](#cash-a-check-for-an-exact-amount) - [Cash a Check for a flexible amount](#cash-a-check-for-a-flexible-amount) - [Cancel a Check](#cancel-a-check) @@ -51,9 +51,9 @@ If you are using [RippleAPI](reference-rippleapi.html), you can use the `prepare **Note:** RippleAPI supports Checks in versions 0.19.0 and up. -#### Example Check Preparation +#### Example CheckCreate Preparation -This example transaction creates a Check for 100 XRP from rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo to rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy, with no expiration: +The following examples create Checks from rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za to rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis for 100 XRP. @@ -82,9 +82,7 @@ This example transaction creates a Check for 100 XRP from rUn84CUYbNjRoTQ6mSW7BV ### {{send_n.next()}}. Sign the CheckCreate transaction -The most secure way to sign a transaction is to do it locally with a signing library, such as [RippleAPI](reference-rippleapi.html). Alternatively, you can sign the transaction using the [`sign`](reference-rippled.html#sign) command, but this must be done through a trusted and encrypted connection, or through a local connection, and only to a server you control. - -In all cases, note the signed transaction's identifying hash for later. +{% include 'snippets/tutorial-sign-step.md' %} #### Example Request @@ -136,9 +134,8 @@ In all cases, note the signed transaction's identifying hash for later. ### {{send_n.next()}}. Submit the signed transaction -Take the signed transaction blob from the previous step and submit it to a `rippled` server. You can do this safely even if you do not operate the `rippled` server. The response contains a provisional result, which should be `tesSUCCESS`, but this result is [usually not final](reference-transaction-format.html#finality-of-results). A provisional response of `terQUEUED` is also OK, since [queued transactions](concept-transaction-cost.html#queued-transactions) are generally included in the next open ledger version (usually about 10 seconds after submission). - -**Tip:** If the preliminary result is `tefMAX_LEDGER`, the transaction has failed permanently because its `LastLedgerSequence` parameter is lower than the current ledger. This happens when you take longer than the expected number of ledger versions between preparing and submitting the transaction. If this occurs, [start over from step 1](#1-prepare-the-checkcreate-transaction) with a higher `LastLedgerSequence` value. +{% set step_1_link = "#1-prepare-the-checkcreate-transaction" %} +{% include 'snippets/tutorial-submit-step.md' %} #### Example Request @@ -199,7 +196,7 @@ Use the [`tx` method](reference-rippled.html#tx) with the CheckCreate transactio Look for a `CreatedNode` object in the transaction metadata to indicate that the transaction created a [Check ledger object](reference-ledger-format.html#check). The `LedgerIndex` of this object is the ID of the Check. In the following example, the Check's ID is `49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0`. -***TODO: Add code to look up the Check ID using account_objects in RippleAPI or to calculate the ID deterministically. Also, if https://github.com/ripple/ripple-lib/issues/876 gets resolved, there will be an easier way to get the Check ID from the RippleAPI response.*** +**Note:** RippleAPI does not report the Check's ID when you look up a CheckCreate transaction. You can work around this by calculating the Check's ID from the [Check ID format](reference-ledger-format.html#check-id-format), as in the example RippleAPI code below. #### Example Request @@ -211,6 +208,18 @@ Look for a `CreatedNode` object in the transaction metadata to indicate that the {% include 'code_samples/checks/js/getCreateTx.js' %} ``` +*WebSocket* + +```json +{% include 'code_samples/checks/websocket/tx-create-req.json' %} +``` + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/tx-create-req.sh' %} +``` + #### Example Response @@ -238,6 +247,149 @@ Look for a `CreatedNode` object in the transaction metadata to indicate that the +## Look up Checks by sender address + + + +### 1. Look up all Checks for the address + +To get a list of all incoming and outgoing Checks for an account, use the `account_objects` command with the sending account's address and set the `type` field of the request to `checks`. + +**Note:** The commandline interface to the `account_objects` command does not accept the `type` field. You can use the [`json` command](reference-rippled.html#json) to send the JSON-RPC format request on the commandline instead. + +**Caution:** RippleAPI does not have built-in support for the `account_objects` method. You can make a raw request in the WebSocket format using the `api.connection.request(websocket_request_json)` method. The response to this method is in the `rippled` API format. (For example, XRP is specified in integer "drops" rather than as a decimal.) + +#### Example Request + + + +*RippleAPI* + +```js +{% include 'code_samples/checks/js/getChecks.js' %} +``` + +*JSON-RPC* + +```json +{% include 'code_samples/checks/json-rpc/account_objects-req.json' %} +``` + + + +#### Example Response + + + +*RippleAPI* + +``` +{% include 'code_samples/checks/js/get-checks-resp.txt' %} +``` + +*JSON-RPC* + +```json +200 OK + +{% include 'code_samples/checks/json-rpc/account_objects-resp.json' %} +``` + + + +### 2. Filter the responses by sender + +The response may include Checks where the account from the request is the sender and Checks where the account is the recipient. Each member of the `account_objects` array of the response represents one Check. For each such Check object, the address in the `Account` is address of that Check's sender. + +The following pseudocode demonstrates how to filter the responses by sender: + +```js +sender_address = "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za" +account_objects_response = get_account_objects({ + account: sender_address, + ledger_index: "validated", + type: "check" +}) + +for (i=0; i < account_objects_response.account_objects.length; i++) { + check_object = account_objects_response.account_objects[i] + if (check_object.Account == sender_address) { + log("Check from sender:", check_object) + } +} +``` + + +## Look up Checks by recipient address + +### 1. Look up all Checks for the address + +To get a list of all incoming and outgoing Checks for an account, use the `account_objects` command with the recipient account's address and set the `type` field of the request to `checks`. + +**Note:** The commandline interface to the `account_objects` command does not accept the `type` field. You can use the [`json` command](reference-rippled.html#json) to send the JSON-RPC format request on the commandline instead. + +**Note:** RippleAPI does not have built-in support for the `account_objects` method. You can make a raw request in the WebSocket format using the `api.connection.request(websocket_request_json)` method. + +#### Example Request + + + +*RippleAPI* + +```js +{% include 'code_samples/checks/js/getChecks.js' %} +``` + +*JSON-RPC* + +```json +{% include 'code_samples/checks/json-rpc/account_objects-req.json' %} +``` + + + +#### Example Response + + + +*RippleAPI* + +``` +{% include 'code_samples/checks/js/get-checks-resp.txt' %} +``` + +*JSON-RPC* + +```json +200 OK + +{% include 'code_samples/checks/json-rpc/account_objects-resp.json' %} +``` + + + + +### 2. Filter the responses by recipient + +The response may include Checks where the account from the request is the sender and Checks where the account is the recipient. Each member of the `account_objects` array of the response represents one Check. For each such Check object, the address in the `Destination` is address of that Check's recipient. + +The following pseudocode demonstrates how to filter the responses by recipient: + +```js +recipient_address = "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za" +account_objects_response = get_account_objects({ + account: recipient_address, + ledger_index: "validated", + type: "check" +}) + +for (i=0; i < account_objects_response.account_objects.length; i++) { + check_object = account_objects_response.account_objects[i] + if (check_object.Account == recipient_address) { + log("Check to recipient:", check_object) + } +} +``` ## Cancel a Check @@ -271,45 +423,114 @@ If you are using [RippleAPI](reference-rippleapi.html), you can use the `prepare **Note:** RippleAPI supports Checks in versions 0.19.0 and up. -### {{cancel_n.next()}}. Sign the CheckCancel transaction +#### Example CheckCancel Preparation -***TODO: separate signing/submitting of CheckCancel*** +The following examples demonstrate how to cancel a Check. + + + +*JSON-RPC, WebSocket, or Commandline* ``` -$ ./rippled submit snkuWqxoqt6aeykTbkEWrTMJHrWGM '{ -> "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", -> "TransactionType": "CheckCancel", -> "CheckID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", -> "Fee": "12" -> }' -Loading: "/home/mduo13/.config/ripple/rippled.cfg" -2018-Jan-24 01:11:07 HTTPClient:NFO Connecting to 127.0.0.1:5005 - { - "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" : "12001222800000002400000003501849647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB068400000000000000C7321022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78744630440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A181147990EC5D1D8DF69E070A968D4B186986FDF06ED0", - "tx_json" : { - "Account" : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", - "CheckID" : "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", - "Fee" : "12", - "Flags" : 2147483648, - "Sequence" : 3, - "SigningPubKey" : "022C53CD19049F32F31848DD3B3BE5CEF6A2DD1EFDA7971AB3FA49B1BAF12AEF78", - "TransactionType" : "CheckCancel", - "TxnSignature" : "30440220615F9D19FA182F08530CD978A4C216C8676D0BA9EDB53A620AC909AA0EF0FE7E02203A09CC34C3DB85CCCB3137E78081F8F2B441FB0A3B9E40901F312D3CBA0A67A1", - "hash" : "414558223CA8595916BB1FEF238B3BB601B7C0E52659292251CE613E6B4370F9" - } - } + "TransactionType": "CheckCancel", + "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", + "CheckID": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0", + "Fee": "12" } ``` +*RippleAPI* + +```js +{% include 'code_samples/checks/js/prepareCancel.js' %} +``` + + + +### {{cancel_n.next()}}. Sign the CheckCancel transaction + +{% include 'snippets/tutorial-sign-step.md' %} + +#### Example Request + + + +*RippleAPI* + +```js +{% include 'code_samples/checks/js/signCancel.js' %} +``` + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/sign-cancel-req.sh' %} +``` + + + + +#### Example Response + + + +*RippleAPI* + +``` +{% include 'code_samples/checks/js/sign-cancel-resp.txt' %} +``` + +*Commandline* + +```json +{% include 'code_samples/checks/cli/sign-cancel-resp.txt' %} +``` + + + + ### {{cancel_n.next()}}. Submit the signed CheckCancel transaction -***TODO: examples of submitting signed blob*** +{% set step_1_link = "#1-prepare-the-checkcancel-transaction" %} +{% include 'snippets/tutorial-submit-step.md' %} + +#### Example Request + + + +*RippleAPI* + +```js +{% include 'code_samples/checks/js/submitCancel.js' %} +``` + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/submit-cancel-req.sh' %} +``` + + + + +#### Example Response + + + +*RippleAPI* + +```js +{% include 'code_samples/checks/js/submit-cancel-resp.txt' %} +``` + +*Commandline* + +```json +{% include 'code_samples/checks/cli/submit-cancel-resp.txt' %} +``` + + ### {{cancel_n.next()}}. Wait for validation @@ -325,6 +546,12 @@ Look for a `DeletedNode` object in the transaction metadata with `"LedgerEntryTy +*RippleAPI* + +```js +{% include 'code_samples/checks/js/getCancelTx.js' %} +``` + *Commandline* ```bash @@ -338,6 +565,12 @@ Look for a `DeletedNode` object in the transaction metadata with `"LedgerEntryTy +*RippleAPI* + +```json +{% include 'code_samples/checks/js/get-cancel-tx-resp.txt' %} +``` + *Commandline* ```json @@ -360,7 +593,6 @@ The specified recipient can also [cash the check for a flexible amount](#cash-a- {% include 'snippets/checkcash-prereqs.md' %} ### {{cash_exact_n.next()}}. Prepare the CheckCash transaction -***TODO: Uses check id: `838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334`*** Figure out the values of the [CheckCash transaction][] fields. To cash a check for an exact amount, the following fields are the bare minimum; everything else is either optional or can be [auto-filled](reference-transaction-format.html#auto-fillable-fields) when signing: @@ -371,46 +603,93 @@ Figure out the values of the [CheckCash transaction][] fields. To cash a check f | `CheckID` | String | The ID of the Check object in the ledger to cancel. You can get this information by looking up the metadata of the CheckCreate transaction using the [`tx` method](reference-rippled.html#tx) or by looking for Checks using the [`account_objects` method](reference-rippled.html#account-objects). | | `Amount` | String or Object (Amount) | The amount to redeem from the Check. For XRP, this must be a string specifying drops of XRP. For issued currencies, this is an object with `currency`, `issuer`, and `value` fields. The `currency` and `issuer` fields must match the corresponding fields in the Check object, and the `value` must be less than or equal to the amount in the Check object. For more information on specifying currency amounts, see [Specifying Currency Amounts][]. | -### {{cash_exact_n.next()}}. Sign the CheckCash transaction -### {{cash_exact_n.next()}}. Submit the signed CheckCancel transaction +#### Example CheckCash Preparation for an exact amount -***TODO: examples of submitting signed blob*** +The following examples show how to prepare a transaction to cash a Check for a fixed amount. + + + +*JSON-RPC, WebSocket, or Commandline* ``` -$ ./rippled submit sn2Zh1tRZyodU9qNy9tMnQr9UbBss '{ -> "Account": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", -> "TransactionType": "CheckCash", -> "Amount": "100000000", -> "CheckID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", -> "Fee": "12" -> }' -Loading: "/home/mduo13/.config/ripple/rippled.cfg" -2018-Jan-24 01:17:54 HTTPClient:NFO Connecting to 127.0.0.1:5005 - { - "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" : "120011228000000024000000015018838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334614000000005F5E10068400000000000000C732102F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED74473045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C811449FF0C73CA6AF9733DA805F76CA2C37776B7C46B", - "tx_json" : { - "Account" : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", - "Amount" : "100000000", - "CheckID" : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", - "Fee" : "12", - "Flags" : 2147483648, - "Sequence" : 1, - "SigningPubKey" : "02F135B14C552968B0ABE8493CC4C5795A7484D73F6BFD01379F73456F725F66ED", - "TransactionType" : "CheckCash", - "TxnSignature" : "3045022100C64278AC90B841CD3EA9889A4847CAB3AC9927057A34130810FAA7FAC0C6E3290220347260A4C0A6DC9B699DA12510795B2B3414E1FA222AF743226345FBAAEF937C", - "hash" : "0521707D510858BC8AF69D2227E1D1ADA7DB7C5B4B74115BCD0D91B62AFA8EDC" - } - } + "Account": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", + "TransactionType": "CheckCash", + "Amount": "100000000", + "CheckID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", + "Fee": "12" } ``` +*RippleAPI* + +```js +{% include 'code_samples/checks/js/prepareCashExact.js' %} +``` + + + +### {{cash_exact_n.next()}}. Sign the CheckCash transaction + +{% include 'snippets/tutorial-sign-step.md' %} + +#### Example Request + + + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/sign-cash-exact-req.sh' %} +``` + + + + +#### Example Response + + + +*Commandline* + +```json +{% include 'code_samples/checks/cli/sign-cash-exact-resp.txt' %} +``` + + + + +### {{cash_exact_n.next()}}. Submit the signed CheckCash transaction + +{% set step_1_link = "#1-prepare-the-checkcash-transaction" %} +{% include 'snippets/tutorial-submit-step.md' %} + +#### Example Request + + + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/submit-cash-exact-req.sh' %} +``` + + + + +#### Example Response + + + +*Commandline* + +```json +{% include 'code_samples/checks/cli/submit-cash-exact-resp.txt' %} +``` + + + ### {{cash_exact_n.next()}}. Wait for validation {% include 'snippets/wait-for-validation.md' %} @@ -421,12 +700,40 @@ Use the [`tx` method](reference-rippled.html#tx) with the CheckCash transaction' If the check was cashed for an exact `Amount` and succeeded, you can assume that the recipient was credited for exactly that amount (with possible rounding for very large or very small amounts of issued currencies). -If cashing the Check failed, +If cashing the Check failed, the Check remains in the ledger so you can try cashing again later. You may want to [cash the Check for a flexible amount](#cash-a-check-for-a-flexible-amount) instead. + +#### Example Request + + + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/tx-cash-exact-req.sh' %} +``` + + + + +#### Example Response + + + +*Commandline* + +```json +{% include 'code_samples/checks/cli/tx-cash-exact-resp.txt' %} +``` + + + ## Cash a Check for a flexible amount -***TODO: description*** +As long as the Check is in the ledger and not expired, the specified recipient can cash it to receive a flexible amount by sending a [CheckCash transaction][] with a `DeliverMin` field. When cashing a Check in this way, the receiver gets as much as is possible to deliver, debiting the Check's sender for the Check's full `SendMax` amount or as much as is available. Cashing fails if it doesn't deliver at least the `DeliverMin` amount to the Check's recipient. + +The specified recipient can also [cash the check for an exact amount](#cash-a-check-for-an-exact-amount). {% set cash_flex_n = cycler(* range(1,99)) %} @@ -446,11 +753,90 @@ Figure out the values of the [CheckCash transaction][] fields. To cash a check f | `CheckID` | String | The ID of the Check object in the ledger to cancel. You can get this information by looking up the metadata of the CheckCreate transaction using the [`tx` method](reference-rippled.html#tx) or by looking for Checks using the [`account_objects` method](reference-rippled.html#account-objects). | | `DeliverMin` | String or Object (Amount) | A minimum amount to receive from the Check. If you cannot receive at least this much, cashing the Check fails, leaving the Check in the ledger so you can try again. For XRP, this must be a string specifying drops of XRP. For issued currencies, this is an object with `currency`, `issuer`, and `value` fields. The `currency` and `issuer` fields must match the corresponding fields in the Check object, and the `value` must be less than or equal to the amount in the Check object. For more information on specifying currency amounts, see [Specifying Currency Amounts][]. | +#### Example CheckCash Preparation for a flexible amount + +The following examples show how to prepare a transaction to cash a Check for a flexible amount. + + + +*JSON-RPC, WebSocket, or Commandline* + +``` +{ + "Account": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "TransactionType": "CheckCash", + "DeliverMin": "95000000", + "CheckID": "2E0AD0740B79BE0AAE5EDD1D5FC79E3C5C221D23C6A7F771D85569B5B91195C2" +} +``` + +*RippleAPI* + +```js +{% include 'code_samples/checks/js/prepareCashFlex.js' %} +``` + + + ### {{cash_flex_n.next()}}. Sign the CheckCash transaction +{% include 'snippets/tutorial-sign-step.md' %} + +#### Example Request + + + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/sign-cash-flex-req.sh' %} +``` + + + + +#### Example Response + + + +*Commandline* + +```json +{% include 'code_samples/checks/cli/sign-cash-flex-resp.txt' %} +``` + + + + ### {{cash_flex_n.next()}}. Submit the signed CheckCash transaction -***TODO: examples of submitting signed blob*** +{% set step_1_link = "#1-prepare-the-checkcash-transaction-1" %} +{% include 'snippets/tutorial-submit-step.md' %} + +#### Example Request + + + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/submit-cash-flex-req.sh' %} +``` + + + + +#### Example Response + + + +*Commandline* + +```json +{% include 'code_samples/checks/cli/submit-cash-flex-resp.txt' %} +``` + + ### {{cash_flex_n.next()}}. Wait for validation @@ -460,6 +846,33 @@ Figure out the values of the [CheckCash transaction][] fields. To cash a check f Use the [`tx` method](reference-rippled.html#tx) with the CheckCash transaction's identifying hash to check its status. Look for a `"TransactionResult": "tesSUCCESS"` field in the transaction's metadata, indicating that the transaction succeeded, and the field `"validated": true` in the result, indicating that this result is final. +#### Example Request + + + +*Commandline* + +```bash +{% include 'code_samples/checks/cli/tx-cash-flex-req.sh' %} +``` + + + + +#### Example Response + + + +*Commandline* + +```json +{% include 'code_samples/checks/cli/tx-cash-flex-resp.txt' %} +``` + + + +#### Handling Errors + If cashing the Check failed with a `tec`-class code, look up the code in the [Full Transaction Response List](reference-transaction-format.html#full-transaction-response-list) and respond accordingly. Some common possibilities for CheckCash transactions: | Result Code | Meaning | How to Respond | @@ -469,7 +882,7 @@ If cashing the Check failed with a `tec`-class code, look up the code in the [Fu | `tecNO_LINE` | The recipient doesn't have a trust line for the Check's currency. | If you want to hold this currency from this issuer, create a trust line for the specified currency and issuer with a reasonable limit using a [TrustSet transaction][], then try to cash the check again. | | `tecNO_PERMISSION` | The sender of the CheckCash transaction isn't the `Destination` of the Check. | Double-check the `Destination` of the Check. | | `tecNO_AUTH` | The issuer of the currency from the check is using [Authorized Trust Lines](concept-authorized-trust-lines.html) but the recipient's trust line to the issuer is not approved. | Ask the issuer to authorize this trust line, then try again to cash the Check after they do. | -| `tecPATH_PARTIAL` | The Check could not deliver enough issued currency, either due to trust line limits or because the sender does not have enough balance of the currency to send (after including the issuer's [transfer fee](concept-transfer-fee.html), if there is one). ***TODO: confirm this.*** | If the problem is the trust line limit, send a [TrustSet transaction][] to increase your limit (if desired) or lower your balance by spending some of the currency, then try to cash the Check again. If the problem is the sender's balance, wait for the sender to have more of the Check's currency, or try again to cash the Check for a lesser amount. | +| `tecPATH_PARTIAL` | The Check could not deliver enough issued currency, either due to trust line limits or because the sender does not have enough balance of the currency to send (after including the issuer's [transfer fee](concept-transfer-fee.html), if there is one). | If the problem is the trust line limit, send a [TrustSet transaction][] to increase your limit (if desired) or lower your balance by spending some of the currency, then try to cash the Check again. If the problem is the sender's balance, wait for the sender to have more of the Check's currency, or try again to cash the Check for a lesser amount. | | `tecUNFUNDED_PAYMENT` | The Check could not deliver enough XRP. | Wait for the sender to have more XRP, or try again to cash the Check for a lesser amount. | ### {{cash_flex_n.next()}}. Confirm delivered amount @@ -477,11 +890,45 @@ If cashing the Check failed with a `tec`-class code, look up the code in the [Fu If the Check was cashed for a flexible `DeliverMin` amount and succeeded, you can assume that the Check was cashed for at least the `DeliverMin` amount. To get the exact amount delivered, check the transaction metadata. The metadata's `AffectedNodes` array contains one or two objects that reflect the change in balances from cashing the Check, depending on the type of currency. - For XRP, the `AccountRoot` object of the Check's sender has its XRP `Balance` field debited. The `AccountRoot` object of the Check's recipient (the one who sent the CheckCash transaction) has its XRP `Balance` credited for at least the `DeliverMin` of the CheckCash transaction minus the [transaction cost](concept-transaction-cost.html) of sending the transaction. -- For issued currencies where the sender or recipient of the check is the issuer, the `RippleState` object representing the trust line between those accounts has its `Balance` adjusted in the favor of the Check's recipient. -- For issued currencies with a third-party issuer, there are changes to two `RippleState` objects, representing the trust lines connecting the sender to the issuer, and the issuer to the recipient. The `RippleState` object representing the relationship between the Check's sender and the issuer has its `Balance` changed in favor of the issuer, and the `RippleState` object representing the relationship between the issuer and the recipient has its `Balance` changed in favor of the recipient. - - If the issued currency has a [transfer fee](concept-transfer-fees.html), the Check's sender may be debited more than the recipient is credited. (The difference is the transfer fee, which is returned to the issuer as a decreased net obligation.) -***TODO: clarify the above with more precise examples?*** + For example, the following `ModifiedNode` shows that the the account rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis, the Check's recipient and the sender of this CheckCash transaction, had its XRP balance change from `9999999970` drops to `10099999960` drops, meaning the recipient was credited a _net_ of 99.99999 XRP as a result of processing the transaction. + + { + "ModifiedNode": { + "FinalFields": { + "Account": "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "Balance": "10099999960", + "Flags": 0, + "OwnerCount": 2, + "Sequence": 5 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "7939126A732EBBDEC715FD3CCB056EB31E65228CA17E3B2901E7D30B90FD03D3", + "PreviousFields": { + "Balance": "9999999970", + "Sequence": 4 + }, + "PreviousTxnID": "0283465F0D21BE6B1E91ABDE17266C24C1B4915BAAA9A88CC098A98D5ECD3E9E", + "PreviousTxnLgrSeq": 8005334 + } + } + + The net amount of 99.99999 XRP includes deducting the transaction cost is destroyed to pay for sending this CheckCash transaction. The following transaction instructions (excerpted) show that the transaction cost (the `Fee` field) was 10 drops of XRP. By adding this to the net balance change, we conclude that the recipient, rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis, was credited a _gross_ amount of exactly 100 XRP for cashing the Check. + + "Account" : "rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis", + "TransactionType" : "CheckCash", + "DeliverMin" : "95000000", + "Fee" : "10", + +- For issued currencies where the sender or recipient of the check is the issuer, the `RippleState` object representing the trust line between those accounts has its `Balance` adjusted in the favor of the Check's recipient. + + + +- For issued currencies with a third-party issuer, there are changes to two `RippleState` objects, representing the trust lines connecting the sender to the issuer, and the issuer to the recipient. The `RippleState` object representing the relationship between the Check's sender and the issuer has its `Balance` changed in favor of the issuer, and the `RippleState` object representing the relationship between the issuer and the recipient has its `Balance` changed in favor of the recipient. + + + + - If the issued currency has a [transfer fee](concept-transfer-fees.html), the Check's sender may be debited more than the recipient is credited. (The difference is the transfer fee, which is returned to the issuer as a decreased net obligation.) diff --git a/content/tutorial-regular-keys.md b/content/tutorial-regular-keys.md index b2adb1165a..3979a7bb09 100644 --- a/content/tutorial-regular-keys.md +++ b/content/tutorial-regular-keys.md @@ -130,7 +130,7 @@ When you make subsequent `SetRegularKey` requests, you can sign using the existi #### Sign Your Transaction -The most secure way to sign a transaction is to do it offline with a signing library, such as [RippleAPI](reference-rippleapi.html#offline-functionality). Alternatively, you can sign the transaction using the [`sign`](reference-rippled.html#sign) command, but this must be done through a trusted and encrypted connection, or through a local connection, and only to a server you control. +{% include 'snippets/tutorial-sign-step.md' %} Populate the request fields with the following values: