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 validation for complete-deposit transactions #545

Merged
merged 18 commits into from
Sep 24, 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
3 changes: 2 additions & 1 deletion signer/src/bitcoin/zmq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ pub fn parse_bitcoin_core_message(message: ZmqMessage) -> Result<BitcoinCoreMess
}
// We do not implement parsing for any other message types but if
// we're here, then we probably have a valid message from
// bitcoin-core. Let's try to note the topic for easier debugging.
// bitcoin-core (we know `data` has three parts). Let's try to note
// the topic for easier debugging.
_ => {
let topic = core::str::from_utf8(data[0]).map(ToString::to_string);
Err(Error::BitcoinCoreZmqUnsupported(topic))
Expand Down
5 changes: 5 additions & 0 deletions signer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::borrow::Cow;

use blockstack_lib::types::chainstate::StacksBlockId;

use crate::stacks::contracts::DepositValidationError;
use crate::{codec, ecdsa, network};

/// Top-level signer error
Expand Down Expand Up @@ -103,6 +104,10 @@ pub enum Error {
#[error("could not decode Nakamoto block from tenure with block: {1}; {0}")]
DecodeNakamotoTenure(#[source] blockstack_lib::codec::Error, StacksBlockId),

/// Failed to validate the complete-deposit contract call transaction.
#[error("{0}")]
DepositValidation(#[from] Box<DepositValidationError>),

/// An error when serializing an object to JSON
#[error("{0}")]
JsonSerialize(#[source] serde_json::Error),
Expand Down
8 changes: 8 additions & 0 deletions signer/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use crate::error::Error;

/// The public key type for the secp256k1 elliptic curve.
#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct PublicKey(secp256k1::PublicKey);

impl From<&secp256k1::PublicKey> for PublicKey {
Expand Down Expand Up @@ -182,6 +183,12 @@ impl From<&PublicKey> for stacks_common::util::secp256k1::Secp256k1PublicKey {
}
}

impl From<PublicKey> for stacks_common::util::secp256k1::Secp256k1PublicKey {
fn from(value: PublicKey) -> Self {
Self::from(&value)
}
}

impl From<&stacks_common::util::secp256k1::Secp256k1PublicKey> for PublicKey {
fn from(value: &stacks_common::util::secp256k1::Secp256k1PublicKey) -> Self {
let key = secp256k1::PublicKey::from_slice(&value.to_bytes_compressed())
Expand Down Expand Up @@ -231,6 +238,7 @@ impl std::fmt::Display for PublicKey {

/// A private key type for the secp256k1 elliptic curve.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
#[serde(transparent)]
pub struct PrivateKey(secp256k1::SecretKey);

impl FromStr for PrivateKey {
Expand Down
Loading
Loading