Metadata in exchange transaction

+2 votes
Hi Multichain Team,

Is it possible to append metadata while creating and completing the exchange transaction?

Thanks.
asked Dec 21, 2016 by amanc

1 Answer

0 votes

Great question. Right now you have two imperfect options:

  1. Build the exchange from known inputs using createrawtransaction, then pass it to each party to call signrawtransaction, instead of using createrawexchange + appendrawexchange. This will allow you to add metadata outputs in the usual way, and have all parties sign that metadata. But it means you need to know the parties to the exchange ahead of time.
  2. Once the exchange has been completed using createrawexchange + appendrawexchange, manually modify the transaction (using an external library which can unpack and pack the bitcoin transaction format) to add the OP_RETURN output and a new input, then sign the resulting transaction using signrawtransaction on whichever node has the private key for that new input added.

We're looking into making this easier in a future version.

answered Dec 21, 2016 by MultiChain
Can you please tell the step by step approach for option 1 which you have listed above(using createrawtransaction)?
Its failing for me saying mismatch in inputs and outputs even though I get a complete : true when I sign from both the nodes?
I was able to figure out, did the following:-
1. preparelockunpsent at node1 for asset1
2. preparelockunpsent at node2 for asset2
3. createrawtransaction at node1 with inputs from 1 & 2
4. appendrawdata at node1
5. signrawtransaction at node1
6. signrawtransaction at node2
7. sendrawtransaction from node2 (this should work from node1 as well)

Please verify if this is the right approach?
Yes, this is exactly right. You can also combine steps 3-5 by using the new createrawtransaction parameters to create the transaction, add data and sign, all in one call.
...