Skip to content
This repository was archived by the owner on Oct 22, 2026. It is now read-only.

WIP: Demonstrate usage of the bitcoin-units compat layer - #1041

Draft
satsfy wants to merge 6 commits into
rust-bitcoin:release-13.xfrom
satsfy:units-compat-demo-13
Draft

satsfy wants to merge 6 commits into
rust-bitcoin:release-13.xfrom
satsfy:units-compat-demo-13

Conversation

@satsfy

@satsfy satsfy commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Built on top of units 1.0 compat layer. Mirrors the rust-psbt and corepc demos.

Done against version 13.x, so that I can test on BDK which is in 13.x.

Changes:

  • Expected MSRV bump to 1.74.0 (to be reduced later back to 1.63), forced by units 1.0. Cannot be feature gated bcs a public field type would break other crates in the graph.
  • Patch bitcoin to the 0.32.101 compat layer, stable types come from bitcoin::compat.
  • One commit per migrated type for Sequence, Weight, absolute and relative LockTime.
  • Stable types in the public API. No conversation paths presented so that user is forces into stable types.
  • bitcoind-tests and embedded need their own [patch.crates-io] or they resolve bitcoin 0.32.6 (todo: nothing in them was migrated here, awaiting primitives).
  • A lint rule for each type prevents regression, forcing user to put lint exception.

I noticed that TxIn, TxOut and Transaction (from primitives) are responsible for all lint exceptions, because they are using the unstable types, awaiting primitives compat layer.

This change will be reverted when units reverts to 1.63.

For now, bitcoin-units 1.0 use rust version 1.74, so
pulling in the compat layer in one crate requires the
crate MSRV to raise for all dep graph.
Enable the compat feature of bitcoin 0.32.101 and patch
bitcoin to the compat layer branch, on root workspace and
in the embedded and bitcoind-tests.

The branch lives on fork so its state stays under control.
Switch RelLockTime and the satisfier internals to use
stable Sequence from the compat layer.

Block conversions to and from the unstable sequence for
a clean breaking major with no commitment to keep old type.

Eventually LockTime will be upgraded and UnstableSequence
cases associated with it will be cleared. Churn here is a
tradeoff of bissectability and ease of review by clear
commit separation.

Disallow bitcoin::Sequence in lint.
Switch max_weight_to_satisfy return type and the witness
script size check conditional weight type to stable through
compat later.

The api for Weight has not changed, no conversions needed.

Disallow bitcoin::Weight force using new type on lint.
Switch every absolute lock time to stable. Convert at psbt
boundaries with to_stable because of primitives.
The stable type renames from_time to from_mtp.

Disallow bitcoin::absolute::LockTime in lint.
Switch relative lock time to the compat relative::LockTime.

Some inevitable churn related to Sequence already stable
the satisfier and interpreter no longer dip in unstable,
those allows go away.

Kill conversions to the unstable locktime for callers.

Disallow bitcoin::relative::LockTime in lint.
@satsfy
satsfy force-pushed the units-compat-demo-13 branch from 12eacdf to 9e8b3e6 Compare September 2, 2026 13:59
@apoelstra

Copy link
Copy Markdown
Member

FWIW from miniscript 14 onward we should just bump the MSRV.

@satsfy

satsfy commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@tcharding just pinging

Comment thread src/psbt/finalizer.rs
Comment on lines -488 to +489
lock_time: absolute::LockTime::ZERO,
lock_time: bitcoin::absolute::LockTime::ZERO,

@tcharding tcharding Sep 10, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce SequenceUnstable but use bitcoin::absolute::LockTime?

This is @apoelstra's place but FWIW I'm currently leaning towards preference for the latter (ie using path to distinguish and not use an alias). Whichever we choose we should be uniform.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sequence is part of a Bitcoin transaction and there is only one kind.

vs LockTime where there are two kinds, absolute and relative, so I prefer using one layer of path.

The bitcoin:: part I have no opinion about.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what I was talking about. The comment does not match the code context. My bad.

Comment thread src/plan.rs
Comment on lines -880 to +879
Some(Sequence(1000).to_relative_lock_time().unwrap()),
Some(relative::LockTime::from_consensus(1000).unwrap()),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this change is interesting. How you did it in the other place (changing to bitcoin::Sequence confused me, so I guess this is the clearer way. Not sure though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a little alarming to see the direct Sequence(1000) constructor which would bypass all invariants (though for Sequence, unlike the locktime types, I believe there are no invariants). So this is definitely clearer.

I'm not sure what "the other place" you're referring to is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'other place' I think is above but I cannot really tell what I was talking about. So please ignore.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants