Descriptor Checksum Inconsistency #23539

issue SachinMeier opened this issue on November 17, 2021
  1. SachinMeier commented at 8:06 PM on November 17, 2021: none

    <!-- Describe the issue -->

    Issue:

    The Checksum generated by getdescriptorinfo is not accepted when I use it in importdescriptors. The two RPC calls calculate a different checksum for the same descriptor.

    <!--- What behavior did you expect? -->

    I ran the following commands on MacOS with bitcoind v0.21.1 installed. Since my descriptor lacked a checksum, I used getdescriptorinfo to generate one, as I read here: https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md#checksums

    The checksum for a descriptor without one can be computed using the getdescriptorinfo RPC.
    

    I expected the checksum generated by getdescriptorinfo to be accepted by importdescriptors. It was not.

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    The actual behavior is below. I am redacting the actual descriptors/hashes for personal privacy.

    $ bitcoin-cli --version
    Bitcoin Core RPC client version v0.21.1
    # getdescriptorinfo generates a checksum beginning with 3a.
    $ bitcoin-cli getdescriptorinfo "<DESCRIPTOR>"
    {
      "descriptor": "<DESCRIPTOR>#3a...",
      "checksum": "3a...",
      "isrange": false,
      "issolvable": true,
      "hasprivatekeys": false
    }
    # importdescriptors rejects the checksum generated by getdescriptorinfo and calculates its own different one
    $ bitcoin-cli -rpcwallet=my_wallet importdescriptors '[{ "desc": "<DESCRIPTOR>#3a...", "timestamp": "now" }]'
    [
      {
        "success": false,
        "error": {
          "code": -5,
          "message": "Provided checksum '3a...' does not match computed checksum '6z...'"
        }
      }
    ]
    # importdescriptors properly accepts the checksum provided by itself.
    $ bitcoin-cli -rpcwallet=my_wallet importdescriptors '[{ "desc": "<DESCRIPTOR>#6z...", "timestamp": "now" }]' 
    [
      {
        "success": true
      }
    ]
    # Using checksum expected by importdescriptors throws an error when used in getdescriptorinfo cmd
    $ bitcoin-cli getdescriptorinfo "<DESCRIPTOR>#6z..."
    error code: -5
    error message:
    Provided checksum '6z40f68x' does not match computed checksum '3av8evsc'
    

    System information

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    Bitcoin Core info: Bitcoin Core RPC client version v0.21.1 Downloaded from Bitcoin.org binary. Not compiled from source.

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    Machine/OS: MacOS Catalina 10.15.6 Memory 16GB

  2. SachinMeier added the label Bug on Nov 17, 2021
  3. sipa commented at 8:09 PM on November 17, 2021: member

    Are you sure the checksum in the "descriptor" field and the one in the "checksum" field are the same?

    They can differ, because the echoed-back descriptor in the "descriptor" field is normalized (and e.g. lacks private keys), and the checksum there is computed over the echoed-back form. The "checksum" field is supposed to be for exactly your input descriptor as you provided it.

    If that's not it, I fear we'll need a more concrete example to reproduce.

  4. SachinMeier commented at 8:15 PM on November 17, 2021: none

    Yes, I just double checked this now. I am using a descriptor of the form wpkh([fp/a'/b']xpub.../c) where a,b,c are single digit ints. The output of getdescriptorinfo is exactly the same as my input.

  5. achow101 commented at 8:26 PM on November 17, 2021: member

    This shouldn't be possible since they use the exact same code.

    Can you share exactly the descriptors that you used (or generate descriptors that exhibit the same issue that you are willing to share)?

  6. SachinMeier commented at 8:31 PM on November 17, 2021: none

    I just generated a new xpub and added a random fingerpint. I ran the same commands and saw the same behavior.

    ~ $ bitcoin-cli getdescriptorinfo "wpkh([a2bd0d5d/1'/0']xpub68hdHBdprdRvzD54QhhWYDqVVj7uxg1gK78MkkxVCD6687dJ19rqGt5dhBV1czH8n6Jhb2PPzVFwcy3fnMCPtFBmwLcDWLcP1Nxbfad1MmN/2)"
    {
      "descriptor": "wpkh([a2bd0d5d/1'/0']xpub68hdHBdprdRvzD54QhhWYDqVVj7uxg1gK78MkkxVCD6687dJ19rqGt5dhBV1czH8n6Jhb2PPzVFwcy3fnMCPtFBmwLcDWLcP1Nxbfad1MmN/2)#fhgkwdud",
      "checksum": "fhgkwdud",
      "isrange": false,
      "issolvable": true,
      "hasprivatekeys": false
    }
    ~ $ bitcoin-cli -rpcwallet=hot_wallet_1 importdescriptors '[{ "desc": "wpkh([a2bd0d5d/1'/0']xpub68hdHBdprdRvzD54QhhWYDqVVj7uxg1gK78MkkxVCD6687dJ19rqGt5dhBV1czH8n6Jhb2PPzVFwcy3fnMCPtFBmwLcDWLcP1Nxbfad1MmN/2)#fhgkwdud", "timestamp": "now" }]'
    [
      {
        "success": false,
        "error": {
          "code": -5,
          "message": "Provided checksum 'fhgkwdud' does not match computed checksum 'mg62v6fs'"
        }
      }
    ]
    ~ $ bitcoin-cli -rpcwallet=hot_wallet_1 importdescriptors '[{ "desc": "wpkh([a2bd0d5d/1'/0']xpub68hdHBdprdRvzD54QhhWYDqVVj7uxg1gK78MkkxVCD6687dJ19rqGt5dhBV1czH8n6Jhb2PPzVFwcy3fnMCPtFBmwLcDWLcP1Nxbfad1MmN/2)#mg62v6fs", "timestamp": "now" }]'
    [
      {
        "success": true
      }
    ]
    
  7. sipa commented at 8:32 PM on November 17, 2021: member

    Your issue is that bash is eating the ' characters in the second command.

  8. SachinMeier commented at 8:34 PM on November 17, 2021: none

    Yep, that's it. Sorry for the waste of time. If its helpful, the example provided in the bitcoin-cli help uses single quotes, which threw me off. perhaps these should be changed up.

  9. SachinMeier closed this on Nov 17, 2021

  10. sipa commented at 8:35 PM on November 17, 2021: member

    no worries

  11. DrahtBot locked this on Nov 17, 2022

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-29 06:14 UTC

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