[][src]Struct xpring::Xrpl

pub struct Xrpl { /* fields omitted */ }

The Xrpl struct will allow you to access all the Xrpl methods

Methods

impl Xrpl[src]

pub fn new<S: Into<String>>(
    xrplclient_url: S,
    test: bool
) -> Result<Xrpl, Error>
[src]

Creates a Xpring struct.

Arguments

  • xrplclient_url - &str Url for the XRP Ledger node.
  • test - bool true for TestNet, false for MainNet.

Remarks

Returns a Xpring struct wrapped in a Result (Result<Xpring, anyhow::Error>).

Example

let mut xpring =  Xrpl::new("http://test.xrp.xpring.io:50051", false)?;

pub fn generate_random_wallet<S: Into<Option<String>>>(
    &mut self,
    entropy: S
) -> Result<XWalletGenerationResult, Error>
[src]

Generates a random wallet. An Entropy can be passed for generation but it is optional.

Arguments

  • entropy - Option<String> (Optional) Entropy.

Remarks

Returns a XWalletGenerationResult with the generated wallet wrapped in a Result (Result<XWalletGenerationResult, anyhow::Error>).

Example

let random_wallet = xpring.generate_random_wallet(None)?;

// {
//   wallet:
//     XWallet {
//        public_key: "029D92AA16B71AB5EBADFD7A911C7CF8253C86BABFD7C6CB6A5587FCE20D26C5F0",
//        private_key: "0006039508EB1F0BDDD511276BB8E08CDC00426992840F20083DF8E81E0AD84270",
//        test: false,
//        address: Some("XVesH3RwNwJ3bpAcVh54A2TxaVyyyomhErvVhfjHvrA3z2h")
//     },
//     mnemonic: "notable dilemma fringe install chicken icon please aim era security utility atom",
//     derivation_path: "m/44\'/144\'/0\'/0/0"
// }

pub fn wallet_from_mnemonic<S: Into<String>>(
    &mut self,
    mnemonic: S,
    derivation_path: Option<&str>
) -> Result<XWallet, Error>
[src]

Generates a wallet from a mnemonic (and derivation path).

Arguments

  • mnemonic - Option<String> Mnemonic.

Remarks

Returns a XWaller with the generated wallet wrapped in a Result (Result<XWallet, anyhow::Error>).

Example

let wallet_from_mnemonic = xrpl.wallet_from_mnemonic(
    "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", 
    Some("m/44'/144'/0'/0/1")
)?;
// XWallet {
//  public_key: "038BF420B5271ADA2D7479358FF98A29954CF18DC25155184AEAD05796DA737E89",
//  private_key: "000974B4CFE004A2E6C4364CBF3510A36A352796728D0861F6B555ED7E54A70389",
//  test: true,
//  address: Some("T7FxQEtaiNkq6ELhqGk3Pz2ov5aEoaGo6V642R74aaywJNT")
// }

pub fn wallet_from_seed<S: Into<String>>(
    &mut self,
    seed: S,
    derivation_path: Option<&str>
) -> Result<XWallet, Error>
[src]

Generates a wallet from a seed.

Arguments

  • seed - String Seed
  • derivation_path - Option<String> (Optional) Derivation path.

Remarks

Returns a XWallet with the generated wallet wrapped in a Result (Result<XWallet, anyhow::Error>).

Example

let wallet_from_seed =
    xprl.wallet_from_seed("snYP7oArxKepd3GPDcrjMsJYiJeJB", None)?;

// XWallet {
//  public_key: "038BF420B5271ADA2D7479358FF98A29954CF18DC25155184AEAD05796DA737E89",
//  private_key: "000974B4CFE004A2E6C4364CBF3510A36A352796728D0861F6B555ED7E54A70389",
//  test: true,
//  address: Some("T7FxQEtaiNkq6ELhqGk3Pz2ov5aEoaGo6V642R74aaywJNT")
// }

pub fn wallet_sign<S: Into<String>>(
    &mut self,
    message: S,
    private_key: S
) -> Result<String, Error>
[src]

Signs a message with a private key.

Arguments

  • message - String Message to be signed.
  • private_key - String Private key that will sign the message.

Remarks

Returns a String with the signed message wrapped in a Result (Result<String, anyhow::Error>).

Example

let signed_message = xrpl.wallet_sign(
    "mymessage",
    "000974B4CFE004A2E6C4364CBF3510A36A352796728D0861F6B555ED7E54A70389",
)?;

// "3045022100DD88E31FF9AFD2A6DA48D40C4B4E8F11725E11C9D9E52388710E35ED19212EF6022068CFA9C09071322751C11DD21E89088879DC28B3B683D3F863090FB7C331EC32"

pub fn wallet_verify<S: Into<String>>(
    &mut self,
    message: S,
    signature: S,
    public_key: S
) -> Result<bool, Error>
[src]

Verifies with a public key a signed message.

Arguments

  • message - String Message to be signed.
  • signature - String Message signature.
  • public_key - String Signer's public key.

Remarks

Returns a bool, true if verification is successful, false if not, wrapped in a Result (Result<bool, anyhow::Error>).

Example

let message_verification_result = xrpl.wallet_verify(
    "mymessage", 
    "3045022100DD88E31FF9AFD2A6DA48D40C4B4E8F11725E11C9D9E52388710E35ED19212EF6022068CFA9C09071322751C11DD21E89088879DC28B3B683D3F863090FB7C331EC32", 
    "038BF420B5271ADA2D7479358FF98A29954CF18DC25155184AEAD05796DA737E89"
)?;

