No `label` field in `listunspent` entries in ranged descriptors #23749

issue darosior opened this issue on December 12, 2021
  1. darosior commented at 10:04 AM on December 12, 2021: member

    Importing a descriptor with a label, i expected to be able to use it to filter UTxOs per descriptor in listunspent. It's possible using the addr() descriptor but not with a non "opaque" one. I'm not sure what the expected behaviour here is, but it is inconsistent between the two and doesn't seem to be implied by the help: - EDIT: labels are disabled for range descriptors, see the second comment.

    "label": "str", (string, optional, default="") Label to assign to the address, only allowed with internal=false

    A repro on regtest follows.

    With multi() (not active)

    createwallet desc true true "" false true     
    
    {                                                                                                                                                                                    
      "name": "desc",                                                                                                                                                                    
      "warning": "Empty string given as passphrase, wallet will not be encrypted.\nWallet is an experimental descriptor wallet"
    }
    
    -rpcwallet=desc importdescriptors '[{"desc":"wsh(multi(1,tpubD6NzVbkrYhZ4X1zm1SuRG3uzkbjY5iVaDSZ8HfUDwEhMA5DtP6ebV1iR42eXKjxU7SAtf4PVHTVvbPqaTTisxH5Le8ynt2QSQNvZjTZWqwV/*,tpubD6NzVbkrYhZ4Wx4iTSmZQJWE6PsHR32TbeLGPoDNpoHHmeMR8RmHiAfco2npEzHLY8nmSNrKM5c7coGkaQwriSAnrXUfW6cQVw64Haj7aRv/*))#qw8vdw82","timestamp":"now","la
    bel":"testlabel"}]'                                                                       
    
    [                                                                                                                                                                                    
      {                                                                                                                                                                                  
        "success": true,
        "warnings": [                                                                         
          "Range not given, using default keypool range"
        ]                                                                                                                                                                                
      }                                                                                                                                                                                  
    ] 
    
    -rpcwallet=desc deriveaddresses "wsh(multi(1,tpubD6NzVbkrYhZ4X1zm1SuRG3uzkbjY5iVaDSZ8HfUDwEhMA5DtP6ebV1iR42eXKjxU7SAtf4PVHTVvbPqaTTisxH5Le8ynt2QSQNvZjTZWqwV/*,tpubD6NzVbkrYhZ4Wx4iTSmZQJWE6PsHR32TbeLGPoDNpoHHmeMR8RmHiAfco2npEzHLY8nmSNrKM5c7coGkaQwriSAnrXUfW6cQVw64Haj7aRv/*))#qw8vdw82" 1           
                         
    [                                                                                                                                                                                                                                                                                                                                                                          
      "bcrt1qmwhug9v6j9gehpwzv0vaan7qlv2dnhak2rjetuw0cwawe8d22p5qtj0xru",                                                                                                                                                                                                                                                                                                      
      "bcrt1qhnzlvkn2cq3pq786j5l8vr23d4wv7hafumn87ysx7wckydcxyr4sxz53y7"                                                                                                                                                                                                                                                                                                       
    ]
    
    sendtoaddress bcrt1qhnzlvkn2cq3pq786j5l8vr23d4wv7hafumn87ysx7wckydcxyr4sxz53y7 1
    
    c06e372849ecb41ca879939d558dfd071451dd7ae37f82f8971885428fa0e2ac
    
    -rpcwallet=desc listunspent 0
    
    [
      {
        "txid": "c06e372849ecb41ca879939d558dfd071451dd7ae37f82f8971885428fa0e2ac",
        "vout": 0,
        "address": "bcrt1qhnzlvkn2cq3pq786j5l8vr23d4wv7hafumn87ysx7wckydcxyr4sxz53y7",
        "witnessScript": "512102002ce4dcd76b141d6fc3b87333bb487be0420a7b6c262486612e973ff67d480d210347c912c52c73fd5d9e676efae6daeceafb6d2e7e506e802a4d256d135b74b6d852ae",
        "scriptPubKey": "0020bcc5f65a6ac0221078fa953e760d516d5ccf5fa9e6e67f1206f3b162370620eb",
        "amount": 1.00000000,
        "confirmations": 0,
        "spendable": true,
        "solvable": true,
        "desc": "wsh(multi(1,[cb5d6fba/1]02002ce4dcd76b141d6fc3b87333bb487be0420a7b6c262486612e973ff67d480d,[a5461cc7/1]0347c912c52c73fd5d9e676efae6daeceafb6d2e7e506e802a4d256d135b74b6d8))#hh5argze",
        "safe": false
      }
    ]
    

    And once confirmed:

    -rpcwallet=desc listunspent
    
    [
      {
        "txid": "c06e372849ecb41ca879939d558dfd071451dd7ae37f82f8971885428fa0e2ac",
        "vout": 0,
        "address": "bcrt1qhnzlvkn2cq3pq786j5l8vr23d4wv7hafumn87ysx7wckydcxyr4sxz53y7",
        "witnessScript": "512102002ce4dcd76b141d6fc3b87333bb487be0420a7b6c262486612e973ff67d480d210347c912c52c73fd5d9e676efae6daeceafb6d2e7e506e802a4d256d135b74b6d852ae",
        "scriptPubKey": "0020bcc5f65a6ac0221078fa953e760d516d5ccf5fa9e6e67f1206f3b162370620eb",
        "amount": 1.00000000,
        "confirmations": 1,
        "spendable": true,
        "solvable": true,
        "desc": "wsh(multi(1,[cb5d6fba/1]02002ce4dcd76b141d6fc3b87333bb487be0420a7b6c262486612e973ff67d480d,[a5461cc7/1]0347c912c52c73fd5d9e676efae6daeceafb6d2e7e506e802a4d256d135b74b6d8))#hh5argze",
        "safe": true
      }
    ]
    

    With multi(), imported as active

    Interestingly, the behaviour is slightly different if the descriptor was imported as active: the label gets set to the default.

    -rpcwallet=desc listunspent 0
                                                                                                                                                                                                                                                                                                     
    [                                                                                                                                                                                                                                                                                                                                                                          
      {                                                                                                                                                                                                                                                                                                                                                                        
        "txid": "4d210ea111d4b195dbbb9ef9c41adbd593a15abd474186c1db1345adebfd6a29",                                                                                                                                                                                                                                                                                            
        "vout": 1,                                                                                                                                                                                                                                                                                                                                                             
        "address": "bcrt1qmwhug9v6j9gehpwzv0vaan7qlv2dnhak2rjetuw0cwawe8d22p5qtj0xru",                                                                                                                                                                                                                                                                                         
        "label": "",                                                                                                                                                                                                                                                                                                                                                           
        "witnessScript": "512102a52540cdedb82efaf7f2f2a95e1934fe69fd4d6b2c1e7875d29a71e751e35234210389887d9cc54cd6e1eaabd16cd003779882fa51d2c524741f38aae526211ec8ea52ae",                                                                                                                                                                                                     
        "scriptPubKey": "0020dbafc4159a91519b85c263d9decfc0fb14d9dfb650e595f1cfc3baec9daa5068",                                                                                                                                                                                                                                                                                
        "amount": 1.00000000,                                                                                                                                                                                                                                                                                                                                                  
        "confirmations": 0,                                                                                                                                                                                                                                                                                                                                                    
        "ancestorcount": 1,                                                                                                                                                                                                                                                                                                                                                    
        "ancestorsize": 165,                                                                                                                                                                                                                                                                                                                                                   
        "ancestorfees": 165,                                                                                                                                                                                                                                                                                                                                                   
        "spendable": true,                                                                                                                                                                                                                                                                                                                                                     
        "solvable": true,                                                                                                                                                                                                                                                                                                                                                      
        "desc": "wsh(multi(1,[cb5d6fba/0]02a52540cdedb82efaf7f2f2a95e1934fe69fd4d6b2c1e7875d29a71e751e35234,[a5461cc7/0]0389887d9cc54cd6e1eaabd16cd003779882fa51d2c524741f38aae526211ec8ea))#e7u440ul",                                                                                                                                                                        
        "safe": false                                                                                                                                                                                                                                                                                                                                                          
      }                                                                                                                                                                                                                                                                                                                                                                        
    ]
    

    With addr() (inactive, but active status doesn't matter)

    createwallet descaddr true true "" false true
    
    {
      "name": "descaddr",
      "warning": "Empty string given as passphrase, wallet will not be encrypted.\nWallet is an experimental descriptor wallet"
    }
    
    -rpcwallet=descaddr importdescriptors '[{"desc":"addr(bcrt1qhnzlvkn2cq3pq786j5l8vr23d4wv7hafumn87ysx7wckydcxyr4sxz53y7)#duqgr8lc","timestamp":0,"label":"foraddrdescriptorsitworks"}]'
    
    [
      {
        "success": true
      }
    ]
    
    -rpcwallet=descaddr listunspent
    
    [
      {
        "txid": "c06e372849ecb41ca879939d558dfd071451dd7ae37f82f8971885428fa0e2ac",
        "vout": 0,
        "address": "bcrt1qhnzlvkn2cq3pq786j5l8vr23d4wv7hafumn87ysx7wckydcxyr4sxz53y7",
        "label": "foraddrdescriptorsitworks",
        "scriptPubKey": "0020bcc5f65a6ac0221078fa953e760d516d5ccf5fa9e6e67f1206f3b162370620eb",
        "amount": 1.00000000,
        "confirmations": 1,
        "spendable": true,
        "solvable": false,
        "safe": true
      }
    ]
    
  2. darosior added the label Bug on Dec 12, 2021
  3. darosior commented at 10:59 AM on December 12, 2021: member

    Labels are disabled for ranged descriptors. https://github.com/bitcoin/bitcoin/blob/ac92ab6da58e34993d0641b98eef5b5f55b6cbf9/src/wallet/wallet.cpp#L3355-L3362

    So this is not a Bug, rather a question on the rationale behind this decision and regarding what should be done to support them. But i can't change the label.

    EDIT: So addresses of ranged descriptors aren't set at import time. It would be clunky to iterate through all the scriptpubkeys up to the gap limit and add them all to the address book. How about adding an optional label to WalletDescriptor? https://github.com/bitcoin/bitcoin/blob/ac92ab6da58e34993d0641b98eef5b5f55b6cbf9/src/wallet/walletutil.h#L74-L84

  4. darosior renamed this:
    No `label` field in `listunspent` entries in some descriptors (repro with `multi()`)
    No `label` field in `listunspent` entries in ranged descriptors (repro with `multi()`)
    on Dec 12, 2021
  5. darosior renamed this:
    No `label` field in `listunspent` entries in ranged descriptors (repro with `multi()`)
    No `label` field in `listunspent` entries in ranged descriptors
    on Dec 12, 2021
  6. fanquake commented at 3:46 AM on December 13, 2021: member
  7. MarcoFalke referenced this in commit ce463cf450 on Dec 16, 2021
  8. sidhujag referenced this in commit 8f60bf651f on Dec 16, 2021
  9. darosior commented at 8:49 AM on January 29, 2022: member

    This was discussed during Yesterday's meeting.

    11:02 < achow101> #topic labels for ranged descriptors (darosior)
    11:02 < core-meetingbot`> topic: labels for ranged descriptors (darosior)
    11:02 -!- brunoerg [~brunoerg@2804:14d:5281:8ae2:1c0a:deda:9648:d9a6] has joined #bitcoin-core-dev
    11:02 < laanwj> hi
    11:03 < darosior> So as part of the Miniscript work, i tested the branch against my application (which uses Miniscript internally and the descriptor wallet as watchonly to track 2 main descriptors) and discovered that labels are deactivated for range descriptors.
    11:03 < darosior> However labels are pretty useful to differentiate the coins when you have multiple descriptors on the same watchonly wallet (which i think is the intent?). Typically for triage in the `listsinceblock` or `listunspent` results: i think i'm just an instance and they are useful as well.
    11:03 < darosior> So i wondered what people here thought about enabling the same features to the descriptor level, to not have to add all addresses to the address book in advance (which i guessed is the reason to disable them for range descriptors in the first place?). Or if something else than labels was envisioned to enable the same features.
    11:03 < darosior> s/and they are useful as well/ and they are useful as well to others/
    11:04 -!- sipsorcery [~sipsorcer@2a02:8084:6180:500::12b] has joined #bitcoin-core-dev
    11:04 < achow101> the reason that labels were not implemented originally was because it seemed odd to me that someone would want to assign the same label to all addresses generated by a descriptor
    11:04 < sipa> What are you thinking of, something like a label template on the descriptor, with say a %i in it that gets replaced by the index?
    11:04 < sipa> Or just the same label for everything?
    11:04 < achow101> and also I think there was some complexity with applying labels to addresses that did not exist yet
    11:05 < darosior> The same label for any address derived for this descriptor. Something to say "this received coin is for this descriptor"
    11:05 -!- bomb-on [~bomb-on@194.144.47.113] has joined #bitcoin-core-dev
    11:06 < achow101> if you think it's something people will use, go for it
    11:06 < michaelfolkson> Sorry for the ELI5 but by label do you mean the subscripts of Miniscript?
    11:07 < darosior> No i mean a metadata to identify a descriptor
    11:07 < darosior> Could just add the descriptor itself to the result, i guess, although i'd to think how a client of the API would manage that
    11:07 -!- brunoerg [~brunoerg@2804:14d:5281:8ae2:1c0a:deda:9648:d9a6] has quit [Ping timeout: 252 seconds]
    11:07 < sipa> No, label, as in the setlabel RPC.
    11:07 < sipa> and getaddressesbylabel
    11:07 < michaelfolkson> Oh ok
    11:08 < darosior> Ok, thanks. It was mainly to know if there were prior discussions on this topic. Guess i'm done :)
    11:08 < achow101> I'm not sure I understand the use case, but I am ambivalent on this
    

    I then suggested that i would lay out the motivation better in a new "feature request" issue. In the end i think the use case i presented here is covered by the desc field in the listunspent result. The descriptor being solvable is a pre-condition to having this usecase in the first place. It is only missing from the listsinceblock result but i think i'll open PR adding it.

    cc @achow101 re Yesterday's topic ^. TL;DR: should have done my homework better before proposing a topic. :)

  10. darosior closed this on Jan 29, 2022

  11. darosior commented at 9:07 AM on June 30, 2022: member

    FWIW #25504 addresses this. Note also the desc field in listunspent isn't enough, since it is not an identifier for the imported descriptor.

  12. DrahtBot locked this on Jun 30, 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:14 UTC

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