Atomic exchange transactions with imported addresses (key managed off wallet)

+1 vote
Hi there,

I was reading your tutorial on atomic exchange transactions and I'm wondering if there is a way to use the api with imported addresses which do not have their keys stored in the node wallet?
asked Apr 25, 2017 by Steven Chan

2 Answers

0 votes
 
Best answer

It can be done, but it's a little more complicated, and you need to use the raw transaction interface as well as some external library for packing/unpacking bitcoin format transactions (we hope to improve this last bit soon).

To show some of the steps in the command line, you can replace:

preparelockunspentfrom 1A..Z '{"asset1":567}'

... with ...

createrawsendfrom 1A..Z '{"1A..Z":567}' '[]' lock

then sign the transaction with your external key (either outside MultiChain or using signrawtransaction with the private key passed in) and then transmit it with sendrawtransaction. The txid that preparelockunspentfrom would have given you is the txid of the transaction sent, and the vout is 0. It won't lock this transaction output, but you can do that in the next stage instead.

You can also replace:

createrawexchange ab..12 0 '{"asset2":890}' 

... with ...

createrawtransaction '[{"txid":"ab..12","vout":0},...]' '{"1A..Z":{"asset2":890}}' '[]' lock

then sign the transaction with your external key (either outside MultiChain or using signrawtransaction with the private key passed in) to get the exchange offer. In either case you need to sign it using the signature type SIGHASH_SINGLE|SIGHASH_ANYONE_CAN_PAY which you can do by passing SINGLE|ANYONECANPAY in the last parameter to signrawtransaction.

Unfortunately appendrawexchange is more complicated because you currently can't use MultiChain's APIs to add some more inputs and outputs to an existing raw transaction, apart from the specific cases of appendrawchange and appendrawdata, neither of which do what you want here. But perhaps if one side isn't using external keys, that's the side that would perform the second step using appendrawexchange.

answered Apr 26, 2017 by MultiChain
0 votes

Beta 2 of MultiChain, just released, includes a new API appendrawtransaction, which will make the last part of the process (described in my previous answer) easier as well.

answered Jun 15, 2017 by MultiChain
...