mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-04 09:05:37 -05: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,
|
swap_amounts: SwapAmounts,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<(bob::Swap, bob::EventLoop)> {
|
) -> Result<(bob::Swap, bob::EventLoop)> {
|
||||||
let initial_state = init_bob_state(
|
let initial_state = self
|
||||||
swap_amounts.btc,
|
.make_initial_state(swap_amounts.btc, swap_amounts.xmr, config)
|
||||||
swap_amounts.xmr,
|
.await?;
|
||||||
self.bitcoin_wallet.clone(),
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let (event_loop, event_loop_handle) = self.init_event_loop()?;
|
let (event_loop, event_loop_handle) = self.init_event_loop()?;
|
||||||
|
|
||||||
@ -160,31 +156,31 @@ impl SwapFactory {
|
|||||||
self.alice_address.clone(),
|
self.alice_address.clone(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async fn init_bob_state(
|
async fn make_initial_state(
|
||||||
btc_to_swap: bitcoin::Amount,
|
&self,
|
||||||
xmr_to_swap: monero::Amount,
|
btc_to_swap: bitcoin::Amount,
|
||||||
bob_btc_wallet: Arc<bitcoin::Wallet>,
|
xmr_to_swap: monero::Amount,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<BobState> {
|
) -> Result<BobState> {
|
||||||
let amounts = SwapAmounts {
|
let amounts = SwapAmounts {
|
||||||
btc: btc_to_swap,
|
btc: btc_to_swap,
|
||||||
xmr: xmr_to_swap,
|
xmr: xmr_to_swap,
|
||||||
};
|
};
|
||||||
|
|
||||||
let refund_address = bob_btc_wallet.new_address().await?;
|
let refund_address = self.bitcoin_wallet.new_address().await?;
|
||||||
let state0 = bob::State0::new(
|
let state0 = bob::State0::new(
|
||||||
&mut OsRng,
|
&mut OsRng,
|
||||||
btc_to_swap,
|
btc_to_swap,
|
||||||
xmr_to_swap,
|
xmr_to_swap,
|
||||||
config.bitcoin_cancel_timelock,
|
config.bitcoin_cancel_timelock,
|
||||||
config.bitcoin_punish_timelock,
|
config.bitcoin_punish_timelock,
|
||||||
refund_address,
|
refund_address,
|
||||||
config.monero_finality_confirmations,
|
config.monero_finality_confirmations,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(BobState::Started { state0, amounts })
|
Ok(BobState::Started { state0, amounts })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user