Second bundled wallet, same shape as bchwallet:
- keys: api.vault.derive("siawallet/mainnet/0") as the seed for walletd's
KeyFromSeed(seed, index) (blake2b(seed||index) -> ed25519); addresses are
standard unlock hashes, so a future walletd seed import yields the same
addresses. Seed and keys live in memory only.
- lib/sia.js: Sia binary encoder, StandardUnlockHash, address checksum,
v2 InputSigHash ("sia/sig/input|" + replay byte 2 + transaction
semantics), transaction weight, walletd JSON. Address hashing and the
sighash were verified against real mainnet v2 transactions (signatures
from block 591853 verify under this implementation).
- lib/walletd.js: address-scoped walletd HTTP client (tip, fee, balance,
outputs with proofs, events, broadcast). The node URL is a user setting
with no default; hosted providers embed the access key in the path, so
only the origin is ever displayed or logged.
- lib/wallet.js: gap-limit discovery via events, mature/immature balance,
history deltas from v1/v2/foundation/miner events, largest-first
selection with change to the current address, fee = walletd rate x
weight x 1-3 multiplier, broadcast with the outputs' basis. A signed tx
built here was accepted structurally by a live walletd (rejected only
for the stub key not owning the parent).
- panel: Receive (QR), Send, History, Settings (node URL, derivation info,
seed reveal behind approval, connected sites); gates for locked vault,
no vault, no node URL.
- window.siacoin dapp bridge: getAddress (rememberable), signAndSend with
100/1,000/10,000 SC allowances, signMessage (ed25519 over blake2b-256 of
the message) — same approval and permission rules as the BCH wallet.
179 lines
9.4 KiB
HTML
179 lines
9.4 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Siacoin Wallet</title>
|
|
<style>
|
|
:root { color-scheme: light dark;
|
|
--bg:#0e131c; --panel:#141a24; --card:#0f1621; --line:rgba(255,255,255,.09);
|
|
--ink:#e7eaf1; --mut:#8b98a9; --dim:#5e6678; --acid:#d6ff3d; --danger:#f6768a; --ok:#5ad38a;
|
|
--sia:#20ee82; }
|
|
@media (prefers-color-scheme: light) {
|
|
:root { --bg:#f8faff; --panel:#ffffff; --card:#f1f4fa; --line:rgba(0,0,0,.10);
|
|
--ink:#1a1f2b; --mut:#5c6577; --dim:#8a93a5; --sia:#1abc6a; }
|
|
}
|
|
* { box-sizing: border-box; }
|
|
html, body { margin: 0; height: 100%; }
|
|
body { background: var(--bg); color: var(--ink);
|
|
font: 13.5px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
|
|
display: flex; flex-direction: column; }
|
|
header { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
|
|
header .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
header .t { font-weight: 600; display: flex; gap: 8px; align-items: center; }
|
|
header .t .coin { color: var(--sia); font-size: 16px; }
|
|
.net { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11.5px; white-space: nowrap; }
|
|
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
|
|
.dot.on { background: var(--ok); } .dot.busy { background: #e0b341; }
|
|
.bal { margin-top: 8px; font-variant-numeric: tabular-nums; }
|
|
.bal .big { font-size: 22px; font-weight: 650; letter-spacing: .2px; }
|
|
.bal .big small { font-size: 13px; color: var(--mut); font-weight: 500; margin-left: 4px; }
|
|
.bal .sub { color: var(--dim); font-size: 11.5px; }
|
|
nav { display: flex; border-bottom: 1px solid var(--line); background: var(--panel); }
|
|
nav button { flex: 1; padding: 9px 0 8px; border: 0; background: transparent; color: var(--mut); cursor: pointer;
|
|
font: inherit; font-size: 12.5px; border-bottom: 2px solid transparent; }
|
|
nav button.on { color: var(--acid); border-bottom-color: var(--acid); }
|
|
nav button:hover { color: var(--ink); }
|
|
main { flex: 1; overflow: auto; padding: 14px; }
|
|
section[hidden] { display: none; }
|
|
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
|
|
.mono { font: 12.5px/1.45 ui-monospace, "Cascadia Code", Consolas, monospace; word-break: break-all; }
|
|
.lbl { color: var(--dim); font-size: 11.5px; margin-bottom: 4px; }
|
|
.btn { padding: 7px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
|
|
cursor: pointer; font: inherit; font-size: 12.5px; }
|
|
.btn:hover { border-color: rgba(214,255,61,.4); }
|
|
.btn.primary { background: var(--acid); color: #0b0e14; border-color: transparent; font-weight: 650; }
|
|
.btn.primary:disabled { opacity: .45; cursor: default; }
|
|
.btn.danger { color: var(--danger); }
|
|
.btn.sm { padding: 4px 9px; font-size: 12px; }
|
|
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
|
|
.qrwrap { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 10px; margin-bottom: 12px; }
|
|
canvas { image-rendering: pixelated; }
|
|
input[type=text], textarea { width: 100%; padding: 7px 9px; border-radius: 7px; background: var(--panel);
|
|
border: 1px solid var(--line); color: var(--ink); font: inherit; font-size: 13px; outline: none; }
|
|
input:focus, textarea:focus { border-color: rgba(214,255,61,.5); }
|
|
.field { margin-bottom: 12px; }
|
|
.hint { color: var(--dim); font-size: 11.5px; margin-top: 4px; }
|
|
.amt { display: flex; gap: 6px; }
|
|
.amt input { flex: 1; }
|
|
.fee { display: flex; align-items: center; gap: 10px; }
|
|
.fee input[type=range] { flex: 1; accent-color: var(--acid); }
|
|
.fee .v { color: var(--mut); font-size: 12px; min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
|
|
.summary { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 12.5px; margin-top: 10px; }
|
|
.summary .k { color: var(--dim); } .summary .v { text-align: right; font-variant-numeric: tabular-nums; }
|
|
.msg { margin-top: 10px; font-size: 12.5px; padding: 8px 10px; border-radius: 7px; }
|
|
.msg.err { background: rgba(246,118,138,.12); color: var(--danger); }
|
|
.msg.ok { background: rgba(90,211,138,.12); color: var(--ok); }
|
|
.tx { display: grid; grid-template-columns: 22px 1fr auto; gap: 2px 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
|
|
.tx:hover { background: rgba(255,255,255,.03); }
|
|
.tx .ic { font-size: 15px; line-height: 1.3; }
|
|
.tx .ic.in { color: var(--ok); } .tx .ic.out { color: var(--danger); }
|
|
.tx .what { font-size: 12.5px; }
|
|
.tx .when { color: var(--dim); font-size: 11.5px; grid-column: 2; }
|
|
.tx .amt2 { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; }
|
|
.tx .amt2.in { color: var(--ok); }
|
|
.tx .conf { grid-column: 3; text-align: right; color: var(--dim); font-size: 11px; }
|
|
.tx .conf.pending { color: #e0b341; }
|
|
.empty { color: var(--dim); text-align: center; padding: 30px 10px; font-size: 12.5px; }
|
|
.gate { padding: 40px 18px; text-align: center; color: var(--mut); }
|
|
.gate .big { font-size: 28px; margin-bottom: 8px; }
|
|
.gate b { color: var(--ink); }
|
|
.gate input { margin-top: 14px; text-align: left; }
|
|
.kv { margin-top: 10px; }
|
|
.kv .lbl { margin-top: 8px; }
|
|
a.link { color: var(--acid); text-decoration: none; cursor: pointer; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="row">
|
|
<div class="t"><span class="coin">Ⓢ</span><span>Siacoin</span></div>
|
|
<div class="net"><span class="dot" id="dot"></span><span id="netlbl">connecting…</span></div>
|
|
</div>
|
|
<div class="bal">
|
|
<div class="big"><span id="balSc">—</span><small>SC</small></div>
|
|
<div class="sub" id="balSub">mainnet</div>
|
|
</div>
|
|
</header>
|
|
<nav>
|
|
<button data-tab="receive" class="on">Receive</button>
|
|
<button data-tab="send">Send</button>
|
|
<button data-tab="history">History</button>
|
|
<button data-tab="settings">Settings</button>
|
|
</nav>
|
|
<main>
|
|
<div id="gate" class="gate" hidden></div>
|
|
<div id="tabs">
|
|
<section id="tab-receive">
|
|
<div class="qrwrap"><canvas id="qr" width="200" height="200"></canvas></div>
|
|
<div class="card">
|
|
<div class="lbl">Receiving address <span id="addrMeta"></span></div>
|
|
<div class="mono" id="addr">—</div>
|
|
<div class="actions">
|
|
<button class="btn sm" id="copyAddr">Copy</button>
|
|
<button class="btn sm" id="nextAddr">Next unused address</button>
|
|
<button class="btn sm" id="viewAddr">Explorer</button>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section id="tab-send" hidden>
|
|
<div class="field">
|
|
<div class="lbl">Recipient</div>
|
|
<input type="text" id="sendTo" spellcheck="false" autocomplete="off" placeholder="76-character Sia address">
|
|
<div class="hint" id="sendToHint"></div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="lbl">Amount (SC)</div>
|
|
<div class="amt">
|
|
<input type="text" id="sendAmt" inputmode="decimal" autocomplete="off" placeholder="0.00">
|
|
<button class="btn sm" id="sendMax" type="button">Max</button>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="lbl">Fee</div>
|
|
<div class="fee"><input type="range" id="feeMult" min="1" max="3" step="1" value="1"><span class="v" id="feeLbl">normal</span></div>
|
|
</div>
|
|
<div class="card">
|
|
<div class="summary">
|
|
<div class="k">Amount</div><div class="v" id="sumAmt">—</div>
|
|
<div class="k">Network fee</div><div class="v" id="sumFee">—</div>
|
|
<div class="k">Total</div><div class="v" id="sumTotal">—</div>
|
|
</div>
|
|
</div>
|
|
<div class="actions"><button class="btn primary" id="sendBtn" disabled>Send</button></div>
|
|
<div class="msg" id="sendMsg" hidden></div>
|
|
</section>
|
|
<section id="tab-history" hidden>
|
|
<div id="txlist"></div>
|
|
</section>
|
|
<section id="tab-settings" hidden>
|
|
<div class="field">
|
|
<div class="lbl">walletd node URL</div>
|
|
<input type="text" id="setUrl" spellcheck="false" placeholder="https://host[:port]">
|
|
<div class="hint" id="urlHint">Any walletd (v2) with index mode "full". Hosted providers put your access key in the path; it is stored locally only.</div>
|
|
</div>
|
|
<div class="actions">
|
|
<button class="btn primary" id="applySettings">Apply</button>
|
|
<button class="btn" id="refreshBtn">Rescan</button>
|
|
</div>
|
|
<div class="card" style="margin-top:16px">
|
|
<div class="lbl">Recovery info</div>
|
|
<div class="hint">Keys come from your Theseus password vault under <span class="mono">silentmode/addons/siawallet/mainnet/0</span>, using walletd's per-index key scheme. The same vault seed on another machine recreates this wallet.</div>
|
|
<div class="kv" id="recovery"></div>
|
|
<div class="actions">
|
|
<button class="btn" id="showInfo">Show derivation</button>
|
|
<button class="btn danger" id="showSeed">Show wallet seed</button>
|
|
</div>
|
|
</div>
|
|
<div class="card" style="margin-top:16px">
|
|
<div class="lbl">Connected sites</div>
|
|
<div class="hint">Sites allowed to read your address, and sites with a payment allowance they can spend without asking. Message signing always asks.</div>
|
|
<div id="sites" class="kv"></div>
|
|
</div>
|
|
<div class="msg err" id="settingsMsg" hidden></div>
|
|
</section>
|
|
</div>
|
|
</main>
|
|
<script src="qr.js"></script>
|
|
<script src="panel.js"></script>
|
|
</body>
|
|
</html>
|