[][src]Crate openalias

Look up and parse OpenAlias data.

openalias.rs as а library

This library can be used on a couple different levels (basic->high-level):

  1. Parsing/validating OpenAlias "names" (e.g. "donate@getmonero.org", "nabijaczleweli.xyz")
  2. Parsing/validating OpenAlias records (e.g. "oa1:btc recipient_address=1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H; recipient_name=Monero Development; tx_description=Donation to Monero Core Team;")
  3. Looking up OpenAliases with the DNS (e.g. "donate.nabijaczleweli.xyz" -> CryptoAddress)

In that order, examples:

// Normally a user would type this in.
let address = "donate@getmonero.org";

if let Some(fqdn) = openalias::alias_to_fqdn(address) {
    println!("{} maps to {}", address, fqdn);
} else {
    // Address is not an OpenAlias
}

Consult the alias_to_fqdn() documentation for more information and examples.

let record = "oa1:btc recipient_address=1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H; \
                      recipient_name=Monero Development; \
                      tx_description=Donation to Monero Core Team;";

match record.parse::<openalias::CryptoAddress>() {
    Ok(ca) => {
        println!("{} address: {}", ca.cryptocurrency.to_uppercase(), ca.address);
        // Probably also handle more fields
    }
    Err(err) => {
        // The record is not an OpenAlias record,
        //   see err variable so as to the position of failure.
    }
}

Consult the CryptoAddress documentation for more information and examples.

// Normally a user would type this in.
let alias = "donate.nabijaczleweli.xyz";

match openalias::address_strings(alias) {
    Ok(cas) => {
        println!("{} addresses", cas.len());
        // cas contains "oa1:"-prefixed records
    }
    Err(err) => {
        // alias isn't an OpenAlias, or there was an error talking with a DNS server
    }
}

match openalias::addresses(alias) {
    Ok(cas) => {
        println!("{} addresses", cas.len());
        // cas contains CryptoAddresses
    }
    Err(err) => {
        // alias isn't an OpenAlias,
        //   or there was an error talking with a DNS server,
        //   or an "oa1:"-prefixed record isn't an OpenAlias record.
    }
}

Consult the address_strings() and addresses() documentation for more information and examples.

openalias.rs as аn executable

This is just a very short synopsis of the manpage, so consult that for more data.

OPTIONS

Option Description
<OPEN_ALIAS>... FQDN or email-style aliases to look up addresses for.
--verbose Print more data about what's happenning to stderr.
--raw Print just the record text.
--currency=[CURRENCY]... Limit results to specified currencies.

EXAMPLES

openalias nabijaczleweli.xyz donate.getmonero.org

Addresses of nabijaczleweli.xyz:
  btc:
    nabijaczleweli
    1CgLs6CxXMAY4Pj4edQq5vyaFoP9NdqVKH

Addresses of donate.getmonero.org:
  xmr:
    Monero Development
    44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3
      XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A
    Donation to Monero Core Team
  btc:
    Monero Development
    1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H
    Donation to Monero Core Team

openalias -rv nabijaczleweli.xyz donate@getmonero.org

Looking up nabijaczleweli.xyz...
Addresses for nabijaczleweli.xyz:
  oa1:btc recipient_address=1CgLs6CxXMAY4Pj4edQq5vyaFoP9NdqVKH; recipient_name=nabijaczleweli;

Looking up donate@getmonero.org...
Addresses for donate@getmonero.org:
  oa1:xmr recipient_address=44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3
                              XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A;
          recipient_name=Monero Development; tx_description=Donation to Monero Core Team;
  oa1:btc recipient_address=1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H; recipient_name=Monero Development;
          tx_description=Donation to Monero Core Team;

openalias -cxmr -c doge nabijaczleweli.xyz donate.getmonero.org

No xmr, nor doge addresses found for nabijaczleweli.xyz.

Addresses of donate.getmonero.org:
  xmr:
    Monero Development
    44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3
      XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A
    Donation to Monero Core Team

Structs

CryptoAddress

OpenAlias-parsed cryptocurrency address.

Options

Representation of the application's all configurable values.

ParseError

OpenAlias record parsing error

Enums

Error

Some error emerging from the library.

Functions

address_strings

Ask a DNS server for "oa1:"-prefixed TXT records for the specified OpenAlias.

addresses

Ask a DNS server for addresses for the specified OpenAlias.

alias_to_fqdn

Convert an OpenAlias to an FQDN.