stellar-deprecated/stellard

account_tx ignores "forward" key if ledger_min/ledger_max set

Closed this issue · 2 comments

When sending an account_tx RPC call, the "forward" key is ignored if the "ledger_min" or "ledger_max" keys are included (even if both are set to -1).

Furthermore, when not using "ledger_min"/"ledger_max", the (undocumented in Stellar, but documented in Ripple) "marker" field is present in the result, and can be used on subsequent calls. But if "ledger_min" or "ledger_max" is used, "marker" disappears and instead we get "offset".

Similarly, if "offset" is present in the request, then "marker" is not returned and instead "offset" shows up in the response, though this bit isn't particularly surprising. FWIW "forward" works just fine with "offset", as long as "ledger_min" and "ledger_max" are omitted.

Example:

curl -X POST https://test.stellar.org:9002 -d '
{
  "method": "account_tx",
  "params": [
    {
      "account": "ganVp9o5emfzpwrG5QVUXqMv8AgLcdvySb",
      "limit" : 1,
      "forward": true
    }
  ]
}'
{
   "result" : {
      "account" : "ganVp9o5emfzpwrG5QVUXqMv8AgLcdvySb",
      "ledger_index_max" : 86715,
      "ledger_index_min" : 0,
      "limit" : 1,
      "marker" : {
         "ledger" : 461,
         "seq" : 0
      },
      "status" : "success",
      "transactions" : [
         {
            "meta" : { ... },
            "tx" : {
               "ledger_index" : 457
               ...
            },
            "validated" : true
         }
      ]
   }
}

Note the presence of "marker". Same example with the default values for ledger_min/ledger_max:

curl -X POST https://test.stellar.org:9002 -d '
{
  "method": "account_tx",
  "params": [
    {
      "account": "ganVp9o5emfzpwrG5QVUXqMv8AgLcdvySb",
      "limit" : 1,
      "forward": true,
      "ledger_min": 0,
      "ledger_max": -1
    }
  ]
}'
{
   "result" : {
      "account" : "ganVp9o5emfzpwrG5QVUXqMv8AgLcdvySb",
      "ledger_index_max" : 86708,
      "ledger_index_min" : 0,
      "limit" : 1,
      "offset" : 0,
      "status" : "success",
      "transactions" : [
         {
            "meta" : { ... },
            "tx" : {
               "ledger_index" : 86674
               ...
            },
            "validated" : true
         }
      ],
      "validated" : false
   }
}

No "marker", instead this time we get "offset". Similarly, the "ledger_index" on the transaction is now 86674, i.e. the most recent, instead of 457, indicating that "forward" was ignored.

Clone of #37 . Updated API docs aren't deployed yet.

Use ledger_index_min and ledger_index_max instead of ledger_min and ledger_max.