`create_tx` panics when chain tip height is not a valid locktime height

Open Beginner friendly
#550 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

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.

Description

bug

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)?

  • None / not backend-related (e.g. bdk_chain, bdk_core)

Is this blocking production use?

  • No
Dominant language
Rust
Stars
59
Forks
109
Avg merge
3d 13h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bitcoindevkit/bdk_wallet

All issues in bitcoindevkit/bdk_wallet

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.