Skip to content
Aakil Fernandes edited this page Jul 1, 2015 · 12 revisions

Publishing is the act of broadcasting a vendor's data to the Bitcoin blockchain. Once a vendor's data has been published, anyone can retrieve his/her data by supplying the xpubkey.

At a high level, the vendor data is compressed into a msgpack object, signed, and split into 37-byte chunks called "manifests". Each manifest is given a 3-byte header for a total of 40-bytes.

The following is pseudocode to help understand the publishing process.

//pack the vendor data using the msgpack encoding scheme
vendorDataMsg = msgpack.encode(vendorData)

//sign the vendor data with the vendor's address
signature = sign.(vendorDataMsg,vendor.address)

//compute the number of transactions a broadcast will take
transactionsRequired = ((1+vendorData)/37).roundUp()

//add everything together into a single byte array
manifest = [transactionsRequired] + signature + vendorDataMsg 

//split the bytes into chunks of 37
manifestChunks = manifest.splitIntoChunksOfByteSize(37)

//create an OP_RETURN transaction for each chunk and broadcast it to the network
manifestChunks.each(function(vendorDataMsgChunk){
    sendrawtransaction('OP_RETURN',header+vendorDataMsgChunk,vendor.address)
})

Vendor Data

All fields are to be decoded using UTF8. Only the product image url is optional.

  • Name (n)
  • Currency (c)
  • Pgp Key Data (k)
  • Info (i)
  • Array of Products (p)
    • Name (n)
    • Price (p)
    • Image URL (i) (optional)

Manifest Headers

Each manifest chunk contains a 3 byte header.

  1. A constant 0x6D to indicate a manifest chunk. 0x6D is the hex code for m.
  2. A random hex between 0x00 and 0xff. This is to help protect against multiple manifests broadcast around the same time.
  3. The index of the transaction sequence. For example the first header would be 0x00 while the second one would be 0x01.
Clone this wiki locally