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:
Copy and paste the displayed address here:
Now use any node which has an address with
activate privileges to add receive-only permissions to the stream address:
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:
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
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:
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:
- On the first node, call
preparelockunspentfrom [publish-address-1] 0
- Note the
- On second node, call
preparelockunspentfrom [publish-address-2] 0
- Note the
- On either node, call
voutpairs as inputs, with a single output sending
0to the stream address.
appendrawmetadatato add the hexadecimal stream item to this raw transaction.
- Sign this larger raw transaction on one node using
- Pass the partially signed transaction to the second node.
- On the second node, finish signing the transaction using
- On either node, use
sendrawtransactionto broadcast the final, fully signed transaction.