AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 66 Bitcoin

tx: Fix BIP118 ANYPREVOUTANYSCRIPT sighash

Public commit record

What the developer wrote

Authored by Greg Sanders

68/100 · Adequate
tx: Fix BIP118 ANYPREVOUTANYSCRIPT sighash

In the current code anytime sh_anyprevout_anyscript is true,
sh_anyonecanpay will also be true. Therefore it will fall
through and hash the prevout erroneously. Fix this by
checking for APOAS first.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a bug in how a special Bitcoin/Elements signature hash flag (BIP118 ANYPREVOUTANYSCRIPT) is processed. Because of the order of checks, the code was accidentally treating ANYPREVOUTANYSCRIPT as if it also needed to include the previous transaction output in the hash, which it should not. This could cause signatures created or verified with this flag to be incorrect, potentially leading to invalid transactions or, in the worst case, a signature that could be reused in unexpected ways.

Recommended action

Review any signatures or transactions generated with BIP118 ANYPREVOUTANYSCRIPT using the unfixed code; they may be invalid or non-standard. Update to the patched version and add test vectors covering APOAS sighash to prevent regression.

Security signals we found

01

Incorrect cryptographic hash construction for BIP118 ANYPREVOUTANYSCRIPT sighash

02

Flag implication bug: APOAS implies ANYONECANPAY, causing fall-through to wrong branch

03

Potential signature malleability or replay risk due to extra prevout data being hashed

04

Fix is small and targeted: reorder conditional checks

Risk score

Why this scored 66/100

Our methodology →
Potential impact 22/30
Exploitability 12/25
Stealth signal 10/15
Affected reach 10/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.