Skip to content

Instantly share code, notes, and snippets.

@HaddadJoe
Created August 16, 2020 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaddadJoe/6a986af7ff35fda6c9b6a867b0940f9c to your computer and use it in GitHub Desktop.
Save HaddadJoe/6a986af7ff35fda6c9b6a867b0940f9c to your computer and use it in GitHub Desktop.
const bsv = require('bsv')
const opentac_prefix = '07AC'
const version = '0.1'
const version_hex_encoded = Buffer.from(version).toString('hex')
const invoice_json = {
field1: "1",
field2: "2",
field3: "2"
}
const invoice_stringified = JSON.stringify(invoice_json)
const invoice_stringified_hex_encoded = Buffer.from(invoice_stringified).toString('hex')
const sig_a = "3045022100e0f86a5b1748ae48b0d10ea305202769d754071272cba0fbb82f74f8e8da8b530220494351742f3ba9e51b155df15b13f27c927d21956822aedcbb7d179c66d4d4c0"
const pk_a = "02644f5000535bbc135f9c8613f86f10c66a4a773eda5e913eff64eb328bc6326a"
const sig_b = "3045022100dd007f2c91390fe1d51242c5a22e6c07dfbc79e1950a4c0d71070a96555d169a0220118cf6ed9f9445896e4b9866bfb5f2681b726a9d31621a78e8dcf66d873d9fca"
const pk_b = "026d8884b5b08a0211d2c8297fb1c28aa51335f45fc3b3f9017b0ce16fe20185d8"
console.log("As bitcoin assembly code:");
console.log(bsv.Script.buildSafeDataOut([opentac_prefix, version_hex_encoded, invoice_stringified_hex_encoded, sig_a, pk_a, sig_b, pk_b], 'hex').toASM())
console.log("As pure hex (with pushdata opcodes added in):");
console.log(bsv.Script.buildSafeDataOut([opentac_prefix, version_hex_encoded, invoice_stringified_hex_encoded, sig_a, pk_a, sig_b, pk_b], 'hex').toHex())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment