Listtransactions - How Does It Work?

Discussion in 'Transactions' started by kripto, Apr 25, 2016.

  1. 2017/12/15 - Decred v1.1.2 released! → Release Notes  → Downloads
  1. kripto

    kripto New Member

    Jan 13, 2016
    17
    3
    #1 kripto, Apr 25, 2016
    Last edited: Apr 26, 2016
    Sorry for the long post but I'll try to describe my pain as best as I can.

    help says:
    listtransactions ("account" count=10 from=0 includewatchonly=false)

    What do "count" and "from" input params stand for exactly?

    I'm on v0.1.0. using testnet.

    History of my testnet wallet transactions as I understand them:
    1. received 10 DCR from a good guy on this forum, he sent it to TshrtfsFLv2wKMXkCYkzMiRxfewmy6eNvrr which is in my testnet wallet
    2. sent 1 DCR to TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU which is in my own testnet wallet:
    curl -XPOST -d '{"jsonrpc": "2.0", "id":"kg_callid", "method": "sendfrom", "params": ["default","TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",1,10]}' 'testnet:testnet@127.0.0.1:19110'
    3. sent 0.5 DCR TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU which is in my own testnet wallet:
    curl -XPOST -d '{"jsonrpc": "2.0", "id":"kg_callid", "method": "sendfrom", "params": ["default","TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",0.5,10]}' 'testnet:testnet@127.0.0.1:19110'
    4. sent 0.75 DCR to TsWk5uMnhrK8KsLQZMGXw9rmEtYxuv6vyBB which is in wallet.decred.org (testnet):
    curl -XPOST -d '{"jsonrpc": "2.0", "id":"kg_callid", "method": "sendfrom", "params": ["default","TsWk5uMnhrK8KsLQZMGXw9rmEtYxuv6vyBB",0.75,10]}' 'testnet:testnet@127.0.0.1:19110'
    5, sent 0.74 DCR (0.01 was fee) back to TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU which is in my testnet wallet


    * if I query my testnet wallet with listtransactions ("*" count=1 from=0) - my expectation was to get the last transaction connected to my wallet instead I get empty list (the same is for count 2 and 3):
    curl -s -XPOST -d '{"jsonrpc": "2.0", "id":"kg_callid", "method": "listtransactions", "params": ["*",1,0,false]}' 'testnet:testnet@127.0.0.1:19110'
    ---
    Code:
    {
       "id" : "kg_callid",
       "result" : [],
       "error" : null
    }
    * if I query my testnet wallet with listtransactions ("*" count=100 from=0) - my expectation was to get all transaction connected to my wallet, so 5 of them, instead I get 9 transactions. It seems both "external" (sent not from my wallet) receive transactions have companioning send transaction (has same txid) with the same although negative amount as the receive ones. Both my "internal" (sent to the address within my wallet) send transactions have companioning receive transaction (has same txid) with the same although positive amount. The only "non-double" transaction is the one I sent to wallet.decred.org (testnet):
    curl -s -XPOST -d '{"jsonrpc": "2.0", "id":"kg_callid", "method": "listtransactions", "params": ["*",100,0,false]}' 'testnet:testnet@127.0.0.1:19110'
    ---
    Code:
    {
       "error" : null,
       "id" : "kg_callid",
       "result" : [
          {
             "walletconflicts" : [],
             "timereceived" : 1461422353,
             "fee" : 0,
             "vout" : 0,
             "account" : "",
             "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
             "category" : "send",
             "confirmations" : 1139,
             "blocktime" : 1461422388,
             "blockhash" : "000000001164969faa70e6e5ce09a60f3b5656e1d99dcf5b1f322f0c98b1b3c2",
             "txid" : "b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26",
             "time" : 1461422353,
             "amount" : -0.74
          },
          {
             "vout" : 0,
             "account" : "default",
             "walletconflicts" : [],
             "timereceived" : 1461422353,
             "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
             "category" : "receive",
             "txid" : "b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26",
             "confirmations" : 1139,
             "blocktime" : 1461422388,
             "blockhash" : "000000001164969faa70e6e5ce09a60f3b5656e1d99dcf5b1f322f0c98b1b3c2",
             "amount" : 0.74,
             "time" : 1461422353
          },
          {
             "amount" : -0.75,
             "time" : 1461418681,
             "txid" : "09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34",
             "blockhash" : "000000000abcdf9fc2dd62089012f8659f64ae31fe596786bebe252af07b86c8",
             "blocktime" : 1461419993,
             "confirmations" : 1156,
             "category" : "send",
             "address" : "TsWk5uMnhrK8KsLQZMGXw9rmEtYxuv6vyBB",
             "account" : "",
             "vout" : 1,
             "fee" : -2.53e-06,
             "timereceived" : 1461418681,
             "walletconflicts" : []
          },
          {
             "amount" : -0.5,
             "time" : 1461418487,
             "txid" : "02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d",
             "blockhash" : "0000000005d37da7aafbd0a61ee00a939a07f0a484b4d961b63ee87d49b67309",
             "confirmations" : 1165,
             "blocktime" : 1461418661,
             "category" : "send",
             "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
             "vout" : 0,
             "account" : "",
             "fee" : -2.53e-06,
             "timereceived" : 1461418487,
             "walletconflicts" : []
          },
          {
             "amount" : 0.5,
             "time" : 1461418487,
             "txid" : "02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d",
             "blockhash" : "0000000005d37da7aafbd0a61ee00a939a07f0a484b4d961b63ee87d49b67309",
             "blocktime" : 1461418661,
             "confirmations" : 1165,
             "category" : "receive",
             "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
             "account" : "default",
             "vout" : 0,
             "timereceived" : 1461418487,
             "walletconflicts" : []
          },
          {
             "category" : "send",
             "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
             "timereceived" : 1461404895,
             "walletconflicts" : [],
             "vout" : 0,
             "account" : "",
             "fee" : -2.53e-06,
             "time" : 1461404895,
             "amount" : -1,
             "blockhash" : "00000000047eca73fc2c459749b72a2cbbe2a9b13c80908ad952d913296b9af7",
             "confirmations" : 1263,
             "blocktime" : 1461404925,
             "txid" : "0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467"
          },
          {
             "account" : "default",
             "vout" : 0,
             "walletconflicts" : [],
             "timereceived" : 1461404895,
             "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
             "category" : "receive",
             "txid" : "0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467",
             "confirmations" : 1263,
             "blocktime" : 1461404925,
             "blockhash" : "00000000047eca73fc2c459749b72a2cbbe2a9b13c80908ad952d913296b9af7",
             "amount" : 1,
             "time" : 1461404895
          },
          {
             "txid" : "063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4",
             "blocktime" : 1460946992,
             "confirmations" : 5052,
             "blockhash" : "000000000d62c7b8e3fc41e0f37b93e7dd7e65436d5ab07a18c65ee6b1c702d8",
             "amount" : -10,
             "time" : 1460946901,
             "fee" : 0,
             "vout" : 1,
             "account" : "",
             "walletconflicts" : [],
             "timereceived" : 1460946901,
             "address" : "TshrtfsFLv2wKMXkCYkzMiRxfewmy6eNvrr",
             "category" : "send"
          },
          {
             "vout" : 1,
             "account" : "default",
             "timereceived" : 1460946901,
             "walletconflicts" : [],
             "category" : "receive",
             "address" : "TshrtfsFLv2wKMXkCYkzMiRxfewmy6eNvrr",
             "txid" : "063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4",
             "blockhash" : "000000000d62c7b8e3fc41e0f37b93e7dd7e65436d5ab07a18c65ee6b1c702d8",
             "confirmations" : 5052,
             "blocktime" : 1460946992,
             "amount" : 10,
             "time" : 1460946901
          }
       ]
    }
    

    I want to include Decred as a payment option in my gaming/betting project so what I actually need is track deposits/withdrawals of my users which I find hard to do with listtransactions. I even tried to use gettransaction/
    gettxout functions which I found similarly confusing. Maybe I just don't understand the use of these functions good enough or maybe some other approach would be better.

    Can someone please help me understand how this API works.

    Thx,
    kripto
     
    Noah likes this.
  2. kripto

    kripto New Member

    Jan 13, 2016
    17
    3
    it's the same with upgrade to v0.1.1
     
  3. Ayush

    Ayush Full Member
    Advocate (Facebook)

    Jan 9, 2016
    512
    100
    Male
    .
    .
    Does simply using just --listtransactions work?
    Cause it works for me
     
  4. David

    David Sr. Member

    Jan 22, 2016
    364
    207
    Male
    USA
    Use the "help" command in dcrctl for more information. Example:

    Code:
    C:\>dcrctl help --wallet listtransactions
    listtransactions ("account" count=10 from=0 includewatchonly=false)
    
    Returns a JSON array of objects containing verbose details for wallet transactions.
    
    Arguments:
    1. account          (string, optional)                 DEPRECATED -- Unused (must be unset or "*")
    2. count            (numeric, optional, default=10)    Maximum number of transactions to create results from
    3. from             (numeric, optional, default=0)     Number of transactions to skip before results are created
    4. includewatchonly (boolean, optional, default=false) Unused
    
    Result:
    [{
     "account": "value",               (string)          DEPRECATED -- Unset
     "address": "value",               (string)          Payment address for a transaction output
     "amount": n.nnn,                  (numeric)         The value of the transaction output valued in decred
     "blockhash": "value",             (string)          The hash of the block this transaction is mined in, or the empty string if unmined
     "blockindex": n,                  (numeric)         Unset
     "blocktime": n,                   (numeric)         The Unix time of the block header this transaction is mined in, or 0 if unmined
     "category": "value",              (string)          The kind of transaction: "send" for sent transactions, "immature" for immature coinbase outputs, "generate"
     for mature coinbase outputs, or "recv" for all other received outputs.  Note: A single output may be included multiple times under different categories
     "confirmations": n,               (numeric)         The number of block confirmations of the transaction
     "fee": n.nnn,                     (numeric)         The total input value minus the total output value for sent transactions
     "generated": true|false,          (boolean)         Whether the transaction output is a coinbase output
     "involveswatchonly": true|false,  (boolean)         Unset
     "time": n,                        (numeric)         The earliest Unix time this transaction was known to exist
     "timereceived": n,                (numeric)         The earliest Unix time this transaction was known to exist
     "txid": "value",                  (string)          The hash of the transaction
     "vout": n,                        (numeric)         The transaction output index
     "walletconflicts": ["value",...], (array of string) Unset
     "comment": "value",               (string)          Unset
     "otheraccount": "value",          (string)          Unset
    },...]
    
    Therefore, the syntax should be:
    Code:
    dcrctl --wallet listtransactions * 1000
    ...to list the last 100 transactions.

    When looking at transactions I prefer to redirect the output into a text file and then copy everything into a spreadsheet for manageability. Example:
    Code:
    dcrctl --wallet listtransactions * 1000 > transactionlist.txt
     
    chappjc likes this.
  5. root

    root Member

    Feb 3, 2016
    381
    76
    jq - Command-line JSON processor
    can be useful - e.g.
    listtransactions '*' 999999 | jq '.[:3]'
     
    chappjc likes this.
  6. kripto

    kripto New Member

    Jan 13, 2016
    17
    3
    #6 kripto, Apr 28, 2016
    Last edited: Apr 28, 2016
    @David: sure I can use dcrctl instead of JSON-RPC but my confusion remains.

    Actual history of my local wallet:
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4 ... 1st tx (received 10 DCR from a guy on this forum)
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467 ... 2nd tx (sent 1 DCR to the address inside my local wallet)
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d ... 3rd tx (sent 0.5 DCR to the address inside my local wallet)
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34 ... 4th tx (sent 0.75 DCR to online wallet)
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26 ... 5th tx (received 0.74 DCR from online wallet)


    Problems when using listtransactions

    1. Duplication of transactions in the list. The only non-duplicated transaction is the one representing DCR sent from my local wallet to online wallet (https://wallet.decred.org) - txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34
    2. According to my experimentation with count/from params it looks like there are 3 "phantom transactions" at the end (chronologically) of my transaction list.


    These are transactions returned using various count/from parameters. Transactions are in exact order as outputed by dcrctl (complete JSON was intentionally omitted for clarity reasons):

    dcrctl --wallet listtransactions '*' 10000 0
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4

    dcrctl --wallet listtransactions '*' 1 0
    returns empty list

    dcrctl --wallet listtransactions '*' 2 0
    returns empty list

    dcrctl --wallet listtransactions '*' 3 0
    returns empty list

    dcrctl --wallet listtransactions '*' 4 0
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26

    dcrctl --wallet listtransactions '*' 5 0
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34

    dcrctl --wallet listtransactions '*' 6 0
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d

    dcrctl --wallet listtransactions '*' 7 0
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467

    dcrctl --wallet listtransactions '*' 8 0
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4

    dcrctl --wallet listtransactions '*' 1 3
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26
    txid:b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26

    dcrctl --wallet listtransactions '*' 1 4
    txid:09be7567b3f5d7d1d1921e74def0257ef6cd72404037dad6a0f1920477398d34

    dcrctl --wallet listtransactions '*' 1 5
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d
    txid:02b9a97435d18c275085867943cf02dba6656255de80c72072fffba7f10e4e8d

    dcrctl --wallet listtransactions '*' 1 6
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467
    txid:0dae564d9c907169ce7a8fc8ead2ee22d38cb67ae74d53ee66ecd2236da82467

    dcrctl --wallet listtransactions '*' 1 7
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4
    txid:063221486436dc1db17cf9a69f7c481f51693e8b33caee55dd2e787e25b9f2d4


    I would really like to know what is going on with phantom transactions and duplications in the list.
     
  7. kripto

    kripto New Member

    Jan 13, 2016
    17
    3
    I did complete blockchain resync from testnet genesis and create a fresh wallet from my seed but the mystery remains.

    My best guess is that 3 phantom transaction are there due to funds being transferred between addresses within my local wallet. All "duplications" are there most probably due to the same reason which can actually be understood as transaction within the wallet has dual nature - one is the 'send' and the other the 'receive' part. What I don't understand is why the last actual transaction (sending 0.74 DCR from online wallet to the local one) is also duplicated. I would expect there to be only the 'receive' part but using listtransactions shows also the 'send' one:

    {
    "walletconflicts" : [],
    "timereceived" : 1461926920,
    "blockhash" : "000000001164969faa70e6e5ce09a60f3b5656e1d99dcf5b1f322f0c98b1b3c2",
    "vout" : 0,
    "fee" : 0,
    "blocktime" : 1461422388,
    "txid" : "b70b52e3ff649cd01a4911d29117b50171bc1bf8baf798921bebac2eb9f37e26",
    "account" : "",
    "amount" : -0.74,
    "category" : "send",
    "address" : "TsnJCvM3W8meR183GtLwS7KUgKTXhppLVnU",
    "time" : 1461926920,
    "confirmations" : 4163
    }

    Why?
     
  8. kripto

    kripto New Member

    Jan 13, 2016
    17
    3
  9. root

    root Member

    Feb 3, 2016
    381
    76
    #9 root, May 31, 2016
    Last edited: May 31, 2016
    Any update with this bug please ? I tried
    listtransactions '*' 9999999 0 | grep txid | cut -d':' -f2 | uniq -d | wc -l
    and something like 1/3 of all txids are repeated.

    After the wallet was recreated from seed, the result was the same.

    I'd say proper transaction handling is the core of a good cryptocurrency, but may be it is just a small "reporting issue".

    EDIT: tested with latest from git
     
  10. root

    root Member

    Feb 3, 2016
    381
    76
    Nearly a month passed already, any update here please ?
    Tested with 0.1.6, testnet, over 11000 duplicates.
     
  11. ay-p

    ay-p Full Member
    Developer

    Dec 7, 2015
    148
    106
    Male
    Looking into the original bug now (as reported by @kripto)

    But there are going to be txid dups in there, there are entries for every vout that all share the same txid.
     
    chappjc and raedah like this.
  12. root

    root Member

    Feb 3, 2016
    381
    76
    Well - so it is not a bug - please tell jc-v to change github tag that this is not a bug, but a feature :)
     
  13. raedah

    raedah Jr. Member

    Mar 6, 2016
    55
    36
    Yes. It can be noted that this is the same way btcd and bitcoin core function as well.
     

Share This Page