Repository navigation
scanner: reject duplicate BIP21 parameter keys (#63) - #151
Tyagiquamar wants to merge 5 commits into
Conversation
|
Hi, friendly ping for review on this PR when you have a moment. Happy to address any feedback. Thanks! |
|
Hi, just following up on this when you get a chance. The branch is up to date and checks are green. If it looks good from your side, it should be ready to merge. Happy to make any changes if needed. Thanks! |
There was a problem hiding this comment.
Requesting changes for three issues:
-
The test suite will not compile as written.
test_invalid_lightning_invoice_syncis synchronous but still uses#[tokio::test], whose target must be anasync fn. Please either restoreasyncor change the attribute to#[test]. -
This does not reproduce or fix #63. The issue input contains two concatenated
bitcoin:URIs and therefore two?characters.decode_onchainstill splits on every?and parses onlyparts[1], silently discardingparts[2]. The duplicate-key loop never sees the second URI. Please add the exact payload from #63 as a regression test and preserve/validate the complete query, for example by usingsplit_once('?')before rejecting the embedded secondbitcoin:URI.
This distinction is confirmed by both consumer apps. Android and iOS added matching January 19 workarounds that detect a second bitcoin: prefix in their scan and manual-entry paths, explicitly referencing bitkit-core#63. Those workarounds would still be required after this PR.
- Rejecting every repeated query key is too broad. BIP 21 does not state that all duplicate keys are invalid, and its replacement BIP 321 explicitly permits repeated payment-instruction keys and requires accepting repeated unknown keys. Singleton fields such as
amount,label,message, andpopshould reject duplicates, but this needs a per-key policy rather than blanketHashMaprejection. BIP 321 also treats query keys as case-insensitive.
Relevant references:
…ncatenated URIs (synonymdev#63) Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
|
Thank you for the detailed review and reference links. All three items have been addressed in commit \27b3d92:
All 28 scanner unit tests pass cleanly in Docker. |
pwltr
left a comment
There was a problem hiding this comment.
The original three findings are addressed, but two BIP 321 compliance issues remain:
-
popandreq-popare treated as separate singleton keys. TheHashSettracks their literal names independently, so?pop=callback1&req-pop=callback2succeeds. BIP 321 treats these as the same proof-of-payment field and explicitly lists that combination as invalid. Please map both names to one canonical singleton identity and add the specification's mixed-key example as a regression test. -
Rejecting every additional
?rejects valid query data.query.contains('?')rejects inputs such as?message=Why?. BIP 321 definesqcharusing the RFC 3986 query grammar, excluding only=and&; RFC 3986 explicitly permits?as data inside the query component. The embedded-secondary-bitcoin:check already catches the issue #63 payload without this blanket restriction.
I reproduced both cases with focused tests against commit 27b3d92; both failed. The existing 28 scanner tests pass locally, including the exact #63 regression, and the updated scanner files pass rustfmt --check.
References:
…mark query data (synonymdev#63) Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
|
Thank you for the follow-up review and exact references. Both remaining BIP 321 compliance findings have been addressed in commit
Test & Check Results:
|
pwltr
left a comment
There was a problem hiding this comment.
No remaining findings. Approved.
|
Fixed the false-positive rejection of valid Bitcoin URIs containing The original malformed URI from #63 is still rejected by the duplicate Added regression tests for valid query values, duplicate singleton parameters containing those values, and concatenated addresses. All 36 scanner tests pass. The fix is in signed, verified commit 08a7818. |
|
Addressed the minor review follow-ups in f501fbb:
All 38 scanner tests pass with For SDK adoption, both iOS and Android should remove all call sites of their temporary substring-based BIP21 guard, including clipboard validation where applicable. No mobile dependency or integration changes are included here. |
Fixes #63
Description
Previously, collecting Bitcoin URI query parameters directly into a
HashMapsilently overwrote duplicate keys. This PR rejects duplicate singleton parameters instead of accepting ambiguous payment requests.amount,label,message, andpopparameters case-insensitively. Treatpopandreq-popas the same singleton.?, preserving subsequent question marks as query data.bitcoin:text in notes, labels, and custom values. Query metadata is not a second payment request, and must not change the recipient or amount.decodeis digesting only the first duplicated Bip21 #63 through its duplicatemessageparameter. A concatenated URI in the address is rejected by the existing address validation.pop/req-popare treated as aliases here; general required-parameter handling remains separate.The follow-up removes the overly broad substring check and adds regression tests covering valid embedded payment links, duplicate-key rejection with those values, and concatenated addresses. No binding/API or dependency changes are needed.
Preview
N/A — parser-only change.
QA Notes
cargo test --release --lib modules::scanner --locked --offline: all 38 scanner tests passed, including the exact fix :decodeis digesting only the first duplicated Bip21 #63 regression.git diff --checkpassed.