Jade connection#39
Open
lilbonekit wants to merge 6 commits into
Open
Conversation
…asm on beforeunload
ardier16
requested changes
May 18, 2026
There was a problem hiding this comment.
Pull request overview
Implements Jade hardware wallet integration in web-v2, adding a wallet context/provider that can connect via WebSerial, derive an address, sync balances via LWK/Esplora, and sign + broadcast PSETs; also adds a debug mnemonic-backed connector for dev/test.
Changes:
- Added wallet infrastructure:
WalletProvider,WalletContext,useWallet, session persistence, and periodic balance syncing. - Implemented connectors:
JadeConnector(WebSerial / Jade WASM) andSeedConnector(env-gated debug signer). - Added dashboard demo UI and new env/config plumbing (waterfalls Esplora client, env templates, tx confirmation polling).
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| web-v2/src/types/web-serial.d.ts | Adds minimal ambient Web Serial types for USB connect/disconnect detection. |
| web-v2/src/providers/wallet/WalletProvider.tsx | Core wallet lifecycle: connect/disconnect, polling, session persistence, balance sync, sign+broadcast. |
| web-v2/src/providers/wallet/WalletContext.ts | Wallet context initialization sentinel + context object. |
| web-v2/src/providers/wallet/useWallet.ts | Hook wrapper with “must be used within provider” guard. |
| web-v2/src/providers/wallet/types.ts | Wallet state/session/context types and initial state. |
| web-v2/src/providers/lwk/LwkProvider.tsx | Minor formatting-only change. |
| web-v2/src/providers/AppProviders.tsx | Adds WalletProvider into the app provider composition. |
| web-v2/src/pages/Dashboard/WalletDemo.tsx | Demo UI to connect Jade, show address/balances, verify address, send LBTC, and poll confirmations. |
| web-v2/src/pages/Dashboard/index.tsx | Replaces old LWK demo content with the wallet demo. |
| web-v2/src/lwk/index.ts | Adds createEsploraClient configured for waterfalls/utxoOnly scanning. |
| web-v2/src/lib/wallet-core/wallet/sync.ts | Adds syncBalances() helper (full scan + apply update + balance map). |
| web-v2/src/lib/wallet-core/types.ts | Adds wallet types and connection status modeling. |
| web-v2/src/lib/wallet-core/connector/types.ts | Defines WalletConnector interface for hardware/software connectors. |
| web-v2/src/lib/wallet-core/connector/seed.ts | Debug mnemonic-backed software signer connector. |
| web-v2/src/lib/wallet-core/connector/jade.ts | Jade hardware wallet connector (descriptor, signPset, verify receive address). |
| web-v2/src/hooks/useSessionStorage.ts | Small hook for sessionStorage persistence used by wallet sessions. |
| web-v2/src/constants/env.ts | Adds waterfalls + recipient + debug mnemonic env vars and adjusts defaults. |
| web-v2/src/api/esplora/methods.ts | Adds tx status + confirmation-count helpers for the demo. |
| web-v2/.env.liquidtestnet | Adds a testnet env preset including waterfalls config (+ debug mnemonic comment). |
| web-v2/.env.liquid | Adds a mainnet env preset including waterfalls config. |
| web-v2/.env.example | Updates example env with waterfalls config and debug mnemonic documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+41
| /** Last error message. Persists even after isError is cleared. */ | ||
| error: string | null | ||
| /** Whether the error should be shown to the user. Cleared on reconnect or new connect attempt. */ |
Comment on lines
+176
to
+180
| } catch (err) { | ||
| const error = err instanceof Error ? err.message : String(err) | ||
| sessionRef.current = null | ||
| // USB may still be plugged in even if connect() failed, so preserve usbDeviceDetected. | ||
| setState(s => ({ |
Comment on lines
+137
to
+140
| const connector: WalletConnector = env.VITE_DEBUG_MNEMONIC | ||
| ? new SeedConnector(lwk, lwkNetwork, env.VITE_DEBUG_MNEMONIC) | ||
| : new JadeConnector(lwk, lwkNetwork) | ||
|
|
Comment on lines
+9
to
+13
| VITE_WATERFALLS_URL: z.string().url(), | ||
| VITE_WATERFALLS_RECIPIENT: z | ||
| .string() | ||
| .default('age1xxzrgrfjm3yrwh3u6a7exgrldked0pdauvr3mx870wl6xzrwm5ps8s2h0p'), | ||
| VITE_DEBUG_MNEMONIC: z.string().optional().default(''), |
Comment on lines
+83
to
+89
| const handleVerifyAddress = async () => { | ||
| setVerifyingAddress(true) | ||
| console.warn('[Dashboard] handleVerifyAddress: requesting address verification on device...') | ||
| try { | ||
| const addr = await verifyReceiveAddress() | ||
| console.warn('[Dashboard] handleVerifyAddress: device confirmed address →', addr) | ||
| } catch (err) { |
| ...INITIAL_WALLET_STATE, | ||
| ...(error !== undefined ? { error, isError: true } : {}), | ||
| })) | ||
| window.location.reload() |
Comment on lines
+100
to
+103
| console.warn('[Dashboard] handleSend: start', { sendAddress, sendAmount }) | ||
| try { | ||
| const txid = await sendLbtc(sendAddress, BigInt(sendAmount)) | ||
| console.warn('[Dashboard] handleSend: txid received', txid) |
Comment on lines
+15
to
+18
| if (newValue === null) { | ||
| sessionStorage.removeItem(key) | ||
| } else { | ||
| sessionStorage.setItem(key, JSON.stringify(newValue)) |
| session.connector | ||
| .getConnectionStatus() | ||
| .then(status => { | ||
| if (status === 'locked') window.location.reload() // to prompt for PIN again and avoid serial port conflicts |
ardier16
approved these changes
May 21, 2026
| } | ||
|
|
||
| export interface SavedSession { | ||
| efuseMac: string | null |
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.
Closes #24