I'm trying spend funds that were sent to an SegWit address I created with the bitcoin-cli addwitnessaddress <P2PKH address>
command. The segwit address created was
33uUUt2V76HLcLqbs1Hou2ioofQo3d5kZ2
. I sent a small amount to this address as a test.
{txid: e360a6f86ebbdf0d2c3c86df60d1ad7e95af41248ff9305a48372db519028fcb, vout: 0}
I'm now trying to spend those funds to 3FNYRnLCgbGAaYmhkX1QHaXD5VYyXndpDa
. I created a raw transaction the normal way by specifying inputs and outputs:
bitcoin-cli createrawtransaction '[{"txid":"e360a6f86ebbdf0d2c3c86df60d1ad7e95af41248ff9305a48372db519028fcb","vout":0}]' '{"3FNYRnLCgbGAaYmhkX1QHaXD5VYyXndpDa":0.00451855}'
>> 0200000001cb8f0219b52d37485a30f98f2441af957eadd160df863c2c0ddfbb6ef8a660e30000000000ffffffff010fe506000000000017a9149613523d8525c0c444209b73eefda15101d1750d8700000000
bitcoin-cli signrawtransaction 0200000001cb8f0219b52d37485a30f98f2441af957eadd160df863c2c0ddfbb6ef8a660e30000000000ffffffff010fe506000000000017a9149613523d8525c0c444209b73eefda15101d1750d8700000000 '[{"txid":"e360a6f86ebbdf0d2c3c86df60d1ad7e95af41248ff9305a48372db519028fcb","vout":0,"scriptPubKey":"a914184b69873b307dc7081f2541098aaf4881bac20187","redeemScript":"0014568db227e811df5f502df149c8c9d899492140c9"}]'
>> {"hex": "02000000000101cb8f0219b52d37485a30f98f2441af957eadd160df863c2c0ddfbb6ef8a660e30000000017160014568db227e811df5f502df149c8c9d899492140c9ffffffff010fe506000000000017a9149613523d8525c0c444209b73eefda15101d1750d87024830450221009fe3df8448be56b052bcf81cb3e992ff606a10b1baf94eec49b1bad05914b97c0220752c6823152d0ef59945377a767edba6222a12b6e2b1baabafe498fa4801dea6012103ba8ae62944f27ce7a661866d6837ab3d6dd3fcd62bc6a09be5405074ec2473db00000000","complete": true}
Now I try to send the transaction:
bitcoin-cli sendrawtransaction 02000000000101cb8f0219b52d37485a30f98f2441af957eadd160df863c2c0ddfbb6ef8a660e30000000017160014568db227e811df5f502df149c8c9d899492140c9ffffffff010fe506000000000017a9149613523d8525c0c444209b73eefda15101d1750d87024830450221009fe3df8448be56b052bcf81cb3e992ff606a10b1baf94eec49b1bad05914b97c0220752c6823152d0ef59945377a767edba6222a12b6e2b1baabafe498fa4801dea6012103ba8ae62944f27ce7a661866d6837ab3d6dd3fcd62bc6a09be5405074ec2473db00000000
And get the following error:
error code: -26
error message:
64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)
I tried sending it through blockchain.info/pushtx in case it was a problem with my wallet but I got the same error. I tried looking up what the error meant but couldn't find any explanation that would help me figure out what I did wrong.