Not able to sign Raw Transactions of a multisig by explicitly using the addresses' Privkeys

+2 votes

Below are the two addresses which will be used to create a multisig.

{
    "address" : "14bNaM9aqStabKdvd5icHNxamenvfnYAFhDym9",
    "ismine" : true,
    "iswatchonly" : false,
    "isscript" : false,
    "pubkey" : "02914a95f1076832f718219be88aff3cb9dd69c34f1474c1ba2a53741e934d48c1",
    "iscompressed" : true,
    "account" : "",
    "synchronized" : true,
    "privkey" : "V5jGmnrXg9v8oyyEDqkpstxV85c14aGAJs6CqTUwNv9eww228YC8Vw2t"

},
{
    "address" : "17j2UnsmCDX8QSZtXUZptNfVNBPs7WuToAhpbk",
    "ismine" : true,
    "iswatchonly" : false,
    "isscript" : false,
    "pubkey" : "02110949cacfbf081b8a2d254bd897f5b33ca9b308263972d34f6c19c996eec1e4",
    "iscompressed" : true,
    "account" : "",
    "synchronized" : true
    "privkey" : "V9nkC8qe4r7d6w4ahy1MUajYJ1T5npWaxgx1LqH8UN9LgyJbwjXJNhyC"
},

The Multisig created from the above addresses:

{
    "address" : "4a8CKmGYtZQfdYEvABk9785GoJH68v5d7ccUvH",
    "ismine" : true,
    "iswatchonly" : false,
    "isscript" : true,
    "script" : "multisig",
    "hex" : "522102914a95f1076832f718219be88aff3cb9dd69c34f1474c1ba2a53741e934d48c12102110949cacfbf081b8a2d254bd897f5b33ca9b308263972d34f6c19c996eec1e452ae",
    "addresses" : [
        "14bNaM9aqStabKdvd5icHNxamenvfnYAFhDym9",
        "17j2UnsmCDX8QSZtXUZptNfVNBPs7WuToAhpbk"
    ],
    "sigsrequired" : 2,
    "account" : "",
    "synchronized" : false
}

 

I create a raw transaction to issue new tokens to the above 2 wallets:

createrawsendfrom 4a8CKmGYtZQfdYEvABk9785GoJH68v5d7ccUvH '{"14bNaM9aqStabKdvd5icHNxamenvfnYAFhDym9":{"issue":{"raw":2000}},"17j2UnsmCDX8QSZtXUZptNfVNBPs7WuToAhpbk":{"issue":{"raw":3000}}}' '[{"create":"asset","name":"asset8","multiple":10,"open":true,"details":{"origin":"uk","stage":"one"}}]'

output: 010000000187bc64755f34f3af37ab00585d4c74369ad8086ca33b0a525cc34bc3571a95ae0000000000ffffffff0400000000000000002776a9141a94df3f88701283b2f1696a91c0f94d8fc2a57288ac0c73706b67d0070000000000007500000000000000002776a91431c130ca298a245cb8505d54249f340e03176b3388ac0c73706b67b80b000000000000750000000000000000302d73706b6e016f726967696e0002756b737461676500036f6e65000201010041040a000000000106617373657438756a000000000000000017a914fc7ed9f402ec64cb58727158c9a2c153698094e08700000000

Now I sign the transaction in two different ways:

1) first way I just let the wallet find the private key and sign it:

signrawtransaction 010000000187bc64755f34f3af37ab00585d4c74369ad8086ca33b0a525cc34bc3571a95ae0000000000ffffffff0400000000000000002776a9141a94df3f88701283b2f1696a91c0f94d8fc2a57288ac0c73706b67d0070000000000007500000000000000002776a91431c130ca298a245cb8505d54249f340e03176b3388ac0c73706b67b80b000000000000750000000000000000302d73706b6e016f726967696e0002756b737461676500036f6e65000201010041040a000000000106617373657438756a000000000000000017a914fc7ed9f402ec64cb58727158c9a2c153698094e08700000000

output: 

{
    "hex" : "010000000187bc64755f34f3af37ab00585d4c74369ad8086ca33b0a525cc34bc3571a95ae00000000da00473044022058fb290bd41e34ae78bcd55f40ecc88adf4f241edd4c850090c32fbd29253072022026b3983823bedb2c4e0f5a7be8b668ddb0d701c5cd684bc3744c7bce12ed066401483045022100b93ca891fdc252810c95d17bb24cb9e3af2c319895b6d151045ae215c9a72a5c02202908a9a8526dc6c2dd5e6f43cb965af6483dbd0580bd325d0cd405602906b1fc0147522102914a95f1076832f718219be88aff3cb9dd69c34f1474c1ba2a53741e934d48c12102110949cacfbf081b8a2d254bd897f5b33ca9b308263972d34f6c19c996eec1e452aeffffffff0400000000000000002776a9141a94df3f88701283b2f1696a91c0f94d8fc2a57288ac0c73706b67d0070000000000007500000000000000002776a91431c130ca298a245cb8505d54249f340e03176b3388ac0c73706b67b80b000000000000750000000000000000302d73706b6e016f726967696e0002756b737461676500036f6e65000201010041040a000000000106617373657438756a000000000000000017a914fc7ed9f402ec64cb58727158c9a2c153698094e08700000000",
    "complete" : true
}

2) sign by explicitly using the private keys:

signrawtransaction 01000000016d87d23083aaf4627587c5dfabd0c672bc3baa5ce3a459e0e0ccda6853856e0b0000000000ffffffff0400000000000000002776a9141a94df3f88701283b2f1696a91c0f94d8fc2a57288ac0c73706b67d0070000000000007500000000000000002776a91431c130ca298a245cb8505d54249f340e03176b3388ac0c73706b67b80b000000000000750000000000000000302d73706b6e016f726967696e0002756b737461676500036f6e65000201010041040a000000000106617373657438756a000000000000000017a914fc7ed9f402ec64cb58727158c9a2c153698094e08700000000 '[]' '["V9nkC8qe4r7d6w4ahy1MUajYJ1T5npWaxgx1LqH8UN9LgyJbwjXJNhyC", "V5jGmnrXg9v8oyyEDqkpstxV85c14aGAJs6CqTUwNv9eww228YC8Vw2t"]' 

output: 

{
    "hex" : "01000000016d87d23083aaf4627587c5dfabd0c672bc3baa5ce3a459e0e0ccda6853856e0b0000000000ffffffff0400000000000000002776a9141a94df3f88701283b2f1696a91c0f94d8fc2a57288ac0c73706b67d0070000000000007500000000000000002776a91431c130ca298a245cb8505d54249f340e03176b3388ac0c73706b67b80b000000000000750000000000000000302d73706b6e016f726967696e0002756b737461676500036f6e65000201010041040a000000000106617373657438756a000000000000000017a914fc7ed9f402ec64cb58727158c9a2c153698094e08700000000",
    "complete" : false
}

it fails to sign it. Seems like a bug. Why is this happening?? 

This becomes very important when we are creating multisigs on addresses not in the wallet and private keys are stored externally. Please help!

 

asked Aug 2, 2017 by Prateek Kolhar

1 Answer

0 votes

If you're signing a raw transaction for a multisig by passing explicit private keys, you also need to pass in the txid, vout, scriptPubKey and redeemScript for each input you want to sign. Please see this answer (and the associated thread) for more information:

https://www.multichain.com/qa/5941/random-previous-output-scriptpubkey-mismatch-error?show=5983#c5983

answered Aug 3, 2017 by MultiChain
...