rpc: `listunspent` doesn't return immature coinbase outputs #25728

issue danielabrozzoni opened this issue on July 28, 2022
  1. danielabrozzoni commented at 12:21 PM on July 28, 2022: contributor

    Is your feature request related to a problem? Please describe.

    <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

    I need to know all the utxos I have in my wallet, including the immature ones. When using listunspent, the immature coinbases are not returned:

    ❯ bitcoin-cli listtransactions
    [
      {
        "address": "bcrt1q0epv47eaxhyenhqcjp8v7wytjx26k35r6w2py6",
        "category": "immature",
        "amount": 50.00000000,
        "label": "",
        "vout": 0,
        "confirmations": 1,
        "generated": true,
        "blockhash": "334996db387320711e1176f2591dfc16fe8d92f617af47ae65b97c2a817758b0",
        "blockheight": 102,
        "blockindex": 0,
        "blocktime": 1658995253,
        "txid": "480f0340a98755cfb095743b5464e87d0cf1b0200d204507ec8448962bcafbe6",
        "walletconflicts": [
        ],
        "time": 1658995253,
        "timereceived": 1658995253,
        "bip125-replaceable": "no"
      }
    ]
    ❯ bitcoin-cli listunspent
    [
    ]
    

    Describe the solution you'd like

    <!-- A clear and concise description of what you want to happen. -->

    What do you think of adding a include_immature_coinbase (default to false) parameter to listunspent? If you think it'd be useful, I can start working on this myself.

    Describe alternatives you've considered

    <!-- A clear and concise description of any alternative solutions or features you've considered. -->

    At the moment I'm calling listtransaction and adding to the utxo list every immature output I see (https://github.com/bitcoindevkit/bdk/pull/687). This works just fine, but having the include_immature parameter would make the code a bit cleaner (and it would save one RPC call!).

  2. danielabrozzoni added the label Feature on Jul 28, 2022
  3. evanlinjin commented at 12:40 PM on July 28, 2022: none

    +1 for an include_immature_coinbase parameter.

  4. furszy commented at 1:35 PM on July 28, 2022: member

    quickly drafted it in #25730. We could probably include them under the include_unsafe flag response as well (open for discussion there).

  5. evanlinjin commented at 5:25 PM on July 28, 2022: none

    quickly drafted it in #25730. We could probably include them under the include_unsafe flag response as well (open for discussion there).

    Thank you for the prompt PR @furszy ! An include_unsafe flag will be useful as well.

    I will try give a proper review of the PR later on, but I had a skim over it and I'm wondering whether it would be easy to update the RPCResult to show if the output is an immature coinbase?

  6. furszy commented at 8:32 PM on July 28, 2022: member

    it would be easy to add but I'm a ~0 there. Mainly because such information can be obtained, if needed, using another command like gettransaction <txid>. (The initial filter makes sense because we are by default, and without a way to change it, not returning immature UTXOs in listunspent)

  7. achow101 commented at 9:07 PM on July 28, 2022: member

    quickly drafted it in #25730. We could probably include them under the include_unsafe flag response as well (open for discussion there).

    No, "unsafe" has a specific meaning in the wallet which does not include immature coinbases. Unsafe means that the UTXO could disappear as it is created by an untrusted party and the transaction creating it is still unconfirmed.

    An immature coinbase is not unsafe. It just makes the transaction temporarily invalid. We shouldn't combine those two definitions.

  8. evanlinjin commented at 1:55 AM on July 29, 2022: none

    it would be easy to add but I'm a ~0 there. Mainly because such information can be obtained, if needed, using another command like gettransaction <txid>. (The initial filter makes sense because we are by default, and without a way to change it, not returning immature UTXOs in listunspent)

    If that is the case, I feel like a separate command such as listimmatureunspent would be more useful.

  9. furszy commented at 11:39 PM on August 2, 2022: member

    it would be easy to add but I'm a ~0 there. Mainly because such information can be obtained, if needed, using another command like gettransaction <txid>. (The initial filter makes sense because we are by default, and without a way to change it, not returning immature UTXOs in listunspent)

    If that is the case, I feel like a separate command such as listimmatureunspent would be more useful.

    It's more probable to get consensus over adding an is_coinbase field to the listunspent RPC response than creating a new RPC command just for it.

  10. kouloumos commented at 2:23 PM on August 3, 2022: contributor

    Note: The include_immature_coinbase flag has been added to the *receivedby* RPCs with https://github.com/bitcoin/bitcoin/pull/14707

  11. achow101 referenced this in commit f0c646f026 on Nov 16, 2022
  12. sidhujag referenced this in commit 7387848c0a on Nov 16, 2022
  13. aureleoules commented at 9:09 AM on November 17, 2022: member

    This issue can be closed now that #25730 is merged.

  14. maflcko closed this on Nov 17, 2022

  15. bitcoin locked this on Nov 17, 2023

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:13 UTC

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