mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-02 03:26:23 -04:00
Add minimum monero confirmations to config use it for Bob
This commit is contained in:
parent
c6bc45e7a0
commit
e031681369
12 changed files with 44 additions and 3 deletions
|
@ -8,6 +8,7 @@ use tracing::info;
|
|||
use uuid::Uuid;
|
||||
use xmr_btc::{
|
||||
bob::{self, State2},
|
||||
config::Config,
|
||||
ExpiredTimelocks,
|
||||
};
|
||||
|
||||
|
@ -59,6 +60,7 @@ pub async fn swap<R>(
|
|||
monero_wallet: Arc<crate::monero::Wallet>,
|
||||
rng: R,
|
||||
swap_id: Uuid,
|
||||
config: Config,
|
||||
) -> Result<BobState>
|
||||
where
|
||||
R: RngCore + CryptoRng + Send,
|
||||
|
@ -72,6 +74,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -110,6 +113,7 @@ pub async fn run_until<R>(
|
|||
monero_wallet: Arc<crate::monero::Wallet>,
|
||||
mut rng: R,
|
||||
swap_id: Uuid,
|
||||
config: Config,
|
||||
) -> Result<BobState>
|
||||
where
|
||||
R: RngCore + CryptoRng + Send,
|
||||
|
@ -144,6 +148,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -166,6 +171,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -220,6 +226,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -262,6 +269,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -298,6 +306,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -318,6 +327,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -343,6 +353,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
@ -371,6 +382,7 @@ where
|
|||
monero_wallet,
|
||||
rng,
|
||||
swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ async fn main() -> Result<()> {
|
|||
config.bitcoin_cancel_timelock,
|
||||
config.bitcoin_punish_timelock,
|
||||
refund_address,
|
||||
config.monero_finality_confirmations,
|
||||
);
|
||||
|
||||
let amounts = SwapAmounts {
|
||||
|
@ -159,6 +160,7 @@ async fn main() -> Result<()> {
|
|||
db,
|
||||
alice_peer_id,
|
||||
alice_addr,
|
||||
config,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
@ -234,6 +236,7 @@ async fn main() -> Result<()> {
|
|||
db,
|
||||
alice_peer_id,
|
||||
alice_addr,
|
||||
config,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
@ -301,6 +304,7 @@ async fn alice_swap(
|
|||
swap.await
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn bob_swap(
|
||||
swap_id: Uuid,
|
||||
state: BobState,
|
||||
|
@ -309,6 +313,7 @@ async fn bob_swap(
|
|||
db: Database,
|
||||
alice_peer_id: PeerId,
|
||||
alice_addr: Multiaddr,
|
||||
config: Config,
|
||||
) -> Result<BobState> {
|
||||
let bob_behaviour = bob::Behaviour::default();
|
||||
let bob_transport = build(bob_behaviour.identity())?;
|
||||
|
@ -324,6 +329,7 @@ async fn bob_swap(
|
|||
monero_wallet.clone(),
|
||||
OsRng,
|
||||
swap_id,
|
||||
config,
|
||||
);
|
||||
|
||||
tokio::spawn(event_loop.run());
|
||||
|
|
|
@ -98,6 +98,7 @@ async fn happy_path() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
Uuid::new_v4(),
|
||||
config,
|
||||
)
|
||||
.boxed();
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
Uuid::new_v4(),
|
||||
config,
|
||||
);
|
||||
|
||||
let alice_db_datadir = tempdir().unwrap();
|
||||
|
|
|
@ -106,6 +106,7 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
bob_swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -134,6 +135,7 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
|
|||
bob_xmr_wallet,
|
||||
OsRng,
|
||||
bob_swap_id,
|
||||
config,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
@ -95,6 +95,7 @@ async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
bob_swap_id,
|
||||
Config::regtest(),
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -120,6 +121,7 @@ async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
bob_swap_id,
|
||||
Config::regtest(),
|
||||
);
|
||||
|
||||
let bob_final_state = select! {
|
||||
|
|
|
@ -84,6 +84,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
Uuid::new_v4(),
|
||||
config,
|
||||
)
|
||||
.boxed();
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ async fn given_alice_restarts_after_xmr_is_locked_abort_swap() {
|
|||
bob_xmr_wallet.clone(),
|
||||
OsRng,
|
||||
Uuid::new_v4(),
|
||||
Config::regtest(),
|
||||
);
|
||||
|
||||
let alice_swap_id = Uuid::new_v4();
|
||||
|
|
|
@ -176,6 +176,7 @@ pub async fn init_bob_state(
|
|||
config.bitcoin_cancel_timelock,
|
||||
config.bitcoin_punish_timelock,
|
||||
refund_address,
|
||||
config.monero_finality_confirmations,
|
||||
);
|
||||
|
||||
BobState::Started { state0, amounts }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue