diff --git a/README.md b/README.md index 50b8eb0..82095e2 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ A client-only BRC-100 wallet application at [mountaintops.net](https://mountaint ## Receiving, expiration and recovery -The main Receive view shows one selected address, its expiration status and payment controls. Other addresses, advanced search targets, transaction eligibility and recovery explanations are collapsed until needed; Send has its own view. A saved address with longer coverage is offered directly before suggesting more mining. Expiration warnings and fees remain beside the affected action. +The main Receive view shows one selected address, its expiration status and payment controls. Payments to all addresses are checked explicitly and shown together, so switching receiving addresses does not hide earlier funds. Each import still uses its own address/key and the existing verified-input flow. Other addresses, advanced search targets, transaction eligibility and recovery explanations are collapsed until needed; Send has its own view. A saved address with longer coverage is offered directly before suggesting more mining. Expiration warnings and fees remain beside the affected action. -The original address keeps the exact `[1, 'mountaintops']`, decimal key ID `1`, counterparty `anyone`, `forSelf: true` derivation. Browser workers search canonical decimal key IDs from `1` upward, returning the first match for a fixed BRC-234 target. The suggested target uses a measured 30-second, 95th-percentile work estimate; each work slice is bounded to 30 seconds. Search is free. A match requires explicit **Save address** (wallet fees apply) before the address can be displayed/shared, then **Use for receiving** to switch receiving. Pausing is free; saving resumable progress to the wallet is an explicit fee-bearing step. Unsaved work can always be repeated deterministically from ID 1; no published address depends on that session's memory. +The original address keeps the exact `[1, 'mountaintops']`, decimal key ID `1`, counterparty `anyone`, `forSelf: true` derivation. Browser workers search canonical decimal key IDs from `1` upward, returning the first match for a fixed BRC-234 target. The suggested target uses a measured 30-second, 95th-percentile work estimate; each work slice is bounded to 30 seconds. Search is free. A match requires explicit **Save & use address** (wallet fees apply) before the address can be displayed/shared. One encrypted address-publication record also selects it for receiving, avoiding a second fee-bearing preference transaction. Switching to an older saved address remains an explicit durable selection, with applicable wallet fees. Pausing is free; saving resumable progress to the wallet is an explicit fee-bearing step. Unsaved work can always be repeated deterministically from ID 1; no published address depends on that session's memory. -Address publications, primary selections, search progress, permanent receiving retirements, chain checkpoints, bounded-history completion are immutable encrypted on-chain PushDrop records using SDK `LocalKVStore` in wallet basket `mntops v1`. Each metadata record uses a 1-satoshi output plus applicable network and wallet service fees and the wallet's permission flow. There are no certificate APIs or certificate storage. Independent random record keys allow concurrent-device records to merge without overwriting another device's address history. A published address is never acknowledged until the wallet can read its record back. +Address publications, primary selections, search progress, permanent receiving retirements, chain checkpoints, bounded-history completion are immutable encrypted on-chain PushDrop records using SDK `LocalKVStore` in wallet basket `mntops v1`. Each metadata record uses a 1-satoshi output plus applicable network and wallet service fees and the wallet's permission flow. There are no certificate APIs or certificate storage. Independent random record keys allow concurrent-device records to merge without overwriting another device's address history. A published address is never acknowledged until the wallet can read its record back. Optional `useForReceiving: true` on an address record participates in the same ordered selection stream as legacy `primary` records. Older clients can still recover the address; they must reload an updated build to interpret the combined selection. Restore the same BRC-100 wallet account and its supported storage/recovery service on any device. Browser storage, the old device, an open tab, manually saved key IDs and exports are not recovery dependencies. The original address can be reconstructed without a storage transaction. As with other BRC-100 applications, the wallet account and its storage service must remain available. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b0472e8..ba28ee9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -27,7 +27,6 @@ export default function Mountaintops() { const [balances, setBalances] = useState>({}) const [view, setView] = useState<'receive' | 'send'>('receive') const [target, setTarget] = useState('auto') - const [found, setFound] = useState(null) const [candidate, setCandidate] = useState<{ stage: number; keyID: string; address: string } | null>(null) const [pausedSearch, setPausedSearch] = useState<{ stage: number; next: string } | null>(null) const [recipient, setRecipient] = useState('') @@ -55,7 +54,7 @@ export default function Mountaintops() { const { network } = await client.getNetwork({}) const { publicKey: identity } = await client.getPublicKey({ identityKey: true }) if (previous && (previous.identity !== identity || previous.network !== network)) { - setSession(null); setBalances({}); setFound(null); setCandidate(null); setPausedSearch(null); setHistory([]); setTxid('') + setSession(null); setBalances({}); setCandidate(null); setPausedSearch(null); setHistory([]); setTxid('') throw new Error('Wallet account or network changed. Connect again to load its own records.') } const store = previous?.store ?? new WalletRecords(client, identity, network) @@ -94,9 +93,10 @@ export default function Mountaintops() { if (fresh.network === 'mainnet' && !addressMatches(result.address, fresh.coverage.stage)) throw new Error('Found address has expired. Choose a stricter target.') const expected = await client.getPublicKey({ protocolID: [1, 'mountaintops'], keyID: result.keyID, counterparty: 'anyone', forSelf: true }) if (PublicKey.fromString(expected.publicKey).toAddress(fresh.network) !== result.address) throw new Error('Mined public key does not match the wallet') - if (!existing) await fresh.store.append('address', { keyID: result.keyID, address: result.address, targetStage: result.stage }) - await reload(fresh); setFound(result.keyID); setCandidate(null) - setMessage('Address saved. Select “Use for receiving” to switch to it.') + if (!existing) await fresh.store.append('address', { keyID: result.keyID, address: result.address, targetStage: result.stage, useForReceiving: true }) + else if (fresh.primary !== result.keyID) await fresh.store.append('primary', { keyID: result.keyID }) + await reload(fresh); setCandidate(null) + setMessage('New address saved and ready to receive.') }) } @@ -111,7 +111,7 @@ export default function Mountaintops() { const saved = fresh.records.filter(x => x.kind === 'search' && x.data.stage === chosen).at(-1) const resume = pausedSearch && pausedSearch.stage === chosen ? pausedSearch.next : saved?.data.next const nextWorker = new Worker(new URL('./miner.worker.ts', import.meta.url), { type: 'module' }) - worker.current = nextWorker; searchProgress.current = null; setSearching(true); setFound(null); setCandidate(null); setPausedSearch(null) + worker.current = nextWorker; searchProgress.current = null; setSearching(true); setCandidate(null); setPausedSearch(null) nextWorker.onmessage = ({ data }) => { if (worker.current !== nextWorker) return if (data.kind === 'started') setMessage(`Finding an address… up to 30 seconds.`) @@ -145,13 +145,22 @@ export default function Mountaintops() { if (fresh.receivingBlocked) throw new Error(fresh.receivingBlocked) if (!entry) throw new Error('Address not found') assertReceivable(entry, fresh.coverage.stage) - await fresh.store.append('primary', { keyID }); await reload(fresh); setFound(null); setMessage('Receiving address updated.') + if (fresh.primary !== keyID) await fresh.store.append('primary', { keyID }) + await reload(fresh); setMessage('Receiving address updated.') }) const checkCoins = (keyID: string) => void run(async () => { const fresh = await reload(); const entry = fresh.book.find(x => x.keyID === keyID)! const coins = await refreshCoins(client, fresh.store, entry, fresh.coverage, setMessage) setBalances(x => ({ ...x, [keyID]: coins })); await reload(fresh) - setMessage('Payments checked. Recovery evidence is saved in your wallet.') + setMessage('Payments checked.') + }) + const checkAllCoins = () => void run(async () => { + const fresh = await reload() + for (const entry of fresh.book) { + const coins = await refreshCoins(client, fresh.store, entry, fresh.coverage, setMessage) + setBalances(x => ({ ...x, [entry.keyID]: coins })) + } + await reload(fresh); setMessage('Payments checked.') }) const importMoney = (keyID: string) => void run(async () => { const fresh = await reload() @@ -176,8 +185,7 @@ export default function Mountaintops() { const disabled = busy || searching const primary = session?.book.find(x => x.keyID === session.primary) - const foundEntry = session?.book.find(x => x.keyID === found) - const suggestedEntry = !foundEntry && !candidate && !pausedSearch && !searching && session?.book.filter(x => !x.retiredAt && lastCoveredStage(x.address) > (primary ? lastCoveredStage(primary.address) : -1)).sort((a, b) => lastCoveredStage(b.address) - lastCoveredStage(a.address))[0] + const suggestedEntry = !candidate && !pausedSearch && !searching && session?.book.filter(x => !x.retiredAt && lastCoveredStage(x.address) > (primary ? lastCoveredStage(primary.address) : -1)).sort((a, b) => lastCoveredStage(b.address) - lastCoveredStage(a.address))[0] const pendingActions = session ? unresolvedActions(session.records) : [] const savedSearches = session ? [...new Map(session.records.filter(x => x.kind === 'search').map(x => [Number(x.data.stage), x.data])).values()] .filter(x => Number(x.stage) > Math.max(...session.book.map(entry => lastCoveredStage(entry.address)))) : [] @@ -202,8 +210,8 @@ export default function Mountaintops() { {!entry.retiredAt && !selected && } {!entry.retiredAt && !selected &&

Wallet fees apply when switching addresses.

} -
{total !== undefined ? <>{total.toLocaleString()} sats{money(total)} · available here : Payments}
- {Boolean(coins?.length) &&
Wallet fees apply.
} + {!selected && <>
{total !== undefined ? <>{total.toLocaleString()} sats{money(total)} · available here : Payments}
+ {Boolean(coins?.length) &&
Wallet fees apply.
}}
Address details

{coverageLabel(entry.address, entry.network, session!.coverage.anchorMtp, entry.retiredAt)}

{entry.retiredAt &&

Expired at block {entry.retiredAt.height.toLocaleString()}. New-deposit lookups have stopped permanently.

}

Key ID {entry.keyID} · address rules satisfied through stage {level}. Payment transaction rules also apply.

{coins &&

Funding transactions: {coins.filter(x => x.fundingCoverage === 'covered').length} covered at confirmation, {coins.filter(x => x.fundingCoverage === 'outside coverage').length} outside coverage, {coins.filter(x => x.fundingCoverage === 'unconfirmed').length} unconfirmed. These labels do not change ownership.

}
} @@ -228,23 +236,28 @@ export default function Mountaintops() { {(message || error) &&
{message && !searching &&

{message}

}{error &&

{error}

}
} {view === 'receive' ?
{primary ? card(primary, true) :

Choose a receiving address

Find a new address or choose an active one below. Earlier payments remain yours.

} +

Payments to your addresses

+ {session.book.every(x => balances[x.keyID] !== undefined) ?

All addresses checked this session.

:

Check here for payments to current and earlier addresses.

} + {session.book.filter(x => balances[x.keyID]?.length).map(entry =>
{balances[entry.keyID]!.reduce((sum, coin) => sum + coin.satoshis, 0).toLocaleString()} sats{entry.keyID === '1' ? 'Original address' : `Address …${entry.address.slice(-6)}`}{entry.retiredAt ? ' · earlier payments' : ''}
)} + {session.book.some(x => balances[x.keyID]?.length) &&

Wallet fees apply when moving coins.

} + {session.book.every(x => balances[x.keyID] !== undefined && balances[x.keyID]?.length === 0) &&

No available payments found.

} +

A longer-lasting address

{suggestedEntry ? 'Saved in your wallet. Fees apply to switch.' : 'Free to find. Wallet fees apply to save it.'}

{searching ? : }
{suggestedEntry && {suggestedEntry.address}} {searching &&

{message}

} - {candidate &&

New address found

Save it so you can recover it on any device.

Wallet fees apply. Your receiving address will stay the same.
} - {foundEntry && foundEntry.keyID !== primary?.keyID &&

Saved. Ready to use.

{card(foundEntry)}
} + {candidate &&

New address found

Save it so you can recover it on any device.

Wallet fees apply. No separate switching fee.
}
Advanced search

Search runs for up to 30 seconds at a time. Higher stages take more work and pass stricter future address rules.

{suggestedEntry && } {pausedSearch && <>

Wallet fees apply. Otherwise you can repeat this search on another device for free.

} {!searching && savedSearches.map(search =>

Saved in your wallet · next key ID {String(search.next)}

)}
-
Other addresses {session.book.filter(x => x.keyID !== primary?.keyID).length}

Each address has its own expiration. Expired addresses cannot receive; earlier payments remain yours.

{session.book.filter(x => x.keyID !== primary?.keyID && x.keyID !== foundEntry?.keyID).map(x => card(x))}
+
Other addresses {session.book.filter(x => x.keyID !== primary?.keyID).length}

Each address has its own expiration. Expired addresses cannot receive; earlier payments remain yours.

{session.book.filter(x => x.keyID !== primary?.keyID).map(x => card(x))}

An address can expire. Your coins are still yours.

:

Send BSV

Public payment · wallet fees apply

Expired addresses are blocked. Confirm the result in your wallet before retrying.

{txid &&

Submitted: {txid}

}
}
Activity this session {history.length}

Clears when you leave. Your wallet keeps its own payment records.

{!history.length &&

No payments yet.

}{history.map(x =>

{x.description} · {x.status}
{x.txid}

)}
} {!session && error &&

{error}

} -
Expiration, fees & recovery

