Wrong Outputs in gettransaction query #4807

issue mohamedfarrag openend this issue on September 1, 2014
  1. mohamedfarrag commented at 1:49 pm on September 1, 2014: none

    I got this transaction outputs from bitcoin-qt gettransaction c9c3e63c2e94f643957a6980689c7b2b80eeb645c6f3a47dd0b551c8c4de6cc7 { “amount” : 0.00000000, “fee” : 0.00000000, “confirmations” : 1215, “blockhash” : “00000000000000001b295c20166ff208e6cbb45317bc1c0046c1b496fba11de8”, “blockindex” : 30, “blocktime” : 1408959427, “txid” : “c9c3e63c2e94f643957a6980689c7b2b80eeb645c6f3a47dd0b551c8c4de6cc7”, “walletconflicts” : [ ], “time” : 1408959427, “timereceived” : 1409566299, “details” : [ { “account” : “”, “address” : “1LYUg6Vf3xHsGZNWqbUkqX2pPWBV6jsUGR”, “category” : “send”, “amount” : -2.50050000, “fee” : 0.00000000 }, { “account” : “”, “address” : “1GS527HMj5iv5F2m26C84QzCCVek5pArje”, “category” : “send”, “amount” : -0.42010000, “fee” : 0.00000000 }, { “account” : “520c7bb149ede83218f46c96”, “address” : “1LYUg6Vf3xHsGZNWqbUkqX2pPWBV6jsUGR”, “category” : “receive”, “amount” : 2.50050000 }, { “account” : “520c7bb149ede83218f46c96”, “address” : “1GS527HMj5iv5F2m26C84QzCCVek5pArje”, “category” : “receive”, “amount” : 0.42010000 } ], “hex” : “0100000001c787eb10af208c22484ff037ec17f1fbf44ff8e85af8e5cd08d7fa133d254fc0000000006b483045022100e00869aba056388aadea6ee9e82b6834822a6e5719ce1d3b8ddf8e394e826432022064fb9d133a20c1a4cb1c0fa66db2ceea5a787e9b38dd15be1384ba47dc23a69a0121034ef6e5a1d33180a5899d54816ae27784d0eb5f0269dde87b218d904a9f67da7dffffffff03d075e70e000000001976a914d65e62c64c8ecf246b1eaa6f3a567da300d0f04d88acd0d4ab04000000001976a9149a0875284b705871f158a45d9eb89bf0ed12428088ac90058102000000001976a914a947a40a737c889cac29ba8391c73b8cc0fc7b1188ac00000000” }

    While it looks different in blockchain.info https://blockchain.info/tx/c9c3e63c2e94f643957a6980689c7b2b80eeb645c6f3a47dd0b551c8c4de6cc7

    2014-09-01 16_45_56-bitcoin transaction c9c3e63c2e94f643957a6980689c7b2b80eeb645c6f3a47dd0b551c8c4de

    Could you please explain it to me I’m little bit confused !

  2. mohamedfarrag commented at 1:51 pm on September 1, 2014: none
    The difference that I noticed is the transaction has 4 outputs from bitcoin-qt while it shows 3 outputs from blockchain ! please correct me if I am wrong. Thank you in advance
  3. sipa commented at 2:01 pm on September 1, 2014: member
    gettransaction is a wallet RPC that shows the effects of a transaction on your wallet. It doesn’t show the raw Bitcoin transaction itself. Use getrawtransaction for that (which needs a full transaction index, you’ll need to set txindex=1 in bitcoin.conf, and reindex).
  4. laanwj commented at 2:07 pm on September 1, 2014: member
    Alternatively, get the hex field from gettransaction output, and pass it to decoderawtransaction
  5. laanwj commented at 2:33 pm on September 1, 2014: member
    Closing as “intended behavior”.
  6. laanwj closed this on Sep 1, 2014

  7. mohamedfarrag commented at 2:47 pm on September 1, 2014: none

    First of all thank you for your quick reply. I did the getrawtransaction command and I got this response : No information available about transaction

    for the other option get the “hex” field and pass it to “decoderawtransaction” I saw that the outputs were correct it showed me three outputs. So let me explain the case , it comes from send bitcoin to myself “Payment to yourself” but I specified the receive address without specify the send address , so why it shows the send also ? in the normal case it shows just the receive address in transaction details!

    The problem now is that I relay on gettransaction in my business logic, is it not precise enough ? should I change it to decoderawtransaction to get precise information ? Thank you again.

  8. sipa commented at 3:36 pm on September 1, 2014: member

    gettransactions simply does not give you inputs and outputs. It gives you “ledger entries” - effects that this transaction has on your wallet. If it contains an output that credits an address of yours, that will be represented as a receive, if it spends coins of yours they will be represented as a send (though with change subtracted).

    If you’re not interested in the wallet effects, but just in the actual inputs and outputs at the Bitcoin transaction level, yes, you’ll have to use the raw data.

    Also, getrawtransaction will not work unless you have a transaction index. Use @laanwj’s suggested instead.

  9. emrekenci commented at 5:35 pm on September 1, 2014: none
    His problem is, the gettransaction does not show the NET effect this transaction had in his wallet. If you take a close look, the same details are shown as both received and sent. Same address same amount only with different category. Normally, gettransaction is supposed to show only 2 out of 3 outputs that this transaction has. Out of three outputs of the transaction 2 addresses belong to him. His wallet should show those two as details. The code he pasted shows that the transaction had 0 effect on his wallet. Which shows wrong behavior. I think he understands gettransaction but there is a problem with his case.
  10. sipa commented at 5:41 pm on September 1, 2014: member
    He reported this to be a send to self. Bitcoin is expected to report the payments to non-change addresses, and for both reports both a send and a receive. That seems to be working as intended to me.
  11. emrekenci commented at 5:55 pm on September 1, 2014: none
    Ah sorry. So but shouldn’t the input address be shown as sent and the two outputs be displayed as received in the transaction details in that case? Why are the outputs being shown as sent and received and the input is not in the details at all?
  12. luke-jr commented at 6:01 pm on September 1, 2014: member
    There is no such thing as an input address. He sent to 1LYUg6Vf3xHsGZNWqbUkqX2pPWBV6jsUGR and 1GS527HMj5iv5F2m26C84QzCCVek5pArje, and at the same time since those are addresses in his wallet, also received with 1LYUg6Vf3xHsGZNWqbUkqX2pPWBV6jsUGR and 1GS527HMj5iv5F2m26C84QzCCVek5pArje.
  13. emrekenci commented at 6:12 pm on September 1, 2014: none
    True I meant sending and receiving with input & output. I understand thanks
  14. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 07:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me