Can you put additional data in the payload?

0

It seems to me like you could put arbitrary data into a transaction payload, since it is JSON. Is this true, can a sender add additional fields to the transaction JSON? Or if thats not possible, could a sender put an arbitrary program into the scriptPubKey?

For example, ScriptPubKey could be OP_DUP <myArbitraryData> OP_DROP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG, which would put some arbitrary data on the stack and then pop it off the stack right away again, which wouldn't influence the result of the script but would let the sender include arbitrary data in the transaction.

Marius

Posted 2014-07-19T09:56:51.060

Reputation: 131

what do you mean with json? bitcoin protocoll has nothing to do with json I guess you are talking about blockchain.info or the bitcoin core json rpc api?Dennis Kriechel 2014-07-19T10:14:02.057

Answers

1

The JSON that you see is only a nice way to look at a transaction, provided by the API you're using. The actual raw transaction, as it is transmitted on the network, is binary data that looks quite different.

The only place in the transaction that you can insert arbitrary data is the transaction script. This script is normally used to specify the address that the money can be paid to, but can contain arbitrary data. Note that if this data happens to be a program, it won't be executed by any (typical) client, it's just data.

Tim S.

Posted 2014-07-19T09:56:51.060

Reputation: 4 159

Thanks for clearing up the JSON misunderstanding. Relating to the script, IIUC, it is not actually run by clients, they just extract the hash out of it. This means that I could add extra stuff there?Marius 2014-07-19T14:21:54.050

@Marius the script is executed according to the rules of the OP codes at https://en.bitcoin.it/wiki/Script (basically, a very limited scripting language). If you wanted to include extra stuff that wouldn't run, you might just OP_RETURN and then have your data, e.g. https://blockchain.info/tx/064c3364055cc2d862f9320279e486b95a169806aac315333bb035a5ee684891 (note that this output is unspendable, so you probably want it to be 0 value so you're not throwing money away)

Tim S. 2014-07-19T15:21:06.577