-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli/tauri): Emit events on Monero transaction confirmation update and redeem transaction publication #57
Conversation
In this commit I duplicated the |
Probably better to modify the exiting functions instead |
True, at least for |
I removed the old functions and passed an empty listener instead, though the result is a little ugly. I will look into ways to improve the code quality. |
I'd say it's better to make the listener callback an Option. |
28d0c37
to
d75d074
Compare
d75d074
to
73e52c4
Compare
I changed to Option and re-added |
73e52c4
to
249d745
Compare
8639aba
to
2a33923
Compare
249d745
to
73e52c4
Compare
swap/src/protocol/alice/swap.rs
Outdated
@@ -137,7 +137,10 @@ where | |||
} => match state3.expired_timelocks(bitcoin_wallet).await? { | |||
ExpiredTimelocks::None { .. } => { | |||
monero_wallet | |||
.watch_for_transfer(state3.lock_xmr_watch_request(transfer_proof.clone(), 1)) | |||
.watch_for_transfer_with( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the watch_for_transfer method here
swap/src/monero/wallet.rs
Outdated
@@ -477,7 +502,7 @@ mod tests { | |||
}), | |||
])); | |||
|
|||
wait_for_confirmations( | |||
wait_for_confirmations_with( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the dedicated function here
swap/src/protocol/alice/state.rs
Outdated
@@ -518,7 +518,7 @@ impl State3 { | |||
// Ensure that the XMR to be refunded are spendable by awaiting 10 confirmations | |||
// on the lock transaction | |||
monero_wallet | |||
.watch_for_transfer(self.lock_xmr_watch_request(transfer_proof, 10)) | |||
.watch_for_transfer_with(self.lock_xmr_watch_request(transfer_proof, 10), None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the dedicated function here
swap/src/protocol/bob/swap.rs
Outdated
if let ExpiredTimelocks::None { .. } = state.expired_timelock(bitcoin_wallet).await? { | ||
let watch_request = state.lock_xmr_watch_request(lock_transfer_proof); | ||
// Check if the cancel timelock has expired => we cancel the swap | ||
let ExpiredTimelocks::None { .. } = state.expired_timelock(bitcoin_wallet).await? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo this syntax is worse than what was used before. It's not entirely clear when this codeblock will be executed at first sight. You need to know which other enum variants exist
swap/src/protocol/bob/swap.rs
Outdated
@@ -158,52 +158,56 @@ async fn next_state( | |||
|
|||
let tx_lock_status = bitcoin_wallet.subscribe_to(state3.tx_lock.clone()).await; | |||
|
|||
if let ExpiredTimelocks::None { .. } = state3.expired_timelock(bitcoin_wallet).await? { | |||
tracing::info!("Waiting for Alice to lock Monero"); | |||
let ExpiredTimelocks::None { .. } = state3.expired_timelock(bitcoin_wallet).await? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo this syntax is worse than what was used before. It's not entirely clear when this codeblock will be executed at first sight. You need to know which other enum variants exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to a simple if statement after adding a cancel_timelock_expired
method on ExpiredTimelocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments
I have tested this and it works. |
ab5c776
to
9764144
Compare
9764144
to
8aac029
Compare
Sorry for force pushing. Feel free to push your local branch. I can apply my changes again. |
Two clippy warnings need to be fixed otherwise this LGTM! |
LGTM! I also really like the new |
We now,
This PR closes #12.