2

I have an xpub key and I'd like to generate the sequence of btc addresses in PHP based on the index. Is there a way to do that?

2 Answers 2

0

You can use https://github.com/denpamusic/php-bitcoinrpc to call methods defined in Bitcoin Core API Documentation.

Getting addresses from xpub: https://bitcoincore.org/en/doc/0.20.0/rpc/util/deriveaddresses/

-1

An extensive public key (XPUB) is a sort of different evened out deterministic (HD) wallet key that licenses you to deliver a boundless number of bitcoin addresses from a singular master key. This can be useful on the off chance that you want to make a new bitcoin address for each trade then again to manage endless bitcoin addresses.

To deliver a bitcoin address from a XPUB, you can use a gadget, for instance, the bitcoin-cli request line interface or a programming library like BitcoinJS. Here is a representation of how you could make a bitcoin address from a XPUB using the bitcoin-cli request line interface::

1-Regardless, guarantee you have the bitcoin-cli instrument presented on your structure.

2-Open a terminal window and enter the going with request to communicate with your bitcoin center point:

-- bitcoin-cli -regtest --

3- Next, use the getnewaddress command to generate a new bitcoin address:

-- bitcoin-cli -regtest getnewaddress ---

4- This will return a new bitcoin address that you can use to get portions. To make additional areas, you can use the deriveaddresses request, which acknowledges a XPUB as a conflict and delivers an overview of addresses:

bitcoin-cli -regtest deriveaddresses "xpub6DU6JYBvfZjSJgUJpMh6FiZbvL3Bd4ZxAZuvZQgcCv5vY3qrWj5J35Q2K5zAKvZ8XaZxJpZcPJGmrgvw8HJWfjHRBJ1MgvMYdJzW5xp8Gv"

This will create a summary of 10 areas considering the XPUB that you gave. You can change the amount of addresses made by using the count limit:

1
  • Hi Rafi, I'm confused by this answer. It's not clear to me what the “areas” are that you start talking about in the latter part of the answer, and the question was about PHP, which your answer never mentions. Would you mind looking it over one more time?
    – Murch
    Jan 10 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.