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.

1
  • 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? Commented Jul 19, 2014 at 10:14

1 Answer 1

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.

2
  • 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
    Commented Jul 19, 2014 at 14:21
  • @Marius the script is executed according to the rules of the OP codes at 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. blockchain.info/tx/… (note that this output is unspendable, so you probably want it to be 0 value so you're not throwing money away)
    – Tim S.
    Commented Jul 19, 2014 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.