diff options
| author | Adam Soltys <[email protected]> | 2026-06-15 23:15:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-15 23:15:44 -0700 |
| commit | 60db237749a1189d57b8783cd318c60d6df0cbcc (patch) | |
| tree | bc338d4c94fe02a93bca3505323a80b3516d55ea /src/app.js | |
| parent | 5f478de7d90f9170b81b21af6492de1be2076696 (diff) | |
| download | coinosv3-60db237749a1189d57b8783cd318c60d6df0cbcc.tar.gz coinosv3-60db237749a1189d57b8783cd318c60d6df0cbcc.zip | |
Sync wallet state across devices via encrypted Nostr events
Persist wallet state (addresses, utxos, history, indices, fees) as a NIP-44
encrypted, parameterized-replaceable event (kind 30078) addressed to self on
relay.coinos.io. The Nostr identity is derived from the same seed (NIP-06), so
no extra secret. On load we pull the latest state from Nostr — a device with
no local cache gets full state without re-scanning, and another device's
updates propagate — using savedAt to keep the newest copy. localStorage stays
as the instant/offline cache; state is published (debounced) on every change.
(Relay note: added kind 30078 to the strfry write-policy allowlist on prod.)
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -391,9 +391,12 @@ async function enterWallet(mnemonic, passphrase) { return; } try { - // With a cache, only check the live frontier (cheap) instead of a full - // re-scan; a full scan still runs for a brand-new wallet and periodically. - if (hadCache) await wallet.refreshLive(); + // Cross-device state: pull the latest from Nostr (may supply state on a + // device with no local cache, or a newer copy from another device). + const hadNostr = await wallet.syncFromNostr(); + // With existing state (local or remote), only check the live frontier; + // a brand-new wallet does one full scan. + if (hadCache || hadNostr) await wallet.refreshLive(); else await wallet.scan(); wallet.startRealtime(); } catch { |
