Skip to content

fix(selection): Improve handling of fallback locktime#43

Open
ValuedMammal wants to merge 1 commit intobitcoindevkit:masterfrom
ValuedMammal:fix/improve_fallback_locktime
Open

fix(selection): Improve handling of fallback locktime#43
ValuedMammal wants to merge 1 commit intobitcoindevkit:masterfrom
ValuedMammal:fix/improve_fallback_locktime

Conversation

@ValuedMammal
Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal commented Mar 21, 2026

Description

This is a follow-up to #24 which correctly implements the fallback locktime during PSBT creation, while enabling the fallback to contribute to the maximum accumulated locktime, provided that the lock type units are in agreement.

Notes to the Reviewers

Previously when setting the locktime of the transaction the fallback locktime was being chained onto the input locktimes causing a LockTypeMismatch error whenever a height-based fallback conflicted with a time-based input CLTV requirement. Since the PsbtParams::default defines a fallback_locktime that is height based, this made the default fallback incompatible with a time based input requirement.

This is fixed so that the fallback is only used if no inputs require an absolute timelock, or if the fallback is the same unit, then the maximum locktime value is used.

Added a test to check that the fallback is ignored if the lock type is incompatible.

@ValuedMammal ValuedMammal force-pushed the fix/improve_fallback_locktime branch from f4c0020 to d74993b Compare March 31, 2026 15:58
@ValuedMammal ValuedMammal marked this pull request as ready for review March 31, 2026 16:01
The fallback locktime was being chained onto the input locktimes
causing a `LockTypeMismatch` error whenever a Block based fallback
conflicted with a Time based input CLTV requirement.

This is fixed so that the fallback is used if no inputs require an
absolute timelock, or if the fallback is the same unit we use the
maximum locktime value.
@ValuedMammal ValuedMammal force-pushed the fix/improve_fallback_locktime branch from d74993b to 260a46c Compare March 31, 2026 16:18
@ValuedMammal ValuedMammal reopened this Mar 31, 2026
@ValuedMammal
Copy link
Copy Markdown
Collaborator Author

In the last push

  • Changed fn _accumulate_max_locktime to accumulate_max_locktime (dropped the leading _)
  • accumulate_max_locktime now returns CreatePsbtError::LockTypeMismatch in case there is a mismatch of lock type units.

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