Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add protobuf conversion impls #808

Merged
merged 11 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .generated-sources/blocklist-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ edition = "2021"
serde = { version = "^1.0", features = ["derive"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
1 change: 1 addition & 0 deletions Cargo.lock

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

15 changes: 6 additions & 9 deletions protobufs/stacks/signer/v1/decisions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ import "stacks/common.proto";

// Represents a decision to accept or reject a deposit request.
message SignerDepositDecision {
// The bitcoin transaction ID of the transaction containing the deposit
// request. It must be 32 bytes.
bitcoin.BitcoinTxid txid = 1;
// Index of the deposit request UTXO.
uint32 output_index = 2;
// The bitcoin outpoint that uniquely identifies the deposit request.
bitcoin.OutPoint outpoint = 1;
// Whether or not the signer has accepted the deposit request.
bool accepted = 3;
bool accepted = 2;
// This specifies whether the sending signer can provide signature shares
// for the associated deposit request.
bool can_sign = 4;
bool can_sign = 3;
}

// Represents a decision to accept or reject a deposit request.
message SignerWithdrawDecision {
// Represents a decision to accept or reject a withdrawal request.
message SignerWithdrawalDecision {
// ID of the withdraw request.
uint64 request_id = 1;
// The Stacks block ID of the Stacks block containing the request. It
Expand Down
4 changes: 4 additions & 0 deletions signer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ pub enum Error {
#[error("observer dropped")]
ObserverDropped,

/// A required field in a protobuf type was not set.
#[error("a required protobuf field was not set")]
RequiredProtobufFieldMissing,

/// Thrown when the recoverable signature has a public key that is
/// unexpected.
#[error("unexpected public key from signature. key {0}; digest: {1}")]
Expand Down
8 changes: 8 additions & 0 deletions signer/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
//! [^3]: https://github.com/Trust-Machines/p256k1/blob/3ecb941c1af13741d52335ef911693b6d6fda94b/p256k1/src/scalar.rs#L245-L257
//! [^4]: https://github.com/bitcoin-core/secp256k1/blob/3fdf146bad042a17f6b2f490ef8bd9d8e774cdbd/src/scalar.h#L31-L36

use std::ops::Deref;
use std::str::FromStr;

use bitcoin::ScriptBuf;
Expand All @@ -44,6 +45,13 @@ use crate::error::Error;
#[serde(transparent)]
pub struct PublicKey(secp256k1::PublicKey);

impl Deref for PublicKey {
type Target = secp256k1::PublicKey;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<&secp256k1::PublicKey> for PublicKey {
fn from(value: &secp256k1::PublicKey) -> Self {
Self(*value)
Expand Down
Loading
Loading