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