Creating 2 of 2 multisig transaction

+1 vote
Here's the scenario I have set up: Created seed node S1 and client node C1; seed node issues asset, asset1 from seed node's address AS1, to client node address, AC1. The purpose is to create a 2 of 2 multisig transaction requiring signatures from AS1 and AC1 and send it to address AS1 at seed node.

Referring to the link for data streams (http://www.multichain.com/developers/creating-data-streams/), here are the steps:

At C1:

1. preparelockunspent

2. createmultisig 2 ["AC1","pub key of AS1"]

3. createrawtransaction with txid from 1, vout:0 to multisig address, AM1 from 2 having an asset, asset1 of 2 unit quantity

4. signrawtransaction with hex-blob from 3. This returns a long-hex-blob with Complete:True

5. After granting receive permission to AM1, sendrawtransaction with hex value from 4

6. decoderawtransaction with long-hex-blob from 4 to get details including scriptPubKey in vout[0]. Txid of the result and txid returned from 5 are the same

7. createrawtransaction with txid from 5, vout:0, scriptPubKey from 6 and redeemScript from 2, to AS1, the asset, asset1 and quantity, 2.

8. signrawtransaction with hex-blob from 7 as the transaction, transaction parameter the same as 7, and '["private key of AC1"]'. This returns a long-hex-blob along with Complete:False

At S1:

1. signrawtransaction with same details as in Step 8 at C1, but signed with AS1's private key. This returns a long-hex-blob along with Complete:False

Questions:

1. Why is it that even though the transaction has been signed by both nodes, the step at S1, returns Complete: False? Is there something missing in the transaction flow?

2. The next logical step to follow is to use the long-hex-blob from the signed transactions at either of the nodes, to be able to send the asset to AS1. Would that ensure, that the 2 units of the asset, asset1 are sent from AC1 to AS1? If so, this could then be extended to release assets based on the 2 signatures to any address with receive permissions, in either node's wallets.

3. Note that, during the creation of multisig address, instead of using the pub key of AC1, if AC1 were to be used the error is: No full public key for AS1. Suggestions?
asked Apr 10, 2016 by skarred14

1 Answer

0 votes

I think you may be confusing two things - creating a transaction with two separate signatures, and creating a single multisig output. To create a multisig address and add it to each node's wallet so it can be used for signing, use addmultisigaddress on both nodes (and yes, you need to pass the full public key for addresses not owned by that node). You can then send funds to this multisig address. To spend the funds, you will then need to use createrawtransaction, signrawtransaction, signrawtransaction (on the second node) then sendrawtransaction.

answered Apr 11, 2016 by MultiChain
Thanks for the response. I followed the above suggestion and at first node, upon using addmultisigaddress with nrequired=2 and the  addresses of both nodes, this returns an address (but no redeemscript). After this, 2 units of the asset are sent to this multisigaddress. Then, following the sequence of instructions as above at the first node. The transaction parameters used were: txid from the prior send transaction; vout:0; scriptPubKey from decoderawtransaction's vout[0] for createrawtransaction and signrawtransaction. This returned a hex-blob with Complete:False.

Now at second node, signrawtransaction with exactly the same parameters as above, returns hex-blob with Complete:False.

Whats the issue with the above sequence of steps?

Alternately, I tried creating another multisig address at second node using addmultisigaddress with nrequired=2. Should I be sending another 2 units of asset to the new multisigaddress just created above, for signrawtransaction?

Could you please suggest?
Please take a look at the flow of steps below. I am able to get the two nodes involved in the 2 of 2 multisig to sign successfully. However, it fails at sending of the transaction at the final step (Node 2). Suggestions?
root@1b1aed4ee623:/# multichain-cli chain1 preparelockunspent '{"asset1":2}'

{
    "txid" : "2485e6a780f930bc26f04ea69ccaea78fadba8bf7db89ba305e37f0faf6bd73b",
    "vout" : 0
}
root@1b1aed4ee623:/# multichain-cli chain1 createmultisig 2 '["034bfb0907a2d36ddffd5a64c6081a6765a7bcc3aece227d3891886a155a1eab32","1CYeyLphPStkSVBmrpnT7vsvwYyQt36Visjvk5"]'

{
    "address" : "46NHSVmvouRFRMdJeYKsDrt3AneCceqgwr3ZL6",
    "redeemScript" : “redeem script”
}

root@1b1aed4ee623:/# multichain-cli chain1 createrawtransaction '[{"txid":"2485e6a780f930bc26f04ea69ccaea78fadba8bf7db89ba305e37f0faf6bd73b","vout":0}]' '{"46NHSVmvouRFRMdJeYKsDrt3AneCceqgwr3ZL6":{"asset1":2}}'

01000000013bd76baf0f7fe305a39bb87dbfa8dbfa78eaca9ca64ef026bc30f980a7e685240000000000ffffffff0100000000000000002fa9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c8000000000000007500000000
root@1b1aed4ee623:/# multichain-cli chain1 signrawtransaction 01000000013bd76baf0f7fe305a39bb87dbfa8dbfa78eaca9ca64ef026bc30f980a7e685240000000000ffffffff0100000000000000002fa9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c8000000000000007500000000

{
    "hex" : "01000000013bd76baf0f7fe305a39bb87dbfa8dbfa78eaca9ca64ef026bc30f980a7e68524000000006a47304402201f4c22968ec67c223661b75bd6758e950deefe9b756a37a3031438a12ff050ed022018abc0cd77fdfa9ffa81888baf2479ace57604ccbe95b356c579daf26595e4b7012102916dd82c14e5c4c7af8472a68463d53226b372d55681fa9add470da524d7463affffffff0100000000000000002fa9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c8000000000000007500000000",
    "complete" : true
}

root@1b1aed4ee623:/# multichain-cli chain1 sendrawtransaction 01000000013bd76baf0f7fe305a39bb87dbfa8dbfa78eaca9ca64ef026bc30f980a7e685240000000000ffffffff0100000000000000002fa9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c8000000000000007500000000

error code: -26
error message:
64: Nonstandard transaction input
root@1b1aed4ee623:/# multichain-cli chain1 sendrawtransaction 01000000013bd76baf0f7fe305a39bb87dbfa8dbfa78eaca9ca64ef026bc30f980a7e68524000000006a47304402201f4c22968ec67c223661b75bd6758e950deefe9b756a37a3031438a12ff050ed022018abc0cd77fdfa9ffa81888baf2479ace57604ccbe95b356c579daf26595e4b7012102916dd82c14e5c4c7af8472a68463d53226b372d55681fa9add470da524d7463affffffff0100000000000000002fa9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c8000000000000007500000000

c9db8ee486082fabf79d9fdaee6a78461de09ddd6f23b5b6607535477aa3a633

multichain-cli chain1 decoderawtransaction 01000000013bd76baf0f7fe305a39bb87dbfa8dbfa78eaca9ca64ef026bc30f980a7e685240000000000ffffffff0100000000000000002fa9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c8000000000000007500000000

root@1b1aed4ee623:/# multichain-cli chain1 createrawtransaction '[{"txid":"c3cc562e9274da53b3ee30bf13987e4eabeb716c4196dddc7d39bc4a8e6e13d9","vout":0,"scriptPubKey":"a9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c80000000000000075","redeemScript”:”redeem script”}’’ '{"1bJwWStdoGCv6qxt24mPYELiz99P25uVDho2CQ":{"asset1":2}}'

0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc30000000000ffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000

root@1b1aed4ee623:/# multichain-cli chain1 signrawtransaction '0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc30000000000ffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000' '[{"txid":"c3cc562e9274da53b3ee30bf13987e4eabeb716c4196dddc7d39bc4a8e6e13d9","vout":0,"scriptPubKey":"a9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c80000000000000075","redeemScript”:”redeem script”}’’ '["V7FvZz9t5mU2vHW4E6Nf42uUgNdheoaof6ypRrRZvLHfwoBYoRR3DGVV"]
{
    "hex" : "0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc3000000009200483045022100fa2e21f4c1e0768143501984e1e0238603fedf12c8185065be08b57aaffeb57f02207904d06319431cc2bdd614d17d573157d2a56b4899f8b7745b64e0b6084f7a4201475221034bfb0907a2d36ddffd5a64c6081a6765a7bcc3aece227d3891886a155a1eab322102916dd82c14e5c4c7af8472a68463d53226b372d55681fa9add470da524d7463a52aeffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000",
    "complete" : false
}

At Node 2:
root@24b2f6bc5a96:/# multichain-cli chain1 signrawtransaction '0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc3000000009200483045022100fa2e21f4c1e0768143501984e1e0238603fedf12c8185065be08b57aaffeb57f02207904d06319431cc2bdd614d17d573157d2a56b4899f8b7745b64e0b6084f7a4201475221034bfb0907a2d36ddffd5a64c6081a6765a7bcc3aece227d3891886a155a1eab322102916dd82c14e5c4c7af8472a68463d53226b372d55681fa9add470da524d7463a52aeffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000' '[{"txid":"c3cc562e9274da53b3ee30bf13987e4eabeb716c4196dddc7d39bc4a8e6e13d9","vout":0,"scriptPubKey":"a9142f1f6f4903eb29b9671acfb14e8c5d68728df8c7871673706b7107000000080100002514c80000000000000075","redeemScript”:”redeem script”}’’ '["VFvfha38nA7NtEdaqTj9BVHYNg96eLBHL7kDTm7EJVJsn437ccG14KUe"]'

{
    "hex" : "0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc300000000db00483045022100ebec0f25aa76596027fed75c3eb11744e60d7aa583e1a10fb46291d1aa3f89320220492ab3f977c03273f5faaa6527a8aac96c537bcbd78a819b7c6683f28466c4ac01483045022100fa2e21f4c1e0768143501984e1e0238603fedf12c8185065be08b57aaffeb57f02207904d06319431cc2bdd614d17d573157d2a56b4899f8b7745b64e0b6084f7a4201475221034bfb0907a2d36ddffd5a64c6081a6765a7bcc3aece227d3891886a155a1eab322102916dd82c14e5c4c7af8472a68463d53226b372d55681fa9add470da524d7463a52aeffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000",
    "complete" : true
}
root@24b2f6bc5a96:/# multichain-cli chain1 sendrawtransaction 0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc30000000000ffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000

error code: -26
error message:
18: bad-txns-inputs-spent
root@24b2f6bc5a96:/# multichain-cli chain1 sendrawtransaction 0100000001d9136e8e4abc397ddcdd96416c71ebab4e7e9813bf30eeb353da74922e56ccc3000000009200483045022100fa2e21f4c1e0768143501984e1e0238603fedf12c8185065be08b57aaffeb57f02207904d06319431cc2bdd614d17d573157d2a56b4899f8b7745b64e0b6084f7a4201475221034bfb0907a2d36ddffd5a64c6081a6765a7bcc3aece227d3891886a155a1eab322102916dd82c14e5c4c7af8472a68463d53226b372d55681fa9add470da524d7463a52aeffffffff0100000000000000003176a914fdda1d8bc3e19104664297ff7953544efb521db188ac1673706b7107000000080100002514c8000000000000007500000000

error code: -26
error message:
18: bad-txns-inputs-spent

Note that, during the process of sending the raw transaction to the multisig address, sending fails if I weren't to use the longer-hex-blob that is returned by the preceding signrawtransaction.
Hi,

1. createmultisig
2. createrawtransaction (use the preparelockunspent,address and asset details)
3. signrawtransaction (use step 2's output)
4. sendrawtransaction (use step 3's outout hex value)
5. decoderawtransaction (use step 3's outout hex value)
6. createrawtransaction (use step 5's txid, vout->scriptPubKey->hex value for scriptPubKey and address to where you want to send the asset.
7. signrawtransaction (use step 6's hex value)

and follow your steps.
Thanks Shenthil, this was quite helpful. The missing link was the decoderawtransaction - I was using the wrong hex blob (from createrawtransaction, instead of the one from sendrawtransaction) for sending to multisig address. I got it working finally - thanks again!
...