bitcoin-php icon indicating copy to clipboard operation
bitcoin-php copied to clipboard

How to generate multiple payment addresses from a single secret key

Open maxspb89 opened this issue 6 years ago • 2 comments

I see that electrum wallet generates different payment addresses for receiving BTC. I'm trying to generate new addresses, but they are the same. Is it possible to make them different?

private function generateAddress()
    {
        $pubKeyHash160 = $this->_privateKey->getPublicKey()->getPubKeyHash();
        $pubKeyHashAddr = new PayToPubKeyHashAddress($pubKeyHash160);
        $this->_address = $pubKeyHashAddr->getAddress();
    }

maxspb89 avatar Jun 04 '19 20:06 maxspb89

I've found that electrum generates multiple secret keys -> public keys -> addresses from a single seed phrase. But I don't understand how to restore all the secret keys from it. Any thoughts?

maxspb89 avatar Jun 04 '19 20:06 maxspb89

What do you mean the addresses are the same? The address in your code returns the same value every time, or you're trying to change the address type?

Recent & possibly related to this issue: https://github.com/Bit-Wasp/bitcoin-php/issues/792 https://github.com/Bit-Wasp/bitcoin-php/issues/794

afk11 avatar Jun 05 '19 12:06 afk11