Skip to content

Support bch-wif: protohandler for sweeping CashStamps - #452

Merged
j0ntz merged 1 commit into
masterfrom
jon/bch-wif-sweep
Jul 13, 2026
Merged

Support bch-wif: protohandler for sweeping CashStamps#452
j0ntz merged 1 commit into
masterfrom
jon/bch-wif-sweep

Conversation

@j0ntz

@j0ntz j0ntz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

Asana task

Support sweeping CashStamps, which encode their private key as bch-wif:${WIF} — a normal WIF with a bch-wif: protohandler prefix. Edge already supports sweeping a bare WIF, but parseUri rejected anything with an unrecognized URI scheme, so bch-wif:... threw InvalidUriError and the sweep never started.

parseUri now strips a leading <currencyCode>-wif: prefix (e.g. bch-wif: for BCH) before parsing, so the remaining bare WIF flows through the existing private-key detection in parsePathname and the standard sweep path. The prefix is derived from the wallet's own currency code, so it can only ever match its own coin. A bare WIF and all other URIs are unaffected.

No GUI change is required: the app's sweep flow already consumes parsedUri.privateKeys.

Token (CashToken) sweeping is intentionally out of scope here — it depends on broader CashToken support that is still incoming — and is left as a follow-up.

Tests: added parseUri fixtures for the BCH plugin covering bch-wif: (compressed, non-compressed, and uppercase-prefix) → { privateKeys: [<bare WIF>] }.

Verified end-to-end on iOS sim against the patched plugin (DEBUG_CURRENCY_PLUGINS dev-server): entering bch-wif:<WIF> in Scan → Enter is recognized as a BCH private key (wallet picker filtered to BCH), advances to the "Sweep Funds From Private Key" modal, and on confirm the sweep executes against the key (returning "Private key has no funds" for the empty test WIF). Screenshots attached.


Note

Low Risk
Small, early guard in URI parsing that reuses existing WIF sweep logic; no changes to signing or broadcast.

Overview
parseUri in shared CurrencyTools now removes a leading <currencyCode>-wif: prefix (e.g. bch-wif:) before URI parsing, so CashStamps-style strings no longer hit InvalidUriError and the bare WIF is handled by existing parsePathname private-key detection. Matching is scoped to each plugin’s own currency code (case-insensitive on the prefix).

BCH parseUri fixtures were added for compressed, non-compressed, and uppercase-prefix bch-wif: inputs. CHANGELOG documents the feature under Unreleased.

Reviewed by Cursor Bugbot for commit 89b8321. Bugbot is set up for automated code reviews on this repo. Configure here.

@j0ntz

j0ntz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (iOS sim, DEBUG_CURRENCY_PLUGINS)

agent proof 1215306367142288 01 bchwif recognized wallet picker

agent proof 1215306367142288 01 bchwif recognized wallet picker

agent proof 1215306367142288 02 sweep from private key modal

agent proof 1215306367142288 02 sweep from private key modal

agent proof 1215306367142288 03 sweep executed no funds

agent proof 1215306367142288 03 sweep executed no funds

Captured by the agent's in-app test run (build-and-test).

@j0ntz

j0ntz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

📸 Funded CashStamp sweep — full end-to-end (real on-chain BCH)

agent proof 1215306367142288 04 cashstamp funded

agent proof 1215306367142288 04 cashstamp funded

agent proof 1215306367142288 05 cashstamp swept success

agent proof 1215306367142288 05 cashstamp swept success

Captured by the agent's in-app test run (build-and-test).

@j0ntz

j0ntz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: verified the full funded sweep end-to-end (real on-chain BCH), not just recognition.

A genuine CashStamp key was generated (m/44'/145'-style P2PKH, same construction CashStamps uses), funded with 0.005159 BCH ($1.00) from a test wallet, then swept in-app via bch-wif:<WIF>:

  • Funding tx: c8861e0e8fbbad81f5da09e3ac9b503aff84099e3535ad53e7ef66ccffae23ce
  • Sweep tx: f699a34b9b414c7d38b66d37da3e5d5dcf3ca51b9e53b42b84d5879bb83931e2
  • Result: 0.00515132 BCH received at the sweep success scene; the stamp address is drained to 0 on-chain.

This exercises the complete CashStamps path: bch-wif: parse → private-key recognition → sweep execution → broadcast → funds received. Screenshots above (funded → swept success).

@j0ntz
j0ntz enabled auto-merge July 13, 2026 17:57
CashStamps encode their private key as bch-wif:<WIF>. Strip the
<code>-wif: protohandler prefix in parseUri so the existing
private-key sweep flow handles it. The prefix is derived from the
wallet's own currency code, so it can only ever match this coin.
@j0ntz
j0ntz force-pushed the jon/bch-wif-sweep branch from 99dd63a to 89b8321 Compare July 13, 2026 21:35
@j0ntz
j0ntz merged commit 740eddb into master Jul 13, 2026
4 checks passed
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.

2 participants