You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At present, it seems that a given HierarchicalKey instance can only be encoded as a single address type, eg p2pkh, p2wpkh, p2sh-p2wpkh, etc. AddressCreator takes no constructor arguments and internally generates an address object based on the key's outputscript.
However fundamentally a key is a numeric value that can be encoded into an address in different ways.
A use-case where this becomes important is when deriving wallet keys in the style of bitcoin-core HD wallets. This style of derivation uses a single xprv/xpub root key and derives hardened keys from it. For each derived key, either a "legacy", 'p2sh-segwit' or 'bech32' address can be created, at user's choice. A derivation tool might want to display multiple address-types for each derived key.
So I'm unsure how best to achieve this with the existing library. I supposed that for each derived key, the secret can be extracted and used to instantiate a new key specific to each desired address type. But it seems much cleaner/simpler something like:
For that case I'd probably use some of the KeyToScript things (though I've yet find a nice way to do that with multisig) or do it manually.
I wouldn't have exposed getAddress on HK were it not for the SLIP132 stuff. Before that, the address type wouldn't have been dynamic, but changing the default script type could cause problems for devs.. but since it varies with prefix, getAddress / getScriptAndSignData seemed reasonable.
For the addresses of such scripts, just use $addrCreator->fromOutputScript()
At present, it seems that a given HierarchicalKey instance can only be encoded as a single address type, eg p2pkh, p2wpkh, p2sh-p2wpkh, etc. AddressCreator takes no constructor arguments and internally generates an address object based on the key's outputscript.
However fundamentally a key is a numeric value that can be encoded into an address in different ways.
A use-case where this becomes important is when deriving wallet keys in the style of bitcoin-core HD wallets. This style of derivation uses a single xprv/xpub root key and derives hardened keys from it. For each derived key, either a "legacy", 'p2sh-segwit' or 'bech32' address can be created, at user's choice. A derivation tool might want to display multiple address-types for each derived key.
So I'm unsure how best to achieve this with the existing library. I supposed that for each derived key, the secret can be extracted and used to instantiate a new key specific to each desired address type. But it seems much cleaner/simpler something like:
It's quite possible there is some confusion on my part. If there is a simple way to achieve the above use-case already, please provide an example.
The text was updated successfully, but these errors were encountered: