btcwallet icon indicating copy to clipboard operation
btcwallet copied to clipboard

`listsinceblock` lists additional transactions in category send

Open arnuschky opened this issue 10 years ago • 7 comments

So, this is the bug I've mentioned in #263: listsinceblock lists additional transactions that are not present in the bitcoin core result.

I now realized that all additional transactions reported have the category send even when they haven't been sent from an address in the local wallet. Sorry for not spotting this earlier, but this seems to be a real bug (TM).

Example transaction: http://tbtc.blockr.io/tx/info/0154b341c081a35c316554e1f628919232bbf3769e4ca63188997200b1e5bee7 migiScBNvVKYwEiCFhgBNGtZ87cdygtuSQ is in the wallet, all others are not. btcd correctly returns the receive transaction, but also lists it again as a send.

arnuschky avatar May 13 '15 17:05 arnuschky

I checked on the various block explorers and that address currently has a "balance" of zero (addresses don't have balances, but bear with me), so for every received output in the recv category (or immature, generate, etc.) there should also be a send category, since it was included as an input in another transaction.

jrick avatar May 13 '15 17:05 jrick

Were all the redeeming transactions created by the same wallet? Because btcwallet will still create results in the "send" category when any output is redeemed, even if it did not author and send the transaction.

jrick avatar May 13 '15 17:05 jrick

For every outgoing transaction, btcwallet also lists a 'send' transaction that matches the data of the input spend.

Example:

"transactions": [
    {
      "account": "",
      "address": "mgHzfpfrn1T5dKWACJBcbrGF63PZiguX1W",
      "amount": -0.02,
      "category": "send",
      "confirmations": -1,
      "fee": 0,
      "time": 1431562566,
      "timereceived": 1431562566,
      "txid": "d7e2b041353c57ac39612ac9edd8600e6392757f1e27734f1308c5ae4a3e3965",
      "vout": 0,
      "walletconflicts": []
    },
    {
      "account": "",
      "address": "mgHzfpfrn1T5dKWACJBcbrGF63PZiguX1W",
      "amount": 0.02,
      "category": "receive",
      "confirmations": -1,
      "time": 1431562566,
      "timereceived": 1431562566,
      "txid": "d7e2b041353c57ac39612ac9edd8600e6392757f1e27734f1308c5ae4a3e3965",
      "vout": 0,
      "walletconflicts": []
    },
   ...
]

The second item is the output towards a wallet address, listed as 'receive transaction'. This is correct and also given by bitcoin core. The first item is the wrong 'spend transaction' that appears once the output given in the second item is spend.

Note that the values seem to be the same as for the second item, except an inverted amount and the category. This bug is independent from whether there is change towards the wallet or not. Also change to same or another address doesn't not affect this bug.

Maybe this helps.

arnuschky avatar May 14 '15 00:05 arnuschky

I've gone back and took another look at how core is doing it, and I believe the added objects are the same but the order is different. In core, for each transaction, for each non-change output, if the transaction debits from the wallet, each output is added as sent, and then each received output is added as received. Our code is alternating between adding send and receive categories for each unspent output, instead of looping twice over the outputs.

jrick avatar May 14 '15 17:05 jrick

Sorry for late feedback, I was travelling. Any news on this? If I understand correctly, your last remark doesn't explain why there are additional objects in btcwallet's output, only why there's a different order, no?

arnuschky avatar May 21 '15 09:05 arnuschky

I'm not yet sure why it's adding additional objects. I'll compare against bitcoind behavior later today.

jrick avatar May 21 '15 14:05 jrick

Let me know if I can help with anything.

arnuschky avatar May 21 '15 16:05 arnuschky