bitcoindevkit / bitcoindevkit/bdk_wallet

Add tests for `MissingNonWitnessUtxo` / `InvalidNonWitnessUtxo` signing errors

Open Beginner friendly
#552 0 comments 0 reactions 0 assignees View on GitHub
tests
Dominant language
Rust
Stars
59
Forks
105
Avg merge
10d 9h
Merged PRs (30d)
1

Description

**Describe the enhancement**

`Wallet::sign_with_signers` returns `SignerError::MissingNonWitnessUtxo` when a non-taproot input lacks `non_witness_utxo` and `SignOptions::trust_witness_utxo` is `false` (`src/wallet/mod.rs`, signing loop), and `SignerError::InvalidNonWitnessUtxo` when the provided one does not match the outpoint. Neither branch is covered by tests: nothing in `tests/` or the unit tests signs a segwit v0 PSBT without `non_witness_utxo` under default options, or with a mismatching `non_witness_utxo`.

Since this check is what protects users from signing with a wrong input amount, regressions there would currently go unnoticed.

This issue was found by AI.

Suggested coverage:
- Segwit v0 PSBT with `non_witness_utxo = None`, default `SignOptions` → `MissingNonWitnessUtxo`.
- Same PSBT with `trust_witness_utxo: true` → signs.
- `non_witness_utxo` whose txid does not match the outpoint → `InvalidNonWitnessUtxo`.

**Use case**

Regression protection for the signing path.

**Impact**
- [x] Developer experience / maintainability

**Which backend(s) are relevant (if any)?**
- [x] None / not backend-related (e.g. `bdk_chain`, `bdk_core`)

Contributor guide

Open the contributing guide

Research direction

Start with the signing loop in src/wallet/mod.rs, then inspect existing signing tests in tests/ and the unit tests for PSBT setup patterns. Add coverage for missing and mismatching non_witness_utxo values, including the trust_witness_utxo case, and run the relevant wallet test suite to confirm the expected errors and successful signing.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.