Skip to content

Jade connection#39

Open
lilbonekit wants to merge 6 commits into
devfrom
feature/jade-connect
Open

Jade connection#39
lilbonekit wants to merge 6 commits into
devfrom
feature/jade-connect

Conversation

@lilbonekit
Copy link
Copy Markdown
Collaborator

@lilbonekit lilbonekit commented May 15, 2026

Closes #24

@lilbonekit lilbonekit changed the base branch from main to dev May 15, 2026 18:10
@lilbonekit lilbonekit requested a review from ardier16 as a code owner May 15, 2026 18:10
@lilbonekit lilbonekit removed request for Arvolear and Hrom131 May 15, 2026 18:12
Comment thread web-v2/.env.example Outdated
Comment thread web-v2/.env.liquid Outdated
Comment thread web-v2/src/pages/Dashboard/index.tsx Outdated
Comment thread web-v2/src/constants/env.ts Outdated
Comment thread web-v2/src/lib/wallet-core/wallet/session.ts Outdated
Comment thread web-v2/src/providers/wallet/WalletProvider.tsx Outdated
Comment thread web-v2/src/providers/wallet/WalletProvider.tsx Outdated
Comment thread web-v2/src/providers/wallet/WalletProvider.tsx Outdated
Comment thread web-v2/src/providers/wallet/WalletProvider.tsx Outdated
Comment thread web-v2/src/providers/wallet/WalletProvider.tsx Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) and SeedConnector (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
}

export interface SavedSession {
efuseMac: string | null
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

efuseMac -> connectorId

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.

3 participants