mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-04-19 23:46:01 -04:00
Move generation of keys inside State0::new
This commit is contained in:
parent
228da8015b
commit
256dd7de9f
@ -182,23 +182,15 @@ impl Builder {
|
||||
xmr: xmr_to_swap,
|
||||
};
|
||||
|
||||
let a = bitcoin::SecretKey::new_random(rng);
|
||||
let s_a = cross_curve_dleq::Scalar::random(rng);
|
||||
let v_a = monero::PrivateViewKey::new_random(rng);
|
||||
let redeem_address = self.bitcoin_wallet.new_address().await?;
|
||||
let punish_address = redeem_address.clone();
|
||||
let state0 = State0::new(
|
||||
a,
|
||||
s_a,
|
||||
v_a,
|
||||
amounts.btc,
|
||||
amounts.xmr,
|
||||
self.execution_params.bitcoin_cancel_timelock,
|
||||
self.execution_params.bitcoin_punish_timelock,
|
||||
redeem_address,
|
||||
punish_address,
|
||||
self.bitcoin_wallet.as_ref(),
|
||||
rng,
|
||||
);
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(AliceState::Started { amounts, state0 })
|
||||
}
|
||||
|
@ -101,25 +101,25 @@ pub struct State0 {
|
||||
}
|
||||
|
||||
impl State0 {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new<R>(
|
||||
a: bitcoin::SecretKey,
|
||||
s_a: cross_curve_dleq::Scalar,
|
||||
v_a: monero::PrivateViewKey,
|
||||
pub async fn new<R>(
|
||||
btc: bitcoin::Amount,
|
||||
xmr: monero::Amount,
|
||||
cancel_timelock: Timelock,
|
||||
punish_timelock: Timelock,
|
||||
redeem_address: bitcoin::Address,
|
||||
punish_address: bitcoin::Address,
|
||||
bitcoin_wallet: &bitcoin::Wallet,
|
||||
rng: &mut R,
|
||||
) -> Self
|
||||
) -> Result<Self>
|
||||
where
|
||||
R: RngCore + CryptoRng,
|
||||
{
|
||||
let a = bitcoin::SecretKey::new_random(rng);
|
||||
let s_a = cross_curve_dleq::Scalar::random(rng);
|
||||
let v_a = monero::PrivateViewKey::new_random(rng);
|
||||
let redeem_address = bitcoin_wallet.new_address().await?;
|
||||
let punish_address = redeem_address.clone();
|
||||
let dleq_proof_s_a = cross_curve_dleq::Proof::new(rng, &s_a);
|
||||
|
||||
Self {
|
||||
Ok(Self {
|
||||
a,
|
||||
s_a,
|
||||
v_a,
|
||||
@ -130,7 +130,7 @@ impl State0 {
|
||||
xmr,
|
||||
cancel_timelock,
|
||||
punish_timelock,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn next_message(&self) -> Message1 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user