Look Up Checks by Sender

Requires the Checks Amendment.

This tutorial shows how to look up Checks by their sender. You may also want to look up Checks by recipient.

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 method 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

'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"
        }
    ]
}

Example Response

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. 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:

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