rpc: add deriveaddressesfromprivkey command #24160

pull kallewoof wants to merge 1 commits into bitcoin:master from kallewoof:202201-deriveaddressesfromprivkey changing 1 files +44 −1
  1. kallewoof commented at 5:20 AM on January 26, 2022: member

    This is a simple command for listing out all the address variants given a privkey, a feature which seems obvious but missing (unless I'm not finding the command!).

    $ ./bitcoin-cli -regtest getnewaddress
    bcrt1qss60qxqt3vk6kxm4j6ufwp725f89esvm8lhvf6
    $ ./bitcoin-cli -regtest dumpprivkey bcrt1qss60qxqt3vk6kxm4j6ufwp725f89esvm8lhvf6
    cPsQTSmMZ8e3AEUWGjS73f5R364yJxH6RxcgnwbHjbKbFPUP2Dtu
    $ ./bitcoin-cli -regtest deriveaddressesfromprivkey cPsQTSmMZ8e3AEUWGjS73f5R364yJxH6RxcgnwbHjbKbFPUP2Dtu
    {
      "p2pkh": "msZzuZcZUYP8pdLZ3BktxFNZJQNR8ZBQjd",
      "segwit": "bcrt1qss60qxqt3vk6kxm4j6ufwp725f89esvm8lhvf6",
      "p2sh": "2N6EW9Va47woKmpzUmkqhpzemabnJAZudWW"
    }
    
  2. rpc: add deriveaddressesfromprivkey command 4ed4061267
  3. sipa commented at 5:22 AM on January 26, 2022: member

    I think that deriveaddresses with a "combo(privkey)" descriptor will do this.

  4. kallewoof commented at 5:23 AM on January 26, 2022: member

    Interesting. I'm getting 'missing checksum', though. Syntax?

    $ ./bitcoin-cli -regtest deriveaddresses "combo(cPsQTSmMZ8e3AEUWGjS73f5R364yJxH6RxcgnwbHjbKbFPUP2Dtu)"
    error code: -5
    error message:
    Missing checksum
    
  5. sipa commented at 5:29 AM on January 26, 2022: member

    See https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md

    You can compute the checksum with the getdescriptorinfo RPC.

  6. kallewoof commented at 5:35 AM on January 26, 2022: member

    That worked. Nobody is going to realize that though, so I'm going to propose a change to the deriveaddresses RPC that walks through this example.

  7. kallewoof closed this on Jan 26, 2022

  8. kallewoof deleted the branch on Jan 26, 2022
  9. DrahtBot locked this on Jan 26, 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