Sunday, December 22, 2024

segregated witness – Convert bech32 Bitcoin handle to legacy

This reply is concerning the variations between handle codecs and what causes incompatibilities. If you happen to do not code your pockets, do not belief your pockets about recognizing completely different addresses produced from the identical public key! Do not experiment with something I’ve stated with actual cash!

In Bitcoin Money, CashAddr and 1 addresses are alternative ways to encode the general public key hash for Pay-2-Public-Key-Hash. To spend P2PKH outputs, the general public key’s revealed, for which a signature is signed. How the general public key hash is serialized would not change how the output is spent or created. Thus these addresses are convertible.

Listed below are the knowledge Bech32 (P2WPKH), SegWit in P2SH (P2SH-P2WPKH) and 1 addresses preserve:

  • P2PKH incorporates the <20-byte-key-hash>
  • P2WPKH incorporates the <20-byte-key-hash>
  • P2SH-P2WPKH incorporates the hash of the script 0 <20-byte-key-hash>

Does that imply P2PKH and P2WPKH are the identical? No, sending cash to the P2PKH and the Bech32 of the identical public key will yield completely different transactions. And the way the payee’s pockets will spend it with the corresponding personal key shall be completely different too. Nevertheless it’s the identical personal key, the pockets ought to have the ability to spend each! When a pockets generated a Bech32 handle for instance, there’s nothing that requires the pockets to scan for the transactions spending to that public key as P2PKH or P2SH-P2WPKH. This may rely upon the implementation. (BTW, in P2PKH a compressed or uncompressed public key can be utilized. P2WPKH or P2SH-P2WPKH cannot be used with an uncompressed public key)

For P2WPKH and P2SH-P2WPKH, much like the earlier case, from P2WPKH you may craft a P2SH-P2WPKH, and use it if the payee’s pockets is suitable (I do not learn about Bitcoin Core however there is not any purpose a light-weight pockets to be suitable with this). Then again, when you see one’s P2SH-P2WPKH, you may’t derive the P2WPKH or P2PKH until that handle has spent. That is associated to hashing as soon as, appending a zero, hashing once more. When spent, the general public key (and it is hash) are uncovered.

Abstract: It is theoretically attainable however no implementation shall be suitable.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles