Home Bitcoin sighash – Attempting to make SIGHASH_SINGLE transaction

sighash – Attempting to make SIGHASH_SINGLE transaction

sighash – Attempting to make SIGHASH_SINGLE transaction


I’m making an attempt to make a SIGHASH_SINGLE transaction.

I’ve two inputs, one output. I perceive that second enter could be not signed (actually?).

Script I’ve is:

#!/usr/bin/env python3

import hashlib
import subprocess
from bitcoin import SelectParams
from bitcoin.core import b2x, lx, COIN, COutPoint, CMutableTxOut, CMutableTxIn, CMutableTransaction, Hash160
from bitcoin.core.script import CScript, OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG, SignatureHash, SIGHASH_ALL, SIGHASH_SINGLE
from bitcoin.core.scripteval import VerifyScript, SCRIPT_VERIFY_P2SH
from bitcoin.pockets import CBitcoinAddress, CBitcoinSecret

h = b'personal key bytes in python hex format'
seckey = CBitcoinSecret.from_secret_bytes(h)
txid = lx('tx number one')
vout = 0
txid2 = lx('tx quantity 2')
vout2 = 1
txin = CMutableTxIn(COutPoint(txid, vout))
txin2 = CMutableTxIn(COutPoint(txid2, vout2))
txin_scriptPubKey = CScript([OP_DUP, OP_HASH160, Hash160(seckey.pub), OP_EQUALVERIFY, OP_CHECKSIG])
txout = CMutableTxOut(10000, CBitcoinAddress('output deal with').to_scriptPubKey())
tx = CMutableTransaction([txin]+[txin2], [txout])
sighash = SignatureHash(txin_scriptPubKey, tx, 0, SIGHASH_SINGLE)
sig = seckey.signal(sighash) + bytes([SIGHASH_SINGLE])
txin.scriptSig = CScript([sig, seckey.pub])
VerifyScript(txin.scriptSig, txin_scriptPubKey, tx, 0, (SCRIPT_VERIFY_P2SH,))
r=subprocess.run(["/mnt/c/Program Files/Bitcoin/daemon/bitcoin-cli.exe", "sendrawtransaction", b2x(tx.serialize())])

I get error:

error code: -25
error message:

Each inputs have steadiness, I’m positive of that. Script is run from WSL1 Bash on Home windows.

What am I lacking right here?



Please enter your comment!
Please enter your name here