Skip to content

Propagate errors correctly when decoding and parsing PSBTs - #363

Open
emma31-dev wants to merge 1 commit into
bitcoindevkit:masterfrom
emma31-dev:fix/357-psbt-decode-errors
Open

emma31-dev wants to merge 1 commit into
bitcoindevkit:masterfrom
emma31-dev:fix/357-psbt-decode-errors

Conversation

@emma31-dev

@emma31-dev emma31-dev commented Oct 20, 2026 •

Copy link
Copy Markdown

Description

Propagate PSBT decoding and parsing errors instead of wrapping them in Error::Generic.

  • BASE64_STANDARD.decode() failures in sign, finalize_psbt, and broadcast now propagate directly via ?
  • Psbt::deserialize() failures are no longer swallowed into a generic string message
  • BlockchainClient::broadcast() maps backend errors to dedicated typed variants (Error::Electrum, Error::Esplora, Error::BitcoinCoreRpcError)
  • wallet.apply_update() / apply_update_events() map to Error::Chain instead of Error::Generic
  • Integration tests added for sign, finalize_psbt, and broadcast error paths

Fixes #357 . Related to the broader error-propagation cleanup across the codebase.

Notes to the reviewers

Uses the existing From conversions for DecodeError and PsbtError.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

  • I'm linking the issue being fixed by this PR

@tvpeter tvpeter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This a low impact PR. The only thing it did is change the error type from "Generic error" to "Basse64 decoding error". Maybe you should extend it to cover finalize_psbt and broadcast, because they also return the "Generic" error type. Also, you can add a test that they return the specific error.

Thank you

@tvpeter tvpeter added the chore Non-coding related work label Nov 2, 2026
@tvpeter tvpeter added this to the CLI 4.1.0 milestone Nov 2, 2026
@emma31-dev

Copy link
Copy Markdown
Author

@tvpeter I've extended it past just sign.

@muawiya1

muawiya1 commented Nov 4, 2026

Copy link
Copy Markdown

While reviewing this PR, I added five tests to help cover the specific errors mentioned in the review, the tests check that sign and finalize_psbt return the expected errors for invalid base64 and invalid psbt data, they also check the base64 decoding error for broadcast --psbt.

All the 13 tests in the offline test module passed successfully locally including the new five added tests.

This is my test commit: 1d00acd @emma31-dev, you can check and cherry-pick it if it’s useful.

@tvpeter, I also want to check if this covers what you have in mind, I’m happy to adjust if needed.

@emma31-dev

Copy link
Copy Markdown
Author

@muawiya1 Thanks. send a pr to this branch or if its too stressful to you i'll copy it out

emma31-dev pushed a commit to emma31-dev/bitcoin-bdk-cli that referenced this pull request Nov 5, 2026
Check specific Base64 and PSBT parsing errors for sign and
finalize_psbt, and Base64 decoding errors for broadcast.

Related to bitcoindevkit#363.
- Decode Base64 and parse PSBTs without wrapping the error in `Error::Generic`
- Use the dedicated `Electrum`, `Esplora`, `BitcoinCoreRpcError` and `Chain`
  error variants in `BlockchainClient`
- Cover sign, finalize_psbt and broadcast error paths with integration tests

Related to bitcoindevkit#363.
@emma31-dev
emma31-dev force-pushed the fix/357-psbt-decode-errors branch from 2ee52fb to d8176e8 Compare November 7, 2026 16:17

@tvpeter tvpeter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK d8176e8

Please update the PR description to capture the changes.

Thank you.

@emma31-dev

Copy link
Copy Markdown
Author

@tvpeter I have updated the PR description. Thank you.

@tvpeter

tvpeter commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@tvpeter I have updated the PR description. Thank you.

Ensure all the CI jobs are passing

@vadim-anfv

Copy link
Copy Markdown
Collaborator

@tvpeter I have updated the PR description. Thank you.

Ensure all the CI jobs are passing

It seems something wrong with CI, my pr template edit also fails on CI - https://github.com/bitcoindevkit/bdk-cli/pull/386/checks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Non-coding related work

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

wallet sign command returns generic error for decoding failures

4 participants