Monday, August 21, 2023
HomeBitcoinHow can purchasers know the vacation spot tackle for this P2WPKH transaction?

How can purchasers know the vacation spot tackle for this P2WPKH transaction?


<- Advertisement ->

Transaction outputs comprise two fields, an 8-byte signed integer quantity and the output script of variable size (additionally known as scriptPubKey within the Bitcoin Core codebase). Because the identify suggests, the output script incorporates Script directions or one of many customary templates that suggest a set of Script directions. At any time when a transaction is confirmed in the most effective chain, the assigned quantity of funds get encumbered by the spending circumstances outlined per the output script.

We use addresses to characterize sure customary output templates. An tackle encodes the output script in a kind that’s protected by a checksum and introduced in a extra human-consumable form. On this particular case, we’re taking a look at a local segwit v0 witness program with 32 bytes payload, or a P2WSH output.

The tackle is calculated from the output script by taking the human-readable half (“hrp”) and the info of the output script (witness model and witness program) to calculate a checksum. The tackle is then assembled by concatenating:

  • the hrp bc for Bitcoin mainnet
  • the separator 1
  • the info encoded utilizing bech32 (see desk under)
  • the checksum encoded utilizing bech32

bech32 translation table via BIP173

Vice versa, a sender can decode the tackle they get from the receiver by checking the tackle string for validity, eradicating the checksum, and decoding the info half to extract the output script. Based mostly on model, they will verify whether or not the witness program has the proper kind (esp. size).

In the event you’re seeking to implement bech32, I’d recommend to take a look at one of many eight reference implementations and the take a look at vectors on the BIP. Be aware that addresses for native segwit model 1+ use the bech32m encoding outlined in BIP350 as a substitute of bech32 (BIP173). Though the one distinction is that bech32m modifies the checksum fixed.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments