Skip to content

Instantly share code, notes, and snippets.

@sanket1729
Created July 24, 2019 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanket1729/8a7b6949118f4fca1b238405fc9203ca to your computer and use it in GitHub Desktop.
Save sanket1729/8a7b6949118f4fca1b238405fc9203ca to your computer and use it in GitHub Desktop.
pub trait ToPkh{
fn to_pkh(&self) -> hash160::Hash;
}
impl ToPkh for hash160::Hash{
fn to_pkh(&self) -> hash160::Hash{
*self
}
}
pub trait PublicKey: Clone + Eq + Ord + str::FromStr + fmt::Debug +fmt::Display {
type Hash: Clone + Eq + Ord + str::FromStr + fmt::Display + fmt::Debug + ToPkh;
///Converts an object to PublicHash
fn to_pubkeyhash(&self) -> Result<Self::Hash, Error>;
/// Converts an object to a public key
fn to_public_key(&self) -> Result<bitcoin::PublicKey, Error>;
/// Computes the size of a public key when serialized in a script,
/// including the length bytes
fn serialized_len(&self) -> Result<usize, Error>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment