Skip to content

fix: adopt core bip21 validation - #1454

Merged
ovitrif merged 7 commits into
masterfrom
codex/adopt-core-bip21-validation
Nov 11, 2026
Merged

ovitrif merged 7 commits into
masterfrom
codex/adopt-core-bip21-validation

Conversation

@pwltr

@pwltr pwltr commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1843

Twin: synonymdev/bitkit-ios#909
Dependency: synonymdev/bitkit-core#151 (included in published 0.8.0-rc13)

This PR delegates Bitcoin payment URI validation to the shared core decoder instead of the app-side substring workaround.

Uses the published 0.8.0-rc13 Core release. Rebased onto master at 4f401bd3c681465ad27f24a29e9b6d433930e4fd; current head bc3dd46e4b4f45656fe098a5b78d719f8e7599e7. All seven rebased PR commits are verified GitHub-signed and attributed to pwltr. The clipboard privacy fix in 734405f93f76ca875a3923c3f57bae644150d75c is also verified GitHub-signed and attributed to pwltr. The normalization/toast fix e136c24ca184d858887288df6a8f1fa2f3376921 is also verified GitHub-signed and attributed to pwltr. Previous QA remains recorded at its original revisions.

Description

  • Matches HTTP-wrapped LNURLs across CR, NEL and Unicode line/paragraph separators without invoking native decoding before consent, using Core’s non-LF matching semantics explicitly.

  • Recognizes Core-normalized clipboard candidates through repeated Bitkit-wrapper removal and matching whitespace handling before any network-capable decoder call.

  • Uses the localized decoding ERROR and InvalidAddressToast for refused Bitcoin URI scans/deep links, while keeping the generic warning for other unreadable codes.

  • Keeps automatic LNURL and Lightning Address clipboard inspection offline until confirmation, while preserving native local BIP21 validation.

  • Removes the fixed SDK release and adoption-PR merge instructions from shared BIP21 journey documentation; guidance remains valid after dependency updates.

  • Removes the substring guard from scanning and manual entry so legitimate bitcoin: text in query metadata is accepted.

  • Keeps core decoding failures on the existing invalid-address and incoming-payment-request failure paths so rejected data cannot become a new payment.

  • Replaces heuristic tests with app delegation and real Android native-binding coverage while preserving invoice generation.

  • Adds the same deeplink journey as iOS so the two platforms verify matching payment behavior.

  • Pins the released Core SDK to 0.8.0-rc13, retaining Navigation intro buy #151 BIP21 validation and adding Wake client fixes and cached synced-BDK-wallet composition used by hardware sends.

Remaining verification

  • Manual clipboard case 1 was verified by the user on the rc12 revision on November 10. The rc13 update was checked with the full gate, native decoder tests and J1 below; the earlier manual result remains historical evidence.

Out of Scope

  • Core parser: the known embedded-URI/first-occurrence limitation is tracked in synonymdev/bitkit-ios#1272, following the accepted Low finding in Core #151 and the user’s explicit scope decision (iOS review thread). It remains outside this adoption; it is not claimed fixed here.
  • Core parser: complete BIP321 and general required-parameter semantics beyond Navigation intro buy #151.
  • Payments: unrelated network, fee, Quickpay and payment-method selection changes.

Design

N/A — no UI changes.

Preview

N/A — validation only.

Decoder limitations

Core #151 rejects the doubled URI fixtures exercised by J1. Its embedded-URI check requires a valid Bitcoin address followed by a query (?). A concatenation such as bitcoin:A?amount=0.001bitcoin:B with a queryless second half can instead decode to the visible first recipient with no amount; this PR does not claim every concatenation is rejected. The user must enter and review an amount before paying. This limitation is recorded in response to the Android review.

QA Notes

Setup

For J2, use bitkit-docker at 694c0e4807b8fbaa677f73e39bdd2bc2f4fa4d48 and follow journeys/hardware-wallet/README.md: start the deterministic Model T/T2T1 Bridge emulator with ../bitkit-docker/scripts/trezor-emulator start; build/install with E2E=true E2E_BACKEND=local TREZOR_BRIDGE=true TREZOR_BRIDGE_URL=http://10.0.2.2:21325 ./gradlew installDevDebug -PuseMavenLocal=false. Complete onboarding, pair through connect-home-tile.xml, and fund the paired native-segwit account with at least 50,000 confirmed local regtest sats using the Bitcoin RPC recipe below. Use a fresh node-owned regtest destination, an amount smaller than the available balance, and approve signing through the emulator controller. This tests Bridge, not physical USB/BLE. The installed SDK pins remain those listed below. The reviewer has announced J2; this is reproducible setup, not a passing result.

For ClipboardInspectionTest, no external server or account is needed: the test binds an owned loopback fixture at 127.0.0.1:33337 inside the emulator. The port must be free. The fixture returns HTTP 404 so explicit native decoding fails after its request; the request itself is the positive control. Run it with ./gradlew connectedDevDebugAndroidTest -PuseMavenLocal=false -Pandroid.testInstrumentationRunnerArguments.class=to.bitkit.services.ClipboardInspectionTest. Manual case 2 needs a separately running owned LNURL/Lightning Address endpoint with request logging; the test-owned fixture only lives during the instrumented test.

Current dependency set after the rebase: Breez Spark 0.28.0 from master, published Core 0.8.0-rc13, Paykit 0.1.1-rc6, LDK Node 0.7.0-rc.79, VSS 0.5.26-rc2, with useMavenLocal=false. The November 10 rebase rerun used the same local backend configuration below with bitkit-docker resolved at 694c0e4807b8fbaa677f73e39bdd2bc2f4fa4d48 (Bitcoin 26.0/electrs 0.10.2), a fresh disposable emulator wallet funded with 200,000 regtest sats, and QuickPay verified Off.

Use an onboarded English regtest wallet with QuickPay off and at least 100,000 sats in Savings. Decline the optional USDT introduction and dismiss received-payment/backup prompts before J1. Do not pay either journey fixture.

Use bitkit-docker at f5eae182db9ddecd61a0f1b5e9f48aee283bb3dc (Bitcoin Core 26.0, electrs 0.10.2), with local RPC on 43782 and Electrum on 60001:

cd ../bitkit-docker
git checkout f5eae182db9ddecd61a0f1b5e9f48aee283bb3dc
docker compose up -d bitcoind bitcoinsetup electrs
btc() { docker compose exec -T bitcoind bitcoin-cli -regtest -rpcport=43782 -rpcuser=polaruser -rpcpassword=polarpass "$@"; }
# Once for a new disposable test fixture:
btc createwallet bip21-review
btc -rpcwallet=bip21-review -generate 101
# For each app, replace the placeholder with its own Savings receive address:
btc -rpcwallet=bip21-review sendtoaddress '<app Savings address>' 0.002
btc -rpcwallet=bip21-review -generate 3

Wait for 200,000 sats to appear in Savings. The native parser tests need no backend or funded wallet. The URI delivery commands and recipient-inspection mechanics are in journeys/send/README.md.

The default Android build consumes com.synonym:bitkit-core-android:0.8.0-rc13 and the other pinned SDKs from GitHub Packages using the credentials documented in the README (gpr.user/gpr.key or equivalent environment variables). Current rc13 build, unit, lint, native and J1 verification all used the published Maven artifacts with useMavenLocal=false; no local AAR override was used. The exact Core AAR downloaded by Gradle was compared against the authenticated published artifact and matched SHA-256 17543552f8065471addcc38f161ff73683b5d5322e5804be2639ac566e11c7b3.

Historical rc12 local-source setup

The default Android build consumes com.synonym:bitkit-core-android:0.8.0-rc12 from GitHub Packages with the credentials documented in the repository README. Local verification hit HTTP 401 with the runner's repository credential and instead built the pinned SDK sources, then set ORG_GRADLE_PROJECT_useMavenLocal=ldk-node,vss,bitkit-core,paykit.

Source pins: Core v0.8.0-rc12; LDK v0.7.0-rc.78 / 1976754dd49886e102f2b3132d5f700d6aabd8d7; VSS v0.5.26-rc1 / eba41ef62b7314aa75827a5a3e71d2b23930b981; Paykit v0.1.1-rc2 / 01de5dd232d2b22f132d066697cce041700e7136. Their build entry points are Core/VSS ./build_android.sh, LDK ./bindgen.sh, and Paykit ./build_android.sh inside paykit-ffi; these populate Maven local. The build used NDK 28.2.13676358, JDK 17 for SDK generation, and Rust 1.91.1 for Paykit. Local SDK binaries are not claimed byte-identical to the published AARs or compatible with published debug symbols.

Build/run the regtest app with E2E=true E2E_BACKEND=local. Verification used the medium_phone Android 16/API 36 arm64 emulator. For the native tests, run ./gradlew connectedDevDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=to.bitkit.services.Bip21DecodingTest with -PuseMavenLocal=false. CI retains normal published dependency resolution.

Journeys

  • J1: new bip21-core-validation.xml — valid metadata preserves recipient/amount; concatenated URIs and duplicate parameters show an error and cannot open a payment sheet. All 12 actions were executed on both platforms; reviewer checkboxes remain unchecked.

  • J2: existing hardware-wallet/send-onchain.xml — exercise rc13 cached-wallet composition, Trezor signing and broadcast. Reviewer announced this gate; no Android author execution is claimed.

Manual Tests

  • 2. With automatic clipboard reading enabled, copy a payment LNURL or Lightning Address backed by an owned endpoint with request logging, then return to Home: the prompt appears without an endpoint request; Cancel sends no request; repeat and confirm to allow resolution. Arbitrary OS clipboard injection and a persistent owned LNURL endpoint are not supplied by the journey environment.

  • 1. Copy a valid Bitcoin URI with message=bitcoin:donation to the system clipboard → return to Home and confirm Read Clipboard → the correct payment opens; repeat with the String formmating error lint #63 malformed URI → no payment opens — arbitrary OS clipboard injection is not in Capabilities.

Automated Checks

  • ClipboardInspectionTest.kt uses the published native decoder and an emulator-owned loopback HTTP fixture to verify zero connections during production clipboard inspection, plus an explicit-decoding positive control against the same fixture.

  • AppViewModelSendFlowTest.kt verifies that network-shaped candidates bypass Core until confirmation, explicit clipboard confirmation still emits the existing processing event, and BIP21/LNURL metadata still uses Core rejection results.

  • added Bip21DecodingTest.kt — checks the actual Android native decoder using the String formmating error lint #63 fixture, duplicate singleton keys, valid metadata and question marks in notes; device execution passed with the source-built rc12 SDK, as recorded below.

  • updated AppViewModelSendFlowTest.kt — verifies manual-entry, scanning and clipboard delegation, rejected-payment state clearing, and incoming-payment-request failure feedback.

  • removed substring-workaround cases in Bip21UrlBuilderTest.kt — replaced by decoder integration coverage; invoice generation tests remain.

Evidence

  • Final Android base refresh on bc3dd46e4b4f45656fe098a5b78d719f8e7599e7 (tree 04108e2fd202f5ac73a7ba707c7a72a25c1338e0), onto master 4f401bd3c681465ad27f24a29e9b6d433930e4fd: resolved only the adjacent dependency-catalog conflict, retaining Core rc13 and master's Breez Spark 0.28.0. git range-diff preserved all seven PR changes apart from the catalog context; the dependency diff against master still changes only Core rc11 to rc13. All seven replayed commits are verified GitHub-signed and attributed to pwltr.

  • Fresh validation on the rebased candidate, using published Maven SDKs with useMavenLocal=false: just compile, just test (5,300 passed, zero failures/errors/skips) and just lint passed. The five native tests in Bip21DecodingTest and ClipboardInspectionTest passed with zero failures/errors/skips, including all HTTP terminator fixtures, zero pre-consent requests and explicit-decoding positive controls.

  • J1 rerun on the tested tree subsequently signed as bc3dd46e4b4f45656fe098a5b78d719f8e7599e7, medium_phone Android 16/API 36 arm64, 200,000 local regtest sats, QuickPay Off: all 12 actions passed. Both valid inputs retained the full recipient and 3,500 sats. All three malformed cases showed visually inspected Decoding Error and no payment sheet. No fixture payment sent. The duplicate-amount input was repeated to capture its short-lived toast; app logs independently confirmed native rejection. After native test cleanup, fresh onboarding/funding explicitly selected Savings in the new three-tab Receive screen. The report and snapshots/screenshots are retained under review-followups/android-http-wrapper-rebase-J1.md and android-journey-evidence/http-rebase-j1-* in the runner's rc13 artifact folder. git diff --check passed. CI is starting on the new signed head; older results below remain historical.

  • HTTP-wrapper privacy fix on 4492e2e2f81994d1a6c90d10eef66a6847de16c5 (tree e8c2819b9283d6e06612b2c59f6baf0884bd5b0e), published SDKs with useMavenLocal=false: just compile, just test (5,009 passed, zero failures/errors/skips), and just lint passed. connectedDevDebugAndroidTest for Bip21DecodingTest and ClipboardInspectionTest passed all five native tests with zero failures/errors/skips. A diagnostic on the previous head first confirmed one native-decoder call and one loopback HTTP request from the reported CR wrapper before confirmation. The fixed production inspector now makes zero decoder calls/requests for CR, NEL, U+2028 and U+2029 HTTP wrappers under direct and Bitkit/Lightning prefixes. Explicit native decoding of all four wrappers still contacts the same fixture (five positive-control requests including the plain LNURL); an LF wrapper stays unsupported with zero requests, matching Core. git diff --check passed. CI did not start on that pre-rebase head because master gained a conflicting dependency entry; it is superseded by the signed base refresh above.

  • CI completed successfully on e136c24ca184d858887288df6a8f1fa2f3376921: build/unit and Compose UI, lint, and all seven E2E shards passed. All three required checks are successful; migration jobs were skipped and are not counted as passing. The reviewer also confirmed the normalization fix and decoding-error parity on this head. Separately listed manual clipboard/dialog and hardware-send QA gaps remain unverified by these CI results.

  • November 11 normalization/toast fixes on e136c24ca184d858887288df6a8f1fa2f3376921 (tree 3a7d12f68c980eceb4286c2e3f6289d81087a9ec), published SDKs and useMavenLocal=false: just compile, just test (5,008 passed, zero failures/errors/skips) and just lint passed. The two new unit regressions failed on the prior code (network-capable Core calls for normalized clipboard variants; generic warning instead of decoding error), then passed with the fixes. The native Bip21DecodingTest and ClipboardInspectionTest passed all four tests with zero failures/errors/skips, including U+0085, whitespace after lightning:, and nested-wrapper shadows: zero connections during inspection, one for explicit native decoding against the same owned loopback fixture.

  • J1 was rerun on the exact candidate subsequently signed as e136c24ca184d858887288df6a8f1fa2f3376921, medium_phone Android 16/API 36 arm64, published SDKs, 200,000 local regtest sats and QuickPay Off: all 12 actions passed. Both valid links preserved the full recipient/3,500 sats. All three malformed cases showed the visually inspected input-neutral Decoding Error with no payment sheet; the unit regression separately asserts ERROR and InvalidAddressToast, while unrelated unreadable scans retain their generic warning. No payment sent. The native test cleanup required fresh onboarding/funding before J1. Snapshots/screenshots and action report are retained under the runner's rc13 app-updates/android-journey-evidence/normalization-j1-* and review-followups/android-normalization-J1.md.

  • git diff --check passed. The tested native APK SHA-256 is 7fdf7dbe0921289b0402ad0c088bd7d13ee713583c56700914878dc180107da3. CI passed on this signed head as recorded above; prior CI below remains associated with its original revision. The matching iOS privacy normalization fix is 0f353319b3024813935d5826963b75136f2a4eda in Contact add/delete flow parity (iOS + Android) #909, where the full selected unit suite passed 3,177 tests with zero failures and one optional fixture skip.

  • CI completed successfully on clipboard-fix head 734405f93f76ca875a3923c3f57bae644150d75c: build/unit and Compose UI, lint, and all seven E2E shards passed. Required build, lint, and e2e-status are successful; migration jobs were skipped and are not counted as passes. This does not execute the separately documented manual clipboard/dialog case 2.

  • November 11 clipboard fix verified on 734405f93f76ca875a3923c3f57bae644150d75c (tree 02a8f4ab609e40ee99981ccfad164e6c0491956b), using published Maven SDKs with useMavenLocal=false: just compile passed; just test passed 5,006 tests, zero failures/errors/skips; just lint passed after correcting initial line-wrapping findings. connectedDevDebugAndroidTest limited to Bip21DecodingTest and ClipboardInspectionTest passed all four native tests with zero failures/errors/skips on medium_phone Android 16/API 36 arm64. The production inspector made zero connections to the owned loopback fixture for LNURL/Bitkit wrappers and BIP21/LNURL inputs; explicit native decoding contacted the same fixture once and received the expected HTTP 404. Valid metadata remained accepted and malformed BIP21/LNURL input was rejected. git diff --check passed. CI also passed on this head, as recorded above; the preceding J1 execution remains historical.

  • CI completed successfully on b640f7b966f69c8ee2375f168309450ea35b3895: build/unit and Compose UI tests, lint, and all seven E2E shards passed. Required build, lint, and e2e-status are successful. Migration jobs were skipped and are not counted as passing.

  • Conflict resolution verified on b640f7b966f69c8ee2375f168309450ea35b3895 (tree f531b7a9209b5a0af9e2d9cb62ac112074afd7c3), rebased onto 816f08ed7bfc9774d15ec1bb8e5f37bf13479b26: retained Core rc13 alongside master's Paykit rc6, LDK rc79 and VSS rc2. The only manual conflict resolution was the adjacent Core/Paykit version lines; git range-diff preserved the four PR changes, and the dependency diff against master changes only Core rc11 to rc13.

  • Rebase verification with published Maven artifacts: just compile passed; just test passed 5,004 tests across 265 suites, zero failures/errors/skips; just lint passed. connectedDevDebugAndroidTest limited to Bip21DecodingTest passed both native tests with zero failures/errors/skips. An initial compile invocation ran before the second catalog conflict was resolved and stopped on conflict markers; the completed candidate was rerun through all three gates successfully.

  • J1 rerun on the rebased app, medium_phone Android 16/API 36 arm64, published SDKs, 200,000 local regtest sats, QuickPay Off: all 12 actions passed. Both valid inputs retained the full recipient and 3,500-sat amount; all three malformed inputs showed visually inspected decoding errors while Home remained visible and no payment sheet opened. Closed both valid sheets without paying. The instrumented runner cleared app data during cleanup, so J1 used a freshly onboarded and funded wallet. The exact tested APK SHA-256 is 3a47661d3e25907409456178c62c83669345f6d957fbf7635753e8b292e935b2; the tested local candidate and signed head have identical trees. Snapshots, screenshots and the action report are retained under the runner's rc13 app-updates/review-followups/android-rebase-J1.md and android-journey-evidence/rebase-j1-*.

  • git diff --check and shared XML validation passed; iOS and Android still have identical journey action text. CI passed on the rebased signed head; the older results below remain historical.

  • Final documentation-only follow-up 77c4d5736af3501bac3868cdce91ead20d301a79 removes the fixed SDK release from the shared XML precondition. git diff --check and XML/reference validation passed; all 12 action texts are unchanged and the two platform XML files remain identical. App code and SDK artifacts are unchanged from the tested revision below.

  • CI completed on 68b13df460da5a71bc4e54e31bea4150e339fdf2: build/unit tests and Compose UI retry passed (attempt 2), lint passed, and all seven E2E shards passed. Required build, lint, and e2e-status are all successful. The first Compose attempt failed during cached-emulator unlock before tests began (No service published for: input); retry succeeded without code changes. Migration checks were skipped and are not reported as passing.

  • November 10 rc13 verification applies to 68b13df460da5a71bc4e54e31bea4150e339fdf2 (tree 185c2b8f3da94dc10c9cbf78d07be6b471b95dd3). Only the SDK pin and shared journey documentation changed; no Kotlin production code changed.

  • Full local gate passed with published Maven SDKs and useMavenLocal=false: just compile, just test (4,942 tests, zero failures/errors/skips), and just lint. All 604 send-flow cases passed.

  • ./gradlew connectedDevDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=to.bitkit.services.Bip21DecodingTest: two real native emulator tests passed, zero failures/errors/skips, using the published rc13 SDK. This resolves the earlier local-source versus published-artifact validation distinction.

  • J1 passed all 12 actions on the rc13 app on medium_phone, Android 16/API 36 arm64, with 200,000 local regtest sats and QuickPay off. Valid metadata preserved the full recipient and 3,500-sat amount; all three malformed inputs showed visually inspected error toasts without opening a payment. No fixture payment was sent. The instrumented-test runner removed the target app on cleanup, so this used a freshly onboarded and funded test wallet after reinstalling the exact generated E2E APK.

  • The cached Core AAR matched the published Maven artifact, SHA-256 17543552f8065471addcc38f161ff73683b5d5322e5804be2639ac566e11c7b3. git diff --check and shared 12-action XML validation passed. No credentials or local fixture were committed.

Previous rc12 verification (original revisions preserved)
  • Manual case 1: on November 10, pwltr reported Android looked good after repeating the valid-URI clipboard flow and malformed concatenated-URI scanner Paste check described in this thread. Recorded as user-reported verification on 38543277954bc1b33b014b604ad51a5886efa60a, using the Android 16/API 36 medium_phone emulator and local regtest backend. Before handoff, the installed APK SHA-256 c8cc7010bc9c6bdca34d4ed045868b1352043529e1adecfd9e76cdeed306cade was verified to match the retained app-dev-arm64-v8a-debug.apk from the tested PR checkout. This was the source-built SDK app; it does not constitute a separate runtime check of the CI APK.
  • CI build and unit tests passed on 38543277954bc1b33b014b604ad51a5886efa60a using the normal published Maven dependencies and the automatic Actions token (packages: read); no Maven-local opt-in or SDK source-build step is present. The regtest universal APK is available for 30 days. The final required build gate, lint, and Compose UI tests have now all passed on this head. Draft-only E2E/migration jobs were skipped; they are not reported as passing.
  • Author verification on November 9 used the local candidate subsequently committed as 38543277954bc1b33b014b604ad51a5886efa60a (tree abe6b284ec3087b953c35ff45ad055fc5665659c). Production code and SDK pins were unchanged after these checks.
  • J1 passed all 12 actions on each platform with 200,000 local regtest sats and QuickPay off; no fixture payments were sent. Snapshots/screenshots and source-build provenance are retained in the runner-local releases/bitkit-core/0.8.0-rc12/app-updates artifact folder.
  • The original journey expected a visible BIP21 note. Existing confirmation UI on both platforms does not render that note; the shared assertion was corrected to recipient/amount, both complete journeys were rerun, and native/app tests separately verify preserved metadata.
  • just compile, just test, and just lint passed with the explicit local-source SDK selection. Unit results: 4,942 tests, zero failures/errors/skips, including all 604 send-flow cases.
  • Bip21DecodingTest.kt: two native emulator tests passed, zero failures/errors/skips. These include duplicate aliases/concatenation and valid metadata/question-mark fixtures.
  • Native tests built the E2E app used for J1; Android error-toast screenshots were visually inspected and semantic snapshots confirmed no stale payment sheet.
Historical authored verification before the rc12 refresh

The precise tested app revisions were not recorded in the original body; these historical results do not describe the refreshed head.

  • ran the full unit suite — 3,628 tests executed; three new mock-stub failures were corrected, then all 365 cases in AppViewModelSendFlowTest.kt passed on the focused rerun.
  • ran native-test compilation — the new Android binding coverage compiles against 0.5.18, but its device execution remains pending the fixed SDK release.
  • ran shared journey XML checks — the platform journey files are identical; neither device journey was run against the unfixed SDK.

Gaps

  • Manual clipboard/dialog case 2, including interior-terminator fixtures, remains unrun through OS UI. J1 and the native network-boundary tests were rerun on the signed base refresh above.

  • J2 Android hardware-send gate is awaiting reviewer execution; the matching iOS hardware send was previously verified, but is not Android evidence.

  • Manual case 2 has not been run through OS clipboard/dialog interaction. The native loopback probe and app delegation tests verify the network boundary; they do not constitute execution of that manual case.

  • User manual clipboard case 1 passed on rc12 (38543277954bc1b33b014b604ad51a5886efa60a); the full OS clipboard prompt flow was not repeated for rc13. Native/app tests and J1 were rerun with published rc13 artifacts.

  • Earlier rc12 native/emulator evidence used source-built SDKs. Current rc13 native tests and J1 used published Maven dependencies, closing that source distinction. Device checks used the locally generated E2E APK, not a separately installed GitHub CI APK; CI build/unit tests, Compose UI, lint and all seven E2E shards have now passed on this head.

Models used

  • Planning/scoping: Unknown (reasoning: Unknown), gpt-6.1-sol (reasoning: high)
  • Implementation: Unknown (reasoning: Unknown), gpt-6.1-sol (reasoning: high)
  • Review: Unknown (reasoning: Unknown)

Metadata note: the verified model/effort pair covers this rc12 refresh and comes from T3 runtime metadata. Earlier planning/implementation/review metadata is absent from the existing PR body, and a targeted lookup of accessible native session records for the original October 9/13 changes found no matching executions. No independent review was performed in this refresh; no review-round count is inferred.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from bc3dd46 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@pwltr
pwltr marked this pull request as ready for review November 10, 2026 14:53
@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new defects were established.

Summary

Moves Bitcoin URI checks from the app’s substring workaround to Core 0.8.0-rc13.

  • Bitcoin payment links now use Core's validation.
  • Clipboard prompts recognize payment links without decoding them first.

No new actionable issues were established. Tests were inspected, not run during this review.

Reviews (3) · Last reviewed commit: "fix: keep http-wrapped clipboard inspect..." · Reviewed by Greptile

@ovitrif

ovitrif commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Triage: in 3.2.0. This PR closes #1843, filed in the 3.2.0 milestone at 👀 Review: it moves payment URI checks to the core decoder, a behaviour change for scanning and manual entry. Twin: synonymdev/bitkit-ios#909.

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No findings. Drops the app-side isDuplicatedBip21 substring guard from manual entry and scanning and leaves the decision to bitkit-core 0.8.0-rc12, which rejects duplicate singleton parameters. Reviewed 3854327, full tier, static.

What I checked, and 4 candidates I ruled out

Read: validateAddressWithFeedback, handleScan, normalizedScanInput, canDecodeClipboard, clearIncomingPaymentRequestTarget call sites in AppViewModel.kt at the head; the new tests in AppViewModelSendFlowTest.kt and Bip21DecodingTest.kt.
Dependency: synonymdev/bitkit-core#151 is merged and its merge commit is an ancestor of v0.8.0-rc12 (compare: rc12 is 23 commits ahead, 0 behind).
CI: build-and-test, build, lint, detekt green on this head; compose-ui / ui-tests still running when this was posted.
Build skipped: not built here. The Maven packages need a registry credential this review does not hand to a branch build, so CI is the gate.

Ruled out

  • Concatenated URI now reaches a payment: both removed guards sat before coreService.decode, and a decode failure lands on the same InvalidAddressToast path (manual entry) or handleDecodedScan(null, ...) (scan), which the renamed request-target test covers.
  • Previous payment survives a rejected scan: resetSendState runs before decode in handleScan, and scanned concatenated bip21 rejected by core clears previous payment asserts the cleared state.
  • E2E selector break from dropping DuplicatedBip21Toast: no reference to that tag in bitkit-e2e-tests main.
  • Bip21Utils callers left dangling: the remaining callers (WalletRepo.kt, ReceiveInvoiceUtils.kt) use only buildBip21Url, which stays.

Merge confidence: 4/5, no findings, but this payment-URI parsing path was reviewed from code and CI only, and the decoder's rejection rests on the device tests rather than a run here.

@pwltr
pwltr requested review from a team, ben-kaufman and coreyphillips and removed request for a team November 10, 2026 15:39

@coreyphillips coreyphillips left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two independent reviews.

worth doing, does not block

  • Concatenated URI whose second half has no query now opens Send (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:4851)

nits

  • Journey docs hard-code rc13 and a pre-merge instruction (journeys/send/README.md:3)

the reviewers disagree, your call

  • Concatenated URIs pass validation after bitcoin text in metadata (gradle/libs.versions.toml:24)

Comment thread journeys/send/README.md Resolved
Comment thread gradle/libs.versions.toml Resolved

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed b640f7b.

No consequential introduced correctness defect was established in the inspected Android changes.

Medium candidate — Clipboard inspection may contact endpoints before consent

app/src/main/java/to/bitkit/ui/utils/AutoReadClipboardHandler.kt:89–96 calls native decoding before the consent dialog. If native decoding resolves attacker-controlled LNURL or similar endpoints, that exposes network contact before consent. This call path is pre-existing; the shipped decoder's behavior was unavailable, so the concern is conditional and unconfirmed.

Low candidate — Removed ambiguity guard depends on the native artifact

The change delegates URI ambiguity rejection to Core rc13. Android's tests do not establish every singleton-key and concatenation variant, and the native artifact was not executed or independently verified. No concrete accepted ambiguous request was established.

Review details

General: GPT-6.1 Sol / high. Focused security: Moonshot Kimi K3 / high.

@coreyphillips coreyphillips left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rechecked after the branch was rewritten, so every earlier point was verified again from scratch. 1 blocking finding the reviewers disagree about.

addressed

  • Journey docs hard-code rc13 and a pre-merge instruction (journeys/send/README.md:3). Fixed: journeys/send/README.md no longer names a release or a merge step (searching journeys/ for rc13, 0.8.0, merging and adoption PR finds nothing), and journeys/send/bip21-core-validation.xml:2 now asks for a Core release that includes bitkit-core PR #151. I diffed the XML against the iOS twin head e9918a1 and they are byte-identical.

still open

  • Concatenated URI whose second half has no query now opens Send (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:4851). Removing Bip21Utils.isDuplicatedBip21 leaves core #151 as the only check, and core only flags an embedded URI when bitcoin: is followed by a valid address and a ? (value_embeds_bip21_uri in bitkit-core src/modules/scanner/implementation.rs at v0.8.0-rc13). For bitcoin:A?amount=0.001bitcoin:B, the single param is amount=0.001bitcoin:B. split_once('?') on B returns None, so it is not flagged. parse_amount_as_satoshis then fails and the amount becomes 0. handleScan gets Scanner.OnChain(address=A, amount=0) and onScanOnchain (AppViewModel.kt:5215) opens Send for A with no amount. Before this PR the substring guard rejected it with an error toast. Impact is low: Bitkit-built URIs always carry ? and URL-encode values, and the user pays the visible first address. It does narrow the PR's claim that concatenated URIs show an error, so it is worth a core follow-up or a note in the description. I confirmed this by tracing the rc13 core source. I did not run it on a device. Codex still sees it: An isolated rc13 parser check still returned the first recipient with zero sats, which app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:5427 routes to amount entry. The description now accurately documents this non-blocking limitation, but the behavior remains unchanged.
  • Concatenated URIs pass validation after bitcoin text in metadata (gradle/libs.versions.toml:24). Removing the guards allows concatenated payment URIs through when the first note already contains bitcoin:. Reproduce with: bitcoin:bcrt1qr289x0fhg62672e8urudfnxnsr8tcax64xk2vk?amount=0.000035&message=bitcoin:donationbitcoin:bcrt1qr289x0fhg62672e8urudfnxnsr8tcax64xk2vk?amount=0.00005 I executed the v0.8.0-rc13 scanner source in isolation. The existing regression fixtures passed, but this input returned Scanner.OnChain for 3,500 sats. value_embeds_bip21_uri checks only the first occurrence, so the benign prefix hides the later URI. Scanning and manual entry accept that successful result as a payment. The removed guard rejected this input. Codex still sees it: The isolated rc13 parser still accepted the supplied payload for the first recipient and 3,500 sats; app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:4900 still forwards that successful decode. The response documents a non-blocking Core deferral, but does not fix or disprove the reproduced behavior.

@pwltr

pwltr commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the clipboard finding from #1454 (review) in verified, signed pwltr commit 734405f. Automatic inspection now recognizes LNURL and Lightning Address candidates without calling Core, then keeps the existing confirmation/processing path. Bitcoin URI candidates still undergo local Core validation, including malformed BIP21 carrying LNURL metadata.

Validation against the published rc13 artifact: compile passed; 5,006 unit tests passed; lint passed; all four native tests passed. The new production-inspection loopback test observed zero connections before confirmation, while the explicit-native-decoding positive control contacted the same fixture once. This verifies the SDK network behavior rather than relying on mocks alone. The native-artifact concern is also covered by the existing BIP21 native tests and the prior 12-action journey; the known Core concatenation limitation remains explicitly deferred as agreed.

OS clipboard/dialog manual case 2 is documented separately and has not been run; the native probe is not claimed as that manual UI execution. No separate issue or Core PR was opened.

@pwltr

pwltr commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Recheck acknowledged: #1454 (review)

The queryless-second-URI case remains accurately documented under Decoder limitations, as the original finding requested; that note does not claim a parser fix. The first-occurrence/bitcoin:donation case is the same known Core limitation that pwltr explicitly directed us to keep outside these app PRs, already raised in Core #151 and tracked in synonymdev/bitkit-ios#1272. Both reproduced behaviors remain unfixed; the scope decision is not a technical rebuttal. Your blocking assessment of the latter remains a reviewer/owner disagreement. No new Core PR or workaround is being added under the current instructions.

This recheck targets b640f7b. Current head 734405f adds the separately requested offline clipboard-inspection fix and native network-boundary tests. It does not change the Core pin or either concatenation behavior. Local compile, 5,006 unit tests, lint and all four native tests passed; CI is running on that head.

@jvsena42 jvsena42 left a comment

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.

Code scan at 734405f93: two LOWs, inline. I reviewed this as a remote-input change: scanned, pasted and deep-linked BIP21 now go only through bitkit-core rc13's validation, and the clipboard is inspected before consent.

Checked and clean:

  • Guard removal: a core decode failure in handleScan reaches handleDecodedScan(null), which clears the incoming-request target, hides the sheet and toasts. resetSendState runs before the decode, so no earlier payment survives. Manual entry lands on InvalidAddressToast.
  • bitcoin: clipboard shortcut: any payload classified as bitcoin: reaches only core's offline branches (decode_lightning, decode_onchain, NodeId), never find_lnurl.
  • Double paste of a unified URI: refused by value_embeds_bip21_uri.
  • Removed DuplicatedBip21Toast: no consumers left here or in bitkit-e2e-tests main.
  • Behaviour changes, not findings: rc13 lowercases BIP21 keys, so all-caps unified QRs now prefill the amount and pick Lightning. Any lowercase email on the clipboard now prompts, as on iOS.
  • perf: not relevant; clipboard inspection makes fewer network calls than before.

rc11 → rc13 also brings core's cached BDK wallet behind onchain_compose_transaction, which hardware sends call (TrezorService.kt:227). I found no defect in it, and I'll drive hardware-wallet/send-onchain.xml in the gate. The PR body only mentions the Wake fixes; the compose cache is worth a line there too.

Both LOWs can be fixed here or moved to a follow-up issue, your choice. Please say which on each thread.

CI is green at 734405f93.

Device gate (partial): 734405f93 — not run yet; J1 send/bip21-core-validation.xml and hardware-wallet/send-onchain.xml (compose on rc13) are next. I'll post the result in a follow-up review.

Reviewer model: Claude Fable 5.2 (claude-fable-5-2), Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: not exposed

@pwltr

pwltr commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the interior-carriage-return HTTP-wrapper finding in signed pwltr commit 4492e2e. The issue was dynamically confirmed on the published rc13 Android binding: the prior production inspector invoked native decoding and sent one loopback HTTP request before confirmation. The matcher now uses an explicit non-LF character class rather than regex-engine-specific dot behavior.

Added app delegation and native regression fixtures for CR, NEL, U+2028 and U+2029, direct and wrapped inputs, plus an LF negative control. The fixed inspector makes zero requests; explicit native decoding still makes the expected requests against the same owned fixture. Compile, all 5,009 unit tests, lint and all five native tests passed. No skip in these Android suites. CI is running on the new head. The matching iOS case also reproduced and its fix is being validated in #909. Manual OS clipboard/dialog testing is still recorded separately as unrun; no Core change is involved.

@pwltr
pwltr force-pushed the codex/adopt-core-bip21-validation branch from 4492e2e to bc3dd46 Compare November 11, 2026 11:42
@pwltr

pwltr commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

The HTTP-wrapper fix was pushed, then a final status check found master had merged Spark with a new adjacent dependency-catalog entry, making #1454 conflict. Rebased onto 4f401bd while retaining Core rc13 and master’s Spark 0.28.0. New head bc3dd46; all seven PR commits are verified, signed and attributed to pwltr. No PR was merged by this update.

Fresh validation passed: compile, 5,300 unit tests (0 failures/errors/skips), lint, all five native tests (0 failures/errors/skips), and all 12 J1 actions on the same source tree. HTTP-wrapper privacy regression stays fixed with zero pre-confirmation requests; native positive controls still contact the fixture. No J1 payment sent. The body records current setup and evidence while preserving older results at their original revisions. Manual clipboard/dialog and Android hardware-send gaps remain recorded; the separately deferred Core parser limitation is unchanged. CI is starting on the new head.

@jvsena42 jvsena42 left a comment

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.

Device gate at bc3dd46e4: both journeys pass, and both of my LOWs are fixed (confirmed on the threads). Approving.

The delta since e136c24ca is a rebase onto master (including Spark), with context-only changes, plus bc3dd46e4. That commit narrows the http/bitcoin prefix in lnurlPattern to [^\n]*. Inputs it now matches are treated as supported without calling decode, which is the offline direction.

Journey Result
send/bip21-core-validation.xml Pass, all 12 actions. A doubled BIP21, amount+AMOUNT, and message+Message each show the ERROR "Decoding Error" toast and open no sheet. custom=bitcoin:… keeps the recipient and 3,500 sats.
hardware-wallet/send-onchain.xml (compose on core rc13) Pass, all 14 actions. Sent −10,141 (141 fee) once, with the Trezor's four approvals.

perf: compose (tap "Open Trezor Connect" → first Trezor prompt) took 8.2–9.3 / 7.1–8.3 s on this build vs 23.1–24.0 / 17.0–18.0 s on master 4f401bd3c, at host load 11–14. Core's cached wallet makes it about 2–3× faster.

Device gate: bc3dd46e4 — journeys: 2 passed; perf: compose 7–9 s (master 17–24 s); l10n: no UI text changed; iOS: synonymdev/bitkit-ios#909 is being gated now.

CI: build-and-test, lint and detekt pass; the e2e shards were still running.

Reviewer model: Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: not exposed

@ovitrif

ovitrif commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

@pwltr Merged, as it was approved and green.

@ovitrif
ovitrif merged commit b5e5148 into master Nov 11, 2026
23 checks passed
@ovitrif
ovitrif deleted the codex/adopt-core-bip21-validation branch November 11, 2026 13:45
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.

bug: valid bitcoin payment uris refused on scan

5 participants