user54706: 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 hex Key c3accc350d70d1981c4366fd6fd86d9cc311048ae8620dac0b3dc9d18ce415fa
Public Key 320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae

Private hex 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"
            }
        ],
        [
            "cN8vhcMrmcf3fUkWeTrRNt6mmiBoqnKmuce3yNcWkUjjNNskbjbg",
            "cU94urfRuwnEpGtJiiKyGsBqbC7woGazxST1HbGYWMgfVdafKmgu"
        ]
    ]
}

Result = Error{code=-5, message='Invalid private key', data='null'}


user64730: bitcoin-cli's signrawtransaction expects a few arguments.  You got most of them right, but forgot to add the details for redeeming the actual p2wsh part.  Specifically for p2sh(p2wsh), you'd need to provide both :
$ bitcoin-cli -tesnet signrawtransaction \
0200000001d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca53128120100000000ffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac00000000 \
'[{"txid":"122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6","vout":1,"scriptPubKey":"A914035E0A0739EEC3C195F9DC0D8B85E6E3F6AE1ECE87","redeemScript":"002016A91E58E02069F95EA6DEFBA7436199658573C34D384C69779779F4500D7CAC","amount":0.1},{"txid":"122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6","vout":1,"scriptPubKey":"A914035E0A0739EEC3C195F9DC0D8B85E6E3F6AE1ECE87","redeemScript":"5221020B020E27E49F049EAC10010506499A84E1D59A500CD3680E9DED580DF9A107B0210320CE424C6D61F352CCFEA60D209651672CFB03B2DC77D1D64D3BA519AEC756AE52AE","amount":0.1}]' \
'["cU94urfRuwnEpGtJiiKyGsBqbC7woGazxST1HbGYWMgfVdafKmgu","cN8vhcMrmcf3fUkWeTrRNt6mmiBoqnKmuce3yNcWkUjjNNskbjbg"]'
{
  "hex": "02000000000101d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca5312812010000002322002016a91e58e02069f95ea6defba7436199658573c34d384c69779779f4500d7cacffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac04004730440220783b89197a238a9300bc30b55b926848dfb8d94016930c050a037c9420c7e2c70220542fa6b3cbd34e32cdc7ea13c00410735c546a6e390e6de2be87c3a9314e67f80147304402206d25c1b31c405fef9aef5dc3bf30ccea2760d59bc25787c7de9fd87a4ade39490220612e9d5fc283a5fd11ac690dc006a914af88c31d0c5d4eb07d38cc4b66e5a1cf01475221020b020e27e49f049eac10010506499a84e1d59a500cd3680e9ded580df9a107b0210320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae52ae00000000",
  "complete": true
}


54706: <p>I am attempting generate a <strong>P2SH-P2WSH</strong> address and then spend an output sent to this address, but when I attempt signing I receive <strong><em>Invalid private key</em></strong> error from <strong>bitcoind</strong> (v0.15.1.0). So where am I going wrong I am not entirely sure that I <strong>generate address correctly</strong> or that <strong>bitcoind rpc methods correctly support segwit signing operation</strong>. 
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. </p>

<p>Here's what I came up with:</p>

<p><strong>Address generation</strong> 2 of 2 multisig:</p>

<pre><code>Private hex Key c3accc350d70d1981c4366fd6fd86d9cc311048ae8620dac0b3dc9d18ce415fa
Public Key 320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae

Private hex 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
</code></pre>

<p>I created these using bitcoinj library I am <strong>not</strong> entirely sure that this is correct, but from the look of it seemed like it was described in segwit dev guide by bitcoin core.</p>

<p><strong>Fund deposit</strong>
I sent to this address test coins (<strong>Testnet3</strong>) with this TX = 122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6</p>

<p><strong>Creating raw transaction</strong>:</p>

<pre><code>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
</code></pre>

<p><strong>Signing raw transaction</strong>:</p>

<pre><code>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"
            }
        ],
        [
            "cN8vhcMrmcf3fUkWeTrRNt6mmiBoqnKmuce3yNcWkUjjNNskbjbg",
            "cU94urfRuwnEpGtJiiKyGsBqbC7woGazxST1HbGYWMgfVdafKmgu"
        ]
    ]
}

Result = Error{code=-5, message='Invalid private key', data='null'}
</code></pre>
 64730: <p>bitcoin-cli's <code>signrawtransaction</code> expects a few arguments.  You got most of them right, but forgot to add the details for redeeming the actual p2wsh part.  Specifically for p2sh(p2wsh), you'd need to provide both :</p>

<pre><code>$ bitcoin-cli -tesnet signrawtransaction \
0200000001d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca53128120100000000ffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac00000000 \
'[{"txid":"122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6","vout":1,"scriptPubKey":"A914035E0A0739EEC3C195F9DC0D8B85E6E3F6AE1ECE87","redeemScript":"002016A91E58E02069F95EA6DEFBA7436199658573C34D384C69779779F4500D7CAC","amount":0.1},{"txid":"122831a5cc3d3875cadd89e2a2690c2e5bc9e703d177385e1a3318a44675b6d6","vout":1,"scriptPubKey":"A914035E0A0739EEC3C195F9DC0D8B85E6E3F6AE1ECE87","redeemScript":"5221020B020E27E49F049EAC10010506499A84E1D59A500CD3680E9DED580DF9A107B0210320CE424C6D61F352CCFEA60D209651672CFB03B2DC77D1D64D3BA519AEC756AE52AE","amount":0.1}]' \
'["cU94urfRuwnEpGtJiiKyGsBqbC7woGazxST1HbGYWMgfVdafKmgu","cN8vhcMrmcf3fUkWeTrRNt6mmiBoqnKmuce3yNcWkUjjNNskbjbg"]'
{
  "hex": "02000000000101d6b67546a418331a5e3877d103e7c95b2e0c69a2e289ddca75383dcca5312812010000002322002016a91e58e02069f95ea6defba7436199658573c34d384c69779779f4500d7cacffffffff0198929800000000001976a914423ffad905158d1d472f5fcd5fbc6916c2fb031f88ac04004730440220783b89197a238a9300bc30b55b926848dfb8d94016930c050a037c9420c7e2c70220542fa6b3cbd34e32cdc7ea13c00410735c546a6e390e6de2be87c3a9314e67f80147304402206d25c1b31c405fef9aef5dc3bf30ccea2760d59bc25787c7de9fd87a4ade39490220612e9d5fc283a5fd11ac690dc006a914af88c31d0c5d4eb07d38cc4b66e5a1cf01475221020b020e27e49f049eac10010506499a84e1d59a500cd3680e9ded580df9a107b0210320ce424c6d61f352ccfea60d209651672cfb03b2dc77d1d64d3ba519aec756ae52ae00000000",
  "complete": true
}
</code></pre>
