The old way to create an authenticated append-only archive

With the release of advanced data streams functionality in MultiChain 1.0 alpha 24, this method for creating quasi data streams (using watch-only addresses) is no longer recommended or required. However this information is preserved for those who require it.

Creating a quasi stream

Quasi streams are created and identified using a regular blockchain address. To create a quasi stream, run the following on any node:

getnewaddress

Copy and paste the displayed address here:

Now use any node which has an address with admin or activate privileges to add receive-only permissions to the stream address:

grant receive

Subscribing to a stream

The node which created a stream will automatically be subscribed to it. Other nodes can subscribe by adding it as a watch-only address:

importaddress

This may take some time as the blockchain is rescanned for transactions sent to this address. If you have never published to the stream before, you can avoid this delay by running: importaddress '' false

Publishing to a stream

To publish some data to a stream, encode that data in hexadecimal format, then send it as transaction metadata to the stream address. Note than no assets need be sent together with the transaction. For example to send the data 0123456789abcdef:

sendwithmetadata 0 0123456789abcdef

To sign the item using a particular address, use sendwithmetadatafrom and add the from-address as the first parameter.

Retrieving from a stream

To retrieve the most recent (say) 5 stream items seen by a particular node, use the following command:

listaddresstransactions 5

The most recent items will be returned, from oldest to newest. Note that the first item in a stream is the transaction which created it – this will contain a non-empty permissions array and can be ignored.

For each genuine stream item returned, the following fields might be useful:

  • data – the hexadecimal data contained in the stream item.
  • confirmations – the current number of block confirmations for the item.
  • txid – the transaction in which the stream item was published.
  • timereceived – the time when this node first saw the item, as a Unix timestamp.

To see who published/signed stream items, use the verbose version of the same API call:

listaddresstransactions 5 0 true

For each item, the publishers are listed in the addresses field of the vin elements listing the transaction’s inputs. (For pilot purposes you can also use the top-level addresses field of each item, but this is not secure because it might include addresses in other transaction outputs.)

Publishing with multiple signatures

A single item can be published in a stream with signatures from multiple addresses. To publish an item from two addresses held on different nodes:

  1. On the first node, call preparelockunspentfrom [publish-address-1] 0
  2. Note the txid and vout values returned.
  3. On second node, call preparelockunspentfrom [publish-address-2] 0
  4. Note the txid and vout values returned.
  5. On either node, call createrawtransaction using both txid/vout pairs as inputs, with a single output sending 0 to the stream address.
  6. Use appendrawmetadata to add the hexadecimal stream item to this raw transaction.
  7. Sign this larger raw transaction on one node using signrawtransaction.
  8. Pass the partially signed transaction to the second node.
  9. On the second node, finish signing the transaction using signrawtransaction.
  10. On either node, use sendrawtransaction to broadcast the final, fully signed transaction.