pub struct Privkey {
pub compressed: bool,
pub network: Network,
pub key: SecretKey,
}
Expand description
A Bitcoin ECDSA private key
Fields§
§compressed: bool
Whether this private key represents a compressed address
network: Network
The network on which this key should be used
key: SecretKey
The actual ECDSA key
Implementations§
Source§impl Privkey
impl Privkey
Sourcepub fn from_secret_key(
key: SecretKey,
compressed: bool,
network: Network,
) -> Privkey
pub fn from_secret_key( key: SecretKey, compressed: bool, network: Network, ) -> Privkey
Creates a Privkey
from a raw secp256k1 secret key
Sourcepub fn public_key<C: Signing>(&self, secp: &Secp256k1<C>) -> PublicKey
pub fn public_key<C: Signing>(&self, secp: &Secp256k1<C>) -> PublicKey
Computes the public key as supposed to be used with this secret
Sourcepub fn to_address<C: Signing>(&self, secp: &Secp256k1<C>) -> Address
pub fn to_address<C: Signing>(&self, secp: &Secp256k1<C>) -> Address
Converts a private key to a segwit address
Sourcepub fn to_legacy_address<C: Signing>(&self, secp: &Secp256k1<C>) -> Address
pub fn to_legacy_address<C: Signing>(&self, secp: &Secp256k1<C>) -> Address
Converts a private key to a legacy (non-segwit) address
Sourcepub fn secret_key(&self) -> &SecretKey
pub fn secret_key(&self) -> &SecretKey
Accessor for the underlying secp key
Sourcepub fn into_secret_key(self) -> SecretKey
pub fn into_secret_key(self) -> SecretKey
Accessor for the underlying secp key that consumes the privkey
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Accessor for the compressed flag
Trait Implementations§
impl Eq for Privkey
impl StructuralPartialEq for Privkey
Auto Trait Implementations§
impl Freeze for Privkey
impl RefUnwindSafe for Privkey
impl Send for Privkey
impl Sync for Privkey
impl Unpin for Privkey
impl UnwindSafe for Privkey
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