Repository navigation
Migrate URI parsing to bitcoin_uri 0.2 - #1975
Open
caarloshenriq wants to merge 4 commits into
Open
caarloshenriq wants to merge 4 commits into
caarloshenriq wants to merge 4 commits into
Conversation
caarloshenriq
force-pushed
the
update/bitcoin_uri-0.2
branch
from
October 14, 2026 20:55
991add4 to
ad753c5
Compare
Collaborator
Coverage Report for CI Build 43485379827Coverage decreased (-0.05%) to 87.779%Details
Uncovered Changes
Coverage Regressions145 previously-covered lines in 35 files lost coverage.
Coverage Stats
💛 - Coveralls |
caarloshenriq
force-pushed
the
update/bitcoin_uri-0.2
branch
4 times, most recently
from
October 22, 2026 18:11
f3306ff to
c81da26
Compare
Member
|
Merged 0.2.0 which is now on crates.io, so this can be taken out of draft TODO:
After this merges, the next thing to do is reading |
caarloshenriq
force-pushed
the
update/bitcoin_uri-0.2
branch
from
November 11, 2026 20:14
c81da26 to
89fa5b6
Compare
caarloshenriq
marked this pull request as ready for review
November 11, 2026 20:41
bitcoin_uri 0.2 is a plain BIP 321 tokenizer and no longer takes a deserialization hook for extension params, so the payjoin adapter traits go away. Uri and PjUri now wrap an owned bitcoin_uri::Uri and read pj/pjos with get_all, keeping the payjoin rules (duplicates, pjos without pj, endpoint checks) in this crate. bitcoin_uri 0.2 reports req- parameters instead of rejecting them, so the BIP 321 rule that a URI with a required parameter we cannot handle MUST be rejected is enforced here. req-pj and req-pjos are understood. UriBuilder::build needs a network, but a checked address does not expose its own, so network_of probes for one the address is valid for. check_pj_supported rebuilds the inner URI so Display keeps the canonical param order (standard params, then pjos, then pj) whatever the input order was. The public API and the emitted URI are unchanged, so senders, receivers and their tests are untouched.
Pin how the payjoin Uri consumes bitcoin_uri's BIP 321 tokenizer: unknown req- parameters are rejected while req-pj and req-pjos are understood, keys match case-insensitively, a URI needs a body address, and every network survives a print and re-parse. Display is checked to be canonical: all 120 orderings of the same five parameters print identically, and printing is a fixpoint after one round.
The integration tests hand the sender the receiver's own printed URI. A wallet shows it differently in a QR code: upper-case scheme, keys and bech32 address, a lightning fallback, pj marked as required and the parameters reordered. Pay such a URI over v1 on regtest to check that bitcoin_uri 0.2 parsing holds up through a full payjoin
caarloshenriq
force-pushed
the
update/bitcoin_uri-0.2
branch
from
November 13, 2026 18:00
89fa5b6 to
2299db4
Compare
check_pj_supported rebuilt the URI from the parameters payjoin reads, so printing a sender's PjUri dropped any other parameter, such as a lightning or sp fallback, and reordered the rest. Keep the parsed bitcoin_uri::Uri instead, so a PjUri prints exactly what it parsed. set_amount still rebuilds the URI, so document that it drops those parameters on a parsed URI. Replacing it is left to a follow-up. Tests that pinned the canonical output now check that the input is printed unchanged.
caarloshenriq
force-pushed
the
update/bitcoin_uri-0.2
branch
from
November 13, 2026 18:43
2299db4 to
6ece25d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on payjoin/bitcoin_uri#17. Draft until that is merged and 0.2 is on crates.io, at which point the git dependency switches to the released version.
Moves payjoin onto bitcoin_uri 0.2. The 0.2 parser is a plain BIP 321 tokenizer, so the adapter traits we had for 0.1 are gone and pj/pjos handling now lives in this crate.
What changes:
UriandPjUriwrap an ownedbitcoin_uri::Uriand read pj/pjos off it. Duplicate params, pjos without pj and the endpoint checks are enforced here.check_pj_supportedrebuilds the URI in canonical order (standard params, then pjos, then pj), so the printed URI is the same as before whatever the input order.The public API and the emitted URIs don't change, so send/receive code and their tests are untouched.
Tests: a bip321 module covering the req- rules, case-insensitive keys, all 120 orderings of five params printing the same, printing being a fixpoint, and every network round-tripping. Plus an integration test that pays, over v1 on regtest, a URI shaped the way a wallet shows it in a QR code (upper case, a lightning fallback, req-pj, reordered params).
Reviewer: @DanGould
Disclosure: co-authored by Claude
Pull Request Checklist
Please confirm the following before requesting review: