pub struct PublicKey {
pub compressed: bool,
pub key: PublicKey,
}
Expand description
A Bitcoin ECDSA public key
Fields§
§compressed: bool
Whether this public key should be serialized as compressed
key: PublicKey
The actual ECDSA key
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn pubkey_hash(&self, secp: &Secp256k1) -> PubkeyHash
pub fn pubkey_hash(&self, secp: &Secp256k1) -> PubkeyHash
Returns bitcoin 160-bit hash of the public key
Sourcepub fn wpubkey_hash(&self, secp: &Secp256k1) -> Option<WPubkeyHash>
pub fn wpubkey_hash(&self, secp: &Secp256k1) -> Option<WPubkeyHash>
Returns bitcoin 160-bit hash of the public key for witness program
Sourcepub fn write_into<W: Write>(
&self,
secp: &Secp256k1,
writer: W,
) -> Result<(), Error>
pub fn write_into<W: Write>( &self, secp: &Secp256k1, writer: W, ) -> Result<(), Error>
Write the public key into a writer
Sourcepub fn read_from<R: Read>(secp: &Secp256k1, reader: R) -> Result<Self, Error>
pub fn read_from<R: Read>(secp: &Secp256k1, reader: R) -> Result<Self, Error>
Read the public key from a reader
This internally reads the first byte before reading the rest, so
use of a BufReader
is recommended.
Sourcepub fn from_slice(secp: &Secp256k1, data: &[u8]) -> Result<PublicKey, Error>
pub fn from_slice(secp: &Secp256k1, data: &[u8]) -> Result<PublicKey, Error>
Deserialize a public key from a slice
Sourcepub fn from_private_key(secp: &Secp256k1, sk: &PrivateKey) -> PublicKey
pub fn from_private_key(secp: &Secp256k1, sk: &PrivateKey) -> PublicKey
Computes the public key as supposed to be used with this secret
Trait Implementations§
Source§impl Deserialize for PublicKey
impl Deserialize for PublicKey
Source§impl Ord for PublicKey
impl Ord for PublicKey
Source§impl PartialOrd for PublicKey
impl PartialOrd for PublicKey
impl Eq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more