pub enum Address {
Bitcoin(BitcoinAddress),
Ethereum(EthereumAddress),
}Expand description
Unified address type supporting Bitcoin and Ethereum.
Variants§
Bitcoin(BitcoinAddress)
Bitcoin address (P2PKH, P2WPKH, or P2TR)
Ethereum(EthereumAddress)
Ethereum address
Implementations§
Source§impl Address
impl Address
Sourcepub fn parse(s: &str) -> Result<Self, AddressError>
pub fn parse(s: &str) -> Result<Self, AddressError>
Parse address from string with auto-detection.
Detects address type based on prefix:
1,m,n→ Bitcoin P2PKHbc1q,tb1q→ Bitcoin P2WPKHbc1p,tb1p→ Bitcoin P2TR0x→ Ethereum
Sourcepub fn is_bitcoin(&self) -> bool
pub fn is_bitcoin(&self) -> bool
Check if this is a Bitcoin address.
Sourcepub fn is_ethereum(&self) -> bool
pub fn is_ethereum(&self) -> bool
Check if this is an Ethereum address.
Trait Implementations§
Source§impl From<BitcoinAddress> for Address
impl From<BitcoinAddress> for Address
Source§fn from(addr: BitcoinAddress) -> Self
fn from(addr: BitcoinAddress) -> Self
Converts to this type from the input type.
Source§impl From<EthereumAddress> for Address
impl From<EthereumAddress> for Address
Source§fn from(addr: EthereumAddress) -> Self
fn from(addr: EthereumAddress) -> Self
Converts to this type from the input type.
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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