When does my address expire?

The date depends on BRC-234 chain conditions. Until it is known, each address shows “Expiration date not set yet.” Address details show its exact stage and eligibility gate. A gate is not a guaranteed expiration date.

When an address expires, stop using it everywhere. Mountaintops disables receiving and stops looking for new deposits. Earlier coins remain yours and can still be moved to your wallet.

Can I recover on another device?

Connect the same BRC-100 wallet account. Your saved addresses and coin evidence come from the wallet, without browser data or files from this device. Keep your wallet account and its recovery service available.

What costs money?

Searching and pausing are free. Saving an address or search progress, and switching your receiving address, create encrypted 1-satoshi records in your wallet. Network and wallet service fees may apply. Moving or sending coins also incurs wallet fees.

Does a longer-lasting address cover every payment?

No. Funding TXID rules also apply, and from stage 13 the transaction must use version 1. Mountaintops prepares eligible transactions within a bounded work budget. External senders may create payments outside those rules. Eligibility never changes who owns the coins.

Technical status{session &&

{session.network} · checked through block {session.coverage.height.toLocaleString()} · stage {session.coverage.stage}

}

Client-only. Encrypted PushDrop recovery records use your BRC-100 wallet’s baskets. WhatsOnChain supplies chain data and historical recovery; unavailable or incomplete data cannot establish a balance.

