Skip to content

Test MTP improvements#38

Open
evanlinjin wants to merge 7 commits intobitcoindevkit:masterfrom
evanlinjin:option-mtp-testing
Open

Test MTP improvements#38
evanlinjin wants to merge 7 commits intobitcoindevkit:masterfrom
evanlinjin:option-mtp-testing

Conversation

@evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Jan 31, 2026

Description

This PR provides the testing infrastructure and integration tests for #36 (MTP locktime fixes). The tests require unreleased upstream changes, so they're separated from the core fix.

Changes

Dependency Updates

  • Bump miniscript from 12.3.5 to 13.0.0
  • Remove Signer wrapper type (KeyMap now implements GetKey directly)
  • Adapt to bdk_chain CanonicalView API and CheckPoint<Header> generics
  • Update Emitter for new mempool API (update/evicted fields)
  • Patch dependencies to use unreleased branches with MTP support

Test Infrastructure

  • Convert repo to Cargo workspace with new bdk_tx_testenv crate under testenv/
  • Move Wallet struct into bdk_tx_testenv so they can be used in both examples and tests
  • Add all_candidates_with(&Assets) method for custom asset parameters

Integration Tests

Add 4 time-based timelock tests that verify BDK predictions match Bitcoin Core's actual broadcast acceptance at exact boundaries:

  • test_absolute_time_timelock_logic
  • test_relative_time_timelock_logic
  • test_is_time_timelocked_absolute_unit
  • test_is_time_timelocked_relative_unit

CI

  • Remove no-std feature flag for miniscript (no longer exists in 13.0.0)

Notes

@evanlinjin evanlinjin force-pushed the option-mtp-testing branch 7 times, most recently from 287f17c to c1f703e Compare February 3, 2026 16:02
@evanlinjin evanlinjin force-pushed the option-mtp-testing branch 3 times, most recently from c33e0dc to 169364b Compare February 4, 2026 12:46
@evanlinjin evanlinjin changed the title Testing MTP improvements Test MTP improvements Feb 4, 2026
@evanlinjin evanlinjin marked this pull request as ready for review February 4, 2026 12:51
evanlinjin and others added 5 commits February 6, 2026 08:01
Correctly calculate spendability of coins that are timelocked by taking
MTP into account.

API changes are a result of the different requirements between relative
and absolute locktimes.
- Bump miniscript dependency from 12.3.5 to 13.0.0
- Remove `Signer` wrapper type (KeyMap now implements GetKey)
- Adapt to bdk_chain CanonicalView API and CheckPoint<Header> generics
- Update Emitter usage for new mempool API (update/evicted fields)
- Use prev_mtp from CheckPoint for ConfirmationStatus
- Point [patch.crates-io] to feature/bitcoind_rpc_emit_header branch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Convert repo to a Cargo workspace with a new unpublished
  bdk_tx_testenv crate under testenv/
- Merge the duplicated Wallet (examples/common.rs) and TestWallet
  (tests/timelock.rs) into a single Wallet struct with signer and secp
  fields always present
- Deduplicate old_rpc_client() helper (was copied in 4 files)
- Add all_candidates_with(&Assets) method for custom asset parameters
- Reduce examples/common.rs to a thin re-export shim

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The `no-std` feature flag no longer exists for miniscript 13.0.0
Add 4 new time-based timelock tests that verify BDK's predictions match
Bitcoin Core's actual broadcast acceptance at exact boundaries:
- test_absolute_time_timelock_logic (integration)
- test_relative_time_timelock_logic (integration)
- test_is_time_timelocked_absolute_unit
- test_is_time_timelocked_relative_unit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
evanlinjin and others added 2 commits February 6, 2026 08:39
Add comprehensive unit tests covering edge cases for is_block_timelocked,
is_time_timelocked, and is_timelocked methods:

- Unconfirmed inputs with relative timelocks (must be considered locked)
- Missing prev_mtp for relative time locks (returns None)
- No-lock and wrong-lock-type scenarios (return false/Some(false))
- Combined is_timelocked method with various lock combinations

These tests cover the bug cases identified in PR bitcoindevkit#36 review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add `create_test_input` helper for unit tests and `Wallet::get_inputs`
helper for integration tests, reducing ~720 lines of repeated code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
ValuedMammal added a commit that referenced this pull request Feb 13, 2026
a35ecbf refactor!: Rename `filter_unspendable_now` to `filter_unspendable` (志宇)
302faff fix!: Account for MTP in locktime calculations (志宇)

Pull request description:

  ### Description

  Previously, time-based locktimes are based on header timestamps, but they should be based on MTP.

  ### Changes

  * Correctly calculate spendability of coins that are time-locked by taking MTP into account.
  * Rename `TxStatus` to `ConfirmationStatus`.
  * Split `is_timelocked` method into two methods as time-based and block-based timelocks have different required metadata.

  ### Testing

  Testing is done in #38 as they require some unreleased changes in upstream crates.

ACKs for top commit:
  ValuedMammal:
    ACK a35ecbf
  aagbotemi:
    ACK a35ecbf

Tree-SHA512: e037b292338d51bb1682c33106bc326ad5f1603f7c5d7542090e2625bf1cf08b3c3d43217724ed6e4d0ab39d646fb66e8fefee3b6a6bb6606f1c5c23d5d405be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant