Skip to content

Commit

Permalink
Version 0.2.4
Browse files Browse the repository at this point in the history
- handle the `WtxidRelay` message during handshake
  that now comes in due to a protocol version bump
  • Loading branch information
alfred-hodler committed May 23, 2024
1 parent dd9ddd0 commit f350bc9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pushtx-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pushtx-cli"
version = "0.2.3"
version = "0.2.4"
edition = "2021"
authors = ["Alfred Hodler <[email protected]>"]
license = "MIT"
Expand All @@ -18,5 +18,5 @@ anyhow = "1.0.86"
clap = { version = "4.5.4", features = ["derive"] }
env_logger = "0.11.3"
log = "0.4.20"
pushtx = { version = "0.2.3", path = "../pushtx" }
pushtx = { version = "0.2.4", path = "../pushtx" }
thiserror = "1.0.61"
2 changes: 1 addition & 1 deletion pushtx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pushtx"
version = "0.2.3"
version = "0.2.4"
edition = "2021"
authors = ["Alfred Hodler <[email protected]>"]
license = "MIT"
Expand Down
23 changes: 23 additions & 0 deletions pushtx/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub enum Update {
Verack,
/// The peer sent a `SendAddrV2` message (BIP-155).
SendAddrV2,
/// The peer sent a `WtxidRelay` message (BIP-0339).
WtxidRelay,
/// The peer sent another message.
Other,
}
Expand All @@ -20,6 +22,7 @@ impl From<&NetworkMessage> for Update {
NetworkMessage::Version(v) => Self::Version(v.clone()),
NetworkMessage::Verack => Self::Verack,
NetworkMessage::SendAddrV2 => Self::SendAddrV2,
NetworkMessage::WtxidRelay => Self::WtxidRelay,
_ => Self::Other,
}
}
Expand All @@ -38,6 +41,8 @@ pub enum Event<'a> {
version: &'a VersionMessage,
/// Whether the peer prefers AddrV2 messages.
wants_addr_v2: bool,
/// Wtxid relay
wtxid_relay: bool,
},
}

Expand All @@ -50,6 +55,8 @@ pub struct Handshake {
their_verack: bool,
/// Whether the peer prefers AddrV2 messages.
wants_addr_v2: bool,
/// Wtxid relay
wtxid_relay: bool,
}

impl Handshake {
Expand All @@ -73,25 +80,41 @@ impl Handshake {
their_version: Some(_),
their_verack: false,
wants_addr_v2: wants_addr_v2 @ false,
..
},
Update::SendAddrV2,
) => {
*wants_addr_v2 = true;
Event::Wait
}

(
Self {
their_version: Some(_),
their_verack: false,
wtxid_relay: wtxid_relay @ false,
..
},
Update::WtxidRelay,
) => {
*wtxid_relay = true;
Event::Wait
}

(
Self {
their_version: Some(v),
their_verack: their_verack @ false,
wants_addr_v2,
wtxid_relay,
},
Update::Verack,
) => {
*their_verack = true;
Event::Done {
version: v,
wants_addr_v2: *wants_addr_v2,
wtxid_relay: *wtxid_relay,
}
}

Expand Down

0 comments on commit f350bc9

Please sign in to comment.