mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-23 22:01:21 -05:00
rename alice::Message0 to Message1
This commit is contained in:
parent
18f326ddd1
commit
88bf080dc0
@ -1,6 +1,6 @@
|
||||
use crate::protocol::{
|
||||
alice,
|
||||
alice::{Message3, TransferProof},
|
||||
alice::{Message1, Message3, TransferProof},
|
||||
bob,
|
||||
bob::{EncryptedSignature, Message2, Message4},
|
||||
};
|
||||
@ -35,7 +35,7 @@ pub enum BobToAlice {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum AliceToBob {
|
||||
SwapResponse(Box<alice::SwapResponse>),
|
||||
Message0(Box<alice::Message0>),
|
||||
Message1(Box<Message1>),
|
||||
Message3(Box<Message3>),
|
||||
Message2,
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ use uuid::Uuid;
|
||||
|
||||
pub use self::{
|
||||
event_loop::{EventLoop, EventLoopHandle},
|
||||
execution_setup::Message0,
|
||||
execution_setup::Message1,
|
||||
state::*,
|
||||
swap::{run, run_until},
|
||||
swap_response::*,
|
||||
|
@ -15,7 +15,7 @@ use libp2p_async_await::BehaviourOutEvent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Message0 {
|
||||
pub struct Message1 {
|
||||
pub(crate) A: bitcoin::PublicKey,
|
||||
pub(crate) S_a_monero: monero::PublicKey,
|
||||
pub(crate) S_a_bitcoin: bitcoin::PublicKey,
|
||||
@ -64,7 +64,7 @@ impl Behaviour {
|
||||
pub fn run(&mut self, bob: PeerId, state0: State0) {
|
||||
self.inner
|
||||
.do_protocol_listener(bob, move |mut substream| async move {
|
||||
let alice_message0 = state0.next_message();
|
||||
let message1 = state0.next_message();
|
||||
|
||||
let state1 = {
|
||||
let bob_message0 = serde_cbor::from_slice::<bob::Message0>(
|
||||
@ -76,8 +76,7 @@ impl Behaviour {
|
||||
|
||||
substream
|
||||
.write_message(
|
||||
&serde_cbor::to_vec(&alice_message0)
|
||||
.context("failed to serialize Message0")?,
|
||||
&serde_cbor::to_vec(&message1).context("failed to serialize message1")?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -8,8 +8,7 @@ use crate::{
|
||||
},
|
||||
monero,
|
||||
protocol::{
|
||||
alice,
|
||||
alice::{Message3, TransferProof},
|
||||
alice::{Message1, Message3, TransferProof},
|
||||
bob,
|
||||
bob::{EncryptedSignature, Message2, Message4},
|
||||
SwapAmounts,
|
||||
@ -135,8 +134,8 @@ impl State0 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next_message(&self) -> alice::Message0 {
|
||||
alice::Message0 {
|
||||
pub fn next_message(&self) -> Message1 {
|
||||
Message1 {
|
||||
A: self.a.public(),
|
||||
S_a_monero: monero::PublicKey::from_private_key(&monero::PrivateKey {
|
||||
scalar: self.s_a.into_ed25519(),
|
||||
|
@ -2,8 +2,7 @@ use crate::{
|
||||
bitcoin::Signature,
|
||||
network::request_response::BUF_SIZE,
|
||||
protocol::{
|
||||
alice,
|
||||
alice::Message3,
|
||||
alice::{Message1, Message3},
|
||||
bob::{State0, State2},
|
||||
},
|
||||
};
|
||||
@ -81,14 +80,11 @@ impl Behaviour {
|
||||
)
|
||||
.await?;
|
||||
|
||||
let alice_message0 = serde_cbor::from_slice::<alice::Message0>(
|
||||
&substream.read_message(BUF_SIZE).await?,
|
||||
)
|
||||
.context("failed to deserialize message0")?;
|
||||
let message1 =
|
||||
serde_cbor::from_slice::<Message1>(&substream.read_message(BUF_SIZE).await?)
|
||||
.context("failed to deserialize message1")?;
|
||||
|
||||
let state1 = state0
|
||||
.receive(bitcoin_wallet.as_ref(), alice_message0)
|
||||
.await?;
|
||||
let state1 = state0.receive(bitcoin_wallet.as_ref(), message1).await?;
|
||||
{
|
||||
let message2 = state1.next_message();
|
||||
substream
|
||||
|
@ -10,8 +10,7 @@ use crate::{
|
||||
monero,
|
||||
monero::{monero_private_key, TransferProof},
|
||||
protocol::{
|
||||
alice,
|
||||
alice::Message3,
|
||||
alice::{Message1, Message3},
|
||||
bob,
|
||||
bob::{EncryptedSignature, Message2, Message4},
|
||||
SwapAmounts,
|
||||
@ -133,7 +132,7 @@ impl State0 {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn receive<W>(self, wallet: &W, msg: alice::Message0) -> anyhow::Result<State1>
|
||||
pub async fn receive<W>(self, wallet: &W, msg: Message1) -> anyhow::Result<State1>
|
||||
where
|
||||
W: BuildTxLockPsbt + GetNetwork,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user