// true

pub fn validate_address(&mut self, address: &str) -> Result<bool, Error>[src]

Validates an address (X or Classic).

Arguments

  • address - &str Address.

Remarks

Returns a bool, true if verification is successful, false if not, wrapped in a Result (Result<bool, anyhow::Error>).

Example

let is_address_valid =
    xrpl.validate_address("TVr7v7JGN5suv7Zgdu9aL4PtCkwayZNYWvjSG23uMMWMvzZ")?;

// true

pub fn validate_x_address(&mut self, x_address: &str) -> Result<bool, Error>[src]

Validates an X-Address

Arguments

  • x_address - &str X-Address

Remarks

Returns a bool, true if verification is successful, false if not, wrapped in a Result (Result<bool, anyhow::Error>).

Example

let is_address_valid =
    xrpl.validate_x_address("TVr7v7JGN5suv7Zgdu9aL4PtCkwayZNYWvjSG23uMMWMvzZ")?;

// true

pub fn validate_classic_address(
    &mut self,
    classic_address: &str
) -> Result<bool, Error>
[src]

Validates a Classic Address.

Arguments

  • address - &str Classic Address.

Remarks

Returns a bool, true if verification is successful, false if not, wrapped in a Result (Result<bool, anyhow::Error>).

Example

let is_address_valid =
    xrpl.validate_classic_address("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1")?;

// true

pub fn encode_classic_address(
    &mut self,
    classic_address: &str,
    tag: Option<u16>,
    test: Option<bool>
) -> Result<String, Error>
[src]

Encodes a Classic Address into a X-Address

Arguments

  • classic_address - &str Classic Address

Remarks

Returns a String with the X-Address wrapped in a Result (Result<String, anyhow::Error>).

Example

let x_address =
    xrpl.encode_classic_address("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1", Some(12345), None)?;


// "XVfC9CTCJh6GN2x8bnrw3LtdbqiVCUvtU3HnooQDgBnUpQT"

pub fn decode_x_address(
    &mut self,
    x_address: &str
) -> Result<XClassicAddress, Error>
[src]

Decodes a X-Address into a Classic Address.x

Arguments

  • x_address - &str X-Address.

Remarks

Returns a XClassicAddress struct wrapped in a Result (Result<XClassicAddress, anyhow::Error>).

Example

let classic_address =
    xrpl.decode_x_address("XVfC9CTCJh6GN2x8bnrw3LtdbqiVCUvtU3HnooQDgBnUpQT")?;

// {
//  address: "rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1",
//  tag: Some(12345),
//  test: false
// }

pub fn get_balance(&mut self, x_address: &str) -> Result<f32, Error>[src]

Returns an account balance.

Arguments

  • x_address - &str Account in x format.

Remarks

Returns a f32 with the balance in decimal format wrapped in a Result (Result<f32, anyhow::Error> ).

Example

let balance = xrpl.get_balance("TVr7v7JGN5suv7Zgdu9aL4PtCkwayZNYWvjSG23uMMWMvzZ")?;

// 1000

pub fn send(
    &mut self,
    amount: f32,
    from_x_address: &str,
    to_x_address: &str,
    source_wallet: XWallet
) -> Result<XrplReliableSendResponse, Error>
[src]

Sends a payment from one account to another.

Arguments

  • amount - f32 Payment amount in decimal format (Ex. 10.32).
  • from_address - &str Origin account in x format.
  • to_address - &str Destination account in x format.
  • source_wallet - XWallet Wallet that will fund the payment and sign the transaction.

Remarks

Returns a XrplReliableSendResponse wrapped in a Result (Result<XrplReliableSendResponse, anyhow::Error>).

Example

let sending_wallet =
    xrpl.wallet_from_seed(
        "shKtxFAYfNUHYayYMYkp3KjQQX2UY", 
        None
    )?;
let payment = xrpl.send(
    12.12,
    "T7jkn8zYC2NhPdcbVxkiEXZGy56YiEE4P7uXRgpy5j4Q6S1",
    "T7QqSicoC1nB4YRyzWzctWW7KjwiYUtDzVaLwFd4N7W1AUU",
    sending_wallet,
)?;

// {
//  transaction_status: FAILED,
//  transaction_hash: "2E01FED358DDB9B843116D858695D8EF3285BA6C7A478D054E05AD20BD50857C",
//  transaction_info: "Insufficient XRP balance to send."
// }

pub fn get_transaction_status(
    &mut self,
    transaction_hash: &str
) -> Result<XTransactionStatus, Error>
[src]

Returns a certain transaction status.

Arguments

  • transaction_hash - &str Transaction hash.

Remarks

Returns a XTransactionStatus with the transaction status wrapped in a Result (Result<XTransactionStatus, anyhow::Error>).

Example

let transaction_status = xrpl.get_transaction_status(
     "DCDFF1F2A89762CC8209F545D3C950CDCA00262A6A07CCA99C06235198746803",
)?;

// FAILED

Auto Trait Implementations

impl !RefUnwindSafe for Xrpl

impl Send for Xrpl

impl Sync for Xrpl

impl Unpin for Xrpl

impl !UnwindSafe for Xrpl

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoRequest<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]