feat: add React web frontend with dark Electrum-like UI
- Vite + React app with dark Bitcoin-orange theme - HD Wallet: generate, display seed/xpub/addresses, save with encryption - Single addresses: P2PKH, P2WPKH, P2TR, P2PK, P2SH (multisig) - Decrypt: load encrypted JSON wallet and reveal private data - Bitcoin SVG icon in public/icons/ - Vite proxy /api → localhost:8000
This commit is contained in:
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
16
frontend/README.md
Normal file
16
frontend/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# React + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
||||
29
frontend/eslint.config.js
Normal file
29
frontend/eslint.config.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{js,jsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: { jsx: true },
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
||||
},
|
||||
},
|
||||
])
|
||||
13
frontend/index.html
Normal file
13
frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/icons/bitcoin.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Bitcoin Address Generator</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
4217
frontend/package-lock.json
generated
Normal file
4217
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
frontend/package.json
Normal file
26
frontend/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "bitcoin-address-generator",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"vite": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^16.5.0",
|
||||
"vite": "^7.3.1"
|
||||
}
|
||||
}
|
||||
10
frontend/public/icons/bitcoin.svg
Normal file
10
frontend/public/icons/bitcoin.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<!-- Background circle -->
|
||||
<circle cx="32" cy="32" r="32" fill="#F7931A"/>
|
||||
<!-- Bitcoin B symbol -->
|
||||
<path fill="#FFFFFF" d="
|
||||
M46.5 28.2c0.6-4.1-2.5-6.3-6.8-7.8l1.4-5.6-3.4-0.8-1.3 5.4c-0.9-0.2-1.8-0.4-2.7-0.6l1.3-5.5-3.4-0.8-1.4 5.6c-0.7-0.2-1.5-0.3-2.2-0.5l0-0.1-4.7-1.2-0.9 3.7s2.5 0.6 2.4 0.6c1.4 0.3 1.6 1.2 1.6 1.9l-1.6 6.5c0.1 0 0.2 0.1 0.3 0.1-0.1 0-0.2-0.1-0.4-0.1l-2.3 9.1c-0.2 0.4-0.6 1.1-1.6 0.8 0 0.1-2.4-0.6-2.4-0.6l-1.7 3.9 4.5 1.1c0.8 0.2 1.6 0.4 2.4 0.6l-1.4 5.7 3.4 0.8 1.4-5.6c0.9 0.2 1.9 0.5 2.8 0.7l-1.4 5.5 3.4 0.8 1.4-5.7c5.9 1.1 10.3 0.7 12.1-4.6 1.5-4.3-0.1-6.8-3.2-8.4C44.5 33.3 46.1 31.4 46.5 28.2z
|
||||
M40.1 38.9c-1.1 4.2-8.3 2-10.7 1.4l1.9-7.6C33.7 33.3 41.2 34.5 40.1 38.9z
|
||||
M41.2 28.1c-1 3.9-7 1.9-9 1.4l1.7-6.9C35.9 23.1 42.2 24.1 41.2 28.1z
|
||||
"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 863 B |
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
27
frontend/src/App.jsx
Normal file
27
frontend/src/App.jsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useState } from 'react'
|
||||
import Sidebar from './components/Sidebar'
|
||||
import HDWallet from './components/HDWallet'
|
||||
import SingleAddress from './components/SingleAddress'
|
||||
import DecryptWallet from './components/DecryptWallet'
|
||||
|
||||
const SINGLE_ADDRESS_PAGES = ['p2pkh', 'p2wpkh', 'p2tr', 'p2pk', 'p2sh']
|
||||
|
||||
export default function App() {
|
||||
const [page, setPage] = useState('hd')
|
||||
|
||||
const renderPage = () => {
|
||||
if (page === 'hd') return <HDWallet />
|
||||
if (SINGLE_ADDRESS_PAGES.includes(page)) return <SingleAddress initialTab={page} key={page} />
|
||||
if (page === 'decrypt') return <DecryptWallet />
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<Sidebar active={page} onSelect={setPage} />
|
||||
<main className="main">
|
||||
{renderPage()}
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
frontend/src/assets/react.svg
Normal file
1
frontend/src/assets/react.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
18
frontend/src/components/CopyButton.jsx
Normal file
18
frontend/src/components/CopyButton.jsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
export default function CopyButton({ text, label = 'Copy' }) {
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
const handle = () => {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 1500)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<button className="btn btn-ghost btn-icon" onClick={handle} title="Copy to clipboard">
|
||||
{copied ? '✓' : '⎘'}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
171
frontend/src/components/DecryptWallet.jsx
Normal file
171
frontend/src/components/DecryptWallet.jsx
Normal file
@@ -0,0 +1,171 @@
|
||||
import { useState, useRef } from 'react'
|
||||
import CopyButton from './CopyButton'
|
||||
|
||||
const API = ''
|
||||
|
||||
export default function DecryptWallet() {
|
||||
const [password, setPassword] = useState('')
|
||||
const [wallet, setWallet] = useState(null)
|
||||
const [result, setResult] = useState(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
const [fileName, setFileName] = useState(null)
|
||||
const [seedVisible, setSeedVisible] = useState(false)
|
||||
const fileRef = useRef()
|
||||
|
||||
const onFile = (e) => {
|
||||
const file = e.target.files[0]
|
||||
if (!file) return
|
||||
setFileName(file.name)
|
||||
setResult(null)
|
||||
setError(null)
|
||||
const reader = new FileReader()
|
||||
reader.onload = (ev) => {
|
||||
try {
|
||||
setWallet(JSON.parse(ev.target.result))
|
||||
} catch {
|
||||
setError('Invalid JSON file.')
|
||||
setWallet(null)
|
||||
}
|
||||
}
|
||||
reader.readAsText(file)
|
||||
}
|
||||
|
||||
const decrypt = async () => {
|
||||
if (!wallet) return
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
setResult(null)
|
||||
try {
|
||||
const res = await fetch(`${API}/api/hd/decrypt`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ wallet, password }),
|
||||
})
|
||||
if (!res.ok) throw new Error((await res.json()).detail)
|
||||
setResult(await res.json())
|
||||
setSeedVisible(false)
|
||||
} catch (e) {
|
||||
setError(e.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const ks = result?.keystore
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="page-title">Decrypt Wallet</div>
|
||||
<div className="page-subtitle">Load an encrypted JSON wallet and reveal its private data</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="card-title">Load wallet file</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 12, alignItems: 'center', marginBottom: 16 }}>
|
||||
<button className="btn btn-secondary" onClick={() => fileRef.current.click()}>
|
||||
📂 Choose file…
|
||||
</button>
|
||||
{fileName && <span style={{ color: 'var(--text-dim)', fontSize: 13 }}>{fileName}</span>}
|
||||
<input ref={fileRef} type="file" accept=".json" style={{ display: 'none' }} onChange={onFile} />
|
||||
</div>
|
||||
|
||||
{wallet && (
|
||||
<div className="alert alert-info" style={{ marginBottom: 16 }}>
|
||||
Wallet loaded · encrypted: <strong>{wallet.use_encryption ? 'yes' : 'no'}</strong>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="form-group" style={{ marginBottom: 16 }}>
|
||||
<label className="form-label">Password</label>
|
||||
<input
|
||||
className="form-input"
|
||||
type="password"
|
||||
placeholder="Wallet encryption password"
|
||||
value={password}
|
||||
onChange={e => setPassword(e.target.value)}
|
||||
onKeyDown={e => e.key === 'Enter' && wallet && decrypt()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button className="btn btn-primary" onClick={decrypt} disabled={loading || !wallet}>
|
||||
{loading ? <><span className="spinner" /> Decrypting…</> : '🔓 Decrypt'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{error && <div className="alert alert-error">{error}</div>}
|
||||
|
||||
{result && ks && (
|
||||
<>
|
||||
<div className="card">
|
||||
<div className="card-title" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<span>Seed Phrase</span>
|
||||
<div className="btn-row">
|
||||
<CopyButton text={ks.seed} />
|
||||
<button className="btn btn-ghost btn-icon" onClick={() => setSeedVisible(v => !v)}>
|
||||
{seedVisible ? '🙈' : '👁'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="seed-words">
|
||||
{ks.seed.split(' ').map((w, i) => (
|
||||
<span key={i} className={`seed-word${seedVisible ? '' : ' hidden'}`}>
|
||||
<span>{i + 1}.</span>{w}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="card-title">Keystore</div>
|
||||
{[
|
||||
['Derivation', ks.derivation],
|
||||
['Root fingerprint', ks.root_fingerprint],
|
||||
['xpub', ks.xpub],
|
||||
['xprv', ks.xprv],
|
||||
].map(([label, value]) => (
|
||||
<div className="kv-row" key={label}>
|
||||
<span className="kv-label">{label}</span>
|
||||
<span className="kv-value">{value}</span>
|
||||
<span className="kv-actions"><CopyButton text={value} /></span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="card-title">Receiving Addresses</div>
|
||||
<table className="addr-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Path</th>
|
||||
<th>Address</th>
|
||||
<th>WIF</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{result.addresses.receiving.map(a => (
|
||||
<tr key={a.index}>
|
||||
<td className="addr-index">{a.index}</td>
|
||||
<td className="addr-path">{a.path}</td>
|
||||
<td className="addr-mono">{a.address}</td>
|
||||
<td className="addr-mono" style={{ maxWidth: 160, overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{a.private_key_wif}
|
||||
</td>
|
||||
<td>
|
||||
<div className="btn-row">
|
||||
<CopyButton text={a.address} />
|
||||
<CopyButton text={a.private_key_wif} />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
246
frontend/src/components/HDWallet.jsx
Normal file
246
frontend/src/components/HDWallet.jsx
Normal file
@@ -0,0 +1,246 @@
|
||||
import { useState } from 'react'
|
||||
import CopyButton from './CopyButton'
|
||||
|
||||
const API = ''
|
||||
|
||||
export default function HDWallet() {
|
||||
const [form, setForm] = useState({
|
||||
network: 'mainnet',
|
||||
bip_type: 'bip84',
|
||||
mnemonic: '',
|
||||
passphrase: '',
|
||||
account: '0',
|
||||
num_addresses: '5',
|
||||
})
|
||||
const [wallet, setWallet] = useState(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
const [seedVisible, setSeedVisible] = useState(false)
|
||||
const [savePassword, setSavePassword] = useState('')
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [saveMsg, setSaveMsg] = useState(null)
|
||||
|
||||
const set = (k, v) => setForm(f => ({ ...f, [k]: v }))
|
||||
|
||||
const generate = async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
setWallet(null)
|
||||
setSeedVisible(false)
|
||||
try {
|
||||
const res = await fetch(`${API}/api/hd/generate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
network: form.network,
|
||||
bip_type: form.bip_type,
|
||||
mnemonic: form.mnemonic.trim() || null,
|
||||
passphrase: form.passphrase,
|
||||
account: parseInt(form.account) || 0,
|
||||
num_addresses: parseInt(form.num_addresses) || 5,
|
||||
}),
|
||||
})
|
||||
if (!res.ok) {
|
||||
const e = await res.json()
|
||||
throw new Error(e.detail || 'API error')
|
||||
}
|
||||
setWallet(await res.json())
|
||||
} catch (e) {
|
||||
setError(e.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const saveWallet = async () => {
|
||||
if (!wallet) return
|
||||
setSaving(true)
|
||||
setSaveMsg(null)
|
||||
try {
|
||||
let data = wallet
|
||||
if (savePassword.trim()) {
|
||||
const res = await fetch(`${API}/api/hd/encrypt`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ wallet, password: savePassword }),
|
||||
})
|
||||
if (!res.ok) throw new Error((await res.json()).detail)
|
||||
data = await res.json()
|
||||
}
|
||||
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `wallet_${form.network}_${form.bip_type}.json`
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
setSaveMsg(savePassword ? 'Wallet saved (encrypted).' : 'Wallet saved (unencrypted).')
|
||||
} catch (e) {
|
||||
setSaveMsg('Error: ' + e.message)
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
const ks = wallet?.keystore
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="page-title">HD Wallet</div>
|
||||
<div className="page-subtitle">BIP-32/39 · Hierarchical deterministic wallet</div>
|
||||
|
||||
{/* ── Configuration ── */}
|
||||
<div className="card">
|
||||
<div className="card-title">Configuration</div>
|
||||
<div className="form-grid">
|
||||
<div className="form-group">
|
||||
<label className="form-label">Network</label>
|
||||
<select className="form-select" value={form.network} onChange={e => set('network', e.target.value)}>
|
||||
<option value="mainnet">Mainnet</option>
|
||||
<option value="testnet">Testnet</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label className="form-label">BIP Type</label>
|
||||
<select className="form-select" value={form.bip_type} onChange={e => set('bip_type', e.target.value)}>
|
||||
<option value="bip44">BIP-44 — P2PKH (Legacy)</option>
|
||||
<option value="bip49">BIP-49 — P2SH-P2WPKH (SegWit wrapped)</option>
|
||||
<option value="bip84">BIP-84 — P2WPKH (Native SegWit)</option>
|
||||
<option value="bip86">BIP-86 — P2TR (Taproot)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label className="form-label">Account index</label>
|
||||
<input className="form-input" type="number" min="0" value={form.account} onChange={e => set('account', e.target.value)} />
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label className="form-label">Addresses</label>
|
||||
<input className="form-input" type="number" min="1" max="50" value={form.num_addresses} onChange={e => set('num_addresses', e.target.value)} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-group" style={{ marginBottom: 12 }}>
|
||||
<label className="form-label">Mnemonic phrase</label>
|
||||
<textarea
|
||||
className="form-textarea"
|
||||
placeholder="Leave blank to generate a new 12-word mnemonic…"
|
||||
value={form.mnemonic}
|
||||
onChange={e => set('mnemonic', e.target.value)}
|
||||
/>
|
||||
<span className="form-hint">BIP-39 · 12 or 24 words separated by spaces</span>
|
||||
</div>
|
||||
<div className="form-group" style={{ marginBottom: 16 }}>
|
||||
<label className="form-label">BIP-39 passphrase (optional)</label>
|
||||
<input className="form-input" type="password" placeholder="Optional passphrase" value={form.passphrase} onChange={e => set('passphrase', e.target.value)} />
|
||||
</div>
|
||||
<button className="btn btn-primary" onClick={generate} disabled={loading}>
|
||||
{loading ? <><span className="spinner" /> Generating…</> : '⚡ Generate Wallet'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{error && <div className="alert alert-error">{error}</div>}
|
||||
|
||||
{wallet && (
|
||||
<>
|
||||
{/* ── Seed phrase ── */}
|
||||
<div className="card">
|
||||
<div className="card-title" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<span>Seed Phrase</span>
|
||||
<div className="btn-row">
|
||||
<CopyButton text={ks.seed} />
|
||||
<button className="btn btn-ghost btn-icon" onClick={() => setSeedVisible(v => !v)}>
|
||||
{seedVisible ? '🙈' : '👁'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="seed-words">
|
||||
{ks.seed.split(' ').map((w, i) => (
|
||||
<span key={i} className={`seed-word${seedVisible ? '' : ' hidden'}`}>
|
||||
<span>{i + 1}.</span>{w}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Keystore ── */}
|
||||
<div className="card">
|
||||
<div className="card-title">Keystore</div>
|
||||
{[
|
||||
['Derivation', ks.derivation],
|
||||
['Root fingerprint', ks.root_fingerprint],
|
||||
['xpub', ks.xpub],
|
||||
['xprv', ks.xprv],
|
||||
].map(([label, value]) => (
|
||||
<div className="kv-row" key={label}>
|
||||
<span className="kv-label">{label}</span>
|
||||
<span className="kv-value">{value}</span>
|
||||
<span className="kv-actions"><CopyButton text={value} /></span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* ── Addresses ── */}
|
||||
<div className="card">
|
||||
<div className="card-title">Receiving Addresses</div>
|
||||
<table className="addr-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Path</th>
|
||||
<th>Address</th>
|
||||
<th>Public Key</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{wallet.addresses.receiving.map(a => (
|
||||
<tr key={a.index}>
|
||||
<td className="addr-index">{a.index}</td>
|
||||
<td className="addr-path">{a.path}</td>
|
||||
<td className="addr-mono">{a.address}</td>
|
||||
<td className="addr-mono" style={{ maxWidth: 160, overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{a.public_key}
|
||||
</td>
|
||||
<td>
|
||||
<div className="btn-row">
|
||||
<CopyButton text={a.address} />
|
||||
<CopyButton text={a.private_key_wif} />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* ── Save ── */}
|
||||
<div className="card">
|
||||
<div className="card-title">Save Wallet</div>
|
||||
<div className="form-grid" style={{ marginBottom: 12 }}>
|
||||
<div className="form-group">
|
||||
<label className="form-label">Encryption password (optional)</label>
|
||||
<input
|
||||
className="form-input"
|
||||
type="password"
|
||||
placeholder="Leave blank to save unencrypted"
|
||||
value={savePassword}
|
||||
onChange={e => setSavePassword(e.target.value)}
|
||||
/>
|
||||
<span className="form-hint">AES-256-CBC · Electrum-compatible</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="btn-row">
|
||||
<button className="btn btn-secondary" onClick={saveWallet} disabled={saving}>
|
||||
{saving ? <><span className="spinner" style={{borderTopColor:'var(--text)'}} /> Saving…</> : '💾 Download JSON'}
|
||||
</button>
|
||||
</div>
|
||||
{saveMsg && (
|
||||
<div className={`alert ${saveMsg.startsWith('Error') ? 'alert-error' : 'alert-success'}`} style={{ marginTop: 12, marginBottom: 0 }}>
|
||||
{saveMsg}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
54
frontend/src/components/Sidebar.jsx
Normal file
54
frontend/src/components/Sidebar.jsx
Normal file
@@ -0,0 +1,54 @@
|
||||
const PAGES = [
|
||||
{ id: 'hd', label: 'HD Wallet', icon: '◈', badge: 'BIP-32/39' },
|
||||
{ id: 'p2pkh', label: 'P2PKH', icon: '①', badge: 'Legacy' },
|
||||
{ id: 'p2wpkh', label: 'P2WPKH', icon: '⚡', badge: 'SegWit v0' },
|
||||
{ id: 'p2tr', label: 'P2TR', icon: '◆', badge: 'Taproot' },
|
||||
{ id: 'p2pk', label: 'P2PK', icon: '🔑', badge: 'Legacy' },
|
||||
{ id: 'p2sh', label: 'P2SH', icon: '③', badge: 'Multisig' },
|
||||
{ id: 'decrypt',label: 'Decrypt', icon: '🔓', badge: null },
|
||||
]
|
||||
|
||||
export default function Sidebar({ active, onSelect }) {
|
||||
return (
|
||||
<aside className="sidebar">
|
||||
<div className="sidebar-logo">
|
||||
{/* Bitcoin symbol */}
|
||||
<svg width="28" height="28" viewBox="0 0 28 28" fill="none">
|
||||
<circle cx="14" cy="14" r="14" fill="#f7931a"/>
|
||||
<path d="M18.5 11.8c.3-1.9-1.2-2.9-3.2-3.6l.7-2.6-1.6-.4-.6 2.5c-.4-.1-.9-.2-1.3-.3l.6-2.5-1.6-.4-.7 2.6-1-.3-2.2-.5-.4 1.7s1.2.3 1.1.3c.6.1.7.5.7.8l-1.7 6.9c-.1.2-.3.5-.8.4.0 0-1.1-.3-1.1-.3l-.8 1.8 2.1.5.9.3-.7 2.7 1.6.4.7-2.6c.4.1.9.2 1.3.3l-.7 2.6 1.6.4.7-2.7c2.9.5 5.1.3 6-2.3.7-2.1-.0-3.3-1.5-4.1 1.1-.3 1.9-1 2.1-2.5zm-3.8 5.3c-.5 2-3.9 1-5 .7l.9-3.5c1.1.3 4.7.8 4.1 2.8zm.5-5.3c-.5 1.8-3.3 1-4.3.7l.8-3.2c1 .3 4.1.7 3.5 2.5z" fill="white"/>
|
||||
</svg>
|
||||
<span>BTC Generator</span>
|
||||
</div>
|
||||
|
||||
<nav className="sidebar-nav">
|
||||
<div className="sidebar-section">Wallet</div>
|
||||
{PAGES.slice(0, 1).map(p => (
|
||||
<NavItem key={p.id} page={p} active={active} onSelect={onSelect} />
|
||||
))}
|
||||
|
||||
<div className="sidebar-section">Addresses</div>
|
||||
{PAGES.slice(1, 6).map(p => (
|
||||
<NavItem key={p.id} page={p} active={active} onSelect={onSelect} />
|
||||
))}
|
||||
|
||||
<div className="sidebar-section">Tools</div>
|
||||
{PAGES.slice(6).map(p => (
|
||||
<NavItem key={p.id} page={p} active={active} onSelect={onSelect} />
|
||||
))}
|
||||
</nav>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
function NavItem({ page, active, onSelect }) {
|
||||
return (
|
||||
<button
|
||||
className={`nav-item${active === page.id ? ' active' : ''}`}
|
||||
onClick={() => onSelect(page.id)}
|
||||
>
|
||||
<span>{page.icon}</span>
|
||||
<span>{page.label}</span>
|
||||
{page.badge && <span className="badge">{page.badge}</span>}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
179
frontend/src/components/SingleAddress.jsx
Normal file
179
frontend/src/components/SingleAddress.jsx
Normal file
@@ -0,0 +1,179 @@
|
||||
import { useState } from 'react'
|
||||
import CopyButton from './CopyButton'
|
||||
|
||||
const API = ''
|
||||
|
||||
const TABS = [
|
||||
{ id: 'p2pkh', label: 'P2PKH', desc: 'Legacy · starts with 1 / m' },
|
||||
{ id: 'p2wpkh', label: 'P2WPKH', desc: 'Native SegWit · bc1q / tb1q' },
|
||||
{ id: 'p2tr', label: 'P2TR', desc: 'Taproot · bc1p / tb1p' },
|
||||
{ id: 'p2pk', label: 'P2PK', desc: 'Pay-to-PubKey (no address)' },
|
||||
{ id: 'p2sh', label: 'P2SH', desc: 'Multisig · starts with 3 / 2' },
|
||||
]
|
||||
|
||||
export default function SingleAddress({ initialTab = 'p2pkh' }) {
|
||||
const [tab, setTab] = useState(initialTab)
|
||||
const [network, setNetwork] = useState('mainnet')
|
||||
const [compressed, setCompressed] = useState(true)
|
||||
const [m, setM] = useState(2)
|
||||
const [n, setN] = useState(3)
|
||||
const [result, setResult] = useState(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
|
||||
const generate = async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
setResult(null)
|
||||
try {
|
||||
let body = { network }
|
||||
if (tab === 'p2sh') body = { ...body, m, n, compressed }
|
||||
else if (tab !== 'p2tr') body = { ...body, compressed }
|
||||
|
||||
const res = await fetch(`${API}/api/${tab}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
if (!res.ok) throw new Error((await res.json()).detail)
|
||||
setResult(await res.json())
|
||||
} catch (e) {
|
||||
setError(e.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const currentTab = TABS.find(t => t.id === tab)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="page-title">Single Addresses</div>
|
||||
<div className="page-subtitle">Generate individual Bitcoin addresses and key pairs</div>
|
||||
|
||||
<div className="tabs">
|
||||
{TABS.map(t => (
|
||||
<button key={t.id} className={`tab${tab === t.id ? ' active' : ''}`} onClick={() => { setTab(t.id); setResult(null); setError(null) }}>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* ── Form ── */}
|
||||
<div className="card">
|
||||
<div className="card-title">{currentTab.label} <span style={{ color: 'var(--text-xs)', fontWeight: 400 }}>— {currentTab.desc}</span></div>
|
||||
|
||||
<div className="form-grid" style={{ marginBottom: 14 }}>
|
||||
<div className="form-group">
|
||||
<label className="form-label">Network</label>
|
||||
<select className="form-select" value={network} onChange={e => setNetwork(e.target.value)}>
|
||||
<option value="mainnet">Mainnet</option>
|
||||
<option value="testnet">Testnet</option>
|
||||
<option value="regtest">Regtest</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{tab === 'p2sh' && (
|
||||
<>
|
||||
<div className="form-group">
|
||||
<label className="form-label">Required signatures (m)</label>
|
||||
<input className="form-input" type="number" min="1" max="16" value={m} onChange={e => setM(parseInt(e.target.value))} />
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label className="form-label">Total keys (n)</label>
|
||||
<input className="form-input" type="number" min="1" max="16" value={n} onChange={e => setN(parseInt(e.target.value))} />
|
||||
<span className="form-hint">{m}-of-{n} multisig</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{tab !== 'p2tr' && (
|
||||
<div className="checkbox-group" style={{ marginBottom: 14 }}>
|
||||
<input type="checkbox" id="compressed" checked={compressed} onChange={e => setCompressed(e.target.checked)} />
|
||||
<label htmlFor="compressed">Compressed public key (33 bytes)</label>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button className="btn btn-primary" onClick={generate} disabled={loading}>
|
||||
{loading ? <><span className="spinner" /> Generating…</> : '⚡ Generate'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{error && <div className="alert alert-error">{error}</div>}
|
||||
|
||||
{result && <ResultCard result={result} tab={tab} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ResultCard({ result, tab }) {
|
||||
const fields = buildFields(result, tab)
|
||||
return (
|
||||
<div className="card">
|
||||
<div className="card-title">Result</div>
|
||||
{tab === 'p2sh' ? (
|
||||
<P2SHResult result={result} />
|
||||
) : (
|
||||
fields.map(([label, value]) => (
|
||||
<div className="kv-row" key={label}>
|
||||
<span className="kv-label">{label}</span>
|
||||
<span className="kv-value">{value}</span>
|
||||
<span className="kv-actions"><CopyButton text={value} /></span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function buildFields(result, tab) {
|
||||
const rows = [
|
||||
['Network', result.network],
|
||||
['Script type', result.script_type],
|
||||
]
|
||||
if (result.address) rows.push(['Address', result.address])
|
||||
if (result.public_key_hex) rows.push(['Public key (hex)', result.public_key_hex])
|
||||
if (result.internal_pubkey_x_hex) rows.push(['Internal pubkey (x)', result.internal_pubkey_x_hex])
|
||||
if (result.private_key_wif) rows.push(['Private key (WIF)', result.private_key_wif])
|
||||
if (result.private_key_hex) rows.push(['Private key (hex)', result.private_key_hex])
|
||||
return rows
|
||||
}
|
||||
|
||||
function P2SHResult({ result }) {
|
||||
return (
|
||||
<>
|
||||
{[
|
||||
['Network', result.network],
|
||||
['Script type', result.script_type],
|
||||
['Configuration', `${result.m}-of-${result.n}`],
|
||||
['Address', result.address],
|
||||
['Redeem script', result.redeem_script_hex],
|
||||
].map(([label, value]) => (
|
||||
<div className="kv-row" key={label}>
|
||||
<span className="kv-label">{label}</span>
|
||||
<span className="kv-value">{value}</span>
|
||||
<span className="kv-actions"><CopyButton text={value} /></span>
|
||||
</div>
|
||||
))}
|
||||
<hr className="divider" />
|
||||
<div className="card-title" style={{ marginTop: 4 }}>Participants</div>
|
||||
{result.participants.map((p, i) => (
|
||||
<div className="participant-card" key={i}>
|
||||
<div className="participant-title">Key {i + 1}</div>
|
||||
{[
|
||||
['Public key', p.public_key_hex],
|
||||
['Private key (WIF)', p.private_key_wif],
|
||||
['Private key (hex)', p.private_key_hex],
|
||||
].map(([label, value]) => (
|
||||
<div className="kv-row" key={label} style={{ paddingTop: 4, paddingBottom: 4 }}>
|
||||
<span className="kv-label">{label}</span>
|
||||
<span className="kv-value">{value}</span>
|
||||
<span className="kv-actions"><CopyButton text={value} /></span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
412
frontend/src/index.css
Normal file
412
frontend/src/index.css
Normal file
@@ -0,0 +1,412 @@
|
||||
/* ── Reset & Base ─────────────────────────────────────────────────────────── */
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:root {
|
||||
--bg: #0f1117;
|
||||
--sidebar: #161b27;
|
||||
--panel: #1c2233;
|
||||
--card: #232b3e;
|
||||
--border: #2d3650;
|
||||
--accent: #f7931a;
|
||||
--accent-d: #d97c0e;
|
||||
--text: #e2e8f0;
|
||||
--text-dim: #8896b3;
|
||||
--text-xs: #5a6a8a;
|
||||
--green: #22c55e;
|
||||
--red: #ef4444;
|
||||
--blue: #3b82f6;
|
||||
--mono: 'Courier New', 'Lucida Console', monospace;
|
||||
--sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
}
|
||||
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: var(--sans);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ── Scrollbar ────────────────────────────────────────────────────────────── */
|
||||
::-webkit-scrollbar { width: 6px; height: 6px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
|
||||
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
|
||||
|
||||
/* ── Layout ───────────────────────────────────────────────────────────────── */
|
||||
.app {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ── Sidebar ──────────────────────────────────────────────────────────────── */
|
||||
.sidebar {
|
||||
width: 200px;
|
||||
min-width: 200px;
|
||||
background: var(--sidebar);
|
||||
border-right: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 20px 16px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.sidebar-logo span {
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
color: var(--accent);
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.sidebar-section {
|
||||
padding: 12px 8px 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.1em;
|
||||
color: var(--text-xs);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px 8px 16px;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: var(--text-dim);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s ease;
|
||||
user-select: none;
|
||||
border: none;
|
||||
background: none;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.nav-item:hover { background: var(--panel); color: var(--text); }
|
||||
.nav-item.active { background: var(--card); color: var(--accent); }
|
||||
.nav-item .badge {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 9999px;
|
||||
background: var(--border);
|
||||
color: var(--text-xs);
|
||||
}
|
||||
.nav-item.active .badge { background: var(--accent); color: #000; }
|
||||
|
||||
/* ── Main content ─────────────────────────────────────────────────────────── */
|
||||
.main {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 28px 32px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
color: var(--text-dim);
|
||||
font-size: 13px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
/* ── Cards ────────────────────────────────────────────────────────────────── */
|
||||
.card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.07em;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
/* ── Form ─────────────────────────────────────────────────────────────────── */
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.form-group { display: flex; flex-direction: column; gap: 5px; }
|
||||
|
||||
.form-label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
|
||||
.form-input,
|
||||
.form-select,
|
||||
.form-textarea {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
padding: 7px 10px;
|
||||
outline: none;
|
||||
transition: border-color 0.15s;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.form-input:focus,
|
||||
.form-select:focus,
|
||||
.form-textarea:focus { border-color: var(--accent); }
|
||||
|
||||
.form-textarea { resize: vertical; min-height: 64px; font-family: var(--mono); font-size: 12px; }
|
||||
.form-select option { background: var(--panel); }
|
||||
|
||||
.form-hint {
|
||||
font-size: 11px;
|
||||
color: var(--text-xs);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.checkbox-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
.checkbox-group input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
|
||||
.checkbox-group label { font-size: 13px; cursor: pointer; }
|
||||
|
||||
/* ── Buttons ──────────────────────────────────────────────────────────────── */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 18px;
|
||||
border-radius: 7px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--accent);
|
||||
color: #000;
|
||||
}
|
||||
.btn-primary:hover { background: var(--accent-d); }
|
||||
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-dim);
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.btn-ghost:hover { color: var(--text); }
|
||||
|
||||
.btn-icon {
|
||||
padding: 5px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* ── Key/value rows ───────────────────────────────────────────────────────── */
|
||||
.kv-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.kv-row:last-child { border-bottom: none; }
|
||||
|
||||
.kv-label {
|
||||
min-width: 140px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
padding-top: 1px;
|
||||
}
|
||||
|
||||
.kv-value {
|
||||
flex: 1;
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
word-break: break-all;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.kv-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Seed phrase display ──────────────────────────────────────────────────── */
|
||||
.seed-words { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.seed-word {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 5px;
|
||||
padding: 4px 12px;
|
||||
font-family: var(--mono);
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
transition: filter 0.2s;
|
||||
}
|
||||
.seed-word.hidden { filter: blur(5px); user-select: none; }
|
||||
.seed-word span {
|
||||
color: var(--text-xs);
|
||||
font-size: 10px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
/* ── Address table ────────────────────────────────────────────────────────── */
|
||||
.addr-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
}
|
||||
.addr-table th {
|
||||
text-align: left;
|
||||
padding: 6px 10px;
|
||||
color: var(--text-xs);
|
||||
font-weight: 600;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.addr-table td {
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
vertical-align: middle;
|
||||
}
|
||||
.addr-table tr:last-child td { border-bottom: none; }
|
||||
.addr-table tr:hover td { background: var(--panel); }
|
||||
.addr-mono { font-family: var(--mono); }
|
||||
.addr-index { color: var(--text-xs); font-family: var(--mono); }
|
||||
.addr-path { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }
|
||||
|
||||
/* ── Tabs ─────────────────────────────────────────────────────────────────── */
|
||||
.tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
|
||||
.tab {
|
||||
padding: 6px 14px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--panel);
|
||||
color: var(--text-dim);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.tab:hover { border-color: var(--accent); color: var(--text); }
|
||||
.tab.active { background: var(--accent); color: #000; border-color: var(--accent); }
|
||||
|
||||
/* ── Alert / Status ───────────────────────────────────────────────────────── */
|
||||
.alert {
|
||||
padding: 10px 14px;
|
||||
border-radius: 7px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
|
||||
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25); color: #86efac; }
|
||||
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25); color: #93c5fd; }
|
||||
|
||||
/* ── Copy toast ───────────────────────────────────────────────────────────── */
|
||||
.copy-toast {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
right: 24px;
|
||||
background: var(--green);
|
||||
color: #000;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.4);
|
||||
z-index: 9999;
|
||||
animation: toast-in 0.2s ease;
|
||||
}
|
||||
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
||||
|
||||
/* ── Spinner ──────────────────────────────────────────────────────────────── */
|
||||
.spinner {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 2px solid rgba(0,0,0,0.3);
|
||||
border-top-color: #000;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.7s linear infinite;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
/* ── Divider ──────────────────────────────────────────────────────────────── */
|
||||
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
|
||||
|
||||
/* ── Participants (P2SH) ──────────────────────────────────────────────────── */
|
||||
.participant-card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 12px 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.participant-title {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: var(--accent);
|
||||
margin-bottom: 8px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
10
frontend/src/main.jsx
Normal file
10
frontend/src/main.jsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.jsx'
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
15
frontend/vite.config.js
Normal file
15
frontend/vite.config.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user