diff options
Diffstat (limited to 'src/wallet.js')
| -rw-r--r-- | src/wallet.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/wallet.js b/src/wallet.js index 156d2f4..56e3726 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -1638,10 +1638,20 @@ export class Wallet { const live = new Set(this.utxos.map((u) => utxoId(u))); return Object.values(this.giftRecords()) .filter((r) => !r.revoked && r.outpoints && !r.outpoints.some((o) => live.has(o))) - .map((r) => ({ id: r.id, amount: r.amount, locked: r.locked, created: r.created })) + .map((r) => ({ id: r.id, amount: r.amount, locked: r.locked, created: r.created, claimTxid: r.claimTxid || null, outpoints: r.outpoints })) .sort((a, b) => (b.created || 0) - (a.created || 0)); } + // Remember which tx claimed a gift (resolved lazily via outspend) so the + // history can merge the gift row with its claim transaction. + setGiftClaimTx(id, txid) { + const recs = this.giftRecords(); + if (recs[id] && recs[id].claimTxid !== txid) { + recs[id].claimTxid = txid; + this._saveGiftRecords(); + } + } + // Best-fit coin selection for a gift of `gift` sats (needs gift + a dust // change): the smallest single confirmed coin that covers it — one input and // the least value locked until claim — else the fewest large coins. Returns |
