送金元に基づくCheckの検索

Checks Amendmentが必要です。

このチュートリアルでは、Checkをその送金元で検索する方法を説明します。Checkを受取人で検索することもできます。

1. 特定のアドレスのすべてのCheckの検索

特定のアドレスで受信および送信されるすべてのCheckのリストを取得するには、送金元アカウントのアドレスを指定したaccount_objectsコマンドを実行し、要求のtype フィールドをchecksに設定します。

注記:account_objectsコマンドのコマンドラインインターフェイスではtypeフィールドは受け入れられません。代わりにjsonメソッドを使用してコマンドラインからJSON-RPCフォーマットの要求を送信できます。

注意: RippleAPIには、account_objectsメソッドの組み込みサポートはありません。api.connection.request(websocket_request_json)メソッドを使用して、Webフォーマットで未加工の要求を作成できます。このメソッドに対する応答のフォーマットはrippled APIフォーマットです。(たとえばXRPは小数ではなく整数の「drop数」で指定します。)

要求の例

'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)
{
    "method": "account_objects",
    "params": [
        {
            "account": "rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za",
            "ledger_index": "validated",
            "type": "check"
        }
    ]
}

応答の例

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
200 OK

{
  "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
  }
}

2. 送金元に基づく応答の絞り込み

応答には、要求のアカウントが送金元であるCheckと、アカウントが受取人であるCheckが含まれていることがあります。応答のaccount_objects配列の各メンバーは1つのCheckを表します。これらの各Checkオブジェクトでは、AccountのアドレスはそのCheckの送金元のアドレスです。

以下の疑似コードに、送金元で応答を絞り込む方法を示します。

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