fix(swap): Split approve-and-sign and publish-lock-tx into two states (#498)

* fix(swap): Split approve-and-sign and publish-lock-tx into two states

* fix: cannot get blockchain height

* add RetrievingMoneroBlockheight, RetrievingMoneroBlockheight tauri events

* propagate daemon blcok height fetch error, treat height 0 as error

* check if tx_lock was previously published
This commit is contained in:
Mohan 2025-08-04 11:46:57 +02:00 committed by GitHub
parent e7cfecd070
commit 0936d6210e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 147 additions and 32 deletions

View file

@ -25,6 +25,7 @@ export type TauriSwapProgressEventExt<T extends TauriSwapProgressEventType> =
export enum BobStateName {
Started = "quote has been requested",
SwapSetupCompleted = "execution setup done",
BtcLockReadyToPublish = "btc lock ready to publish",
BtcLocked = "btc is locked",
XmrLockProofReceived = "XMR lock transaction transfer proof received",
XmrLocked = "xmr is locked",
@ -47,6 +48,8 @@ export function bobStateNameToHumanReadable(stateName: BobStateName): string {
return "Started";
case BobStateName.SwapSetupCompleted:
return "Setup completed";
case BobStateName.BtcLockReadyToPublish:
return "Bitcoin lock ready to publish";
case BobStateName.BtcLocked:
return "Bitcoin locked";
case BobStateName.XmrLockProofReceived:

View file

@ -216,6 +216,10 @@ export function StateAlert({
}
return <PunishTimelockExpiredAlert />;
// If the Bitcoin lock transaction has not been published yet
// there is no need to display an alert
case BobStateName.BtcLockReadyToPublish:
return null;
default:
exhaustiveGuard(swap.state_name);
}

View file

@ -50,6 +50,14 @@ export default function SwapStatePage({ state }: { state: SwapState | null }) {
return <SwapSetupInflightPage {...state.curr.content} />;
}
break;
case "RetrievingMoneroBlockheight":
return (
<CircularProgressWithSubtitle description="Retrieving Monero blockheight..." />
);
case "BtcLockPublishInflight":
return (
<CircularProgressWithSubtitle description="Publishing Bitcoin lock transaction..." />
);
case "BtcLockTxInMempool":
if (state.curr.type === "BtcLockTxInMempool") {
return <BitcoinLockTxInMempoolPage {...state.curr.content} />;