pub struct BitcoinAddress<N: BitcoinNetwork> { /* private fields */ }
Expand description
Represents a Bitcoin address
Implementations§
Source§impl<N: BitcoinNetwork> BitcoinAddress<N>
impl<N: BitcoinNetwork> BitcoinAddress<N>
Sourcepub fn p2pkh_from_hash(hash: &[u8]) -> Result<Self, AddressError>
pub fn p2pkh_from_hash(hash: &[u8]) -> Result<Self, AddressError>
Generate a P2PKH address from a hash160.
Sourcepub fn p2sh_p2wpkh_from_hash(hash: &[u8]) -> Result<Self, AddressError>
pub fn p2sh_p2wpkh_from_hash(hash: &[u8]) -> Result<Self, AddressError>
Generate a P2SH_P2WPKH address from a hash160
pub fn p2wsh_from_hash(hash: &[u8]) -> Result<Self, AddressError>
Sourcepub fn bech32_from_hash(hash: &[u8]) -> Result<Self, AddressError>
pub fn bech32_from_hash(hash: &[u8]) -> Result<Self, AddressError>
Generate a Bech32 address from a hash160
Sourcepub fn cash_addr_from_hash(hash: &[u8]) -> Result<Self, AddressError>
pub fn cash_addr_from_hash(hash: &[u8]) -> Result<Self, AddressError>
Generate a CashAddr address from a hash160
pub fn p2tr_from_hash(hash: &[u8]) -> Result<Self, AddressError>
Sourcepub fn p2pkh(
public_key: &<Self as Address>::PublicKey,
) -> Result<Self, AddressError>
pub fn p2pkh( public_key: &<Self as Address>::PublicKey, ) -> Result<Self, AddressError>
Generate a P2PKH address from a given Bitcoin public key.
pub fn p2wsh(original_script: &[u8]) -> Result<Self, AddressError>
Sourcepub fn p2sh_p2wpkh(
public_key: &<Self as Address>::PublicKey,
) -> Result<Self, AddressError>
pub fn p2sh_p2wpkh( public_key: &<Self as Address>::PublicKey, ) -> Result<Self, AddressError>
Generate a P2SH_P2WPKH address from a given Bitcoin public key.
Sourcepub fn bech32(
public_key: &<Self as Address>::PublicKey,
) -> Result<Self, AddressError>
pub fn bech32( public_key: &<Self as Address>::PublicKey, ) -> Result<Self, AddressError>
Generate a Bech32 address from a given Bitcoin public key.
Sourcepub fn cash_addr(
public_key: &<Self as Address>::PublicKey,
) -> Result<Self, AddressError>
pub fn cash_addr( public_key: &<Self as Address>::PublicKey, ) -> Result<Self, AddressError>
Generate a CashAddr address from a given Bitcoin public key.
Sourcepub fn format(&self) -> BitcoinFormat
pub fn format(&self) -> BitcoinFormat
Return the format of the Bitcoin address.
Sourcepub fn create_redeem_script(
public_key: &<Self as Address>::PublicKey,
) -> [u8; 22]
pub fn create_redeem_script( public_key: &<Self as Address>::PublicKey, ) -> [u8; 22]
Generate a redeem script from a given Bitcoin public key.
Sourcepub fn from_script_pub_key(script_pub_key: &[u8]) -> Result<Self, AddressError>
pub fn from_script_pub_key(script_pub_key: &[u8]) -> Result<Self, AddressError>
Decode the ‘script_pub_key’ to a bitcoin address
Trait Implementations§
Source§impl<N: BitcoinNetwork> Address for BitcoinAddress<N>
impl<N: BitcoinNetwork> Address for BitcoinAddress<N>
Source§fn from_secret_key(
secret_key: &Self::SecretKey,
format: &Self::Format,
) -> Result<Self, AddressError>
fn from_secret_key( secret_key: &Self::SecretKey, format: &Self::Format, ) -> Result<Self, AddressError>
Returns the address corresponding to the given Bitcoin private key.
Source§fn from_public_key(
public_key: &Self::PublicKey,
format: &Self::Format,
) -> Result<Self, AddressError>
fn from_public_key( public_key: &Self::PublicKey, format: &Self::Format, ) -> Result<Self, AddressError>
Returns the address corresponding to the given Bitcoin public key.
type SecretKey = SecretKey
type Format = BitcoinFormat
type PublicKey = BitcoinPublicKey<N>
fn is_valid(address: &str) -> bool
Source§impl<N: Clone + BitcoinNetwork> Clone for BitcoinAddress<N>
impl<N: Clone + BitcoinNetwork> Clone for BitcoinAddress<N>
Source§fn clone(&self) -> BitcoinAddress<N>
fn clone(&self) -> BitcoinAddress<N>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<N: Debug + BitcoinNetwork> Debug for BitcoinAddress<N>
impl<N: Debug + BitcoinNetwork> Debug for BitcoinAddress<N>
Source§impl<N: BitcoinNetwork> Display for BitcoinAddress<N>
impl<N: BitcoinNetwork> Display for BitcoinAddress<N>
Source§impl<N: BitcoinNetwork> FromStr for BitcoinAddress<N>
impl<N: BitcoinNetwork> FromStr for BitcoinAddress<N>
Source§impl<N: Hash + BitcoinNetwork> Hash for BitcoinAddress<N>
impl<N: Hash + BitcoinNetwork> Hash for BitcoinAddress<N>
Source§impl<N: Ord + BitcoinNetwork> Ord for BitcoinAddress<N>
impl<N: Ord + BitcoinNetwork> Ord for BitcoinAddress<N>
Source§fn cmp(&self, other: &BitcoinAddress<N>) -> Ordering
fn cmp(&self, other: &BitcoinAddress<N>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<N: PartialEq + BitcoinNetwork> PartialEq for BitcoinAddress<N>
impl<N: PartialEq + BitcoinNetwork> PartialEq for BitcoinAddress<N>
Source§impl<N: PartialOrd + BitcoinNetwork> PartialOrd for BitcoinAddress<N>
impl<N: PartialOrd + BitcoinNetwork> PartialOrd for BitcoinAddress<N>
impl<N: Eq + BitcoinNetwork> Eq for BitcoinAddress<N>
impl<N: BitcoinNetwork> StructuralPartialEq for BitcoinAddress<N>
Auto Trait Implementations§
impl<N> Freeze for BitcoinAddress<N>
impl<N> RefUnwindSafe for BitcoinAddress<N>where
N: RefUnwindSafe,
impl<N> Send for BitcoinAddress<N>
impl<N> Sync for BitcoinAddress<N>
impl<N> Unpin for BitcoinAddress<N>where
N: Unpin,
impl<N> UnwindSafe for BitcoinAddress<N>where
N: UnwindSafe,
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