Using Blockstream's api to broadcast a raw transaction to the Bitcoin testnet, I encountered the following error:
sendrawtransaction RPC error: {"code":-26,"message":"non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)"}
I've noticed that many people have ran into a similar issue before. However, all of the proposed solutions didn't fix my issue. I've looked at the Bitcoin source code on Github and determined that the data I am committing to my hash for signing is incorrect.
Below is the hash pre-image that I'm creating for bip143 p2sh(p2wpkh)
.
nVersion: 01000000
hashPrevouts: 4f3c0f6726ec7f020da2a01598d1741225ea429a34bfdd4c4af2a1c9e45a9bed
hashSequence: 3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044
outpoint: b9d615615976600739be12a67f326836e4256d7d1c4fe50163536ad8dd7647c301000000
scriptCode: 1976a91499f27cf1ecb8c1a4c20bdbcdc7992cdb12c9ee5d88ac
amount: 6981680000000000
nSequence: ffffffff
hashOutputs: 57dbf9cb180c89fe35000b693ea089e521097e6d3f504cfec1620325fcec0036
nLockTime: 00000000
nHashType: 01000000