Skip to content

fix(index): correct P2PKH script byte index [22]->[23] in address ind…#239

Merged
cdonnachie merged 1 commit into5.xfrom
fix/addressindex-p2pkh-script-check
Apr 7, 2026
Merged

fix(index): correct P2PKH script byte index [22]->[23] in address ind…#239
cdonnachie merged 1 commit into5.xfrom
fix/addressindex-p2pkh-script-check

Conversation

@cdonnachie
Copy link
Copy Markdown
Member

The P2PKH script pattern check used script[22] == OP_EQUALVERIFY, but byte [22] is the last byte of the 20-byte hash160 payload. OP_EQUALVERIFY is at byte [23]. This caused ~99.6% of all P2PKH outputs to be silently skipped when building the address index in ConnectBlock, DisconnectBlock, and the mempool address index.

Also fix getaddressutxos and getaddressdeltas RPC defaults from AVN-only to '*' (all assets) so P2PKH-only addresses return results correctly.

Affected sites:

  • src/validation.cpp: DisconnectBlock outputs/inputs, ConnectBlock inputs/outputs (4 sites)
  • src/txmempool.cpp: addAddressIndex inputs/outputs, addSpentIndex (3 sites)
  • src/rpc/indexes.cpp: getaddressutxos, getaddressdeltas default assetName

…exing

The P2PKH script pattern check used script[22] == OP_EQUALVERIFY, but
byte [22] is the last byte of the 20-byte hash160 payload. OP_EQUALVERIFY
is at byte [23]. This caused ~99.6% of all P2PKH outputs to be silently
skipped when building the address index in ConnectBlock, DisconnectBlock,
and the mempool address index.

Also fix getaddressutxos and getaddressdeltas RPC defaults from AVN-only
to '*' (all assets) so P2PKH-only addresses return results correctly.

Affected sites:
- src/validation.cpp: DisconnectBlock outputs/inputs, ConnectBlock inputs/outputs (4 sites)
- src/txmempool.cpp: addAddressIndex inputs/outputs, addSpentIndex (3 sites)
- src/rpc/indexes.cpp: getaddressutxos, getaddressdeltas default assetName
@cdonnachie cdonnachie merged commit ee1f18a into 5.x Apr 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant