Skip to content

Commit

Permalink
fix: refunds on invoice payment failure (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 authored Dec 27, 2023
1 parent 4d38d6f commit b94295a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/Refund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Refund = ({ swap }: { swap: Accessor<Record<string, any>> }) => {
/>
<button
class="btn"
disabled={valid()}
disabled={!valid()}
onclick={() => refund(swap(), t)}>
{t("refund")}
</button>
Expand Down
22 changes: 21 additions & 1 deletion src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

2 comments on commit b94295a

@vercel
Copy link

@vercel vercel bot commented on b94295a Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b94295a Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.