I am attempting generate a P2SH-P2WSH address and then spend an output sent to this address, but when I attempt signing I receive Invalid private key error from bitcoind (v0.15.1.0). So where am I going wrong I am not entirely sure that I generate address correctly or that bitcoind rpc methods correctly support segwit signing operation. I would appreciate if someone could confirm whether address is generated correctly or if I am somehow failing at signing stage from my end. I can provide generation code (written in Java) if needed.
Here’s what I came up with:
Address generation 2 of 2 multisig:
Private Key c3accc350d70d1981c4366fd6fd86d9cc311048ae8620dac0b3dc9d18ce415fa Public Key 320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae Private Key 1093e97f3c01bd766473cc51441d443e9325a59387421a9e2fb69b7f9587d915 Public Key 20b020e27e49f049eac10010506499a84e1d59a500cd3680e9ded580df9a107b0 Witness program=2 PUSHDATA(33)[020b020e27e49f049eac10010506499a84e1d59a500cd3680e9ded580df9a107b0] PUSHDATA(33)[0320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae] 2 CHECKMULTISIG Witness hex=5221020b020e27e49f049eac10010506499a84e1d59a500cd3680e9ded580df9a107b0210320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae52ae redeemScript program=0 PUSHDATA(32)[16a91e58e02069f95ea6defba7436199658573c34d384c69779779f4500d7cac] redeemScript hex=002016a91e58e02069f95ea6defba7436199658573c34d384c69779779f4500d7cac scriptPubKey program=HASH160 PUSHDATA(20)[035e0a0739eec3c195f9dc0d8b85e6e3f6ae1ece] EQUAL scriptPubKey hex=a914035e0a0739eec3c195f9dc0d8b85e6e3f6ae1ece87 TestNetAddress=2MsZ2fpGKUydzY62v6trPHR8eCx5JTy1Dpa
I created these using bitcoinj library I am not entirely sure that this is correct, but from the look of it seemed like it was described in segwit dev guide by bitcoin core.
Fund deposit I sent to this address test coins (Testnet3) with this TX = 122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6
Creating raw transaction:
Created transaction hex (using bitcoin rpc) = { "jsonrpc": "1.0", "id": "reqId1", "method": "createrawtransaction", "params": [ [ { "txid": "122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6", "vout": 1 } ], { "mmZFY7b7NArkrnri43RwxL58m6TZUqty4t": "0.09999" }, 0 ] } Response hex = 0200000001d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca53128120100000000ffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac00000000
Signing raw transaction:
SignRaw transaction request (using bitcoin rpc) = {"jsonrpc":"1.0","id":"signrawtransaction_1510651375833","method":"signrawtransaction","params":["0200000001d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca53128120100000000ffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac00000000",[{"txid":"122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6","vout":1,"scriptPubKey":"a914035e0a0739eec3c195f9dc0d8b85e6e3f6ae1ece87","redeemScript":"002016a91e58e02069f95ea6defba7436199658573c34d384c69779779f4500d7cac","amount":"0.10000000"}],["c3accc350d70d1981c4366fd6fd86d9cc311048ae8620dac0b3dc9d18ce415fa","1093e97f3c01bd766473cc51441d443e9325a59387421a9e2fb69b7f9587d915"]]} { "jsonrpc": "1.0", "id": "reqId2", "method": "signrawtransaction", "params": [ "0200000001d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca53128120100000000ffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac00000000", [ { "txid": "122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6", "vout": 1, "scriptPubKey": "a914035e0a0739eec3c195f9dc0d8b85e6e3f6ae1ece87", "redeemScript": "002016a91e58e02069f95ea6defba7436199658573c34d384c69779779f4500d7cac", "amount": "0.10000000" } ], [ "c3accc350d70d1981c4366fd6fd86d9cc311048ae8620dac0b3dc9d18ce415fa", "1093e97f3c01bd766473cc51441d443e9325a59387421a9e2fb69b7f9587d915" ] ] } Result = Error{code=-5, message='Invalid private key', data='null'}