Struct bdk::wallet::AddressInfo
source · [−]pub struct AddressInfo {
pub index: u32,
pub address: Address,
pub keychain: KeychainKind,
}
Expand description
A derived address and the index it was found at
For convenience this automatically derefs to Address
Fields
index: u32
Child index of this address
address: Address
Address
keychain: KeychainKind
Type of keychain
Methods from Deref<Target = Address>
sourcepub fn address_type(&self) -> Option<AddressType>
pub fn address_type(&self) -> Option<AddressType>
Gets the address type of the address.
Returns
None if unknown, non-standard or related to the future witness version.
sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Checks whether or not the address is following Bitcoin standardness rules.
SegWit addresses with unassigned witness versions or non-standard program sizes are considered non-standard.
sourcepub fn script_pubkey(&self) -> Script
pub fn script_pubkey(&self) -> Script
Generates a script pubkey spending to this address.
sourcepub fn to_qr_uri(&self) -> String
pub fn to_qr_uri(&self) -> String
Creates a URI string bitcoin:address optimized to be encoded in QR codes.
If the address is bech32, both the schema and the address become uppercase. If the address is base58, the schema is lowercase and the address is left mixed case.
Quoting BIP 173 “inside QR codes uppercase SHOULD be used, as those permit the use of alphanumeric mode, which is 45% more compact than the normal byte mode.”
sourcepub fn is_valid_for_network(&self, network: Network) -> bool
pub fn is_valid_for_network(&self, network: Network) -> bool
Parsed addresses do not always have one network. The problem is that legacy testnet, regtest and signet addresse use the same prefix instead of multiple different ones. When parsing, such addresses are always assumed to be testnet addresses (the same is true for bech32 signet addresses). So if one wants to check if an address belongs to a certain network a simple comparison is not enough anymore. Instead this function can be used.
use bitcoin::{Address, Network};
let address: Address = "2N83imGV3gPwBzKJQvWJ7cRUY2SpUyU6A5e".parse().unwrap();
assert!(address.is_valid_for_network(Network::Testnet));
assert!(address.is_valid_for_network(Network::Regtest));
assert!(address.is_valid_for_network(Network::Signet));
assert_eq!(address.is_valid_for_network(Network::Bitcoin), false);
let address: Address = "32iVBEu4dxkUQk9dJbZUiBiQdmypcEyJRf".parse().unwrap();
assert!(address.is_valid_for_network(Network::Bitcoin));
assert_eq!(address.is_valid_for_network(Network::Testnet), false);
Returns true if the given pubkey is directly related to the address payload.
This is determined by directly comparing the address payload with either the hash of the given public key or the segwit redeem hash generated from the given key. For taproot addresses, the supplied key is assumed to be tweaked
Returns true if the supplied xonly public key can be used to derive the address.
This will only work for Taproot addresses. The Public Key is assumed to have already been tweaked.
Trait Implementations
sourceimpl Debug for AddressInfo
impl Debug for AddressInfo
sourceimpl Deref for AddressInfo
impl Deref for AddressInfo
sourceimpl Display for AddressInfo
impl Display for AddressInfo
sourceimpl PartialEq<AddressInfo> for AddressInfo
impl PartialEq<AddressInfo> for AddressInfo
sourcefn eq(&self, other: &AddressInfo) -> bool
fn eq(&self, other: &AddressInfo) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &AddressInfo) -> bool
fn ne(&self, other: &AddressInfo) -> bool
This method tests for !=
.
impl StructuralPartialEq for AddressInfo
Auto Trait Implementations
impl RefUnwindSafe for AddressInfo
impl Send for AddressInfo
impl Sync for AddressInfo
impl Unpin for AddressInfo
impl UnwindSafe for AddressInfo
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more