Add minimum monero confirmations to config use it for Bob

This commit is contained in:
Daniel Karzel 2021-01-05 17:09:55 +11:00
parent c6bc45e7a0
commit e031681369
12 changed files with 44 additions and 3 deletions

View file

@ -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
}

View file

@ -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());