mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Make init_state
associated to bob::SwapFactory
This commit is contained in:
parent
f0e6e45d56
commit
3bc76a91c6
@ -93,13 +93,9 @@ impl SwapFactory {
|
||||
swap_amounts: SwapAmounts,
|
||||
config: Config,
|
||||
) -> Result<(bob::Swap, bob::EventLoop)> {
|
||||
let initial_state = init_bob_state(
|
||||
swap_amounts.btc,
|
||||
swap_amounts.xmr,
|
||||
self.bitcoin_wallet.clone(),
|
||||
config,
|
||||
)
|
||||
.await?;
|
||||
let initial_state = self
|
||||
.make_initial_state(swap_amounts.btc, swap_amounts.xmr, config)
|
||||
.await?;
|
||||
|
||||
let (event_loop, event_loop_handle) = self.init_event_loop()?;
|
||||
|
||||
@ -160,31 +156,31 @@ impl SwapFactory {
|
||||
self.alice_address.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async fn init_bob_state(
|
||||
btc_to_swap: bitcoin::Amount,
|
||||
xmr_to_swap: monero::Amount,
|
||||
bob_btc_wallet: Arc<bitcoin::Wallet>,
|
||||
config: Config,
|
||||
) -> Result<BobState> {
|
||||
let amounts = SwapAmounts {
|
||||
btc: btc_to_swap,
|
||||
xmr: xmr_to_swap,
|
||||
};
|
||||
async fn make_initial_state(
|
||||
&self,
|
||||
btc_to_swap: bitcoin::Amount,
|
||||
xmr_to_swap: monero::Amount,
|
||||
config: Config,
|
||||
) -> Result<BobState> {
|
||||
let amounts = SwapAmounts {
|
||||
btc: btc_to_swap,
|
||||
xmr: xmr_to_swap,
|
||||
};
|
||||
|
||||
let refund_address = bob_btc_wallet.new_address().await?;
|
||||
let state0 = bob::State0::new(
|
||||
&mut OsRng,
|
||||
btc_to_swap,
|
||||
xmr_to_swap,
|
||||
config.bitcoin_cancel_timelock,
|
||||
config.bitcoin_punish_timelock,
|
||||
refund_address,
|
||||
config.monero_finality_confirmations,
|
||||
);
|
||||
let refund_address = self.bitcoin_wallet.new_address().await?;
|
||||
let state0 = bob::State0::new(
|
||||
&mut OsRng,
|
||||
btc_to_swap,
|
||||
xmr_to_swap,
|
||||
config.bitcoin_cancel_timelock,
|
||||
config.bitcoin_punish_timelock,
|
||||
refund_address,
|
||||
config.monero_finality_confirmations,
|
||||
);
|
||||
|
||||
Ok(BobState::Started { state0, amounts })
|
||||
Ok(BobState::Started { state0, amounts })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
Loading…
Reference in New Issue
Block a user