I have a very similar problem of my last post before post again, I tried a lot of time but whitout success. I studied this link but I don't find solution.
I have 50 bitcoins (total Amount) and I want to move 49.999991
It's my compressed public key 02c142cea1c25689d233b35c0021c47194ebc99cbc6154f7de66f2c078c1e773f3
And It's my transaction data
{
"txid": "b4a786ec1a4263cec671aca7865ec71058230596e134c5b6bdf82d7cdc324ab6",
"hash": "b4a786ec1a4263cec671aca7865ec71058230596e134c5b6bdf82d7cdc324ab6",
"version": 2,
"size": 83,
"vsize": 83,
"weight": 332,
"locktime": 0,
"vin": [
{
"txid": "414731e9d65e29e8830052333b316e9d882a6e93e068c4b63130a69ec67afba2",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967295
}
],
"vout": [
{
"value": 49.99999100,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 a37ff6b27599b48c2e0f30fc2e4255d0d81865fb OP_EQUAL",
"hex": "a914a37ff6b27599b48c2e0f30fc2e4255d0d81865fb87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"2N89jRd76YdyNA7Ztw1hQJ3ofLRUHqskiZ2"
]
}
}
]
}
0200000001a2fb7ac69ea63031b6c468e0936e2a889d6e313b33520083e8295ed6e93147410000000000ffffffff017cee052a0100000017a914a37ff6b27599b48c2e0f30fc2e4255d0d81865fb8700000000
The new transaction digest:
TX_VERSION: 02000000
SEQUENCE: ffffffff
OUTPOINT UTXO: a2fb7ac69ea63031b6c468e0936e2a889d6e313b33520083e8295ed6e931474100000000
HASH_PREV_OUT: 4ba3331b8f45c53aabdf26d43ff3ac93c839825cf400eddb935bf47685bc9412
(HASH_PREV_OUT is SHA256 twice of $OUTPOINT)
HASH_SEQUENCE: 3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044
(HASH_SEQUENCE is SHA256 twice of $SEQUENCE)
SCRIPTCODE: 1976a914555dbe4f4b6c5c8919df01dd15c2490b34383b83ac
(SCRIPTCODE is P2PKH script: OP_DUP OP_HASH160 <Public KeyHash> OP_EQUAL OP_CHECKSIG
AMOUNT: 7CEE052A01000000
(49.99999100000000000000)
OUTPUT: 17a914a37ff6b27599b48c2e0f30fc2e4255d0d81865fb87
OUTPUT_HASH: d7515382a6eed4652620ceb623aff05eb2f872e9185220ab2e456eebf2383197
(OUTPUT_HASH is SHA256 twice of $AMOUNT$OUTPUT)
LOCKTIME_PART: 00000000
SIGHASH: 01000000
Then "merge" all values and sign it.
where SIG_AMOUNT is 00F2052A01000000
(50 bitcoins)
$ WITNESS_V0_DIGEST=$TX_VERSION$HASH_PREV_OUT$HASH_SEQUENCE$OUTPOINT$SCRIPTCODE$SIG_AMOUNT$SEQUENCE$OUTPUT_HASH$LOCKTIME_PART$SIGHASH
echo $WITNESS_V0_DIGEST
020000004ba3331b8f45c53aabdf26d43ff3ac93c839825cf400eddb935bf47685bc94123bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044a2fb7ac69ea63031b6c468e0936e2a889d6e313b33520083e8295ed6e9314741000000001976a914555dbe4f4b6c5c8919df01dd15c2490b34383b83ac00F2052A01000000ffffffffd7515382a6eed4652620ceb623aff05eb2f872e9185220ab2e456eebf23831970000000001000000
The sign it, ad put the signature, the public key, the redeem script inside my transaction. My Signed transaction is:
02000000000101a2fb7ac69ea63031b6c468e0936e2a889d6e313b33520083e8295ed6e93147410000000017160014555dbe4f4b6c5c8919df01dd15c2490b34383b83ffffffff017cee052a0100000017a914a37ff6b27599b48c2e0f30fc2e4255d0d81865fb870247304402207f49b94bf1b7251dbb56b56c32f1183cfbdf1ed379b4c118d29430f355d6b05a02201800c4c05c6ba969e7d971f52a5b52aa096d9f392122b53129c11727851c983a012102c142cea1c25689d233b35c0021c47194ebc99cbc6154f7de66f2c078c1e773f300000000
{
"txid": "ea46711ec5e4896632c6d2b1dead1ccf954d4576d2f2c23b1790813116e7ca6d",
"hash": "50135ee943a252816b41f7f1b25f7ec95d178178427c2b5cc6a3c2a1041f71fe",
"version": 2,
"size": 215,
"vsize": 134,
"weight": 533,
"locktime": 0,
"vin": [
{
"txid": "414731e9d65e29e8830052333b316e9d882a6e93e068c4b63130a69ec67afba2",
"vout": 0,
"scriptSig": {
"asm": "0014555dbe4f4b6c5c8919df01dd15c2490b34383b83",
"hex": "160014555dbe4f4b6c5c8919df01dd15c2490b34383b83"
},
"txinwitness": [
"304402207f49b94bf1b7251dbb56b56c32f1183cfbdf1ed379b4c118d29430f355d6b05a02201800c4c05c6ba969e7d971f52a5b52aa096d9f392122b53129c11727851c983a01",
"02c142cea1c25689d233b35c0021c47194ebc99cbc6154f7de66f2c078c1e773f3"
],
"sequence": 4294967295
}
],
"vout": [
{
"value": 49.999991,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 a37ff6b27599b48c2e0f30fc2e4255d0d81865fb OP_EQUAL",
"hex": "a914a37ff6b27599b48c2e0f30fc2e4255d0d81865fb87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"2N89jRd76YdyNA7Ztw1hQJ3ofLRUHqskiZ2"
]
}
}
]
}
it's seem well format but when send it, I receive that error
error code: -26
error message:
non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64)
Im sorry to open a very similar post, but i slightly different. Another question is: If I obtain the well format transaction (I can do decoderawtransaction without problem) it means that the problem is the signature?