Skip to content

Add index and sighash check when control block given - #53

Open
stringhandler wants to merge 2 commits into
BlockstreamResearch:masterfrom
stringhandler:fix-sighash-input-index
Open

stringhandler wants to merge 2 commits into
BlockstreamResearch:masterfrom
stringhandler:fix-sighash-input-index

Conversation

@stringhandler

@stringhandler stringhandler commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Add two extra checks, specifically picked up by AI scans. These are likely low priority, but I'm fixing them here so that they don't show up again.

They are both related to a control block being passed in. One checks for input indexes, that was skipped before hand and the other checks that the control block matches what is being signed.

@stringhandler stringhandler changed the title Add index check when control block given Add index and sighash check when control block given Oct 20, 2026
};
let input_idx: u32 = input_idx.parse().map_err(SimplicitySighashError::InputIndexParsing)?;
// Checked here because the PSET input lookup below is skipped when a control block is given.
if input_idx as usize >= tx.input.len() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 6627744:

This loses the "probably fine" comment on the cast. But we should probably just get rid of the cast and use try_from to convert the u32 to usize. If the try_from fails we can return InputIndexOutOfRange.

Also, rather than doing an explicit check like this then having a panicking [] below, we should just use get here even though the actual input is unused when a control block is given.

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.

2 participants