Skip to content

Commit 74f8c55

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24553: contrib: fix signet miner (sighash mismatch)
12cc020 contrib: fix signet miner (sighash mismatch) (Sebastian Falbesoner) Pull request description: gruve-p reported that the signet miner doesn't work anymore (see bitcoin/bitcoin#24501 (comment)), failing with the following error of the `walletprocesspsbt` RPC: ``` error code: -22 error message: Specified sighash value does not match value stored in PSBT ..... subprocess.CalledProcessError: Command '['bitcoin-cli', '-signet', '-stdin', 'walletprocesspsbt']' returned non-zero exit status 22 ``` PSBT signing was changed to use SIGHASH_DEFAULT by default in #22514. The signet miner script sets the sighash type of the created PSBT to SIGHASH_ALL (3 is the per-input type PSBT_IN_SIGHASH_TYPE, following a little-endian 32 unsigned integer of the sighash type): https://github.com/bitcoin/bitcoin/blob/e04720ec3336e3df7fce522e3b1da972aa65ff62/contrib/signet/miner#L169-L170 hence this leads to a sighash mismatch when the `walletprocesspsbt` RPC is called. Fix this by explicitly passing the correct sighash type. The same change was needed in one of our functional tests, see commit d399266. Note that instead of feeding the PSBT via `-stdin` it is directly passed as parameter, as I couldn't figure out a way to pass multiple parameters otherwise (separating by newline also didn't work). ACKs for top commit: kallewoof: ACK 12cc020 ajtowns: ACK 12cc020 ; code review only Tree-SHA512: 8509e768e96f85e28c0ca0dc2d35874aa29623febddc46bf90472ec38f38cb3a1b5407c563fd9101d07088775d0fdb18e9137cc38955e847885b83c16591c736
2 parents d6cb4e8 + 12cc020 commit 74f8c55

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

contrib/signet/miner

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import base64
88
import json
99
import logging
1010
import math
11-
import os.path
11+
import os
1212
import re
1313
import struct
1414
import sys
@@ -493,10 +493,11 @@ def do_generate(args):
493493
logging.debug("Mining block delta=%s start=%s mine=%s", seconds_to_hms(mine_time-bestheader["time"]), mine_time, is_mine)
494494
mined_blocks += 1
495495
psbt = generate_psbt(tmpl, reward_spk, blocktime=mine_time)
496-
psbt_signed = json.loads(args.bcli("-stdin", "walletprocesspsbt", input=psbt.encode('utf8')))
496+
input_stream = os.linesep.join([psbt, "true", "ALL"]).encode('utf8')
497+
psbt_signed = json.loads(args.bcli("-stdin", "walletprocesspsbt", input=input_stream))
497498
if not psbt_signed.get("complete",False):
498499
logging.debug("Generated PSBT: %s" % (psbt,))
499-
sys.stderr.write("PSBT signing failed")
500+
sys.stderr.write("PSBT signing failed\n")
500501
return 1
501502
block, signet_solution = do_decode_psbt(psbt_signed["psbt"])
502503
block = finish_block(block, signet_solution, args.grind_cmd)

0 commit comments

Comments
 (0)