Porting Jonas Schnelli's reference C implementation to Go
import (
"fmt""github.com/kulpreet/txref"
)
/* ENCODE */varencoded_txref=stringconsthrpstring="tx"//mainnet// now encode for height 100 and pos 100encoded_txref, err:=txref.Encode(hrp, txref.Txref_magic_btc_mainnet, 100, 100, false)
fmt.Printf("Encoded txref is %s\n", encoded_txref)
/* DECODE */decoded, magic, height, position, err:=txref.Decode(encoded_txref)go get -u github.com/kulpreet/txref