mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-27 11:10:31 -05:00
Loop on blockchain call instead of delaying
Previously there was a delay making a get raw transaction call to give some time for a transaction to be confirmed on the blockchain. This has been replaced with a loop that waits until the call is succesful.
This commit is contained in:
parent
f6f4ec2bdb
commit
4e031ff9a2
4 changed files with 26 additions and 22 deletions
|
|
@ -1,7 +1,8 @@
|
|||
use crate::{
|
||||
alice,
|
||||
bitcoin::{
|
||||
self, BroadcastSignedTransaction, BuildTxLockPsbt, GetRawTransaction, SignTxLock, TxCancel,
|
||||
self, BroadcastSignedTransaction, BuildTxLockPsbt, SignTxLock, TxCancel,
|
||||
WatchForRawTransaction,
|
||||
},
|
||||
monero,
|
||||
monero::{CheckTransfer, ImportOutput},
|
||||
|
|
@ -22,7 +23,7 @@ pub use message::{Message, Message0, Message1, Message2, Message3, UnexpectedMes
|
|||
|
||||
pub async fn next_state<
|
||||
R: RngCore + CryptoRng,
|
||||
B: GetRawTransaction + SignTxLock + BuildTxLockPsbt + BroadcastSignedTransaction,
|
||||
B: WatchForRawTransaction + SignTxLock + BuildTxLockPsbt + BroadcastSignedTransaction,
|
||||
M: ImportOutput + CheckTransfer,
|
||||
T: SendReceive<Message, alice::Message>,
|
||||
>(
|
||||
|
|
@ -500,12 +501,14 @@ impl State4 {
|
|||
|
||||
pub async fn watch_for_redeem_btc<W>(self, bitcoin_wallet: &W) -> Result<State5>
|
||||
where
|
||||
W: GetRawTransaction,
|
||||
W: WatchForRawTransaction,
|
||||
{
|
||||
let tx_redeem = bitcoin::TxRedeem::new(&self.tx_lock, &self.redeem_address);
|
||||
let tx_redeem_encsig = self.b.encsign(self.S_a_bitcoin.clone(), tx_redeem.digest());
|
||||
|
||||
let tx_redeem_candidate = bitcoin_wallet.get_raw_transaction(tx_redeem.txid()).await?;
|
||||
let tx_redeem_candidate = bitcoin_wallet
|
||||
.watch_for_raw_transaction(tx_redeem.txid())
|
||||
.await?;
|
||||
|
||||
let tx_redeem_sig =
|
||||
tx_redeem.extract_signature_by_key(tx_redeem_candidate, self.b.public())?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue