Skip to content

Propagate errors correctly when decoding and parsing PSBTs - #363

Merged
vadim-anfv merged 1 commit into
bitcoindevkit:masterfrom
emma31-dev:fix/357-psbt-decode-errors
Nov 16, 2026
Merged

vadim-anfv merged 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
Contributor

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
Contributor 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
Contributor 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
Contributor 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

@emma31-dev

Copy link
Copy Markdown
Contributor Author

@tvpeter The CI failure appears to be a transient network issue with the GitHub Actions runner, not related to the changes in this PR:

Err:2 https://security.ubuntu.com/ubuntu noble InRelease
  Temporary failure resolving 'azure.archive.ubuntu.com'

Evidence this is not from my changes:

  • This PR only modifies error handling in src/client.rs, src/handlers/offline.rs, src/handlers/online.rs, and adds tests to tests/integration/offline.rs
  • No CI configuration files or system dependencies were changed
  • The failure occurs during apt-get install when trying to fetch packages from Ubuntu's mirrors, before any code is built or tested
  • The error message "Temporary failure resolving 'azure.archive.ubuntu.com'" indicates a DNS/network connectivity issue on the runner

I recommend we re-run the failed jobs. This should resolve the issue once the runner has proper network connectivity.

If this becomes a recurring issue, the CI could be made more resilient by adding retry logic to the apt-get commands in .github/workflows/cont_integration.yml

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.15385% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.63%. Comparing base (6858e21) to head (e2811c0).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
src/client.rs 25.00% 6 Missing ⚠️
src/handlers/online.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #363      +/-   ##
==========================================
- Coverage   59.97%   59.63%   -0.34%     
==========================================
  Files          25       25              
  Lines        4734     4544     -190     
==========================================
- Hits         2839     2710     -129     
+ Misses       1895     1834      -61     
Flag Coverage Δ
rust 59.63% <46.15%> (-0.34%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@vadim-anfv vadim-anfv 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 drop the empty chore: rerun CI commit, and keep this commit's hash unchanged so the ACKs stay valid.

@emma31-dev
emma31-dev force-pushed the fix/357-psbt-decode-errors branch from e2811c0 to d8176e8 Compare November 16, 2026 12:26
@emma31-dev

Copy link
Copy Markdown
Contributor Author

@vadim-anfv I have returned to d8176e8 . I just needed a way to rerun ci jobs . Thank you.

@vadim-anfv
vadim-anfv merged commit 2fceeba into bitcoindevkit:master Nov 16, 2026
9 of 18 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in BDK-CLI Nov 16, 2026
emma31-dev added a commit to emma31-dev/bitcoin-bdk-cli that referenced this pull request Nov 19, 2026
- 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.
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: Done

Development

Successfully merging this pull request may close these issues.

wallet sign command returns generic error for decoding failures

4 participants