Skip to content

fix(signer): respect allow_all_sighashes in SignerWrapper::sign_input#476

Merged
ValuedMammal merged 1 commit into
bitcoindevkit:masterfrom
muhahahmad68:fix/fix/sign-input-allow-all-sighashes
May 26, 2026
Merged

fix(signer): respect allow_all_sighashes in SignerWrapper::sign_input#476
ValuedMammal merged 1 commit into
bitcoindevkit:masterfrom
muhahahmad68:fix/fix/sign-input-allow-all-sighashes

Conversation

@muhahahmad68
Copy link
Copy Markdown
Contributor

@muhahahmad68 muhahahmad68 commented May 3, 2026

Description

SignOptions::allow_all_sighashes is documented as controlling whether the signer will accept non-SIGHASH_ALL sighash types. However, the check only existed inside Wallet::sign as a PSBT-wide pre-flight guard. The underlying SignerWrapper<PrivateKey>::sign_input never consulted it, meaning callers using InputSigner or TransactionSigner directly could bypass the check entirely.

Added a sighash guard in SignerWrapper<PrivateKey>::sign_input before the match self.ctx dispatch. This ensures the check covers all signing contexts (Legacy, Segwitv0, Taproot) and all delegating implementations in a single place.

Tests Added

  • Taproot input with SIGHASH_NONE and allow_all_sighashes: false returns NonStandardSighash
  • Same setup with allow_all_sighashes: true passes the guard successfully

Fixes #469

Checklists

All Submissions:

New Features:

  • N/A

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.33%. Comparing base (a9ad3b9) to head (9e45c56).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/wallet/signer.rs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #476      +/-   ##
==========================================
+ Coverage   80.05%   80.33%   +0.27%     
==========================================
  Files          24       24              
  Lines        5360     5430      +70     
  Branches      244      248       +4     
==========================================
+ Hits         4291     4362      +71     
  Misses        990      990              
+ Partials       79       78       -1     
Flag Coverage Δ
rust 80.33% <92.30%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ValuedMammal ValuedMammal moved this to Needs Review in BDK Wallet May 4, 2026
@ValuedMammal ValuedMammal added bug Something isn't working audit Suggested as result of external code audit labels May 4, 2026
@ValuedMammal ValuedMammal added this to the Wallet 3.1.0 milestone May 4, 2026
@muhahahmad68 muhahahmad68 force-pushed the fix/fix/sign-input-allow-all-sighashes branch from a187c70 to 3f07adc Compare May 4, 2026 21:22
Comment thread src/wallet/signer.rs Outdated
Comment thread src/wallet/signer.rs Outdated
@muhahahmad68
Copy link
Copy Markdown
Contributor Author

Makes more sense, I'll effect the changes as suggested. Much thanks @benthecarman

@muhahahmad68 muhahahmad68 force-pushed the fix/fix/sign-input-allow-all-sighashes branch from 3f07adc to 8c6d411 Compare May 5, 2026 13:32
Copy link
Copy Markdown
Collaborator

@aagbotemi aagbotemi left a comment

Choose a reason for hiding this comment

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

Well done working on this @muhahahmad68. I left some reviews for you.

Comment thread src/wallet/signer.rs
Comment thread src/wallet/signer.rs Outdated
@muhahahmad68 muhahahmad68 force-pushed the fix/fix/sign-input-allow-all-sighashes branch 2 times, most recently from 766b080 to e05ea0f Compare May 7, 2026 19:26
Comment thread src/wallet/signer.rs Outdated
@muhahahmad68 muhahahmad68 force-pushed the fix/fix/sign-input-allow-all-sighashes branch from e05ea0f to 9e45c56 Compare May 8, 2026 22:43
Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

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

ACK 9e45c56; ran the tests locally

@ValuedMammal ValuedMammal merged commit 39de6ed into bitcoindevkit:master May 26, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in BDK Wallet May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit Suggested as result of external code audit bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

sign_input should respect allow_all_sighashes sign option

4 participants