0

I'm trying to construct a transaction in regtest mode that spends from a P2WSH 2-of-2 multisig.

Here is the funding transaction for 5 btc. It also contains a change output for 5 btc.

020000000001013314dcdc95c9aee89b7b0324ff2b472d73561d29cbd0cb58b37009b7193573700100000017160014a41c072b586d97105728775b124a88041e43afd2ffffffff020065cd1d00000000220020f9b7fbe4a3a7a621a19e03ef53d91a6391da83615826cbafa3062d3b39adfd380065cd1d00000000160014331039b508a3ad5633c045b24d94489adbaba0a00247304402204538711966348202e3d91352c7e5b2b0a4a7dab503946bc90ce912fd26f407ca02201e4334064a150227acc24095a6685505ef568c8e1e8a4e7053aa389c395ddf26012103993a782afaa894a4ea296210a5e72d46924898e9df91a74e32435c52b044fb3700000000

This is the transaction I am trying to spend from the escrow:

0200000000010135fff0ef75190ac3ead75b46713fb63da6bf642b4e064856d5778a3e21615f300000000000ffffffff010084d717000000001600141a6053fa355499bad556165474ca9661fd517c2b040047304402207be65e2f6d5fd8f7fdb421b65bdd53a1d0c9656e6fd7a8b9bef4954b08bc4250022066156cc85b84a783a7431cafa20f6e92272a2d28a484dd2becc259fea69b687501483045022100b608f0955ec89d0e3ff5e40ca36fb141425ddf0c8ab3880f45c44ca90155fd5702206606bbde73f5bea1fbb5da07fc17445ea5a1018efcad79fcda058180e203dd220147522103c2f21de0f430251d8e3987fbe89ff51f3d6f3a48b234b84b60ddb9f24d587cf52103e0948a03f50377290847d27c93d383b8ab7e2d0bc065e96e0e1136b315388b5452ae00000000

bitcoin-cli is giving me this error message when I try to broadcast it: error code: -26 error message: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)

Here are the private keys associated with the escrow tx: privkey1 = "CF933A6C602069F1CBC85990DF087714D7E86DF0D0E48398B7D8953E1F03534B" privkey2 = "BF933A6C602069F1CBC85990DF087714D7E86DF0D0E48398B7D8953E1F03534B"

and here is the bip_143 transaction digest preimage that does into double SHA256, which is then getting signed by the private keys:

hashPrevOuts ec4982463833211511676584168e5c2749598a966f84594d529ca4627af6f541

hashSequence 3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044

outpoint txid 35fff0ef75190ac3ead75b46713fb63da6bf642b4e064856d5778a3e21615f30

outpoint index 00000000

scriptCode 522103c2f21de0f430251d8e3987fbe89ff51f3d6f3a48b234b84b60ddb9f24d587cf52103e0948a03f50377290847d27c93d383b8ab7e2d0bc065e96e0e1136b315388b5452ae

input_amount 0065cd1d00000000

sequence ffffffff

hashOutputs 0c4a4515b0c862221d8376400bef5e085aba67281d774776f1bc083294180d6b

locktime 00000000

sighash 01000000

Full bip143 tx digest preimage: 02000000ec4982463833211511676584168e5c2749598a966f84594d529ca4627af6f5413bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e7066504435fff0ef75190ac3ead75b46713fb63da6bf642b4e064856d5778a3e21615f3000000000522103c2f21de0f430251d8e3987fbe89ff51f3d6f3a48b234b84b60ddb9f24d587cf52103e0948a03f50377290847d27c93d383b8ab7e2d0bc065e96e0e1136b315388b5452ae0065cd1d00000000ffffffff0c4a4515b0c862221d8376400bef5e085aba67281d774776f1bc083294180d6b0000000001000000

Any help with what could be going on or what to try would be much appreciated!

0

I found the problem, in the bip143 tx digest preimage, the scriptCode needs to be preceded by the length of the scriptCode. In this case 0x47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.