+
Expiration, fees & recovery

When does my address expire?

The date depends on BRC-234 chain conditions. Until it is known, each address shows “Expiration date not set yet.” Address details show its exact stage and eligibility gate. A gate is not a guaranteed expiration date.

When an address expires, stop using it everywhere. Mountaintops disables receiving and stops looking for new deposits. Earlier coins remain yours and can still be moved to your wallet.

Can I recover on another device?

Connect the same BRC-100 wallet account. Your saved addresses and coin evidence come from the wallet, without browser data or files from this device. Keep your wallet account and its recovery service available.

What costs money?

Searching and pausing are free. Saving a new address also makes it your receiving address in one encrypted 1-satoshi wallet record. Saving search progress or switching to an older saved address each needs its own record so your choice can be recovered on another device. Network and wallet service fees may apply. Moving or sending coins also incurs wallet fees.

Does a longer-lasting address cover every payment?

No. Funding TXID rules also apply, and from stage 13 the transaction must use version 1. Mountaintops prepares eligible transactions within a bounded work budget. External senders may create payments outside those rules. Eligibility never changes who owns the coins.

Technical status{session &&

{session.network} · checked through block {session.coverage.height.toLocaleString()} · stage {session.coverage.stage}

}

Client-only. Encrypted PushDrop recovery records use your BRC-100 wallet’s baskets. WhatsOnChain supplies chain data and historical recovery; unavailable or incomplete data cannot establish a balance.

} diff --git a/frontend/src/addressBook.ts b/frontend/src/addressBook.ts index 5be6471..4289bb7 100644 --- a/frontend/src/addressBook.ts +++ b/frontend/src/addressBook.ts @@ -58,7 +58,9 @@ export async function applyExpirations(book: AddressRecord[], coverage: Coverage } export function primaryFromRecords(book: AddressRecord[], records: RecoveryRecord[], stage: number): string | null { - const selected = records.filter(x => x.kind === 'primary').at(-1)?.data.keyID ?? '1' + // A new address and its selection share one encrypted publication record. + // Legacy separate selection records still participate in the same order. + const selected = records.filter(x => x.kind === 'primary' || (x.kind === 'address' && x.data.useForReceiving === true)).at(-1)?.data.keyID ?? '1' const entry = book.find(x => x.keyID === selected) if (!entry) return null try { assertReceivable(entry, stage); return entry.keyID } catch { return null } diff --git a/frontend/src/style.css b/frontend/src/style.css index 4054262..1cd1854 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -1 +1,3 @@ :root{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#edf3f5;background:#101b23;font-synthesis:none;color-scheme:dark}*{box-sizing:border-box}body{margin:0;background:linear-gradient(#101b2355,#101b23ee 680px),url('/mountains.jpg') center top/cover fixed;min-height:100vh}main{max-width:760px;margin:auto;padding:40px 24px 32px}header{margin:0 0 32px}.brand{display:flex;align-items:center;gap:10px}.mountain-mark{font-size:2.5rem;line-height:1;color:#b9dbd1}h1{font-size:1.6rem;letter-spacing:-.04em;margin:0}header p{color:#b7c9cd;font-size:.95rem;margin:8px 0 0 42px}h2{font-size:1.55rem;letter-spacing:-.03em;margin:0 0 12px}h3{font-size:1.05rem;margin:0}p{line-height:1.55;margin:12px 0}section{background:#142630f7;border:1px solid #344b55;border-radius:18px;padding:28px;margin:18px 0;box-shadow:0 16px 48px #0002}.view-tabs{display:flex;align-items:center;gap:4px;border-bottom:1px solid #40535a;padding-bottom:10px}.view-tabs button{background:transparent;color:#b8cbd1;padding:9px 22px}.view-tabs button[aria-pressed=true]{background:#e2f1ed;color:#15342e}.connection{margin-left:auto;font-size:.8rem;color:#a6c0b6}.receive-panel{padding:0;overflow:hidden}.address-card{padding:24px;border:1px solid #3b535d;border-radius:12px;background:#19303a;margin:14px 0}.address-card.selected{background:transparent;margin:0;border:0;border-radius:0;padding:28px}.card-heading{display:flex;align-items:center;gap:12px;justify-content:space-between;margin-bottom:18px}.selected h3{font-size:1.3rem;letter-spacing:-.02em}.badge{background:#264d43;color:#b9e4d2;border-radius:20px;padding:4px 9px;font-size:.72rem;font-weight:650;white-space:nowrap}.badge.caution{background:#61422c;color:#ffe0b1}.address{display:block;overflow-wrap:anywhere;background:#0e2029;border:1px solid #344e59;border-radius:9px;padding:16px;font-size:clamp(.9rem,2.6vw,1.05rem);letter-spacing:.01em;line-height:1.6}.coverage{color:#c6dbd8;font-size:.9rem;margin-bottom:4px}.coverage-comparison{margin:0}.expired{border-color:#c38c57}.expiry-warning{color:#ffd29a;font-weight:600}.buttons{display:flex;gap:10px;flex-wrap:wrap;margin:18px 0 0}button{font:inherit;font-size:.9rem;font-weight:650;cursor:pointer;background:#deebe9;color:#15342e;border:1px solid transparent;border-radius:8px;padding:11px 16px;margin:0}button:hover:not(:disabled){background:#fff}button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:3px solid #ffd39a;outline-offset:3px}button:disabled{opacity:.45;cursor:default}.accent{background:#aee1cf;color:#113d30}.secondary{background:transparent;border-color:#58717b;color:#d4e5e7}.secondary:hover:not(:disabled){background:#29434c}.small{color:#a9c1c8;font-size:.82rem}.fee-note{display:block;margin:9px 0 0}.funds-row{display:flex;align-items:center;justify-content:space-between;gap:16px;border-top:1px solid #344b55;padding-top:20px;margin-top:22px}.funds-row>div{display:flex;flex-direction:column;gap:3px}.funds{font-size:1.55rem;letter-spacing:-.025em}.funds-row button{flex-shrink:0}.import-row{display:flex;align-items:center;gap:12px;margin-top:16px}.technical{font-size:.82rem;color:#adc3c9;margin:20px 0 0}.technical p{font-size:.82rem}.technical summary{font-weight:400}.mining{border-top:1px solid #344b55;padding:24px 28px;background:#172c35}.section-heading{display:flex;align-items:center;justify-content:space-between;gap:20px}.section-heading p{margin:5px 0 0}.section-heading button{flex-shrink:0}.result{padding:20px;margin:20px 0 0;background:#203e46;border:1px solid #6c9e9b;border-radius:12px}.result p{font-size:.9rem}.result .address-card{margin-bottom:0;padding:16px}.result-title{font-weight:650}.advanced{font-size:.82rem;color:#a9c1c8;margin:20px 0 0}.advanced label{font-size:.85rem}.saved-preview{margin-top:16px;font-size:.85rem}.address-list{padding:22px 28px;margin:0;border-top:1px solid #344b55}.count{font-size:.75rem;font-weight:400;background:#334c56;padding:2px 7px;border-radius:20px;margin-left:6px;color:#ccdadf}.ownership-note{text-align:center;font-size:.8rem;color:#abc5c8;padding:18px;margin:0;border-top:1px solid #344b55}.empty-state{padding:28px}.activity,.help{padding:19px 0;border-bottom:1px solid #344b55;margin:0;color:#c6d8dd;font-size:.88rem}.help h3{font-size:.95rem;margin-top:24px}.help p{font-size:.85rem;color:#b7cbd0}.help details{font-size:.82rem;margin-top:20px}.connect{padding:40px 28px}.connect>p{color:#b9cdd2;max-width:420px}.connect>button{margin:12px 0}.connect .small{font-size:.82rem}.feedback{margin-top:16px}.notice,.error{border-radius:10px;padding:12px 16px;overflow-wrap:anywhere;font-size:.87rem}.notice{background:#1b3844;border:1px solid #3e6778;margin:0 0 12px}.error{background:#481e2c;border:1px solid #e99aaa}.warning{border-color:#c38c57}.warning h2{font-size:1.15rem}.warning p{font-size:.9rem}.warning details{margin:12px 0}label{display:block;line-height:1.6;font-weight:600;font-size:.9rem;margin:20px 0}input,select{display:block;width:100%;font:inherit;color:#edf3f5;background:#0e2029;border:1px solid #58717b;border-radius:8px;padding:12px;margin-top:7px}select{white-space:normal}.send-panel>button{width:100%;margin-top:8px}summary{cursor:pointer;font-weight:550}summary::marker{color:#91b1bb}.transaction{overflow-wrap:anywhere;background:#0e2029;padding:12px;border-radius:8px;font-size:.82rem}a{color:#aed8df}footer{display:flex;justify-content:space-between;flex-wrap:wrap;gap:16px;color:#8faab4;font-size:.75rem;padding:28px 0;line-height:1.6}footer div{display:flex;gap:18px}footer a{color:#a9c3ca}@media(max-width:520px){main{padding:24px 16px}header{margin-bottom:24px}.brand h1{font-size:1.4rem}.connection{font-size:.7rem}.view-tabs button{padding:9px 17px}.address-card.selected,.mining,.address-list{padding:22px 18px}.address-card{padding:18px}.card-heading{gap:8px}.selected h3{font-size:1.15rem}.address{padding:12px;font-size:.78rem}.section-heading{align-items:flex-start;flex-direction:column;gap:14px}.section-heading button{width:100%}.funds-row{gap:10px}.funds-row button{max-width:150px;font-size:.8rem}.funds-row .small{font-size:.73rem}.result{padding:16px}.import-row{flex-wrap:wrap}.connect{padding:30px 22px}section{padding:22px}.ownership-note{font-size:.75rem}} + +.payments-panel{padding:24px 28px;border-top:1px solid #344b55}.payments-panel .section-heading{align-items:center}.payment-row{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:18px}.payment-row>div{display:flex;flex-direction:column;gap:4px}.payment-row strong{font-size:1.4rem}.payment-row button{flex-shrink:0}@media(max-width:520px){.payments-panel{padding:22px 18px}.payments-panel .section-heading{flex-direction:row;gap:8px}.payments-panel .section-heading h3{font-size:.9rem}.payments-panel .section-heading button{width:auto;font-size:.8rem}.payment-row{gap:10px}.payment-row button{font-size:.8rem}.payment-row strong{font-size:1.2rem}} diff --git a/frontend/test/walletRecords.test.mjs b/frontend/test/walletRecords.test.mjs index bdecb26..761ea6b 100644 --- a/frontend/test/walletRecords.test.mjs +++ b/frontend/test/walletRecords.test.mjs @@ -34,3 +34,37 @@ test('recovery refuses incomplete pagination and unauthenticated basket entries' wallet.listOutputs = async () => ({ totalOutputs: 1, outputs: [{ outpoint: `${'a'.repeat(64)}.0`, tags: ['foreign'] }] }) await assert.rejects(records.load(), /Ambiguous/) }) + +test('one encrypted publication restores both a new address and its selection', async () => { + const { publicDeriver } = await import('../src/derivation.ts') + const { bookFromRecords, primaryFromRecords } = await import('../src/addressBook.ts') + const state = walletState(), wallet = new FixtureWallet(state) + const identity = (await wallet.getPublicKey({ identityKey: true })).publicKey + const address = publicDeriver(identity)('17', 'mainnet') + await new WalletRecords(wallet, identity, 'mainnet').append('address', { keyID: '17', address, targetStage: 0, useForReceiving: true }) + const restored = await new WalletRecords(new FixtureWallet(state), identity, 'mainnet').load() + const book = bookFromRecords(identity, 'mainnet', restored) + assert.deepEqual(book.map(x => x.keyID), ['1', '17']) + assert.equal(primaryFromRecords(book, restored, 0), '17') + assert.equal(restored.length, 1) + assert.equal([...state.outputs.values()].filter(x => x.basket === RECORD_BASKET).length, 1) + assert.equal(state.actions.length, 1) +}) + +test('combined publication and legacy selections follow the same order and never reactivate retirement', async () => { + const { publicDeriver } = await import('../src/derivation.ts') + const { bookFromRecords, primaryFromRecords } = await import('../src/addressBook.ts') + const wallet = new FixtureWallet(), identity = (await wallet.getPublicKey({ identityKey: true })).publicKey + const derive = publicDeriver(identity) + const records = [ + { kind: 'address', data: { keyID: '17', address: derive('17', 'mainnet'), targetStage: 0 } }, + { kind: 'primary', data: { keyID: '17' } }, + { kind: 'address', data: { keyID: '18', address: derive('18', 'mainnet'), targetStage: 0, useForReceiving: true } } + ] + const book = bookFromRecords(identity, 'mainnet', records) + assert.equal(primaryFromRecords(book, records.slice(0, 2), 0), '17') + assert.equal(primaryFromRecords(book, records, 0), '18') + assert.equal(primaryFromRecords(book, [...records, { kind: 'primary', data: { keyID: '1' } }], 0), '1') + book.find(x => x.keyID === '18').retiredAt = { height: 1000002, lastReceiveHeight: 1000001, hash: 'f'.repeat(64), mtp: 123 } + assert.equal(primaryFromRecords(book, records, 0), null) +})