diff options
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/ark.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/features/ark.js b/src/features/ark.js index 2aef8c5..13481da 100644 --- a/src/features/ark.js +++ b/src/features/ark.js @@ -6,7 +6,7 @@ import * as btc from '@scure/btc-signer'; import { HDKey } from '@scure/bip32'; import { hex, base32nopad, bech32 } from '@scure/base'; import { sha256 } from '@noble/hashes/sha256'; -import { ArkManager, remoteRenewalsInFlight } from '../ark/manager.js'; +import { ArkManager, remoteRenewalsInFlight, lnFoldedIds } from '../ark/manager.js'; export { remoteRenewalsInFlight }; // Coins this device may offer: spendable, and not held by a renewal another @@ -727,8 +727,9 @@ export function arkFeature(ctx) { try { const receipts = await Promise.resolve(ctx.hook('namesLnReceipts')).catch(() => null); if (!receipts || !receipts.length || ark !== mgr || !mgr.state) return; + const twins = lnFoldedIds(mgr.state.movements); const moves = (mgr.state.movements || []) - .filter((m) => m.type === 'receive' && m.status === 'complete'); + .filter((m) => m.type === 'receive' && m.status === 'complete' && !twins.has(m.id)); const used = new Set(moves.filter((m) => m.lnHash).map((m) => m.lnHash)); let changed = false; for (const r of receipts) { @@ -3796,7 +3797,7 @@ export function arkFeature(ctx) { if (a) await Promise.race([mgr.driveLn(a.id).catch(() => {}), new Promise((r) => setTimeout(r, 8000))]); return mgr.lnLookup(q); }, - arkMovements() { const s = arkStateNow(); return s ? (s.movements || []) : []; }, + arkMovements() { const s = arkStateNow(); if (!s) return []; const twins = lnFoldedIds(s.movements); return (s.movements || []).filter((m) => !twins.has(m.id)); }, // The wallet's reusable ark receive address (BIP-353 names publish it). async arkStaticAddress() { const mgr = await connectArk(); @@ -3960,7 +3961,9 @@ export function arkFeature(ctx) { // participation), and only ones that COST something get a row — a free // renewal is net zero, invisible money movement, noise. const seenPay = new Set(); + const lnTwins = lnFoldedIds(s.movements); // a claimed LN receive's coin, told again by the mailbox const moves = (s.movements || []) + .filter((m) => !lnTwins.has(m.id)) .filter((m) => ['receive', 'send', 'board', 'offboard', 'exit', 'ln-send', 'ln-receive', 'refresh', 'reconcile'].includes(m.type) && (m.status === 'complete' || (m.type === 'send' && m.status === 'failed'))) .filter((m) => m.type !== 'refresh' || m.feeSat > 0 || m.manual) // a renewal you asked for is worth a row even when free |
