How to create HD address? #16335

issue tgreco opened this issue on July 4, 2019
  1. tgreco commented at 12:37 AM on July 4, 2019: none

    I am wondering if it's possible to create an HD address with bitcoind's getnewaddress RPC call? If not how does one create an HD address?

  2. promag commented at 12:42 AM on July 4, 2019: member

    See the utility RPC deriveaddresses.

  3. tgreco commented at 1:06 AM on July 4, 2019: none

    Would you be able to provide an example of how to use that?

    The example in the RPC docs is confusing.

    bitcoin-cli deriveaddresses "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#trd0mf0l" "[0,2]"

    I was thinking the public key would be the scriptPubKey from the validateaddress command. But I have no idea what the first [d34db33f/84h/0h/0h] part is.

  4. sipa commented at 1:11 AM on July 4, 2019: member

    Maybe first explain what you're trying to do.

    getnewaddress (Bitcoin Core wallets created after 0.13.0) always generates an HD address under the hood, but generally we don't reveal the derivation path that was used.

  5. fanquake added the label Questions and Help on Jul 4, 2019
  6. sipa commented at 1:12 AM on July 4, 2019: member

    deriveaddresses doesn't create a new address, it just computes one based on a descriptor (this for example does not make the wallet automatically treat transactions to the generated address as incoming payments). For more information on descriptors, see https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md.

  7. tgreco commented at 1:44 AM on July 4, 2019: none

    Maybe first explain what you're trying to do.

    getnewaddress (Bitcoin Core wallets created after 0.13.0) always generates an HD address under the hood, but generally we don't reveal the derivation path that was used.

    I want to generate receiving addresses for my main address I obtained by using the getnewaddress RPC call.

    What would be the steps to be able to plug this into deriveaddresses command? I am not sure how to obtain a descriptor for my main address. I have the private key.

  8. sipa commented at 1:47 AM on July 4, 2019: member

    You're describing a means to accomplish a goal, but not what the goal is.

    Generally if you want to construct a new receiving address for your wallet, you just use getnewaddress, and don't worry about how the wallet came up with it.

    If you want something else, there may be a solution, but it won't be that simple generally. You can't derive more addresses from a given address.

  9. tgreco commented at 1:51 AM on July 4, 2019: none

    You're describing a means to accomplish a goal, but not what the goal is.

    Generally if you want to construct a new receiving address for your wallet, you just use getnewaddress, and don't worry about how the wallet came up with it.

    If you want something else, there may be a solution, but it won't be that simple generally. You can't derive more addresses from a given address.

    The goal is to be able to differentiate deposits (using this for online bill pay on invoices). I would like to generate many addresses so I can track which client has paid their bill by assigning each one a unique address.

    I know I could use getnewaddress to do this but then I have to move funds to a main wallet at some point which adds mining fees for moving funds from one clients address to my main wallet address.

    However if everyone has just a receiving address and all the funds are actually spendable by the main wallet address I eliminate the mining fees required to move from each individual address to the main wallet.

  10. sipa commented at 1:53 AM on July 4, 2019: member

    What about just calling getnewaddress once for every client, but all on the same wallet?

  11. sipa closed this on Jul 4, 2019

  12. sipa commented at 2:00 AM on July 4, 2019: member

    This isn't really the place for support questions. I'll happily continue answering on https://bitcoin.stackexchange.com

  13. DrahtBot locked this on Dec 16, 2021

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