aboutsummaryrefslogtreecommitdiffstats
path: root/names/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'names/server.js')
-rw-r--r--names/server.js46
1 files changed, 18 insertions, 28 deletions
diff --git a/names/server.js b/names/server.js
index a7424f8..6bbec01 100644
--- a/names/server.js
+++ b/names/server.js
@@ -374,23 +374,13 @@ if (CFG.forwarder?.mnemonic) {
// between syncs) lives there, and balance() only counts what state has seen.
await fwd.sync().catch(() => {});
log(`forwarder ark wallet ready — float ${fwd.balance().spendableSat} sat, receive ${fwd.address().slice(0, 24)}…`);
- // A float send never picks a coin at the server's exit-depth cap. Each
- // arkoor hop adds one to a coin's depth and only a round flattens it; at
- // the cap the ASP refuses every cosign. The float's wallet code (the
- // coinosv3 submodule, from 10-16) predates its own cap check, so the
- // smallest coin covering a send — a 13,661-sat change chain at depth 100 —
- // was picked for every forward under 13,661 sat and refused, from
- // 2026-11-24 00:09Z until this went out ("reports of missing deposits",
- // Adam). floatUpkeep refreshes such coins; until that round settles they
- // are just left out here.
- const select = fwd._selectInputs.bind(fwd), free = fwd._free.bind(fwd);
- let selecting = false;
- fwd._free = (v, busy) => free(v, busy) && !(selecting && floatCapped(v));
- fwd._selectInputs = (...a) => { selecting = true; try { return select(...a); } finally { selecting = false; } };
+ // The wallet code must know the server's exit-depth cap: a send from a coin
+ // at it is refused at the cosign. The submodule pinned from 10-16 didn't,
+ // and picked a 13,661-sat coin at depth 100 for every forward under that
+ // from 2026-11-24 00:09Z ("reports of missing deposits", Adam). Say so
+ // loudly if the server ever stops publishing it.
+ if (!fwd._capDepth?.()) log('forwarder: the ark server publishes no exit-depth cap — deep coins will not be skipped or flattened');
}
-function floatDepth(v) { try { return fwd._decoded(v).genesis.length; } catch { return 0; } }
-const floatDepthCap = () => fwd?.info?.maxVtxoExitDepth || 100;
-function floatCapped(v) { return floatDepth(v) >= floatDepthCap(); }
// Is this name's wallet on another network than this registrar's node? Then
// nothing payable may be minted for it here: a mainnet offer for a mutinynet
@@ -1006,28 +996,28 @@ async function floatUpkeep() {
// 2026-09-16 (a large coin, swept two blocks after expiry) and blocked
// every round after it
const live = (v) => !(v.expiryHeight && v.expiryHeight <= tip);
- // coins at or near the depth cap can't be sent (see floatCapped): flatten
- // them as soon as they get there, not on the 30-minute expiry cadence.
+ // Deep coins first, in a round of their own: each arkoor hop adds one to a
+ // coin's depth, the server refuses to cosign one at its cap (100), and it
+ // waives the base fee on a refresh whose every input is at its waiver depth
+ // (60) — so flatten them there, for the ppm alone, long before the cap.
// Deep dust rides along with a bigger deep coin; alone it can't make a round.
- const deep = spendables.filter((v) => live(v) && floatDepth(v) >= floatDepthCap() - 8);
+ const deep = fwd.deepCoins().filter(live);
const deepSat = deep.reduce((n, v) => n + v.amountSat, 0);
- if (Date.now() - floatRefreshAt < (deepSat >= 330 ? 2 * 60_000 : 30 * 60_000)) return;
+ const deepWorth = deepSat - fwd.refreshFee(deep, tip) >= 330;
+ if (Date.now() - floatRefreshAt < (deepWorth ? 2 * 60_000 : 30 * 60_000)) return;
const expiring = spendables.filter((v) =>
live(v) && v.expiryHeight && v.expiryHeight - tip < REFRESH_MARGIN_BLOCKS && v.amountSat >= 330);
- const ids = new Set(expiring.map((v) => v.id));
- if (deepSat >= 330) for (const v of deep) ids.add(v.id);
- if (!ids.size) return;
+ const coins = deepWorth ? deep : expiring;
+ if (!coins.length) return;
floatRefreshAt = Date.now();
- const coins = spendables.filter((v) => ids.has(v.id));
const sat = coins.reduce((n, v) => n + v.amountSat, 0);
- const nDeep = coins.filter((v) => floatDepth(v) >= floatDepthCap() - 8).length;
- log(`float upkeep: refreshing ${coins.length} coins (${sat} sat; ${nDeep} at depth ≥ ${floatDepthCap() - 8}, ${expiring.length} nearing expiry)`);
- await fwd.refresh([...ids]);
+ log(`float upkeep: refreshing ${coins.length} coins (${sat} sat) ${deepWorth ? `at exit depth ≥ ${fwd._waiverDepth() || fwd._capDepth() - 8}` : 'nearing expiry'}`);
+ await fwd.refresh(coins.map((v) => v.id));
log(`float upkeep: refresh submitted — float now ${fwd.balance().spendableSat} sat`);
}
// A float fed by many small receives can hold enough sats yet too many coins
-// for one send (the 24-input cap in _selectInputs). Merge the smallest into
+// for one send (the 48-input cap in _selectInputs). Merge the smallest into
// one fresh round output; floatUpkeep also does it before a send has to fail.
const CONSOLIDATE_AT = 64, CONSOLIDATE_MAX = 64, CONSOLIDATE_SMALL = 5000;
let consolidating = false;