bitcoindevkit / bitcoindevkit/bdk_wallet
`create_tx` panics when chain tip height is not a valid locktime height
- Dominant language
- Rust
- Stars
- 59
- Forks
- 105
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 1
Description
**Describe the bug**
When `TxBuilder::current_height` is not set, `Wallet::create_tx` converts the chain tip height into an `absolute::LockTime` with `.expect("invalid height")` (`src/wallet/mod.rs`, around the `current_height` match). `absolute::LockTime::from_height` fails for heights >= 500,000,000, so a chain tip with such a height makes transaction building panic instead of returning an error.
The tip comes from whatever chain source the wallet is synced against, so a malformed or misbehaving source can trigger the panic.
This issue was found by AI.
**To Reproduce**
1. Apply a `CheckPoint` with height `500_000_000` (or higher) to the wallet via `apply_update`.
2. Call `wallet.build_tx()` with a recipient and `finish()` without setting `current_height`.
3. Observe the panic `invalid height`.
**Expected behavior**
`create_tx` should not panic on an out-of-range tip height; returning an error (or otherwise handling the case) is preferable.
**Build environment**
- BDK tag/commit: `6fc68462` (master)
**Which backend(s) are relevant (if any)?**
- [x] None / not backend-related (e.g. `bdk_chain`, `bdk_core`)
**Is this blocking production use?**
- [x] No
Contributor guide
Research direction
Start in src/wallet/mod.rs around the current_height match and the invalid-height expect described in the issue. Reproduce the case by applying a CheckPoint at height 500,000,000 or higher, then call build_tx and finish without setting current_height. Done means transaction building returns an error or otherwise avoids panicking, with a regression test covering the out-of-range tip.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100