User:Danpape/colortest

Given the following:

We want to create a txref that refers to Transaction #1234 of Block #456789 on the Mainnet chain. We use this data in preparation for the Bech32 encoding algorithm:

As shown in the above notes column, we take the necessary bits of each binary value and copy them into nine unsigned chars as shown below. We only set the lower five bits of each unsigned char as the bech32 algorithm only uses those bits.

The Bech32 algorithm encodes the nine unsigned chars above and computes a checksum of those chars and encodes that as well--this gives a six character checksum (in this case, utt3p0) which is appended to the final txref. The final txref given is: tx1:r29u-mqjx-putt-3p0 and is illustrated in the following table:

 

TxRef character indexes and descriptions   Key  

As we did not specify an outpoint index, the txref tx1:rjk0-uqay-z9l7-m9m explicitly references the first (index 0) outpoint of the 2205th transaction in the 466793rd block in the blockchain.

If we instead wanted to reference the second (index 1) outpoint, we would include the following:

After Bech32 encoding the twelve unsigned chars above, we get a checksum: sfp22t. The final txref given is: tx1:y29u-mqjx-ppqq-sfp2-tt and is illustrated in the following table:

 

TxRef character indexes and descriptions   Key

 