aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/app.js145
-rw-r--r--src/features/ark.js60
-rw-r--r--src/features/names.js2
-rw-r--r--src/i18n.js12
-rw-r--r--tools/balance-settings-row-test.js2
-rw-r--r--tools/send-enter-keys-test.js7
-rw-r--r--tools/signup-quick-test.js36
-rw-r--r--tools/unified-balance-test.js127
8 files changed, 343 insertions, 48 deletions
diff --git a/src/app.js b/src/app.js
index 99cf565..e1df4e2 100644
--- a/src/app.js
+++ b/src/app.js
@@ -1886,6 +1886,12 @@ async function enterWallet(mnemonic, passphrase, opts = {}) {
if (opts.spendingOnly && !acc.kind && !acc.deriveIndex && !acc.savingsAdded && acc.type === 'full') {
acc.kind = 'spending'; acc.savingsLater = true;
} else if (opts.signup && acc.kind === 'spending') acc.savingsLater = true;
+ // ...unless balances are one: then a sign-up is simply the account, its
+ // on-chain side there underneath for whenever someone pays on-chain
+ if (acc.kind === 'spending' && acc.savingsLater && !acc.deriveIndex && !separateBalances()) {
+ delete acc.kind; delete acc.savingsLater;
+ if (!acc.spendingSetup) acc.spendingSetup = Date.now();
+ }
await activateAccount(acc, { ...opts, fresh: true });
}
@@ -3705,8 +3711,8 @@ function accountsScreen() {
// has to say which identity.
...groupAccounts().flatMap(({ pk, rows }) => [
identityHeading(pk),
- ...rows.flatMap((a) => viewsOf(a).map((view) => {
- const isActive = a.id === activeId && accountSel() === view;
+ ...rows.flatMap((a) => (a.id === activeId && unifiedOn(a) ? ['all'] : viewsOf(a)).map((view) => {
+ const isActive = a.id === activeId && (view === 'all' || accountSel() === view);
const netTag = a.network && a.network !== 'mainnet' ? ' · ' + a.network : '';
const seedTag = '';
const tag = (a.type === 'watch' ? ' · ' + t('watchOnlyTag') : '') + netTag + seedTag;
@@ -3947,12 +3953,13 @@ function recoveryCard(a) {
// cannot find this option" (Nils, 2026-11-12) about the Spending card's gear.
function balanceSettingsCard(a) {
if (a.id !== activeId) return null;
- const views = a.kind ? [a.kind] : spendingActive() ? ['spending', 'savings'] : ['savings'];
+ const unified = unifiedOn(a);
+ const views = unified ? ['all'] : a.kind ? [a.kind] : spendingActive() ? ['spending', 'savings'] : ['savings'];
// Each balance wears its own mark in a tinted tile — the bolt and the
// bitcoin disc the balance card uses — rather than a gear beside one and a
// coin beside the other (Adam, 2026-11-15: "Icons and padding need work").
const BOLT = '<svg width="21" height="21" viewBox="0 0 24 24" fill="currentColor" style="display:block"><path d="M13.5 2 4 13.5h6.5L9.5 22 20 9.5h-6.6z"/></svg>';
- const tile = (view) => h('span', { class: 'bs-tile ' + (view === 'spending' ? 'spend' : 'save'), html: view === 'spending' ? BOLT : BITCOIN_ICON(22) });
+ const tile = (view) => h('span', { class: 'bs-tile ' + (view === 'savings' ? 'save' : 'spend'), html: view === 'savings' ? BITCOIN_ICON(22) : BOLT });
const rowOf = (attrs, view, title, desc, tail) => h('button', { class: 'balance-settings-row', ...attrs },
tile(view),
h('span', { class: 'col bs-text' },
@@ -3960,13 +3967,20 @@ function balanceSettingsCard(a) {
h('span', { class: 'small muted' }, desc)),
h('span', { class: 'bs-tail', 'aria-hidden': 'true' }, tail));
const row = (view) => rowOf({ 'data-view': view, onClick: () => openWalletSettings(view) }, view,
- viewLabel(a, view), t(view === 'spending' ? 'spendingSettingsDesc' : 'savingsSettingsDesc'), '›');
+ viewLabel(a, view), t(view === 'all' ? 'allSettingsDesc' : view === 'spending' ? 'spendingSettingsDesc' : 'savingsSettingsDesc'), '›');
// a sign-up's Spending-only account: Savings is one tap away
const addRow = a.kind === 'spending' && a.savingsLater && !a.deriveIndex
? rowOf({ id: 'add-savings', onClick: () => { addSavings(a); toast(t('savingsAddedToast')); } }, 'savings',
t('addSavings'), t('addSavingsDesc'), '+')
: null;
- return h('div', { class: 'card col', style: 'gap:8px' }, h('h3', {}, t('balanceSettingsTitle')), ...views.map(row), addRow);
+ // one balance or two, per device: the same seed and coins either way
+ const apart = !a.kind && a.type === 'full' && spendingActive()
+ ? h('label', { class: 'row gap6', style: 'align-items:center;cursor:pointer;padding:6px 2px 0' },
+ h('input', { type: 'checkbox', id: 'separate-balances', checked: separateBalances(),
+ onChange: (e) => { setSeparateBalances(e.target.checked); ui.recvOnchain = false; render(); } }),
+ h('span', { class: 'small' }, t('separateBalances')))
+ : null;
+ return h('div', { class: 'card col', style: 'gap:8px' }, h('h3', {}, t('balanceSettingsTitle')), ...views.map(row), unified ? null : addRow, apart);
}
function walletNameCard(a) {
const saveName = () => {
@@ -4097,7 +4111,7 @@ function accountSettingsScreen() {
const a = accounts.find((x) => x.id === ui.settingsId) || activeAccount();
if (!a) { ui.screen = 'accounts'; return accountsScreen(); }
const view = ui.settingsView || accountSel();
- const spending = view === 'spending' && a.id === activeId;
+ const spending = (view === 'spending' || view === 'all') && a.id === activeId;
const leave = () => { ui.editLabel = null; ui.revealShown = false; ui.pubkeyShown = false; ui.loadSeed = null; goBack(() => { ui.screen = 'wallet'; }); };
return h(
'div',
@@ -4642,7 +4656,7 @@ function onboardScreen() {
// A sign-up's name is the account itself — what people pay, follow and
// message — so it's claimed here, not skipped.
const signupAcc = activeAccount();
- const signup = !o.fromGift && !!(signupAcc && signupAcc.signupAt && signupAcc.kind === 'spending');
+ const signup = !o.fromGift && !!(signupAcc && signupAcc.signupAt && (signupAcc.kind === 'spending' || !signupAcc.kind));
return page([
title(t(o.fromGift ? 'onbGiftNameTitle' : signup ? 'onbNameTitle' : 'onbSpendTitle')),
h('p', { class: 'muted', style: 'margin:0' }, t(o.fromGift ? 'onbGiftNameBody' : signup ? 'onbNameBody' : 'onbSpendBody')),
@@ -5007,6 +5021,8 @@ function addSavings(acc, { quiet = false } = {}) {
function savingsEvident() {
const a = activeAccount();
if (!a || a.kind !== 'spending' || !a.savingsLater || !wallet.loaded) return;
+ // one balance: on-chain is part of the account from the start, nothing to add
+ if (!separateBalances()) { addSavings(a, { quiet: true }); return; }
if ((wallet.spendable || 0) > 0 || (wallet.pendingIncoming || 0) > 0 || (wallet.txs || []).length) addSavings(a, { quiet: true });
}
// The shape rides the synced snapshot, so the phone opens the account the
@@ -5024,7 +5040,7 @@ wallet.registerCacheExtension({
const a = activeAccount();
if (!d || !a || a.type !== 'full' || a.deriveIndex) return;
if (d.savingsAdded) { if (addSavings(a, { quiet: true }) === false && !a.savingsAdded) { a.savingsAdded = d.savingsAdded; persistAccounts(); } return; }
- if (d.spendingOnly && !a.kind && !a.savingsAdded && !(wallet.txs || []).length && !(wallet.spendable || 0)) {
+ if (d.spendingOnly && separateBalances() && !a.kind && !a.savingsAdded && !(wallet.txs || []).length && !(wallet.spendable || 0)) {
a.kind = 'spending'; a.savingsLater = true;
persistAccounts();
}
@@ -5155,6 +5171,37 @@ function offlineBanner() {
// Lightning) or Savings (on-chain). The balance card headline, the Receive
// pane, and the gift source all follow it.
const ACCOUNT_KEY = 'btc-wallet-account';
+// One balance (Adam, 2026-11-15: "combine the Ark and savings Bitcoin
+// accounts into a single account … a combined history … the balance would
+// be unified"). A seed with both sides shows ONE account: the total, one
+// timeline (a move between the two is one row, priced at what it cost), and
+// Receive leading with the payment address, an on-chain address a tap away.
+// Money stays where it lands; a payment picks its coins by where it's going
+// (Lightning/Ark from the Ark coins, an on-chain address from on-chain coins
+// first). Settings → Wallet can still show the two apart, per device.
+const SEPARATE_KEY = 'btc-wallet-separate-balances';
+function separateBalances() {
+ try { return localStorage.getItem(SEPARATE_KEY) === '1'; } catch { return false; }
+}
+function setSeparateBalances(on) {
+ try { on ? localStorage.setItem(SEPARATE_KEY, '1') : localStorage.removeItem(SEPARATE_KEY); } catch {}
+}
+function unifiedOn(a = activeAccount()) {
+ return !!a && !a.kind && a.type === 'full' && !separateBalances() && spendingActive();
+}
+// History rows, both rails merged: on-chain transactions plus the features'
+// entries. A feature row can stand in for an on-chain transaction
+// (`replacesTxid` — a board or an offboard to our own address, told once).
+function historyEntriesFor(sel) {
+ const all = sel === 'spending' ? [] : wallet.history || [];
+ const feat = featureAll('historyEntries', all, sel);
+ const replaced = new Set(feat.map((e) => e.replacesTxid).filter(Boolean));
+ const txs = replaced.size ? all.filter((tx) => !replaced.has(tx.txid)) : all;
+ return [
+ ...txs.map((tx) => ({ time: tx.confirmed ? (tx.blockTime || 0) * 1000 : Date.now(), render: () => txHistoryItem(tx) })),
+ ...feat,
+ ].sort((a, b) => b.time - a.time);
+}
// Spending is opt-in: a wallet is born on-chain only, and the second balance
// (with its toggle, swipe, and Move money) appears once the user sets it up —
// or the moment money is already there (a restored wallet, a claimed gift),
@@ -5212,6 +5259,7 @@ function seedName(a) {
}
function viewLabel(a, view) {
if (a && a.viewLabels && a.viewLabels[view]) return a.viewLabels[view];
+ if (view === 'all') return t('balance');
return view === 'spending' ? t('spendingName') : t('savingsName');
}
function switchToView(id, view) {
@@ -5228,6 +5276,9 @@ function switchToView(id, view) {
function accountSel() {
const a = activeAccount();
if (a && a.kind) return a.kind; // single-purpose wallet: no other side
+ // one balance: payments start from the Ark coins; the send flow picks
+ // on-chain coins for an on-chain address itself (ark.js matchSend)
+ if (unifiedOn(a)) return 'spending';
if (!spendingActive()) return 'savings'; // one balance, no choice
if (!ui.account) {
let saved = null;
@@ -5264,12 +5315,9 @@ function walletSide() {
const toWallet = (tab) => { goHome(); ui.tab = tab; render(); };
const spending = featureHook('spendingSat') || 0;
const saving = wallet.spendable || 0;
- const sel = accountSel();
- const txs = sel === 'spending' ? [] : wallet.history || [];
- const entries = wallet.loaded ? [
- ...txs.map((tx) => ({ time: tx.confirmed ? (tx.blockTime || 0) * 1000 : Date.now(), render: () => txHistoryItem(tx) })),
- ...featureAll('historyEntries', txs, sel),
- ].sort((a, b) => b.time - a.time).slice(0, 6) : [];
+ const unified = unifiedOn();
+ const sel = unified ? 'all' : accountSel();
+ const entries = wallet.loaded ? historyEntriesFor(sel).slice(0, 6) : [];
const rows = entries.map((e) => {
const row = e.render();
// a row opens its detail on the wallet page: go there first
@@ -5284,8 +5332,8 @@ function walletSide() {
h('button', { type: 'button', class: 'wallet-side-total', onClick: () => toWallet('history') },
h('span', { class: 'small muted' }, t('balance')),
h('span', { class: 'wallet-side-amount' }, wallet.loaded ? fmtAmount(spending + saving) + ' ' + unitLabel() : '…')),
- spendingActive() ? line(t('spendingLabel'), spending) : null,
- spendingActive() ? line(t('savingLabel'), saving) : null,
+ spendingActive() && (!unified || (spending > 0 && saving > 0)) ? line(unified ? t('balInstant') : t('spendingLabel'), spending) : null,
+ spendingActive() && (!unified || (spending > 0 && saving > 0)) ? line(unified ? t('balOnchain') : t('savingLabel'), saving) : null,
h('div', { class: 'row gap6' },
h('button', { type: 'button', class: 'btn-primary grow', onClick: () => toWallet('receive') }, t('tabReceive')),
h('button', { type: 'button', class: 'btn-primary grow', onClick: () => toWallet('send') }, t('tabSend')))),
@@ -5396,7 +5444,7 @@ function balanceCard() {
try { localStorage.setItem(ACCOUNT_KEY, 'spending'); } catch {}
}
ui.arkMoveDir = 'toSpending'; ui.arkMoveOpen = true; render();
- } }, t('topUpFromSavings'))
+ } }, unifiedOn() ? t('topUpInstant') : t('topUpFromSavings'))
: null,
!hasSpending && !kindLocked && featureHook('arkReady') && !wallet.watchOnly && acc0 && acc0.type === 'full'
&& featureHook('namesSettled') !== 'pending' // a restoring name may prove Spending any second — don't flash the setup ask
@@ -5421,6 +5469,32 @@ function balanceCard() {
return w;
})(),
];
+ // One account: one face with everything on it. Where it sits shows only
+ // when it's in both places (instant Ark coins, on-chain coins) — and every
+ // line under the figure (pending, moving, locked in gifts) belongs to it.
+ if (unifiedOn()) {
+ const split = spending > 0 && saving > 0
+ ? [{ label: t('balInstant'), sat: spending }, { label: t('balOnchain'), sat: saving }] : [];
+ const lines = split
+ .concat(pending > 0 ? [{ label: t('pending'), sat: pending, cls: 'v pending' }] : [])
+ .concat(featLines);
+ _accDir = null;
+ return h('div', { class: 'card balance balance-one' },
+ h('div', { class: 'balance-face' },
+ h('div', { class: 'row between', style: 'align-items:center' },
+ h('div', { class: 'small faint', style: 'text-transform:uppercase;letter-spacing:.06em' },
+ (acc0.viewLabels && acc0.viewLabels.all) || ''),
+ manageBtn('all')),
+ h('div', { class: 'amt', style: firstLoad ? 'opacity:.3' : '' },
+ firstLoad ? h('span', { class: 'spinner sm', style: 'margin-right:8px' }) : null,
+ // mid-board money is still this account's: it counts, and its Moving line says where it is
+ animatedAmount('bal:all', spending + (saving || 0) + (featureHook('spendingBoardingSat') || 0)), ' ', unitTag('unit')),
+ lines.length
+ ? h('div', { class: 'split' },
+ ...lines.map((l) => h('div', {}, h('div', { class: 'k' }, l.label), h('div', { class: l.cls || 'v' }, fmtAmount(l.sat), ' ', unitTag()))))
+ : null),
+ ...cardExtras('spending'));
+ }
const carouselMode = hasSpending && !kindLocked;
if (carouselMode) {
// Two SEPARATE cards side by side — the neighbor card peeks past the
@@ -5714,6 +5788,7 @@ function tabsBar() {
tabBtn(label, ui.tab === id, () => {
ui.tab = ui.tab === id ? 'history' : id;
ui.sendError = ''; // a stale send error never survives a tab change
+ ui.recvOnchain = false; // Receive opens on the payment address again
ui.revealShown = false; // re-mask the recovery phrase whenever tabs change
ui.nostrExportStep = false; // and the exported nostr key
ui.txDetail = null; // back to the history list when leaving/returning
@@ -5808,6 +5883,11 @@ function iconGlyph(ic) {
: h('span', { class: 'sel-ico' }, ic);
}
+// One account's Receive: the door to an on-chain address under the payment one.
+function receiveOnchainBtn() {
+ if (!unifiedOn() || wallet.watchOnly) return null;
+ return h('button', { class: 'btn-block', id: 'recv-onchain', onClick: () => { ui.recvOnchain = true; render(); } }, t('recvOnchain'));
+}
function receiveTab() {
// Feature takeovers: boarding success, Ark receive celebration, etc.
const takeover = featureHook('receiveTakeover');
@@ -5846,6 +5926,17 @@ function receiveTab() {
// (receives Ark and Lightning), Savings shows a fresh on-chain address.
const fresh = wallet.freshReceive();
const nameMode = featureAll('receiveModes').find((m) => m.id === 'name');
+ // One account: the payment address leads, an on-chain address is a tap
+ // away (and is all there is offline). What arrives on-chain stays on-chain.
+ if (unifiedOn() && (ui.recvOnchain || wallet.offline)) {
+ return h('div', { class: 'card col', style: 'align-items:center;gap:14px' },
+ wallet.offline ? h('div', { class: 'notice info', style: 'width:100%' }, t('receiveOfflineOnchain')) : null,
+ h('div', { html: qrSvg(fresh.address) }),
+ h('div', { class: 'addr-box', style: 'width:100%' }, fresh.address),
+ copyBtn(fresh.address, t('copyAddress')),
+ h('div', { class: 'small muted', style: 'text-align:center' }, t('recvOnchainNote')),
+ wallet.offline ? null : h('button', { class: 'btn-block', id: 'recv-payaddr', onClick: () => { ui.recvOnchain = false; render(); } }, t('recvPaymentAddress')));
+ }
if (accountSel() === 'spending') {
// Spending needs the network (registrar + ark); offline, offer the
// on-chain path right here instead of an endless spinner.
@@ -5869,7 +5960,8 @@ function receiveTab() {
h('div', { html: qrSvg(ui.arkRecvAddr) }),
h('div', { class: 'addr-box break', style: 'width:100%' }, ui.arkRecvAddr),
copyBtn(ui.arkRecvAddr, t('copyAddress')),
- featureHook('posAvailable') ? h('button', { class: 'btn-block', id: 'recv-amount', onClick: () => featureHook('openAmountRequest') }, t('recvAmount')) : null
+ featureHook('posAvailable') ? h('button', { class: 'btn-block', id: 'recv-amount', onClick: () => featureHook('openAmountRequest') }, t('recvAmount')) : null,
+ receiveOnchainBtn()
);
}
}
@@ -6795,7 +6887,7 @@ function historyTab() {
// ledger (BIP84 txs, silent-payment receipts, gift reservations), Spending
// shows the ark side (receives, sends, boards, LN) — each card of the
// carousel owns its own timeline.
- const histSel = accountSel();
+ const histSel = unifiedOn() ? 'all' : accountSel();
const txs = histSel === 'spending' ? [] : wallet.history; // newest first
const featDetail = featureHook('historyDetail');
if (featDetail) return featDetail;
@@ -6813,16 +6905,11 @@ function historyTab() {
h('span', { class: 'spinner' }),
wallet.historyLoading ? h('p', { class: 'small muted', style: 'margin:0' }, t('loadingHistory')) : null
);
- const featEntries = featureAll('historyEntries', txs, histSel);
+ // Transactions and feature entries merge into one timeline.
+ const entries = historyEntriesFor(histSel);
// nothing yet: no card at all, it appears with the first payment
// (Adam, 2026-11-15: "let's not show an empty history section")
- if (!txs.length && !featEntries.length) return null;
-
- // Transactions and feature entries merge into one timeline.
- const entries = [
- ...txs.map((tx) => ({ time: tx.confirmed ? (tx.blockTime || 0) * 1000 : Date.now(), render: () => txHistoryItem(tx) })),
- ...featEntries,
- ].sort((a, b) => b.time - a.time);
+ if (!entries.length) return null;
const txPages = Math.ceil(entries.length / PAGE_SIZE);
const txPage = Math.min(ui.txPage, Math.max(0, txPages - 1));
const txSlice = entries.slice(txPage * PAGE_SIZE, txPage * PAGE_SIZE + PAGE_SIZE);
@@ -7050,6 +7137,8 @@ const ctx = {
shownPubkey: () => (featureHook('nostrLoginIdentity') || {}).pubkey
|| (wallet.nostrPubkey && wallet.nostrPubkey()) || (activeAccount() || {}).nostrPk || null,
getAccount: () => accountSel(),
+ unifiedBalance: () => unifiedOn(),
+ receiveOnchainBtn: () => receiveOnchainBtn(),
setAccount: (a, dir) => setAccountSel(a, dir),
offerProfileSetup, pickConfirm,
// the ways back in (Settings → Wallet): what's set up, and adding one
diff --git a/src/features/ark.js b/src/features/ark.js
index 0456628..2c1a581 100644
--- a/src/features/ark.js
+++ b/src/features/ark.js
@@ -1516,13 +1516,27 @@ export function arkFeature(ctx) {
: m.type === 'ln-send' && m.invoice ? zapNotes()['inv:' + m.invoice]
: null;
- function arkHistoryItem(m) {
+ // A move inside one account (on-chain ⇄ Ark): no money in or out, only
+ // what moving it cost.
+ function arkInternalMoveItem(m, feeSat, pending) {
+ const label = m.type === 'board' ? (pending ? t('movingInstant') : t('movedInstant')) : t('movedOnchain');
+ return h('div', { class: 'item internal-move', style: m.id ? 'cursor:pointer' : '', onClick: m.id ? () => { ui.arkMoveDetail = m.id; render(); } : undefined },
+ h('div', { class: 'ico' }, '\u21c4'),
+ h('div', { class: 'grow' },
+ h('div', {}, label),
+ h('div', { class: 'small faint' }, (pending ? t('pending') + ' · ' : '') + fmtAmount(m.amountSat || 0) + ' ' + unitLabel() + ' · ' + timeAgo((m.ts || Date.now()) / 1000))),
+ h('div', { style: 'text-align:right' },
+ feeSat > 0 ? h('div', { class: 'amount-neg' }, fmtAmount(feeSat)) : h('div', { class: 'small faint' }, t('arkDepthFree'))));
+ }
+
+ function arkHistoryItem(m, labelAs) {
const failed = m.status === 'failed';
const incoming = !['send', 'offboard', 'exit', 'ln-send', 'refresh'].includes(m.type);
- const label = failed ? t('arkLnPayFailed') : m.type === 'receive' ? t('received') : m.type === 'board' ? t('arkBoarded')
+ let label = failed ? t('arkLnPayFailed') : m.type === 'receive' ? t('received') : m.type === 'board' ? t('arkBoarded')
: m.type === 'ln-send' ? t('arkLnPaidHistory') : m.type === 'ln-receive' ? t('arkLnReceivedHistory')
: m.type === 'offboard' ? t('arkOffboarded') : m.type === 'exit' ? t('arkExited')
: m.type === 'refresh' ? t('arkRenewedHistory') : t('sent');
+ if (labelAs) label = labelAs;
// A spent input proves neither a payment amount nor its date: it can
// contain change, an offboard, or a renewal this device has not synced.
// Show the missing history explicitly until its records arrive.
@@ -4270,7 +4284,11 @@ export function arkFeature(ctx) {
}
// In a Spending wallet an on-chain address means "exit ark to there":
// the offboard happens right in the send flow, no Move money ceremony.
- if (ctx.getAccount() === 'spending' && wallet.isOnchainAddress(inv) && arkAvailable()) {
+ // One balance: an on-chain address is paid from the on-chain coins
+ // when there are any — one ordinary transaction, nothing to move out
+ // of Ark first. Only without them does the payment leave Ark.
+ const onchainFirst = ctx.unifiedBalance && ctx.unifiedBalance() && (wallet.spendable || 0) > 0;
+ if (ctx.getAccount() === 'spending' && !onchainFirst && wallet.isOnchainAddress(inv) && arkAvailable()) {
const b = arkBalance() || {};
if ((b.spendableSat || 0) > 0) {
ui.arkOffboardSend = { address: inv, amount: '' };
@@ -4333,10 +4351,11 @@ export function arkFeature(ctx) {
render();
} }, t('arkExitInFlightLink', { n: fmtAmount(acts.reduce((s2, a) => s2 + a.amountSat, 0)) }));
},
- historyEntries(_txs, sel) {
- if (sel && sel !== 'spending') return []; // ark movements are the Spending timeline
+ historyEntries(txs, sel) {
+ if (sel && sel !== 'spending' && sel !== 'all') return []; // ark movements are the Spending timeline
const s = arkStateNow();
if (!s) return [];
+ if (sel === 'all') return this._histOne(s, txs || []);
// Memoized on the state's REVISION, not a timer. This rebuild sorts and
// dedupes every movement, resolves gifts, and touches secp256k1 — ~60ms
// cold. A 1.5s TTL used to re-cool it between unhurried flicks, so every
@@ -4349,6 +4368,35 @@ export function arkFeature(ctx) {
this._histMemo = { key, val };
return val;
},
+ // One balance's timeline: a board, or an offboard to our own on-chain
+ // address, moves money between two halves of the same account. Its
+ // on-chain transaction and its Ark movement were two rows (Sent, then
+ // Boarded); here they're one, worth what the move cost.
+ _histOne(s, txs) {
+ const key = `${s._rev || 0}:${(s.movements || []).length}:${(s.actions || []).length}`;
+ if (!(this._histMemo && this._histMemo.key === key)) this._histMemo = { key, val: this._histBuild(s) };
+ const own = new Map(txs.map((tx) => [tx.txid, tx]));
+ const rows = this._histMemo.val.map((e) => {
+ const m = e.m;
+ // with no Savings to move to, an offboard elsewhere is a payment
+ if (m && m.type === 'offboard' && !(m.txid && own.has(m.txid))) return { ...e, render: () => arkHistoryItem(m, t('sent')) };
+ if (!m || !m.txid || !own.has(m.txid) || (m.type !== 'board' && m.type !== 'offboard')) return e;
+ const tx = own.get(m.txid);
+ const feeSat = m.type === 'board' ? Math.max(0, -(tx.net || 0) - (m.amountSat || 0)) : (m.feeSat || 0);
+ return { ...e, replacesTxid: m.txid, render: () => arkInternalMoveItem(m, feeSat, false) };
+ });
+ // a board still waiting on its funding transaction's confirmations
+ const told = new Set(rows.map((e) => e.replacesTxid).filter(Boolean));
+ for (const a of s.actions || []) {
+ if (a.type !== 'board' || !a.fundingTxid || ['done', 'failed'].includes(a.step) || told.has(a.fundingTxid)) continue;
+ const tx = own.get(a.fundingTxid);
+ if (!tx) continue;
+ const m = { id: null, type: 'board', amountSat: (a.amountSat || 0) - (a.feeSat || 0), ts: exitStartedTs(a), txid: a.fundingTxid };
+ const feeSat = Math.max(0, -(tx.net || 0) - m.amountSat);
+ rows.push({ time: m.ts, replacesTxid: a.fundingTxid, render: () => arkInternalMoveItem(m, feeSat, true) });
+ }
+ return rows;
+ },
_histBuild(s) {
// In-flight exits are payments the user made — they belong in history
// as pending records, not on a monitoring page nobody thinks to visit.
@@ -4432,7 +4480,7 @@ export function arkFeature(ctx) {
}
}
this._histFolded = folded; // a folded row's detail shows the whole payment
- return exits.concat(renewals, lnPending, out.map((m) => ({ time: m.ts, render: () => arkHistoryItem(m), csv: arkCsvRow(m) })));
+ return exits.concat(renewals, lnPending, out.map((m) => ({ time: m.ts, m, render: () => arkHistoryItem(m), csv: arkCsvRow(m) })));
},
historyDetail() {
if (ui.arkExitDetail) {
diff --git a/src/features/names.js b/src/features/names.js
index 81b64e6..e1f23ce 100644
--- a/src/features/names.js
+++ b/src/features/names.js
@@ -685,6 +685,8 @@ export function namesFeature(ctx) {
}))),
// ask for a sum: the point of sale's amount pad and invoice, simplified
hook('posAvailable') ? h('button', { class: 'btn-block', id: 'recv-amount', onClick: () => hook('openAmountRequest') }, t('recvAmount')) : null,
+ // one balance: an on-chain address for the payers who need one
+ ctx.receiveOnchainBtn ? ctx.receiveOnchainBtn() : null,
moreSection());
}
diff --git a/src/i18n.js b/src/i18n.js
index bb82ed2..9dfc172 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -1679,6 +1679,18 @@ const STR = {
settingsAdvancedDesc: 'Network, rarities, rescues',
aboutTitle: 'About',
recvAmount: 'Amount',
+ recvOnchain: 'Bitcoin address',
+ recvPaymentAddress: 'Payment address',
+ recvOnchainNote: 'For a payment on-chain, from an exchange or another wallet. It stays on-chain until you spend it.',
+ receiveOfflineOnchain: "You're offline. This on-chain address still takes payments.",
+ balInstant: 'Instant',
+ balOnchain: 'On-chain',
+ topUpInstant: 'Make on-chain bitcoin instant',
+ allSettingsDesc: 'Coins, renewals, lock, recovery phrase, public key',
+ separateBalances: 'Show Spending and Savings separately',
+ movedInstant: 'Made instant',
+ movingInstant: 'Making instant',
+ movedOnchain: 'Moved on-chain',
recvAmountTitle: 'Request an amount',
recvAmountNote: 'What it’s for (optional)',
recvAmountGo: 'Create invoice',
diff --git a/tools/balance-settings-row-test.js b/tools/balance-settings-row-test.js
index 38d34b3..351e2fe 100644
--- a/tools/balance-settings-row-test.js
+++ b/tools/balance-settings-row-test.js
@@ -31,7 +31,7 @@ const openWalletPage = async () => {
try {
await page.setViewport({ width: 390, height: 844 });
await page.goto(server.url.href, { waitUntil: 'domcontentloaded' });
- await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'mainnet'));
+ await page.evaluate(() => (localStorage.setItem('btc-wallet-network', 'mainnet'), localStorage.setItem('btc-wallet-separate-balances', '1')));
await page.reload({ waitUntil: 'domcontentloaded' });
await sleep(400);
// on mainnet Create makes a Spending-only account (signup-quick-test); a
diff --git a/tools/send-enter-keys-test.js b/tools/send-enter-keys-test.js
index aac95f8..54f2c02 100644
--- a/tools/send-enter-keys-test.js
+++ b/tools/send-enter-keys-test.js
@@ -45,8 +45,13 @@ const armPrimary = () => page.evaluate(() => {
try {
await page.setViewport({ width: 390, height: 844 });
await page.goto(server.url.origin, { waitUntil: 'domcontentloaded' });
+ // the two-card carousel is the "separately" view now (one balance is the default)
+ await page.evaluate(() => localStorage.setItem('btc-wallet-separate-balances', '1'));
+ await page.reload({ waitUntil: 'domcontentloaded' });
await sleep(400);
- await click('create a new wallet'); await sleep(500); await click('to import'); await sleep(400);
+ // a seed wallet comes in through the seed-phrase door (Create is a sign-up on mainnet)
+ await page.waitForSelector('#onb-signin'); await page.click('#onb-signin'); await sleep(400);
+ await page.click('#onb-restore'); await sleep(400);
await page.waitForSelector('textarea'); await page.type('textarea', generateMnemonic(wordlist)); await click('open wallet');
for (let i = 0; i < 80 && !(await page.evaluate(() => [...document.querySelectorAll('button')].some((b) => b.textContent.trim() === 'Send'))); i++) {
await page.evaluate(() => [...document.querySelectorAll('button')].find((b) => /^(not now|skip|continue|later)$/i.test(b.textContent.trim()))?.click());
diff --git a/tools/signup-quick-test.js b/tools/signup-quick-test.js
index a269faf..3e38c5f 100644
--- a/tools/signup-quick-test.js
+++ b/tools/signup-quick-test.js
@@ -8,11 +8,11 @@
//
// Mainnet, with the Ark server's info read for real and the names registrar
// mocked (nothing is claimed): Create an account → no twelve words, no check
-// → Claim your name (no "Not now") → Choose your look → in, on a Spending-only
-// wallet (no carousel, no Savings face); the wallet line asks for a way back
-// in; Settings → Wallet shows "Ways back in" (passkey via a CDP virtual
-// authenticator → listed, the line goes away) and "Add a savings account"
-// (→ the Savings face appears); a reload keeps both.
+// → Claim your name (no "Not now") → Choose your look → in, on ONE balance
+// (no carousel; on-chain is part of the account, a Bitcoin address a tap away
+// on Receive); Settings → Wallet shows "Ways back in" (passkey via a CDP
+// virtual authenticator → listed) and one balance row, with "Show Spending
+// and Savings separately" (→ the two faces; a reload keeps them).
// Run: bun tools/signup-quick-test.js (NO_BUILD=1 to reuse dist/)
import puppeteer from './puppeteer.js';
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -81,7 +81,7 @@ try {
body: document.body.innerText,
}));
let s = await shape();
- check('in, on Spending alone (no Savings face, no name on it)', s.faces === 1 && !s.carousel && !s.label, JSON.stringify({ faces: s.faces, carousel: s.carousel, label: s.label }));
+ check('in, on one balance (no carousel, no name on it)', s.faces === 1 && !s.carousel && !s.label && !!(await page.$('.balance-one')), JSON.stringify({ faces: s.faces, carousel: s.carousel, label: s.label }));
// asked once, and only with money in the account (2026-11-15): not on an empty one
check('no way-back-in prompt on an empty account', !/add a way back into your account/i.test(s.body) && !(await page.$('.ways-back-prompt')));
// money arrives in Spending (the ark feature, found on the heap, made to
@@ -117,15 +117,22 @@ try {
if (process.env.SHOT4) await page.screenshot({ path: process.env.SHOT4 });
await click('back'); await sleep(500);
check('Back returns to Receive', !(await page.$('.pos-amount')) && !!(await page.$('#recv-amount')));
+ // one account takes on-chain payments too: its address under the payment one
+ check('Receive offers a Bitcoin address', !!(await page.$('#recv-onchain')));
+ await page.click('#recv-onchain'); await sleep(400);
+ const oc = await page.evaluate(() => document.querySelector('.addr-box')?.textContent.trim() || '');
+ check('...an on-chain address', /^bc1q/.test(oc), oc);
+ await page.click('#recv-payaddr'); await sleep(400);
+ check('...and back to the payment address', !!(await page.$('#recv-amount')) && !(await page.$('#recv-payaddr')));
const acct = await page.evaluate(() => JSON.parse(sessionStorage.getItem('btc-wallet-accounts') || '{}'));
const a0 = (acct.accounts || [])[0] || {};
- check('the account: spending-only, phrase unseen, saved to the device', a0.kind === 'spending' && a0.savingsLater && a0.seedSeen === false && a0.persisted, JSON.stringify({ kind: a0.kind, later: a0.savingsLater, seen: a0.seedSeen, persisted: a0.persisted }));
+ check('the account: one balance (no kind), phrase unseen, saved to the device', !a0.kind && !a0.savingsLater && !!a0.spendingSetup && a0.seedSeen === false && a0.persisted, JSON.stringify({ kind: a0.kind, later: a0.savingsLater, seen: a0.seedSeen, persisted: a0.persisted }));
await openWalletPage();
check('Settings → Wallet opens with Ways back in', !!(await page.$('.ways-back')) && /ways back in/i.test(await text()));
const views = await page.$$eval('.balance-settings-row[data-view]', (l) => l.map((e) => e.dataset.view));
check('the ways back in read as auth buttons', (await page.$$eval('.ways-back-add', (l) => l.map((e) => e.textContent.trim()))).join('|') === 'Passkey auth|Google auth|Nostr auth|Pen and paper', (await page.$$eval('.ways-back-add', (l) => l.map((e) => e.textContent.trim()))).join('|'));
- check('only Spending is listed, with Add a savings account', views.join() === 'spending' && !!(await page.$('#add-savings')), views.join());
+ check('one balance row, nothing to add', views.join() === 'all' && !(await page.$('#add-savings')), views.join());
if (process.env.SHOT2) { await page.evaluate(() => document.documentElement.setAttribute('data-theme', 'dark')); await page.evaluate(() => document.querySelector('.balance-settings-row').closest('.card').scrollIntoView()); await sleep(300); await page.screenshot({ path: process.env.SHOT2 }); await page.evaluate(() => document.documentElement.removeAttribute('data-theme')); }
if (process.env.SHOT) { await page.evaluate(() => document.querySelector('.ways-back').scrollIntoView()); await page.screenshot({ path: process.env.SHOT }); }
// a passkey: the relays are stubbed, so the publish fails offline — the
@@ -141,16 +148,21 @@ try {
await sleep(500);
check('Pen and paper opens the recovery phrase card', !!(await page.$('.recovery-card .words')));
- await page.evaluate(() => document.getElementById('add-savings')?.click()); await sleep(800);
+ await page.evaluate(() => document.getElementById('separate-balances')?.click()); await sleep(800);
const views2 = await page.$$eval('.balance-settings-row[data-view]', (l) => l.map((e) => e.dataset.view));
- check('Add a savings account adds Savings beside Spending', views2.join() === 'spending,savings' && !(await page.$('#add-savings')), views2.join());
+ check('Show separately lists Spending and Savings', views2.join() === 'spending,savings', views2.join());
await page.goBack(); await page.goBack(); await sleep(800);
s = await shape();
- check('the wallet now has both faces', s.carousel && s.faces === 2, JSON.stringify({ faces: s.faces, carousel: s.carousel }));
+ check('...and the wallet has both faces', s.carousel && s.faces === 2, JSON.stringify({ faces: s.faces, carousel: s.carousel }));
await page.reload({ waitUntil: 'domcontentloaded' });
await page.waitForSelector('.balance-face', { timeout: 20000 }); await sleep(1500);
s = await shape();
- check('a reload keeps Savings', s.carousel && s.faces === 2);
+ check('a reload keeps them apart', s.carousel && s.faces === 2);
+ await openWalletPage();
+ await page.evaluate(() => document.getElementById('separate-balances')?.click()); await sleep(800);
+ await page.goBack(); await page.goBack(); await sleep(800);
+ s = await shape();
+ check('unticked, one balance again', !s.carousel && s.faces === 1 && !!(await page.$('.balance-one')));
// A new device: everything here wiped, the relays holding only what the
// passkey published. Sign in → Passkey opens THIS account, as itself.
diff --git a/tools/unified-balance-test.js b/tools/unified-balance-test.js
new file mode 100644
index 0000000..c349368
--- /dev/null
+++ b/tools/unified-balance-test.js
@@ -0,0 +1,127 @@
+// One balance (Adam, 2026-11-15: "combine the Ark and savings Bitcoin
+// accounts into a single account … a combined history … the balance would be
+// unified"). The Ark feature's side of it, without a browser:
+// - the combined timeline tells a move between the two halves once: a board
+// (its on-chain Sent + its Boarded) and an offboard to our own address
+// (its Moved to Savings + the on-chain Received) are one row each, worth
+// what the move cost; a board still confirming is one pending row; an
+// offboard to someone else stays a payment
+// - the separate Spending timeline is untouched
+// - an on-chain address is paid from on-chain coins when there are any, and
+// leaves Ark (offboard) only when there aren't
+// Run: bun tools/unified-balance-test.js
+import { buildFeatures } from '../src/features/index.js';
+import { getArkConfig } from '../src/api.js';
+
+let fails = 0;
+const check = (name, ok, detail = '') => {
+ console.log(` ${ok ? '✓' : '✗'} ${name}${detail ? ' — ' + String(detail).slice(0, 240) : ''}`);
+ if (!ok) fails++;
+};
+
+globalThis.fetch = async () => { throw new Error('offline (test)'); };
+globalThis.window = undefined;
+globalThis.localStorage = {
+ _d: {}, getItem(k) { return this._d[k] ?? null; }, setItem(k, v) { this._d[k] = String(v); },
+ removeItem(k) { delete this._d[k]; }, key(i) { return Object.keys(this._d)[i] ?? null; },
+ get length() { return Object.keys(this._d).length; },
+};
+const cfg = getArkConfig();
+localStorage.setItem('btc-wallet-arkinfo:' + cfg.ark, JSON.stringify({ info: { minBoardAmountSat: 1000, boardFees: {} }, tip: 1, at: Date.now() }));
+
+const T = Date.now() - 3600_000;
+const A = 'a'.repeat(64), B = 'b'.repeat(64), C = 'c'.repeat(64), D = 'd'.repeat(64), E = 'e'.repeat(64);
+const arkState = {
+ _rev: 1,
+ vtxos: [{ id: 'v1', amountSat: 20000, state: 'spendable' }],
+ movements: [
+ { id: 'm-board', type: 'board', amountSat: 9000, status: 'complete', txid: A, ts: T },
+ { id: 'm-off', type: 'offboard', amountSat: 5000, feeSat: 300, status: 'complete', txid: B, to: 'bc1qown', ts: T + 1000 },
+ { id: 'm-off-ext', type: 'offboard', amountSat: 7000, feeSat: 300, status: 'complete', txid: D, to: 'bc1qsomeoneelse', ts: T + 2000 },
+ { id: 'm-recv', type: 'receive', amountSat: 1234, status: 'complete', vtxoId: 'v1', ts: T + 3000 },
+ ],
+ actions: [
+ { id: `board-${T + 4000}`, type: 'board', step: 'funded', amountSat: 3000, feeSat: 0, fundingTxid: C },
+ ],
+};
+// the on-chain wallet's view: board fundings out, the own offboard in
+const txs = [
+ { txid: A, net: -9200, confirmed: true, blockTime: T / 1000 },
+ { txid: B, net: 5000, confirmed: true, blockTime: (T + 1000) / 1000 },
+ { txid: C, net: -3150, confirmed: false },
+ { txid: E, net: 40000, confirmed: true, blockTime: (T + 5000) / 1000 },
+];
+
+const store = {};
+const wallet = {
+ watchOnly: false, offline: false, spendable: 0, feeRates: { halfHourFee: 1 },
+ utxos: [], txs, history: txs, receive: [], change: [],
+ account: () => ({}),
+ isOnchainAddress: (a) => /^bc1q/.test(a),
+ loadFeatureState: (n, fb) => JSON.parse(store[n] || 'null') || fb,
+ saveFeatureState: (n, st) => { store[n] = JSON.stringify(st); },
+ _cacheKey: () => 'test', saveCache: () => {},
+ nostrPubkey: () => 'ab'.repeat(32),
+ registerCacheExtension: () => {}, registerRealtimeHook: () => {}, registerLoadHook: () => {},
+ registerScanHook: () => {}, registerCacheSavedHook: () => {}, registerCoinLock: () => {},
+ loadArkState: () => arkState, peekArkState: () => arkState, saveArkState: () => {},
+ _arkNs: () => 'ns', _arkKey: () => 'k', _arkHoldKey: () => 'h', _arkVtxoOwner: () => null, adoptArkState: () => null,
+ freshReceive: () => ({ address: 'bc1qtest' }), freshChange: () => ({ address: 'bc1qchange' }),
+ balance: () => ({ spendableSat: 0 }), emit: () => {}, on: () => {},
+};
+let unified = true;
+const ui = { account: 'spending', send: { recipients: [{ address: '' }] } };
+let features = [];
+const ctx = {
+ h: (tag, attrs, ...kids) => ({ tag, attrs: attrs || {}, kids: kids.flat().filter((k) => k != null && k !== false) }),
+ ui, render: () => {}, wallet,
+ hook: (name, ...args) => { for (const f of features) if (f[name]) { const v = f[name](...args); if (v) return v; } return null; },
+ getAccount: () => ui.account, setAccount: (a) => { ui.account = a; }, unifiedBalance: () => unified,
+ goHome: () => {}, openMnemonic: async () => {},
+ fmtAmount: (n) => Number(n).toLocaleString('en-US'), unitLabel: () => 'sats', unitTag: () => 'sats', getUnit: () => 'sats',
+ parseAmount: (v) => parseInt(v, 10) || 0, amountField: (n) => String(n),
+ copyBtn: () => null, pasteBtn: () => null, toast: () => {}, blankSend: () => ({ recipients: [{ address: '' }] }),
+ openExternal: () => {},
+};
+features = buildFeatures(ctx);
+const ark = features.find((f) => f.id === 'ark');
+const text = (n) => typeof n === 'string' || typeof n === 'number' ? String(n) : n && n.kids ? n.kids.map(text).join(' ') : '';
+
+console.log('[one timeline]');
+{
+ const rows = ark.historyEntries(txs, 'all');
+ const replaced = rows.map((e) => e.replacesTxid).filter(Boolean).sort();
+ check('the board, the own offboard and the confirming board stand in for their on-chain rows', replaced.join() === [A, B, C].sort().join(), replaced.map((x) => x[0]).join());
+ check('the offboard to someone else is not a move', !replaced.includes(D));
+ const byTx = Object.fromEntries(rows.filter((e) => e.replacesTxid).map((e) => [e.replacesTxid, text(e.render())]));
+ check('the board reads Made instant, worth its cost (9,200 out, 9,000 in)', /Made instant/.test(byTx[A]) && /\b200\b/.test(byTx[A]) && /9,000/.test(byTx[A]), byTx[A]);
+ check('the own offboard reads Moved on-chain, worth its fee', /Moved on-chain/.test(byTx[B]) && /\b300\b/.test(byTx[B]), byTx[B]);
+ check('the confirming board is one pending row', /Making instant/.test(byTx[C]) && /Pending/.test(byTx[C]) && /\b150\b/.test(byTx[C]), byTx[C]);
+ const others = rows.filter((e) => !e.replacesTxid).map((e) => text(e.render())).join(' | ');
+ check('the other Ark rows are as they were', /Received/.test(others) && !/Boarded/.test(others), others);
+ check('the offboard to someone else reads Sent, not Moved to Savings', /Sent/.test(others) && !/Savings/.test(others), others);
+}
+
+console.log('[the Spending timeline, shown apart]');
+{
+ const rows = ark.historyEntries([], 'spending');
+ check('no row stands in for an on-chain one', rows.every((e) => !e.replacesTxid), rows.length);
+ check('the board is still its own Boarded row', rows.some((e) => /Boarded/.test(text(e.render()))));
+ check('Savings gets no Ark rows', ark.historyEntries(txs, 'savings').length === 0);
+}
+
+console.log('[paying an on-chain address]');
+{
+ ui.arkOffboardSend = null; wallet.spendable = 50000;
+ ark.matchSendText('bc1qrecipient');
+ check('with on-chain coins it is an ordinary on-chain send', !ui.arkOffboardSend);
+ ui.arkOffboardSend = null; wallet.spendable = 0;
+ ark.matchSendText('bc1qrecipient');
+ check('without them it leaves Ark', !!ui.arkOffboardSend && ui.arkOffboardSend.address === 'bc1qrecipient');
+ ui.arkOffboardSend = null; wallet.spendable = 50000; unified = false;
+ ark.matchSendText('bc1qrecipient');
+ check('shown apart, Spending still pays it from Ark (as before)', !!ui.arkOffboardSend);
+}
+
+console.log(fails ? `FAIL (${fails})` : 'PASS');
+process.exit(fails ? 1 : 0);