Initial commit — federated self-custodial Spark/Lightning tip bot

- grammY bot: /start, /unlock, /tip, /contact, /claim, /settings, /wallet
- AES-256-GCM mnemonic encryption with scrypt key derivation
- In-memory unlock sessions with background sweep
- Atomic claim handling (TOCTOU-safe)
- PIN rate limiting (5 attempts → 15 min lockout)
- Fastify API server + Telegram Mini App (setup, unlock, send, receive, history)
- One-time seed reveal via Mini App or auto-deleted DM message
- Federated registry client
- Docker Compose deployment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
goyban
2026-05-03 13:21:43 +00:00
commit e857bf4ec6
40 changed files with 4689 additions and 0 deletions
+326
View File
@@ -0,0 +1,326 @@
const tg = window.Telegram.WebApp;
tg.ready();
tg.expand();
function walletApp() {
return {
// ── State ──────────────────────────────────────────────────────────────
tab: "dashboard",
botName: tg.initDataUnsafe?.bot?.username ?? "Wallet",
toastVisible: false,
wallet: {
registered: false,
locked: true,
balanceSats: 0,
sparkAddress: "",
unlockExpiresAt: null,
sessionPolicy: null,
},
// Setup (first launch, no wallet)
setup: {
pin: "",
confirmPin: "",
error: "",
creating: false,
},
// Seed reveal
seed: {
screen: false,
loading: false,
words: [],
error: "",
confirmed: false,
},
// PIN unlock overlay
showPinOverlay: false,
pin: "",
pinError: "",
unlocking: false,
// Send
send: {
destination: "",
amountSats: "",
description: "",
detectedType: "",
sending: false,
error: "",
success: "",
},
// Receive
receive: {
tab: "spark",
sparkAddress: "",
lightningInvoice: null,
onchainAddress: null,
amountSats: "",
},
// History
history: {
items: [],
loading: false,
limit: 20,
offset: 0,
},
// ── Init ───────────────────────────────────────────────────────────────
async init() {
if (!tg.initData) {
document.body.innerHTML = "<p style='padding:2rem;color:red'>Open this app from Telegram.</p>";
return;
}
// Seed reveal via one-time token (from bot onboarding link)
const params = new URLSearchParams(window.location.search);
const seedToken = params.get("seedToken");
if (seedToken && window.location.hash === "#seed") {
await this.revealSeed(seedToken);
return;
}
await this.refresh();
},
// ── API ────────────────────────────────────────────────────────────────
async api(method, path, body) {
const opts = {
method,
headers: {
"Content-Type": "application/json",
"X-Init-Data": tg.initData,
},
};
if (body) opts.body = JSON.stringify(body);
const res = await fetch(path, opts);
const data = await res.json();
if (!res.ok) throw new Error(data.error ?? "Request failed");
return data;
},
// ── Wallet state ───────────────────────────────────────────────────────
async refresh() {
try {
const data = await this.api("GET", "/api/wallet");
if (!data.registered) {
this.tab = "setup";
return;
}
this.wallet = data;
this.receive.sparkAddress = data.sparkAddress;
this.$nextTick(() => this.renderQr("qr-spark", data.sparkAddress));
} catch (e) {
console.error("refresh:", e.message);
}
},
// ── Setup — create wallet ──────────────────────────────────────────────
async createWallet() {
this.setup.error = "";
if (this.setup.pin.length < 6) {
this.setup.error = "PIN must be at least 6 characters.";
return;
}
if (this.setup.pin !== this.setup.confirmPin) {
this.setup.error = "PINs do not match.";
return;
}
this.setup.creating = true;
try {
const data = await this.api("POST", "/api/setup", { pin: this.setup.pin });
this.setup.pin = "";
this.setup.confirmPin = "";
// Show seed reveal screen immediately after creation
this.seed.words = data.words;
this.seed.screen = true;
this.seed.confirmed = false;
// Pre-load wallet state for after seed is dismissed
this.wallet.registered = true;
this.wallet.sparkAddress = data.sparkAddress;
this.receive.sparkAddress = data.sparkAddress;
} catch (e) {
this.setup.error = e.message;
} finally {
this.setup.creating = false;
}
},
// ── Seed reveal — via one-time URL token (from bot link) ───────────────
async revealSeed(token) {
this.seed.screen = true;
this.seed.loading = true;
try {
const data = await this.api("GET", `/api/seed/reveal?token=${encodeURIComponent(token)}`);
this.seed.words = data.words;
} catch (e) {
this.seed.error = e.message || "Link already used or expired.";
} finally {
this.seed.loading = false;
}
},
async closeSeedScreen() {
this.seed.words = [];
this.seed.screen = false;
this.seed.confirmed = false;
history.replaceState(null, "", window.location.pathname);
await this.refresh();
},
// ── Unlock / Lock ──────────────────────────────────────────────────────
async unlock() {
if (!this.pin) return;
this.unlocking = true;
this.pinError = "";
try {
await this.api("POST", "/api/unlock", { pin: this.pin });
this.showPinOverlay = false;
this.pin = "";
await this.refresh();
} catch (e) {
this.pinError = e.message;
} finally {
this.unlocking = false;
}
},
async lock() {
await this.api("POST", "/api/lock");
await this.refresh();
},
// ── Send ───────────────────────────────────────────────────────────────
detectType() {
const d = this.send.destination.trim().toLowerCase();
if (!d) { this.send.detectedType = ""; return; }
if (d.startsWith("lnbc") || d.startsWith("lntb") || d.startsWith("lnurl")) {
this.send.detectedType = "⚡ Lightning";
} else if (d.startsWith("spark1") || d.includes("@")) {
this.send.detectedType = "✳️ Spark";
} else {
this.send.detectedType = "₿ On-chain";
}
},
async sendPayment() {
this.send.error = "";
this.send.success = "";
if (!this.send.destination.trim()) { this.send.error = "Enter a destination."; return; }
this.send.sending = true;
try {
const body = {
destination: this.send.destination.trim(),
amountSats: this.send.amountSats ? parseInt(this.send.amountSats, 10) : undefined,
description: this.send.description || undefined,
};
const res = await this.api("POST", "/api/send", body);
this.send.success = `✅ Sent! Fee: ${res.feeSats} sats`;
this.send.destination = "";
this.send.amountSats = "";
this.send.description = "";
this.send.detectedType = "";
await this.refresh();
} catch (e) {
if (e.message === "wallet_locked") {
this.showPinOverlay = true;
} else {
this.send.error = e.message;
}
} finally {
this.send.sending = false;
}
},
// ── Receive ────────────────────────────────────────────────────────────
async loadReceive() {
const params = new URLSearchParams();
if (this.receive.amountSats) params.set("amount", this.receive.amountSats);
try {
const data = await this.api("GET", `/api/receive?${params}`);
this.receive.sparkAddress = data.sparkAddress;
this.receive.lightningInvoice = data.lightningInvoice;
this.receive.onchainAddress = data.onchainAddress;
this.$nextTick(() => {
this.renderQr("qr-spark", data.sparkAddress);
if (data.lightningInvoice) this.renderQr("qr-lightning", data.lightningInvoice);
if (data.onchainAddress) this.renderQr("qr-onchain", data.onchainAddress);
});
} catch (e) {
console.error("loadReceive:", e.message);
}
},
// ── History ────────────────────────────────────────────────────────────
async loadHistory() {
this.history.loading = true;
this.history.offset = 0;
try {
const data = await this.api("GET", `/api/history?limit=${this.history.limit}&offset=0`);
this.history.items = data.transactions;
} catch (e) {
console.error("loadHistory:", e.message);
} finally {
this.history.loading = false;
}
},
async loadMore() {
this.history.offset += this.history.limit;
try {
const data = await this.api("GET", `/api/history?limit=${this.history.limit}&offset=${this.history.offset}`);
this.history.items.push(...data.transactions);
} catch (e) {
console.error("loadMore:", e.message);
}
},
// ── QR ─────────────────────────────────────────────────────────────────
renderQr(canvasId, text) {
if (!text) return;
const canvas = document.getElementById(canvasId);
if (!canvas) return;
QRCode.toCanvas(canvas, text, { width: 220, margin: 2, color: { dark: "#000", light: "#fff" } });
},
// ── Helpers ────────────────────────────────────────────────────────────
satsToBtc(sats) { return (sats / 1e8).toFixed(8); },
formatExpiry(iso) {
if (!iso) return "";
return new Date(iso).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
},
formatDate(iso) {
if (!iso) return "";
const d = new Date(iso + "Z");
return d.toLocaleDateString([], { month: "short", day: "numeric" }) + " " +
d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
},
txIcon(status) {
return { done: "✅", failed: "❌", processing: "⏳", expired: "💨", awaiting_unlock: "🔒" }[status] ?? "•";
},
async copyText(text) {
try {
await navigator.clipboard.writeText(text);
this.toastVisible = true;
setTimeout(() => { this.toastVisible = false; }, 1500);
} catch {
tg.showAlert("Copy: " + text);
}
},
};
}
+333
View File
@@ -0,0 +1,333 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>Lightning Wallet</title>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.3/dist/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/qrcode@1.5.4/build/qrcode.min.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body x-data="walletApp()" x-init="init()" class="app">
<!-- ── Setup screen (no wallet yet) ─────────────────────────────────── -->
<div x-show="tab === 'setup'" class="setup-screen">
<div class="setup-inner">
<div class="setup-icon"></div>
<h1 class="setup-title">Create Your Wallet</h1>
<p class="setup-sub">
Choose a PIN to encrypt your wallet seed.<br>
Your PIN is never stored — only you know it.
</p>
<label class="field-label">PIN <span class="hint">(min 6 characters)</span></label>
<input
x-model="setup.pin"
type="password"
placeholder="Enter PIN"
class="field-input"
autocomplete="new-password"
@keydown.enter="$refs.confirmPin.focus()"
/>
<label class="field-label" style="margin-top:12px">Confirm PIN</label>
<input
x-ref="confirmPin"
x-model="setup.confirmPin"
type="password"
placeholder="Repeat PIN"
class="field-input"
autocomplete="new-password"
@keydown.enter="createWallet()"
/>
<div x-show="setup.error" class="error-msg" x-text="setup.error"></div>
<button
@click="createWallet()"
class="btn-primary btn-wide"
:disabled="setup.creating || !setup.pin || !setup.confirmPin"
style="margin-top:20px"
>
<span x-show="!setup.creating">Create Wallet</span>
<span x-show="setup.creating">Creating…</span>
</button>
</div>
</div>
<!-- ── Seed reveal screen ────────────────────────────────────────────── -->
<div x-show="seed.screen" class="seed-screen" x-transition>
<div x-show="seed.loading" class="seed-loading">Loading your recovery seed…</div>
<template x-if="seed.error">
<div class="seed-error-wrap">
<p class="seed-error-icon">⚠️</p>
<p class="seed-error-msg" x-text="seed.error"></p>
<p class="hint" style="margin-top:8px">Close this window and contact the bot.</p>
</div>
</template>
<template x-if="!seed.loading && !seed.error && seed.words.length">
<div class="seed-content">
<h1 class="seed-title">Your Recovery Seed</h1>
<p class="seed-subtitle">
Write these 12 words down on paper and store them offline.<br>
<strong>Anyone with these words can access your funds.</strong>
</p>
<ol class="seed-grid">
<template x-for="(word, i) in seed.words" :key="i">
<li class="seed-word">
<span class="seed-num" x-text="i + 1"></span>
<span class="seed-val" x-text="word"></span>
</li>
</template>
</ol>
<div class="seed-confirm-wrap">
<label class="seed-check">
<input type="checkbox" x-model="seed.confirmed" />
I have written down all 12 words in the correct order.
</label>
</div>
<button
@click="closeSeedScreen()"
class="btn-primary btn-wide"
:disabled="!seed.confirmed"
x-show="seed.confirmed"
x-transition
>
Done — open my wallet
</button>
</div>
</template>
</div>
<!-- ── PIN unlock overlay ───────────────────────────────────────────── -->
<div x-show="showPinOverlay" class="overlay" x-transition>
<div class="pin-card">
<h2 class="pin-title">Unlock Wallet</h2>
<p class="pin-hint">Enter your PIN to unlock</p>
<input
x-model="pin"
type="password"
placeholder="PIN"
class="pin-input"
@keydown.enter="unlock()"
/>
<div x-show="pinError" class="pin-error" x-text="pinError"></div>
<button @click="unlock()" class="btn-primary" :disabled="unlocking">
<span x-show="!unlocking">Unlock</span>
<span x-show="unlocking">Unlocking…</span>
</button>
</div>
</div>
<!-- ── Normal wallet UI (hidden during setup/seed screens) ──────────── -->
<template x-if="tab !== 'setup' && !seed.screen">
<div class="wallet-ui">
<!-- Header -->
<header class="header">
<span class="header-title" x-text="botName"></span>
<div class="lock-badge" :class="wallet.locked ? 'locked' : 'unlocked'">
<span x-text="wallet.locked ? '🔒 Locked' : '🔓 Unlocked'"></span>
</div>
</header>
<!-- Tab content -->
<main class="content">
<!-- Dashboard -->
<section x-show="tab === 'dashboard'" x-transition>
<div class="balance-card">
<div class="balance-label">Balance</div>
<div class="balance-amount">
<span x-text="wallet.locked ? '—' : wallet.balanceSats.toLocaleString()"></span>
<span class="balance-unit">sats</span>
</div>
<div class="balance-btc" x-show="!wallet.locked">
<span x-text="satsToBtc(wallet.balanceSats)"></span> BTC
</div>
<div x-show="wallet.locked" class="unlock-prompt">
<button @click="showPinOverlay = true" class="btn-primary">Unlock to see balance</button>
</div>
</div>
<div class="quick-actions">
<button @click="tab = 'send'" class="quick-btn">
<span class="quick-icon"></span><span>Send</span>
</button>
<button @click="tab = 'receive'; loadReceive()" class="quick-btn">
<span class="quick-icon"></span><span>Receive</span>
</button>
<button @click="tab = 'history'; loadHistory()" class="quick-btn">
<span class="quick-icon">🕐</span><span>History</span>
</button>
</div>
<div x-show="!wallet.locked" class="address-row">
<div class="address-label">Spark address</div>
<div class="address-value" x-text="wallet.sparkAddress" @click="copyText(wallet.sparkAddress)"></div>
</div>
<div x-show="!wallet.locked" class="session-info">
<button @click="lock()" class="btn-secondary btn-sm">Lock wallet</button>
<span class="hint" x-show="wallet.unlockExpiresAt">
Expires <span x-text="formatExpiry(wallet.unlockExpiresAt)"></span>
</span>
</div>
</section>
<!-- Send -->
<section x-show="tab === 'send'" x-transition>
<h2 class="section-title">Send</h2>
<div x-show="wallet.locked" class="lock-notice">
<p>Wallet is locked.</p>
<button @click="showPinOverlay = true" class="btn-primary">Unlock</button>
</div>
<template x-if="!wallet.locked">
<div>
<label class="field-label">Destination</label>
<textarea
x-model="send.destination"
placeholder="Lightning invoice / Spark address / Bitcoin address"
class="field-textarea"
rows="3"
@input="detectType()"
></textarea>
<div x-show="send.detectedType" class="type-badge" x-text="send.detectedType"></div>
<template x-if="send.detectedType !== '⚡ Lightning'">
<div>
<label class="field-label">Amount (sats)</label>
<input x-model="send.amountSats" type="number" placeholder="0" class="field-input" min="1" />
</div>
</template>
<label class="field-label">Note (optional)</label>
<input x-model="send.description" type="text" placeholder="For coffee…" class="field-input" />
<div x-show="send.error" class="error-msg" x-text="send.error"></div>
<div x-show="send.success" class="success-msg" x-text="send.success"></div>
<button @click="sendPayment()" class="btn-primary btn-wide" :disabled="send.sending || !send.destination">
<span x-show="!send.sending">Send ⚡</span>
<span x-show="send.sending">Sending…</span>
</button>
</div>
</template>
</section>
<!-- Receive -->
<section x-show="tab === 'receive'" x-transition>
<h2 class="section-title">Receive</h2>
<div class="receive-tabs">
<template x-for="t in ['spark', 'lightning', 'onchain']" :key="t">
<button
@click="receive.tab = t; loadReceive()"
class="receive-tab"
:class="{ active: receive.tab === t }"
x-text="t.charAt(0).toUpperCase() + t.slice(1)"
></button>
</template>
</div>
<div x-show="receive.tab === 'spark'">
<div class="qr-wrap"><canvas id="qr-spark"></canvas></div>
<div class="address-copy" x-text="receive.sparkAddress" @click="copyText(receive.sparkAddress)"></div>
<p class="hint">Tap to copy. Works for Spark-to-Spark payments.</p>
</div>
<div x-show="receive.tab === 'lightning'">
<div x-show="wallet.locked" class="lock-notice">
<button @click="showPinOverlay = true" class="btn-primary">Unlock to generate invoice</button>
</div>
<template x-if="!wallet.locked">
<div>
<label class="field-label">Amount (sats, leave blank for any)</label>
<input x-model="receive.amountSats" type="number" placeholder="0" class="field-input" min="1" />
<button @click="loadReceive()" class="btn-secondary" style="margin-top:8px">Generate Invoice</button>
<template x-if="receive.lightningInvoice">
<div>
<div class="qr-wrap"><canvas id="qr-lightning"></canvas></div>
<div class="address-copy invoice-text" x-text="receive.lightningInvoice" @click="copyText(receive.lightningInvoice)"></div>
</div>
</template>
</div>
</template>
</div>
<div x-show="receive.tab === 'onchain'">
<div x-show="wallet.locked" class="lock-notice">
<button @click="showPinOverlay = true" class="btn-primary">Unlock to get address</button>
</div>
<template x-if="!wallet.locked && receive.onchainAddress">
<div>
<div class="qr-wrap"><canvas id="qr-onchain"></canvas></div>
<div class="address-copy" x-text="receive.onchainAddress" @click="copyText(receive.onchainAddress)"></div>
<p class="hint">On-chain deposits may take 16 confirmations.</p>
</div>
</template>
</div>
</section>
<!-- History -->
<section x-show="tab === 'history'" x-transition>
<h2 class="section-title">History</h2>
<div x-show="history.loading" class="hint">Loading…</div>
<div x-show="!history.loading && history.items.length === 0" class="hint">No transactions yet.</div>
<ul class="tx-list">
<template x-for="tx in history.items" :key="tx.id">
<li class="tx-item">
<div class="tx-left">
<span class="tx-icon" x-text="txIcon(tx.status)"></span>
<div>
<div class="tx-amount" x-text="tx.amount_sats.toLocaleString() + ' sats'"></div>
<div class="tx-dest" x-text="tx.recipient_address ? tx.recipient_address.slice(0, 30) + '…' : 'unknown'"></div>
</div>
</div>
<div class="tx-right">
<div class="tx-status" :class="'status-' + tx.status" x-text="tx.status"></div>
<div class="tx-date" x-text="formatDate(tx.created_at)"></div>
</div>
</li>
</template>
</ul>
<button x-show="history.items.length >= history.limit" @click="loadMore()" class="btn-secondary btn-wide">Load more</button>
</section>
</main>
<!-- Bottom tab bar -->
<nav class="tab-bar">
<button @click="tab = 'dashboard'; refresh()" class="tab-btn" :class="{ active: tab === 'dashboard' }">
<span class="tab-icon">💼</span><span class="tab-label">Wallet</span>
</button>
<button @click="tab = 'send'" class="tab-btn" :class="{ active: tab === 'send' }">
<span class="tab-icon"></span><span class="tab-label">Send</span>
</button>
<button @click="tab = 'receive'; loadReceive()" class="tab-btn" :class="{ active: tab === 'receive' }">
<span class="tab-icon"></span><span class="tab-label">Receive</span>
</button>
<button @click="tab = 'history'; loadHistory()" class="tab-btn" :class="{ active: tab === 'history' }">
<span class="tab-icon">🕐</span><span class="tab-label">History</span>
</button>
</nav>
</div>
</template>
<div class="toast" x-show="toastVisible" x-transition>Copied!</div>
<script src="app.js"></script>
</body>
</html>
+471
View File
@@ -0,0 +1,471 @@
/* Telegram theme variables with fallbacks for browser testing */
:root {
--bg: var(--tg-theme-bg-color, #ffffff);
--secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
--text: var(--tg-theme-text-color, #111111);
--hint: var(--tg-theme-hint-color, #888888);
--link: var(--tg-theme-link-color, #2481cc);
--btn-bg: var(--tg-theme-button-color, #2481cc);
--btn-text: var(--tg-theme-button-text-color, #ffffff);
--accent: #f7931a; /* Bitcoin orange */
--radius: 12px;
--safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body.app {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100dvh;
display: flex;
flex-direction: column;
font-size: 15px;
}
/* ── Header ──────────────────────────────────────────────────────────── */
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
background: var(--secondary-bg);
position: sticky;
top: 0;
z-index: 10;
}
.header-title { font-weight: 600; font-size: 16px; }
.lock-badge {
font-size: 12px;
padding: 4px 10px;
border-radius: 20px;
font-weight: 500;
}
.lock-badge.locked { background: #fee; color: #c00; }
.lock-badge.unlocked { background: #efe; color: #060; }
/* ── Content ─────────────────────────────────────────────────────────── */
.content {
flex: 1;
overflow-y: auto;
padding: 16px 16px calc(70px + var(--safe-bottom));
}
.section-title {
font-size: 18px;
font-weight: 600;
margin-bottom: 16px;
}
/* ── Balance card ────────────────────────────────────────────────────── */
.balance-card {
background: var(--btn-bg);
color: var(--btn-text);
border-radius: var(--radius);
padding: 24px 20px;
margin-bottom: 20px;
text-align: center;
}
.balance-label { font-size: 13px; opacity: .8; margin-bottom: 6px; }
.balance-amount {
font-size: 36px;
font-weight: 700;
letter-spacing: -1px;
}
.balance-unit { font-size: 18px; font-weight: 400; margin-left: 4px; }
.balance-btc { font-size: 13px; opacity: .7; margin-top: 4px; }
.unlock-prompt { margin-top: 16px; }
/* ── Quick actions ───────────────────────────────────────────────────── */
.quick-actions {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
margin-bottom: 20px;
}
.quick-btn {
background: var(--secondary-bg);
border: none;
border-radius: var(--radius);
padding: 16px 8px;
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
font-size: 13px;
color: var(--text);
cursor: pointer;
transition: opacity .15s;
}
.quick-btn:active { opacity: .7; }
.quick-icon { font-size: 22px; }
/* ── Address row ─────────────────────────────────────────────────────── */
.address-row {
background: var(--secondary-bg);
border-radius: var(--radius);
padding: 14px;
margin-bottom: 12px;
}
.address-label { font-size: 11px; color: var(--hint); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.address-value {
font-family: monospace;
font-size: 13px;
word-break: break-all;
cursor: pointer;
color: var(--link);
}
/* ── Session info ────────────────────────────────────────────────────── */
.session-info {
display: flex;
align-items: center;
gap: 12px;
margin-top: 4px;
}
.hint { font-size: 12px; color: var(--hint); }
/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
background: var(--btn-bg);
color: var(--btn-text);
border: none;
border-radius: var(--radius);
padding: 13px 22px;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: opacity .15s;
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { opacity: .85; }
.btn-secondary {
background: var(--secondary-bg);
color: var(--text);
border: none;
border-radius: var(--radius);
padding: 10px 18px;
font-size: 14px;
cursor: pointer;
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-wide { width: 100%; margin-top: 16px; }
/* ── Form fields ─────────────────────────────────────────────────────── */
.field-label {
display: block;
font-size: 13px;
color: var(--hint);
margin: 14px 0 6px;
}
.field-input, .field-textarea {
width: 100%;
background: var(--secondary-bg);
color: var(--text);
border: none;
border-radius: var(--radius);
padding: 12px 14px;
font-size: 15px;
resize: none;
outline: none;
}
.field-textarea { line-height: 1.4; }
.type-badge {
font-size: 12px;
color: var(--hint);
margin: 6px 0 0 2px;
}
.error-msg { color: #c00; font-size: 13px; margin-top: 10px; }
.success-msg { color: #060; font-size: 13px; margin-top: 10px; }
/* ── Lock notice ─────────────────────────────────────────────────────── */
.lock-notice {
background: var(--secondary-bg);
border-radius: var(--radius);
padding: 24px;
text-align: center;
}
.lock-notice p { color: var(--hint); margin-bottom: 14px; }
/* ── Receive tabs ────────────────────────────────────────────────────── */
.receive-tabs {
display: flex;
gap: 8px;
margin-bottom: 20px;
}
.receive-tab {
flex: 1;
padding: 9px;
border: none;
border-radius: 8px;
background: var(--secondary-bg);
color: var(--hint);
font-size: 14px;
cursor: pointer;
transition: all .15s;
}
.receive-tab.active {
background: var(--btn-bg);
color: var(--btn-text);
font-weight: 600;
}
/* ── QR ──────────────────────────────────────────────────────────────── */
.qr-wrap {
display: flex;
justify-content: center;
margin: 16px 0;
background: #fff;
border-radius: var(--radius);
padding: 16px;
}
.address-copy {
font-family: monospace;
font-size: 12px;
word-break: break-all;
background: var(--secondary-bg);
border-radius: 8px;
padding: 10px 12px;
cursor: pointer;
color: var(--link);
margin-bottom: 8px;
}
.invoice-text { font-size: 10px; }
/* ── Transaction list ────────────────────────────────────────────────── */
.tx-list { list-style: none; }
.tx-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 14px 0;
border-bottom: 1px solid var(--secondary-bg);
}
.tx-left { display: flex; align-items: center; gap: 12px; }
.tx-icon { font-size: 20px; width: 28px; text-align: center; }
.tx-amount { font-weight: 600; font-size: 15px; }
.tx-dest { font-size: 12px; color: var(--hint); margin-top: 2px; font-family: monospace; }
.tx-right { text-align: right; }
.tx-status {
font-size: 11px;
padding: 2px 8px;
border-radius: 10px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: .3px;
}
.status-done { background: #efe; color: #060; }
.status-failed { background: #fee; color: #c00; }
.status-processing { background: #fef; color: #606; }
.status-expired { background: var(--secondary-bg); color: var(--hint); }
.status-awaiting_unlock { background: #ffe; color: #660; }
.tx-date { font-size: 11px; color: var(--hint); margin-top: 4px; }
/* ── Bottom tab bar ──────────────────────────────────────────────────── */
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: var(--secondary-bg);
display: flex;
padding-bottom: var(--safe-bottom);
border-top: 1px solid rgba(0,0,0,.08);
z-index: 20;
}
.tab-btn {
flex: 1;
background: none;
border: none;
padding: 10px 4px 8px;
display: flex;
flex-direction: column;
align-items: center;
gap: 3px;
cursor: pointer;
color: var(--hint);
transition: color .15s;
}
.tab-btn.active { color: var(--btn-bg); }
.tab-icon { font-size: 20px; }
.tab-label { font-size: 11px; font-weight: 500; }
/* ── PIN overlay ─────────────────────────────────────────────────────── */
.overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,.5);
display: flex;
align-items: flex-end;
z-index: 100;
}
.pin-card {
width: 100%;
background: var(--bg);
border-radius: var(--radius) var(--radius) 0 0;
padding: 28px 24px calc(24px + var(--safe-bottom));
display: flex;
flex-direction: column;
gap: 14px;
}
.pin-title { font-size: 20px; font-weight: 700; text-align: center; }
.pin-hint { font-size: 14px; color: var(--hint); text-align: center; }
.pin-input {
width: 100%;
background: var(--secondary-bg);
color: var(--text);
border: none;
border-radius: var(--radius);
padding: 14px;
font-size: 20px;
text-align: center;
letter-spacing: 4px;
outline: none;
}
.pin-error { font-size: 13px; color: #c00; text-align: center; }
/* ── Wallet UI wrapper (hides during setup/seed) ─────────────────────── */
.wallet-ui {
display: flex;
flex-direction: column;
min-height: 100dvh;
}
/* ── Setup screen ────────────────────────────────────────────────────── */
.setup-screen {
min-height: 100dvh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px 20px calc(24px + var(--safe-bottom));
}
.setup-inner {
width: 100%;
max-width: 360px;
display: flex;
flex-direction: column;
gap: 4px;
}
.setup-icon {
font-size: 52px;
text-align: center;
margin-bottom: 8px;
}
.setup-title {
font-size: 26px;
font-weight: 800;
text-align: center;
color: var(--text);
margin-bottom: 4px;
}
.setup-sub {
font-size: 14px;
color: var(--hint);
text-align: center;
line-height: 1.5;
margin-bottom: 12px;
}
/* ── Seed reveal screen ──────────────────────────────────────────────── */
.seed-screen {
position: fixed;
inset: 0;
background: var(--bg);
z-index: 300;
overflow-y: auto;
padding: 24px 20px calc(32px + var(--safe-bottom));
display: flex;
flex-direction: column;
}
.seed-loading {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
color: var(--hint);
font-size: 15px;
}
.seed-error-wrap {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: 12px;
}
.seed-error-icon { font-size: 48px; }
.seed-error-msg { color: #c00; font-size: 15px; }
.seed-content { display: flex; flex-direction: column; gap: 20px; }
.seed-title {
font-size: 24px;
font-weight: 800;
text-align: center;
color: var(--text);
}
.seed-subtitle {
font-size: 14px;
color: var(--hint);
text-align: center;
line-height: 1.5;
}
.seed-subtitle strong { color: #c00; }
.seed-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
list-style: none;
padding: 0;
margin: 0;
}
.seed-word {
display: flex;
align-items: center;
gap: 8px;
background: var(--secondary-bg);
border-radius: 8px;
padding: 10px 12px;
}
.seed-num {
font-size: 11px;
color: var(--hint);
min-width: 18px;
text-align: right;
font-weight: 600;
}
.seed-val {
font-family: monospace;
font-size: 15px;
font-weight: 700;
color: var(--text);
letter-spacing: .5px;
}
.seed-confirm-wrap {
background: var(--secondary-bg);
border-radius: var(--radius);
padding: 16px;
}
.seed-check {
display: flex;
align-items: flex-start;
gap: 12px;
font-size: 14px;
line-height: 1.4;
cursor: pointer;
}
.seed-check input { margin-top: 2px; width: 18px; height: 18px; flex-shrink: 0; }
/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
position: fixed;
bottom: calc(75px + var(--safe-bottom));
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,.8);
color: #fff;
border-radius: 20px;
padding: 8px 18px;
font-size: 13px;
z-index: 200;
pointer-events: none;
}