[Feature] Allow gettxout to return information for spent outputs #9641

issue kristovatlas opened this issue on January 26, 2017
  1. kristovatlas commented at 9:00 PM on January 26, 2017: none

    Related: #4007

    I'm assuming this is non-trivial to do, but I wish that gettxout could return data for spent outputs. This would allow me to compute, for example, the height at which any transaction was mined. Currently, this is only possible if the transaction in question has one or more unspent outputs due to the current restriction on gettxout.

  2. kristovatlas renamed this:
    Feature request: Allow gettxout to return information for spent outputs
    [Feature] Allow gettxout to return information for spent outputs
    on Jan 26, 2017
  3. TheBlueMatt commented at 9:02 PM on January 26, 2017: contributor

    You can use -txindex and getrawtransaction for this, I believe.

    On January 26, 2017 4:00:29 PM EST, Kristov Atlas notifications@github.com wrote:

    Related: #4007

    I'm assuming this is non-trivial to do, but I wish that gettxout could return data for spent outputs. This would allow me to compute, for example, the height at which any transaction was mined. Currently, this is only possible if the transaction in question has one or more unspent outputs due to the current restriction on gettxout.

    -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/bitcoin/bitcoin/issues/9641

  4. kristovatlas commented at 9:05 PM on January 26, 2017: none

    Sadly, no. Here's an example of data you get from getrawtransaction/decoderawtransaction:

    
    {
        "txid": "8131ffb0a2c945ecaf9b9063e59558784f9c3a74741ce6ae2a18d0571dac15bb",
        "version": 1,
        "locktime": 0,
        "vin": [{
                "txid": "efd9cf795917c178a8fdcc21ec668c17b66958d6cfdba9468561927abe0aaf9d",
                "vout": 0,
                "scriptSig": {
                    "asm": "3046022100c2f7f25be5de6ce88ac3c1a519514379e91f39b31ddff279a3db0b1a229b708b022100b29efbdbd9837cc6a6c7318aa4900ed7e4d65662c34d1622a2035a3a5534a99a01",
                    "hex": "493046022100c2f7f25be5de6ce88ac3c1a519514379e91f39b31ddff279a3db0b1a229b708b022100b29efbdbd9837cc6a6c7318aa4900ed7e4d65662c34d1622a2035a3a5534a99a01"
                },
                "sequence": 4294967295
            },
            {
                "txid": "fbce1a455da4dd974388f22d1241b94f2a63223db16da58d9475f0bd0e3316d5",
                "vout": 0,
                "scriptSig": {
                    "asm": "3044022051243debe6d4f2b433bee0cee78c5c4073ead0e3bde54296dbed6176e128659c022044417bfe16f44eb7b6eb0cdf077b9ce972a332e15395c09ca5e4f602958d266101",
                    "hex": "473044022051243debe6d4f2b433bee0cee78c5c4073ead0e3bde54296dbed6176e128659c022044417bfe16f44eb7b6eb0cdf077b9ce972a332e15395c09ca5e4f602958d266101"
                },
                "sequence": 4294967295
            },
            {
                "txid": "f9839848709b283623fe171142cd7c1be07c417971e544c3b327129633aaf5e1",
                "vout": 0,
                "scriptSig": {
                    "asm": "30440220593252bb992ce3c85baf28d6e3aa32065816271d2c822398fe7ee28a856bc943022066d429dd5025d3c86fd8fd8a58e183a844bd94aa312cefe00388f57c85b0ca3201",
                    "hex": "4730440220593252bb992ce3c85baf28d6e3aa32065816271d2c822398fe7ee28a856bc943022066d429dd5025d3c86fd8fd8a58e183a844bd94aa312cefe00388f57c85b0ca3201"
                },
                "sequence": 4294967295
            },
            {
                "txid": "d590fb81a021549e2eb8dd9f65ae6481662f44314848a7e60595121837e807e2",
                "vout": 0,
                "scriptSig": {
                    "asm": "3045022067cf27eb733e5bcae412a586b25a74417c237161a084167c2a0b439abfebdcb2022100efcc6baa6824b4c5205aa967e0b76d31abf89e738d4b6b014e788c9a8cccaf0c01",
                    "hex": "483045022067cf27eb733e5bcae412a586b25a74417c237161a084167c2a0b439abfebdcb2022100efcc6baa6824b4c5205aa967e0b76d31abf89e738d4b6b014e788c9a8cccaf0c01"
                },
                "sequence": 4294967295
            },
            {
                "txid": "94c366de3e715aaec53e3c442238e6febe37be4dc9b3fa77d9e9a9809d8d3be2",
                "vout": 0,
                "scriptSig": {
                    "asm": "3045022020f2eb35036666b1debe0d1d2e77a36d5d9c4e96c1dba23f5100f193dbf524790221008ce79bc1321fb4357c6daee818038d41544749127751726e46b2b320c8b565a201",
                    "hex": "483045022020f2eb35036666b1debe0d1d2e77a36d5d9c4e96c1dba23f5100f193dbf524790221008ce79bc1321fb4357c6daee818038d41544749127751726e46b2b320c8b565a201"
                },
                "sequence": 4294967295
            }
        ],
        "vout": [{
                "value": 250.00000000,
                "n": 0,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 366a27645806e817a6cd40bc869bdad92fe55091 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914366a27645806e817a6cd40bc869bdad92fe5509188ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash",
                    "addresses": [
                        "15xif4SjXiFi3NDEsmMZCfTdE9jvvVQrjU"
                    ]
                }
            },
            {
                "value": 0.01000000,
                "n": 1,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 ee8bd501094a7d5ca318da2506de35e1cb025ddc OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914ee8bd501094a7d5ca318da2506de35e1cb025ddc88ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash",
                    "addresses": [
                        "1NkKLMgbSjXrT7oHagnGmYFhXAWXjJsKCj"
                    ]
                }
            }
        ]
    }
    
  5. TheBlueMatt commented at 9:10 PM on January 26, 2017: contributor

    Ahh, so you want to add the mined-at-height to that info? That should be easily doable.

  6. kristovatlas commented at 9:10 PM on January 26, 2017: none

    Yes

  7. jonasschnelli commented at 7:48 AM on January 27, 2017: contributor

    I think you can... with the REST interface. Just call /rest/tx/<TX-HASH>.json and read out the confirmations attribute. (requires tx index though).

    I think we should consider adding a RPC call in blockchain.cpp that is capable of returning a Tx over TxToJSON() (mempool & txindex). getrawtransaction lacks internal non-serialized data.

  8. jonasschnelli added the label RPC/REST/ZMQ on Jan 27, 2017
  9. jonasschnelli added the label UTXO Db and Indexes on Jan 27, 2017
  10. maflcko added the label Feature on May 8, 2020
  11. bitcoin deleted a comment on Jan 3, 2024
  12. bitcoin deleted a comment on Jan 3, 2024
  13. bitcoin deleted a comment on Jan 3, 2024

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: 2026-04-13 15:15 UTC

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