From b94295a14f9b0174d0f762d44e56870805557cb8 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Wed, 27 Dec 2023 11:59:33 +0100 Subject: [PATCH] fix: refunds on invoice payment failure (#406) --- src/components/Refund.tsx | 2 +- src/helper.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/Refund.tsx b/src/components/Refund.tsx index aff5007a..ee2a0b89 100644 --- a/src/components/Refund.tsx +++ b/src/components/Refund.tsx @@ -44,7 +44,7 @@ const Refund = ({ swap }: { swap: Accessor> }) => { /> diff --git a/src/helper.js b/src/helper.js index b9994b10..5ad9c46c 100644 --- a/src/helper.js +++ b/src/helper.js @@ -197,7 +197,27 @@ export async function refund(swap, t) { log.info("refunding swap: ", swap.id); let [_, fees] = await Promise.all([setup(), getfeeestimation(swap)]); - const txToRefund = transactionToRefund(); + let txToRefund = transactionToRefund(); + + if (txToRefund === null) { + txToRefund = await new Promise((resolve, reject) => { + fetcher( + "/getswaptransaction", + (res) => { + log.debug(`got swap transaction for ${swap.id}`); + resolve(res); + }, + { + id: swap.id, + }, + () => { + log.warn(`no swap transaction for: ${swap.id}`); + reject(); + }, + ); + }); + } + const Transaction = getTransaction(asset_name); const constructRefundTransaction = getConstructRefundTransaction(asset_name);