Example of external signing of a transaction

+2 votes
Hi Multichain Team,

Do we have an example which shows external signing of a transaction before passing to sendrawtransaction api?

I have a B2C scenario where I am thinking of having multiple addresses at one node for different customers but in watch only mode. And keeping the the private key of the customer on the app side which will externally sign the transaction and pass it to node.
asked Oct 3, 2016 by amanc

1 Answer

0 votes

We don't have an explicit example for this, but you can look at any bitcoin external signing flow, and it will be exactly the same for MultiChain. With MultiChain you can also make life easier by calling preparelockunspent to create a single transaction output containing exactly the asset quantity/quantities you want to send - then you don't need to worry about change or manually choosing which unspent outputs to use.

answered Oct 3, 2016 by MultiChain
Will preparelockunspentfrom work for a watch only address? Does it require a private key to do locking?
I am getting a "from-address must have send and receive permission" when I am using the preparelockunspentfrom command even though in listpermissions, I see the send and receive permissions for this address.
The address which is used here was generated externally and I used "importaddress"  to add it. The corresponding  private key I have kept external to the node.
The preparelockunspentfrom command requires the wallet to contain the private key for the address provided, otherwise it can't generate the transaction that isolates the requested amount. So the bug is in the error message shown, not in the fact that this cannot be done.
I was trying to do external signing as I don't want to have my private key on node, so in this case we cannot use preparelockunspent. So I'll have to use listunspents and use createrawtransaction..right?
Also can you please tell me how to do signrawtransaction externally?
I called createrawtransaction, then appendrawchange, now I want to signrawtransaction using a private key which is externally available, what are the steps I need to perform to replicate the multichain signrawtransaction api?
We haven't yet documented how to use signrawtransaction with private key parameters, but you can consult any bitcoin documentation for this, since it is exactly the same for MultiChain. For example: https://en.bitcoin.it/wiki/Raw_Transactions