aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-15 19:30:16 -0700
committerAdam Soltys <[email protected]>2026-11-15 19:30:16 -0700
commite883fefbc9baff516af25869560cf6198c603fab (patch)
tree5781667c93d057f04d42ce2af603635ec943fb4e /tools
parent5554c7066113976b49c18c5c7505dd252769e72d (diff)
downloadcoinosv3-e883fefbc9baff516af25869560cf6198c603fab.tar.gz
coinosv3-e883fefbc9baff516af25869560cf6198c603fab.zip
One balance: Spending and Savings on the same seed are one account. "Do you think we could combine the ARC and savings Bitcoin accounts into a single account? So if someone receives into a on-chain Bitcoin address, would hold it there, but they'd have a combined history, and it would select which coins to spend based on where you're paying out of, but the balance would be unified" … "Yeah go for it" (Adam, 2026-11-15). Step 1 of two: the wallet shows one balance card (the total, Ark and on-chain, with money mid-board still counted; an Instant / On-chain split appears only when there's some in both). History is one timeline, and a move between the two halves is one row priced at its cost: a board's on-chain Sent and its Boarded become "Made instant" (or "Making instant" while it confirms), and an offboard to our own address becomes "Moved on-chain". An offboard to someone else reads Sent. Receive leads with the payment address, with a Bitcoin address button for on-chain payers; the address stays on-chain and is all that's offered offline. Payments start from the Ark coins, and an on-chain address is paid from on-chain coins when there are any, leaving Ark only when there aren't. Accounts lists one row, Settings → Wallet has one balance row (Spending's coin settings plus the public key), and a per-device "Show Spending and Savings separately" brings the two-card carousel back as it was. Sign-ups are now this one account instead of Spending-only with Savings added later. Older Spending-only accounts are converted the same way, and the Add savings row only shows when the balances are shown apart. Not yet (step 2): covering a shortfall by boarding or offboarding automatically, and the "available now" split on the amount screen. New unified-balance-test (folded rows, their costs, the separate Spending timeline, on-chain-first routing) passes, along with signup-quick (one balance, Bitcoin address on Receive, separate toggle and back), balance-settings-row and send-enter-keys (both now opt into separate; send-enter-keys also enters through the seed-phrase door since Create became a sign-up), features-smoke, onboard-backup, gift-profile-setup, footer-support, pos, chat-layout, account-delete, lock-wallet, padlock-flow, profile-actions, gift-build, ark-ln-savings-small, carousel-flick, amber-dm-upgrade, send-lnaddr-advance, account-switch-leak and ark-offline-init. feed-choice-per-wallet fails at its second wallet's import, and fails the same way on 5554c70.HEADmaster
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6SwkivduFDDkMmnXjZ
Diffstat (limited to 'tools')
-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
4 files changed, 158 insertions, 14 deletions
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);