From 124fee3c15556d62d6efd8714fd4501e95273ebd Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 25 Jun 2026 16:01:39 -0700 Subject: Gift claim: detect already-claimed (even unconfirmed) and block the race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Opening a gift link now checks whether its funding coin is already spent — via the Esplora outspend endpoint, which reports a spend even by an unconfirmed claim. The Claim button is gated until that check passes; if the coin is spent, show an 'Already claimed' screen with a link to the claim tx instead of a claimable amount. doClaim also re-checks on broadcast failure (the race window), and refuses to run while unchecked/taken — so a second opener can't attempt a doomed double-spend. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/api.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/api.js') diff --git a/src/api.js b/src/api.js index 20041e2..1f57353 100644 --- a/src/api.js +++ b/src/api.js @@ -209,6 +209,12 @@ export class Api { return this.#get(`/address/${address}/utxo`); } + // Spend status of one output: { spent, txid (spender), vin, status }. Reports + // a spend even by an unconfirmed tx — used to tell if a gift was already claimed. + outspend(txid, vout) { + return this.#get(`/tx/${txid}/outspend/${vout}`); + } + addressTxs(address) { return this.#get(`/address/${address}/txs`); } -- cgit v1.2.3