Skip to content

Instantly share code, notes, and snippets.

@haidoan
haidoan / createAndSignTx.go
Last active October 29, 2023 08:33
Creating raw bitcoin transaction multiple input output golang
func GetPayToAddrScript(address string) []byte {
rcvAddress, _ := btcutil.DecodeAddress(address, &chaincfg.TestNet3Params)
rcvScript, _ := txscript.PayToAddrScript(rcvAddress)
return rcvScript
}
type TXRef struct{
TXHash string
TXOutputN int
}
@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active July 1, 2024 17:19
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation