[−][src]Struct openalias::CryptoAddress
OpenAlias-parsed cryptocurrency address.
Displaying an address with a checksum will not print out the same sum, but will re-hash the output string
(since the output can, while functionally equivalent, be different).
Examples
Parse a simple example entry:
static MONERO_DONATE_RCRD: &str = "oa1:xmr \ recipient_address=46BeWrHpwXmHDpDEUmZBWZfoQpdc6HaERCNmx1pEYL2rAcu\ wufPN9rXHHtyUA4QVy66qeFQkn6sfK8aHYjA3jk3o1Bv16em; \ recipient_name=Monero Development;"; assert_eq!(MONERO_DONATE_RCRD.parse::<CryptoAddress>().unwrap(), CryptoAddress { cryptocurrency: "xmr".to_string(), address: "46BeWrHpwXmHDpDEUmZBWZfoQpdc6HaERCNmx1pEYL2rAcu\ wufPN9rXHHtyUA4QVy66qeFQkn6sfK8aHYjA3jk3o1Bv16em".to_string(), recipient_name: Some("Monero Development".to_string()), tx_description: None, tx_amount: None, tx_payment_id: None, address_signature: None, checksum: None, additional_values: BTreeMap::new(), });
Parse a more complex record:
static NAB_DONATE_RCRD: &str = "oa1:btc recipient_address=1MoSyGZp3SKpoiXPXfZDFK7cDUFCVtEDeS; \ recipient_name=\"nabijaczleweli; FOSS development\";\ tx_description=Donation for nabijaczleweli:\\ ; \ tx_amount=0.1;checksum=D851342C; kaschism=yass;"; assert_eq!(NAB_DONATE_RCRD.parse::<CryptoAddress>().unwrap(), CryptoAddress { cryptocurrency: "btc".to_string(), address: "1MoSyGZp3SKpoiXPXfZDFK7cDUFCVtEDeS".to_string(), recipient_name: Some("nabijaczleweli; FOSS development".to_string()), tx_description: Some("Donation for nabijaczleweli: ".to_string()), tx_amount: Some("0.1".to_string()), tx_payment_id: None, address_signature: None, checksum: Some((0xD851342C, true)), additional_values: { let mut avs = BTreeMap::new(); avs.insert("kaschism".to_string(), "yass".to_string()); avs }, });
Display a record:
let mut base_record = CryptoAddress { cryptocurrency: "btc".to_string(), address: "1MoSyGZp3SKpoiXPXfZDFK7cDUFCVtEDeS".to_string(), recipient_name: Some("nabijaczleweli; FOSS development".to_string()), tx_description: Some("Donation for nabijaczleweli: ".to_string()), tx_amount: Some("0.1".to_string()), tx_payment_id: None, address_signature: None, checksum: Some((0xD851342C, true)), additional_values: { let mut avs = BTreeMap::new(); avs.insert("kaschism".to_string(), "yass".to_string()); avs }, }; assert_eq!(&base_record.to_string(), "oa1:btc recipient_address=1MoSyGZp3SKpoiXPXfZDFK7cDUFCVtEDeS; \ recipient_name=\"nabijaczleweli; FOSS development\"; \ tx_description=Donation for nabijaczleweli:\\ ; tx_amount=0.1; \ kaschism=yass; checksum=5AAC58F4;"); base_record.checksum = None; assert_eq!(&base_record.to_string(), "oa1:btc recipient_address=1MoSyGZp3SKpoiXPXfZDFK7cDUFCVtEDeS; \ recipient_name=\"nabijaczleweli; FOSS development\"; \ tx_description=Donation for nabijaczleweli:\\ ; tx_amount=0.1; \ kaschism=yass;"); base_record.recipient_name = None; base_record.tx_description = None; base_record.tx_amount = None; base_record.additional_values.clear(); assert_eq!(&base_record.to_string(), "oa1:btc recipient_address=1MoSyGZp3SKpoiXPXfZDFK7cDUFCVtEDeS;");
Fields
cryptocurrency: String
Specified cryptocurrency's name.
Usually "btc" for Bitcoin, "mxr" for Monero, et caetera.
Note, that:
OpenAlias does not maintain a repository of prefixes at this stage, but may do so in future.
address: String
Recipient's specified cryptocurrency address. Required.
Corresponds to recipient_address record key.
recipient_name: Option<String>
Recipient's specified user-friendlier name.
Corresponds to recipient_name record key.
tx_description: Option<String>
Description for the transaction(s) resulting from this record.
Note, that:
Bear in mind that DNS is typically long-lived data and not always updated at request time, so this should only be used if it does not need to be updated constantly.
Corresponds to tx_description record key.
tx_amount: Option<String>
Amount of the specified cryptocurrency for the transaction(s) resulting from this record.
Exact numeric value/type is usecase-dependent. No restrictions are applied within the realm of the library.
Corresponds to tx_amount record key.
tx_payment_id: Option<String>
"Particular to Monero, but is standardised as other cryptocurrencies (CryptoNote-based cryptocurrencies in particular) may find it useful."
It is typically a hex string of 32 characters, but that is not enforced in the standard.
Corresponds to tx_payment_id record key.
address_signature: Option<String>
"If you have a standardised way of signing messages based on the address private key, then this can be used to validate the FQDN."
The message that is signed should be the entire FQDN (eg. donate.getmonero.org) with nothing else. Validation would be to verify that the signature is valid for the FQDN as a message.
Corresponds to address_signature record key.
checksum: Option<(u32, bool)>
CRC-32 of the record up to this key.
Second value of the pair is whether the checksum verified correctly, provided for convenience.
Depending on your use-case, it may serve little or no purpose, although some may choose to include it for additional validation. In order to calculate or verify the checksum, take the entire record up until the checksum key-value pair (ie. excluding the checksum key-value pair). Strip any spaces from either side, and calculate the CRC-32 on that final record.
Corresponds to checksum record key.
additional_values: BTreeMap<String, String>
Set of K-Vs not special-cased above.
Trait Implementations
impl Clone for CryptoAddress[src]
impl Clone for CryptoAddressfn clone(&self) -> CryptoAddress[src]
fn clone(&self) -> CryptoAddressReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Eq for CryptoAddress[src]
impl Eq for CryptoAddressimpl PartialOrd<CryptoAddress> for CryptoAddress[src]
impl PartialOrd<CryptoAddress> for CryptoAddressfn partial_cmp(&self, other: &CryptoAddress) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &CryptoAddress) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &CryptoAddress) -> bool[src]
fn lt(&self, other: &CryptoAddress) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &CryptoAddress) -> bool[src]
fn le(&self, other: &CryptoAddress) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &CryptoAddress) -> bool[src]
fn gt(&self, other: &CryptoAddress) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &CryptoAddress) -> bool[src]
fn ge(&self, other: &CryptoAddress) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl PartialEq<CryptoAddress> for CryptoAddress[src]
impl PartialEq<CryptoAddress> for CryptoAddressfn eq(&self, other: &CryptoAddress) -> bool[src]
fn eq(&self, other: &CryptoAddress) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &CryptoAddress) -> bool[src]
fn ne(&self, other: &CryptoAddress) -> boolThis method tests for !=.
impl Ord for CryptoAddress[src]
impl Ord for CryptoAddressfn cmp(&self, other: &CryptoAddress) -> Ordering[src]
fn cmp(&self, other: &CryptoAddress) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl Hash for CryptoAddress[src]
impl Hash for CryptoAddressfn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl Display for CryptoAddress[src]
impl Display for CryptoAddressfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Debug for CryptoAddress[src]
impl Debug for CryptoAddressfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl FromStr for CryptoAddress[src]
impl FromStr for CryptoAddresstype Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<CryptoAddress, ParseError>[src]
fn from_str(s: &str) -> Result<CryptoAddress, ParseError>Parses a string s to return a value of this type. Read more
Auto Trait Implementations
impl Send for CryptoAddress
impl Send for CryptoAddressimpl Sync for CryptoAddress
impl Sync for CryptoAddressBlanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToString for T where
T: Display + ?Sized, [src]
impl<T> ToString for T where
T: Display + ?Sized, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more