aboutsummaryrefslogtreecommitdiffstats
path: root/biome.json
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-09-06 16:46:30 -0700
committerAdam Soltys <[email protected]>2025-09-06 16:46:30 -0700
commit780a7cca58f3e34140fd9430e2ae02145e4149e0 (patch)
treea68bfecbfa78934f545d97fcbb581b29cc01b1f0 /biome.json
parentfdfbb781f40775f39dbaa10269f559695f670b37 (diff)
downloadcoinos-server-780a7cca58f3e34140fd9430e2ae02145e4149e0.tar.gz
coinos-server-780a7cca58f3e34140fd9430e2ae02145e4149e0.zip
convert pubkey from npub
Diffstat (limited to 'biome.json')
0 files changed, 0 insertions, 0 deletions
background-color: #FFF0F0 } /* Literal.String.Delimiter */ .highlight .sd { color: #D20; background-color: #FFF0F0 } /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
// The cross-device history union must not resurrect a stale pending tx from
// another device's snapshot (a never-broadcast/replaced tx that the local
// scan already pruned). Run: bun tools/sync-zombie-tx-test.js
import assert from 'node:assert/strict';
import { SyncOutbox } from '../src/sync-outbox.js';
import { installSyncWallet } from '../src/features/sync.js';

class Storage {
  data = new Map();
  get length() { return this.data.size; }
  key(i) { return [...this.data.keys()][i] ?? null; }
  getItem(k) { return this.data.get(k) ?? null; }
  setItem(k, v) { this.data.set(k, String(v)); }
  removeItem(k) { this.data.delete(k); }
}
globalThis.localStorage = new Storage();
const mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
const now = Date.now();
const wallet = {
  mnemonic, offline: false, netName: 'mainnet', _savedAt: 0, txs: [{ txid: 'mine-confirmed', confirmed: true, blockHeight: 10 }], _cacheExtensions: [],
  registerCacheSavedHook: () => {}, registerLoadHook: () => {}, registerRealtimeHook: () => {},
  saveCache: () => {}, emit: () => {}, _sortTxs: () => {}, _mergeSnapshotExtensions: () => {}, _applySnapshot() {},
};
installSyncWallet(wallet, { outbox: new SyncOutbox({ storage: new Storage(), send: async () => true, schedule: () => 0, cancel: () => {} }) });
wallet.nostr.load(mnemonic);
wallet.nostr.fetchAllStates = async () => [{
  dtag: 'bitcoin-wallet:x:dead-device:core', created_at: 1,
  state: { netName: 'mainnet', savedAt: 1, txs: [
    { txid: 'zombie', confirmed: false, firstSeen: now - 4 * 86400_000, net: -5000 }, // 4 days pending, unknown to the network
    { txid: 'fresh-pending', confirmed: false, firstSeen: now - 60_000, net: -1 },     // a minute old: give it a chance
    { txid: 'old-confirmed', confirmed: true, blockHeight: 5 },
  ] },
}];
assert.equal(await wallet.syncFromNostr(), true);
const ids = wallet.txs.map((t) => t.txid).sort();
assert.deepEqual(ids, ['fresh-pending', 'mine-confirmed', 'old-confirmed']);
console.log('✓ stale pending txs from other devices are not resurrected; confirmed and fresh ones still union');