contrib: Fix NameError in signet miner gbt()
What changed, and why it matters
This is a small bug fix in a helper signet mining script. The script would crash with a NameError when it tried to log a warning about an unexpected previous block, because it referenced a variable that only existed in the calling function. The fix uses the correct variable that was already passed into the method. It is a straightforward coding mistake with no security exploit.
No security action required. Treat as a normal bug fix; merge if the project workflow requires it.
Security signals we found
No security-relevant signals present
Fixes a runtime exception (NameError) in a non-consensus utility script
No input validation, privilege escalation, or cryptographic issues
Evidence from the diff
In contrib/signet/miner, the Generate.gbt() method logged a warning using bci[“bestblockhash”], but bci is not in scope inside gbt(). The correct local parameter bestblockhash was already available and used in the preceding comparison. The patch replaces the dangling reference, preventing a NameError when getblocktemplate returns a template whose previousblockhash differs from the expected best block hash.
Changed components
contrib/signet/minerGenerate.gbt() methodInspect captured patch +1 / −1
diff --git a/contrib/signet/miner b/contrib/signet/miner
index f46d88b5..a7548841 100755
--- a/contrib/signet/miner
+++ b/contrib/signet/miner
@@ -333,7 +333,7 @@ class Generate:
def gbt(self, bcli, bestblockhash, now):
tmpl = json.loads(bcli("getblocktemplate", '{"rules":["signet","segwit"]}'))
if tmpl["previousblockhash"] != bestblockhash:
- logging.warning("GBT based off unexpected block (%s not %s), retrying", tmpl["previousblockhash"], bci["bestblockhash"])
+ logging.warning("GBT based off unexpected block (%s not %s), retrying", tmpl["previousblockhash"], bestblockhash)
time.sleep(1)
return None
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.