aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/gifts.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-07-04 09:33:52 -0700
committerAdam Soltys <[email protected]>2026-07-04 09:33:52 -0700
commitb7c5abd93868b97c25f52610510544764a3e44eb (patch)
treeab2ae94ab10bb88d32dec24c9987f81ef3c7faf0 /src/features/gifts.js
parent11b2a56a320bbd66b98991fd08478d154ff6c717 (diff)
downloadcoinosv3-b7c5abd93868b97c25f52610510544764a3e44eb.tar.gz
coinosv3-b7c5abd93868b97c25f52610510544764a3e44eb.zip
Features phase 2: gift/swap/ark primitives leave the core wallet
wallet.js drops from 2,762 to 2,374 lines and now exposes two generic seams instead of feature code: - registerCoinLock()/lockedCoinIds(): features contribute coin ids that spending and the balance treat as unavailable (gift reservations). - loadFeatureState()/saveFeatureState(): namespaced per-wallet persisted state. src/features/gifts-wallet.js takes the whole gift engine — reservation sets, gift records, coin selection, the SIGHASH_SINGLE/NONE PSBT builder, the compact codec, claim building, nostr-locked gifts — as an installGiftWallet(wallet) instance install plus standalone exports. Swap storage/key helpers (loadSwaps/saveSwaps/swapNode/nextSwapIndex) install from swap.js; ark state storage installs from the ark feature. The silent-payment scan worker only embeds when the sp feature ships (wallet.js already tolerated its absence). Minimal profile: 412KB, down from 476KB (full: 578KB). All suites pass: ark UI e2e, ArkManager crash-resume, gift lifecycle, minimal smoke. SP's engine (scanning, BIP-352 signing) stays in wallet.js — extracting it safely wants an SP e2e harness on this stack first. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QFAcD4V284DvYZZHP7Rxxy
Diffstat (limited to 'src/features/gifts.js')
-rw-r--r--src/features/gifts.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/features/gifts.js b/src/features/gifts.js
index a0d1f8c..9562b9f 100644
--- a/src/features/gifts.js
+++ b/src/features/gifts.js
@@ -2,7 +2,8 @@
// reclaim) and the claim flow (fresh or existing wallet, nostr-locked gifts,
// claim codes / NIP-07 extension). Gift primitives live in ../wallet.js.
-import { newMnemonic, previewGift, giftOutpoints, buildClaimTx, giftMinimum, lockGift, previewLockedGift } from '../wallet.js';
+import { newMnemonic } from '../wallet.js';
+import { installGiftWallet, previewGift, giftOutpoints, buildClaimTx, giftMinimum, lockGift, previewLockedGift } from './gifts-wallet.js';
import { parseNostrPubkey, npubOf, fetchNostrProfile, decryptWithCode } from '../nostr.js';
import { t } from '../i18n.js';
import { qrSvg } from '../qr.js';
@@ -15,6 +16,7 @@ export function giftsFeature(ctx) {
brandHeader, profileChip, activeAccount, setAccounts, getAccounts, claimTargets,
enterWallet, activateAccount, commitAccount,
} = ctx;
+ installGiftWallet(wallet); // gift primitives live outside the core wallet
// ================================================================ GIFT / CLAIM
// Read a gift link, returning the code (and scrubbing it from the URL so the
@@ -747,7 +749,7 @@ export function giftsFeature(ctx) {
return h('button', { class: 'linklike small', style: 'align-self:center;margin-top:2px', onClick: () => { ui.giftMode = true; ui.sendError = ''; render(); } }, '🎁 ' + t('giftLink'));
},
balanceLines() {
- const locked = wallet.lockedValue;
+ const locked = wallet.giftLockedValue();
return locked > 0 ? [{ label: t('lockedInGifts'), sat: locked }] : [];
},
historyEntries(txs) {