From 6d649f9bdd0582520e23dff4b5a967f0a125857e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 30 Jun 2026 09:29:46 -0700 Subject: Swaps: reuse the generic 'Payment received' screen for LN receives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A reverse-swap claim is an on-chain receive, so instead of a separate LN 'Received!' card (which stacked with the generic celebration and needed suppression), credit the claimed coin to the wallet the instant we broadcast the claim — new wallet.creditReceive() mirrors the instant-payment watcher path (adds the utxo + pending row, advances the receive index, emits). The generic 'Payment received!' then fires immediately with the right amount, one screen, one tap. Dropped the LN success card + the suppression logic. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/swap.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/swap.js') diff --git a/src/swap.js b/src/swap.js index 129712d..9afe7e7 100644 --- a/src/swap.js +++ b/src/swap.js @@ -318,10 +318,14 @@ export class SwapManager { const preimage = sha256(node.privateKey); const d = swapP2TR({ kind: 'reverse', preimageHash160: hash160(preimage), boltzPub33: hexToBytes(rec.refundPublicKey), halPub33: node.publicKey, lockTime: rec.timeoutBlockHeight, network: net }); const fee = this._spendFee(); - const hex = buildSwapSpend({ pay: d.pay, leaf: d.claimLeaf, halPriv: node.privateKey, preimage, lockupTxid: u.txid, lockupVout: u.vout, lockupValue: u.value, destAddress: w.freshReceive().address, fee, network: net }); + const destAddress = w.freshReceive().address; + const hex = buildSwapSpend({ pay: d.pay, leaf: d.claimLeaf, halPriv: node.privateKey, preimage, lockupTxid: u.txid, lockupVout: u.vout, lockupValue: u.value, destAddress, fee, network: net }); const txid = await w.api.broadcast(hex); rec.status = 'claimed'; rec.claimTxid = txid; rec.received = u.value - fee; this._save(rec); this._stop(id); + // Credit the claimed coin (single output → destAddress) now, so the balance + // + generic "payment received" fire instantly instead of waiting for a scan. + if (w.creditReceive) w.creditReceive({ txid, vout: 0, value: rec.received, address: destAddress }); } catch (e) { rec.lastError = String(e?.message || e); this.onUpdate(rec); } }; this.timers.set(id, setInterval(tick, 3000)); tick(); -- cgit v1.2.3