Skip to content

Commit

Permalink
rename message ids
Browse files Browse the repository at this point in the history
  • Loading branch information
cylewitruk committed Feb 5, 2025
1 parent a38d1c9 commit 5f99a29
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions protobufs/stacks/signer/v1/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ message WstsMessage {
oneof id {
// If this WSTS message is related to a Bitcoin signing round, this field
// will be set to the related Bitcoin transaction ID.
bitcoin.BitcoinTxid id_bitcoin_txid = 12;
bitcoin.BitcoinTxid sweep = 12;
// If this WSTS message is related to a rotate-keys transaction, this field
// will be set to the _new_ aggregate public key being verified.
crypto.PublicKey id_rotate_key = 13;
crypto.PublicKey dkg_verification = 13;
// If this WSTS message is related to a DKG round, this field will be set
// to the 32-byte id determined based on the coordinator public key and
// block hash, set by the coordinator.
crypto.Uint256 id_dkg = 14;
crypto.Uint256 dkg = 14;
}
}

Expand Down
14 changes: 7 additions & 7 deletions signer/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,31 +228,31 @@ pub struct BitcoinPreSignAck;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum WstsMessageId {
/// The WSTS message is related to a Bitcoin transaction signing round.
BitcoinTxid(bitcoin::Txid),
Sweep(bitcoin::Txid),
/// The WSTS message is related to a rotate key verification operation.
RotateKey(PublicKey),
DkgVerification(PublicKey),
/// The WSTS message is related to a DKG round.
Dkg([u8; 32]),
}

impl From<bitcoin::Txid> for WstsMessageId {
fn from(txid: bitcoin::Txid) -> Self {
Self::BitcoinTxid(txid)
Self::Sweep(txid)
}
}

impl From<crate::storage::model::BitcoinTxId> for WstsMessageId {
fn from(txid: crate::storage::model::BitcoinTxId) -> Self {
Self::BitcoinTxid(txid.into())
Self::Sweep(txid.into())
}
}

impl std::fmt::Display for WstsMessageId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
WstsMessageId::BitcoinTxid(txid) => write!(f, "bitcoin-txid({})", txid),
WstsMessageId::RotateKey(aggregate_key) => {
write!(f, "rotate-key({})", aggregate_key)
WstsMessageId::Sweep(txid) => write!(f, "sweep({})", txid),
WstsMessageId::DkgVerification(aggregate_key) => {
write!(f, "dkg-verification({})", aggregate_key)
}
WstsMessageId::Dkg(id) => {
write!(f, "dkg({})", hex::encode(id))
Expand Down
22 changes: 11 additions & 11 deletions signer/src/proto/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,13 +1096,13 @@ impl From<WstsMessage> for proto::WstsMessage {

proto::WstsMessage {
id: Some(match value.id {
WstsMessageId::BitcoinTxid(txid) => {
wsts_message::Id::IdBitcoinTxid(proto::BitcoinTxid {
txid: Some(proto::Uint256::from(BitcoinTxId::from(txid).into_bytes())),
})
WstsMessageId::Sweep(txid) => wsts_message::Id::Sweep(proto::BitcoinTxid {
txid: Some(proto::Uint256::from(BitcoinTxId::from(txid).into_bytes())),
}),
WstsMessageId::DkgVerification(pubkey) => {
wsts_message::Id::DkgVerification(pubkey.into())
}
WstsMessageId::RotateKey(pubkey) => wsts_message::Id::IdRotateKey(pubkey.into()),
WstsMessageId::Dkg(id) => wsts_message::Id::IdDkg(id.into()),
WstsMessageId::Dkg(id) => wsts_message::Id::Dkg(id.into()),
}),
inner: Some(inner),
}
Expand Down Expand Up @@ -1149,13 +1149,13 @@ impl TryFrom<proto::WstsMessage> for WstsMessage {
#[allow(deprecated)]
Ok(WstsMessage {
id: match value.id.required()? {
wsts_message::Id::IdBitcoinTxid(txid) => {
WstsMessageId::BitcoinTxid(BitcoinTxId::try_from(txid)?.into())
wsts_message::Id::Sweep(txid) => {
WstsMessageId::Sweep(BitcoinTxId::try_from(txid)?.into())
}
wsts_message::Id::IdRotateKey(pubkey) => {
WstsMessageId::RotateKey(PublicKey::try_from(pubkey)?)
wsts_message::Id::DkgVerification(pubkey) => {
WstsMessageId::DkgVerification(PublicKey::try_from(pubkey)?)
}
wsts_message::Id::IdDkg(id) => WstsMessageId::Dkg(id.into()),
wsts_message::Id::Dkg(id) => WstsMessageId::Dkg(id.into()),
},
inner,
})
Expand Down
6 changes: 3 additions & 3 deletions signer/src/proto/generated/stacks.signer.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,16 @@ pub mod wsts_message {
/// If this WSTS message is related to a Bitcoin signing round, this field
/// will be set to the related Bitcoin transaction ID.
#[prost(message, tag = "12")]
IdBitcoinTxid(super::super::super::super::bitcoin::BitcoinTxid),
Sweep(super::super::super::super::bitcoin::BitcoinTxid),
/// If this WSTS message is related to a rotate-keys transaction, this field
/// will be set to the _new_ aggregate public key being verified.
#[prost(message, tag = "13")]
IdRotateKey(super::super::super::super::crypto::PublicKey),
DkgVerification(super::super::super::super::crypto::PublicKey),
/// If this WSTS message is related to a DKG round, this field will be set
/// to the 32-byte id determined based on the coordinator public key and
/// block hash, set by the coordinator.
#[prost(message, tag = "14")]
IdDkg(super::super::super::super::crypto::Uint256),
Dkg(super::super::super::super::crypto::Uint256),
}
}
/// Wraps an inner type with a public key and a signature,
Expand Down
2 changes: 1 addition & 1 deletion signer/tests/integration/transaction_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ async fn new_state_machine_per_valid_sighash() {

// Now for the nonce request message
let mut nonce_request_msg = WstsMessage {
id: WstsMessageId::BitcoinTxid(*txid),
id: WstsMessageId::Sweep(*txid),
inner: wsts::net::Message::NonceRequest(NonceRequest {
dkg_id: 1,
sign_id: 1,
Expand Down

0 comments on commit 5f99a29

Please sign in to comment.