mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
contrib: fix signet miner (sighash mismatch)
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, hence this leads to a sighash mismatch when the
`walletprocesspsbt` RPC is called. Fix this by explicitly passing the
correct sighash type.
Note that the same change was needed in one of our functional tests,
see commit d3992669df.
Reported by gruve-p.
This commit is contained in:
@@ -8,7 +8,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import os.path
|
import os
|
||||||
import re
|
import re
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
@@ -493,10 +493,11 @@ def do_generate(args):
|
|||||||
logging.debug("Mining block delta=%s start=%s mine=%s", seconds_to_hms(mine_time-bestheader["time"]), mine_time, is_mine)
|
logging.debug("Mining block delta=%s start=%s mine=%s", seconds_to_hms(mine_time-bestheader["time"]), mine_time, is_mine)
|
||||||
mined_blocks += 1
|
mined_blocks += 1
|
||||||
psbt = generate_psbt(tmpl, reward_spk, blocktime=mine_time)
|
psbt = generate_psbt(tmpl, reward_spk, blocktime=mine_time)
|
||||||
psbt_signed = json.loads(args.bcli("-stdin", "walletprocesspsbt", input=psbt.encode('utf8')))
|
input_stream = os.linesep.join([psbt, "true", "ALL"]).encode('utf8')
|
||||||
|
psbt_signed = json.loads(args.bcli("-stdin", "walletprocesspsbt", input=input_stream))
|
||||||
if not psbt_signed.get("complete",False):
|
if not psbt_signed.get("complete",False):
|
||||||
logging.debug("Generated PSBT: %s" % (psbt,))
|
logging.debug("Generated PSBT: %s" % (psbt,))
|
||||||
sys.stderr.write("PSBT signing failed")
|
sys.stderr.write("PSBT signing failed\n")
|
||||||
return 1
|
return 1
|
||||||
block, signet_solution = do_decode_psbt(psbt_signed["psbt"])
|
block, signet_solution = do_decode_psbt(psbt_signed["psbt"])
|
||||||
block = finish_block(block, signet_solution, args.grind_cmd)
|
block = finish_block(block, signet_solution, args.grind_cmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user