diff options
| author | Adam Soltys <[email protected]> | 2026-06-30 09:29:46 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-30 09:29:46 -0700 |
| commit | 6d649f9bdd0582520e23dff4b5a967f0a125857e (patch) | |
| tree | e8312ef64fc95a30144b50bbb563829eba6bc26b /src/swap.js | |
| parent | c74a3181a415024eea016727a11a1fc59335697d (diff) | |
| download | coinosv3-6d649f9bdd0582520e23dff4b5a967f0a125857e.tar.gz coinosv3-6d649f9bdd0582520e23dff4b5a967f0a125857e.zip | |
Swaps: reuse the generic 'Payment received' screen for LN receives
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) <[email protected]>
Diffstat (limited to 'src/swap.js')
| -rw-r--r-- | src/swap.js | 6 |
1 files changed, 5 insertions, 1 deletions
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(); |
