mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-16 17:14:13 -05:00
feat(tauri, gui): Send event on changes to details, timelocks and tx_lock confirmations (#100)
- Send event when new swap state is inserated into database. The event only has the `swap_id` attached. The frontend then sends a request to the `get_swap_info` command to retrieve the updated version - Send event when the Bitcoin lock transaction gets a new confirmation - A new `watcher` daemon runs contineously and sends an event when the timelock updated. The event has the the `swap_id` and the timelock attached - Display logs on `ProcessExitedPage` (if swap was stopped prematurely) - Rename `CliLogEmittedEvent` to `TauriLogEvent` - Apply env_filter to tracing terminal writer to silence logging from other crates - Add `.env.*` files in `src-gui` to `.gitingore` Closes #93 and #12
This commit is contained in:
parent
e6dc7ddcef
commit
8f33fe5b41
28 changed files with 429 additions and 208 deletions
|
|
@ -478,52 +478,36 @@ pub async fn get_swap_info(
|
|||
.await?
|
||||
.iter()
|
||||
.find_map(|state| {
|
||||
if let State::Bob(BobState::SwapSetupCompleted(state2)) = state {
|
||||
let xmr_amount = state2.xmr;
|
||||
let btc_amount = state2.tx_lock.lock_amount();
|
||||
let tx_cancel_fee = state2.tx_cancel_fee;
|
||||
let tx_refund_fee = state2.tx_refund_fee;
|
||||
let tx_lock_id = state2.tx_lock.txid();
|
||||
let btc_refund_address = state2.refund_address.to_string();
|
||||
let State::Bob(BobState::SwapSetupCompleted(state2)) = state else {
|
||||
return None;
|
||||
};
|
||||
|
||||
if let Ok(tx_lock_fee) = state2.tx_lock.fee() {
|
||||
Some((
|
||||
xmr_amount,
|
||||
btc_amount,
|
||||
tx_lock_id,
|
||||
tx_cancel_fee,
|
||||
tx_refund_fee,
|
||||
tx_lock_fee,
|
||||
btc_refund_address,
|
||||
state2.cancel_timelock,
|
||||
state2.punish_timelock,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let xmr_amount = state2.xmr;
|
||||
let btc_amount = state2.tx_lock.lock_amount();
|
||||
let tx_cancel_fee = state2.tx_cancel_fee;
|
||||
let tx_refund_fee = state2.tx_refund_fee;
|
||||
let tx_lock_id = state2.tx_lock.txid();
|
||||
let btc_refund_address = state2.refund_address.to_string();
|
||||
|
||||
let Ok(tx_lock_fee) = state2.tx_lock.fee() else {
|
||||
return None;
|
||||
};
|
||||
|
||||
Some((
|
||||
xmr_amount,
|
||||
btc_amount,
|
||||
tx_lock_id,
|
||||
tx_cancel_fee,
|
||||
tx_refund_fee,
|
||||
tx_lock_fee,
|
||||
btc_refund_address,
|
||||
state2.cancel_timelock,
|
||||
state2.punish_timelock,
|
||||
))
|
||||
})
|
||||
.with_context(|| "Did not find SwapSetupCompleted state for swap")?;
|
||||
|
||||
let timelock = match swap_state.clone() {
|
||||
BobState::Started { .. } | BobState::SafelyAborted | BobState::SwapSetupCompleted(_) => {
|
||||
None
|
||||
}
|
||||
BobState::BtcLocked { state3: state, .. }
|
||||
| BobState::XmrLockProofReceived { state, .. } => {
|
||||
Some(state.expired_timelock(bitcoin_wallet).await?)
|
||||
}
|
||||
BobState::XmrLocked(state) | BobState::EncSigSent(state) => {
|
||||
Some(state.expired_timelock(bitcoin_wallet).await?)
|
||||
}
|
||||
BobState::CancelTimelockExpired(state) | BobState::BtcCancelled(state) => {
|
||||
Some(state.expired_timelock(bitcoin_wallet).await?)
|
||||
}
|
||||
BobState::BtcPunished { .. } => Some(ExpiredTimelocks::Punish),
|
||||
BobState::BtcRefunded(_) | BobState::BtcRedeemed(_) | BobState::XmrRedeemed { .. } => None,
|
||||
};
|
||||
let timelock = swap_state.expired_timelocks(bitcoin_wallet.clone()).await?;
|
||||
|
||||
Ok(GetSwapInfoResponse {
|
||||
swap_id: args.swap_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue