Title: multi-sign and Invalid private key (code -5) Post by: init1 on July 06, 2015, 12:48:43 PM Hello,
I am truing to spend coins from P2SH address. step by step 1) Generated keys Code: # https://brainwallet.org/#generator 2) combine the three keys into a multisig address: Code: ./bitcoind createmultisig 2 '["045e8385118c8b77a044390364dd5fb8c4864d138491fc788948be81f6842f45bc6b6c9401a90f8479b2af8191b7a6a7735053f2724668cf8af8a2c30d853b8011","042cb46c5cfa2a5af18effd8296e7aeda287d407ccc2e42cc15bb7d27c6f84e4a78ade99d1aa7e8efa2fd63f8573548ec1a33f53e0135ccbe15bc5c9eb0d6e0cfd","04d109b4e95fd48162e5424fe71d769c9cb4bc8cb40224ab6b8d1e9fac6f6925c34c902d38caebebf2703a7685bf788adfee83bffa637f95d3c782c3d4bb0120f5"]' 3) Checked address and txid Code: https://www.blocktrail.com/tBTC/address/2MvDgSTXGEbi9nm4UhP1B6Wvi7LMJ9MAdmu/transactions 4) Created rawTX Code: createrawtransaction ''' 5) Decoded raw tx and get - scriptPubKey hex Code: decoderawtransaction 0100000001cdba95b552d24a50182208816179578544d6d623fb0ca1dfbec4e6c845e6a9300000000000ffffffff01f09aeb0b000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac00000000 6) Tried to sign it by the first key Code: signrawtransaction '0100000001cdba95b552d24a50182208816179578544d6d623fb0ca1dfbec4e6c845e6a9300000000000ffffffff01f09aeb0b000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac00000000' Have got -> Invalid private key (code -5) What have I done wrong? some incorrect parameters or steps ? Regards. Title: Re: multi-sign and Invalid private key (code -5) Post by: achow101 on July 06, 2015, 02:44:11 PM 3) Checked address and txid If you look up this transaction in the blockexplorer, you will see that there are 2 outputs from this transaction.Code: https://www.blocktrail.com/tBTC/address/2MvDgSTXGEbi9nm4UhP1B6Wvi7LMJ9MAdmu/transactions The first one is to mwNenFE8gFfjz2p2osbsYXAcPt6gnGGKSk and the second to 2MvDgSTXGEbi9nm4UhP1B6Wvi7LMJ9MAdmu. The second one is to your address. These outputs go in an array, with the first having an index of 0, second has an index of 1, and so on. Now lets look at your raw transactions. 4) Created rawTX In your vins, you specify the txid and the index of the output you wish to spend. In this case, the index of the output is 1, not 0 because the output is the second in the array. Therefore, instead of Code: createrawtransaction ''' Code: "vout": '0' Code: "vout": '1' Your error is coming from not having the private key to spend the first output. Title: Re: multi-sign and Invalid private key (code -5) Post by: init1 on July 07, 2015, 07:51:55 AM Hello!
Thank you for your answer. I have tried to change vout from 0 to 1 Code: createrawtransaction ''' and decode it Code: decoderawtransaction As you can see vout == 1 but the error message same Code: signrawtransaction '0100000001cdba95b552d24a50182208816179578544d6d623fb0ca1dfbec4e6c845e6a9300100000000ffffffff01f09aeb0b000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac00000000' Invalid private key (code -5) what is wrong ? Also tried to use this example 2 of 3 https://gist.github.com/gavinandresen/3966071 The error message same 10:42:00  Invalid private key (code -5) What should I change ? BR! Title: Re: multi-sign and Invalid private key (code -5) Post by: achow101 on July 07, 2015, 02:12:05 PM Code: signrawtransaction '0100000001cdba95b552d24a50182208816179578544d6d623fb0ca1dfbec4e6c845e6a9300100000000ffffffff01f09aeb0b000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac00000000' Invalid private key (code -5) what is wrong ? Also tried to use this example 2 of 3 https://gist.github.com/gavinandresen/3966071 The error message same 10:42:00  Invalid private key (code -5) What should I change ? BR! Also, I don't think you included the scriptpubkey or the redeemscript in the createrawtransaction. Be sure to do that. Follow Gavin's instructions in the link. Title: Re: multi-sign and Invalid private key (code -5) Post by: init1 on July 07, 2015, 05:13:27 PM Thanks.
Quote You are using the wrong private key. Since this is a testnet transaction, you must sign it using a private key in testnet format. The private key that you posted above is for the mainnet. Testnet private keys start with either '9' or 'c'. I'he used next site for generation keys == https://brainwallet.org/#generator which site for the test net do you recommend ? Quote Also, I don't think you included the scriptpubkey or the redeemscript in the createrawtransaction. Be sure to do that. Follow Gavin's instructions in the link. According to the example Code: signrawtransaction '0100000001cdba95b55...' BR! Title: Re: multi-sign and Invalid private key (code -5) Post by: Muhammed Zakir on July 07, 2015, 05:23:10 PM -snip- Quote You are using the wrong private key. Since this is a testnet transaction, you must sign it using a private key in testnet format. The private key that you posted above is for the mainnet. Testnet private keys start with either '9' or 'c'. I'he used next site for generation keys == https://brainwallet.org/#generator which site for the test net do you recommend ? -snip- You need to choose 'Testnet' from the list you get when you click 'BTC'(top right) to get testnet address and its corresponding private key. Anyway, why don't you use Bitcoin Core to create testnet address? - https://bitcoin.org/en/developer-examples#testnet - https://bitcoin.org/en/developer-examples#p2sh-multisig |