Author Topic: A few suggestions for wallet_account_transaction_history...  (Read 1139 times)

0 Members and 1 Guest are viewing this topic.

Offline jamesc

Code: [Select]
wallet_account_transaction_history
  account_name (string, optional, defaults to "")
  asset_symbol (string, optional, defaults to "")
  limit (int32_t, optional, defaults to 0)
  start_block_num (uint32_t, optional, defaults to 0)
  end_block_num (uint32_t, optional, defaults to -1)

This call returns a list of transactions for a given account or multiple accounts in the wallet.  Included in each transaction entry is an array of running_balances.  The running_balances array is just how it sounds, a running total of the accounts balance just like what you would see on your bank statement:

Code: [Select]
TRANSACTION AMOUNT BALANCE
alice to bob +5 5
bob to alice -5 0

When I'm viewing just bob or alice, this list makes perfect since and this is just what the API does.

The confusion comes in when one starts with a higher block number (after alice transfers money to bob).  Currently the API will return this:

Code: [Select]
TRANSACTION AMOUNT BALANCE
bob to alice -5 -5

I would say, that is not correct, it should instead return this:

Code: [Select]
TRANSACTION AMOUNT BALANCE
bob to alice -5 0

Finally, there is one more consideration and this one is probably optional.  I do however see that with security like multi-sig is will be safer to have have larger wallets with more accounts.  So, when querying in a large wallet for say 100 accounts (or leaving the account_name empty), currently each transaction return will have a `running_balances` return for all accounts in the wallet.  Think about your bank statement, running balances only make since when your looking at a single account at a time.  I'm not aware of any case where you want to see all of these running balances together unless your intent is to cache them and report them as single accounts at a time.  If your going to cache them and group into single accounts then it should be trivial to collect up all the smaller balance records from separate transactions and total them.  In other works, each `running_blanaces` array should only contain balances for the accounts involved in that transaction.

This is one test ledger entry from "GENESIS" to "delegate44" as returned by `wallet_account_transaction_history`:

Code: [Select]
{
    "is_virtual": true,
    "is_confirmed": true,
    "is_market": false,
    "is_market_cancel": false,
    "trx_id": "f85054558d6c2ad7fb1021455109817ad3dfc7a1",
    "block_num": 0,
    "ledger_entries": [{
        "from_account": "GENESIS",
        "to_account": "delegate44",
        "amount": {
          "amount": 1980198019801,
          "asset_id": 0
        },
        "memo": "claim PjETkso5HWNvUp5PusP8nufyv192aMe2Ph",
        "running_balances": [[
            "alice",[[
                0,{
                  "amount": 0,
                  "asset_id": 0
                }
              ]
            ]
          ],[
            "bob",[[
                0,{
                  "amount": 0,
                  "asset_id": 0
                }
              ]
            ]
          ],[