Create raw transaction to publish data to a stream offline

+2 votes

Is it possible to create an offline signed raw transaction that publishes data onto a stream?

Or do you need some knowlede of the blockchain ledger like inputs and outputs that you can not know offline?


The idea would be that a client (device) is able to prepare a transaction that publishs data to the blockchain. The device should own the private key locally.

This also raises the question if there are convenient libraries for creating and signing raw transactions.



asked Jan 26, 2017 by Alexoid

1 Answer

+2 votes
Best answer
You can prepare transactions offline in general, but the transaction will require at least one input to be signed, and that input's content will depend on the blockchain's prior state. However if the client device is the only one who knows its private key, it will also be able to control the unspent outputs belonging to that private key. So after sending one transaction with a change output back to itself, it will know with confidence that it has a new output that it can spend for a new transaction (assuming the first was actually broadcast and confirmed). No matter how much time passes, no one else can spend this output.

In general it's not possible on any blockchain platform to prepare a transaction for offline sending with no knowledge of the blockchain's state, because that would mean the transaction could be confirmed multiple times, a so-called "replay attack".

MultiChain is technically compatible with bitcoin in terms of transaction formats and cryptography. So you can use any bitcoin library (there are tons, in many languages) to create and sign the raw transaction. If you want to make life easier for yourself, you can set your blockchain to use bitcoin-compatible addresses and private key formats, but this does not affect the binary address/key format inside transactions themselves. See the top paragraph on this page:

Also note that you'll need to manually build the special transaction output that contains the stream item. The format for this output is described in detail here:
answered Jan 26, 2017 by MultiChain
selected Jan 26, 2017 by Alexoid