Struct XRPL

Source
pub struct XRPL<T: Transport> { /* private fields */ }
Expand description

A client that exposes methods for interacting with the XRP Ledger.

§Examples

use std::convert::TryInto;
use xrpl_rs::{XRPL, transports::HTTP, types::account::AccountInfoRequest, types::CurrencyAmount};
use tokio_test::block_on;

// Create a new XRPL client with the HTTP transport.
let xrpl = XRPL::new(
    HTTP::builder()
        .with_endpoint("http://s1.ripple.com:51234/")
        .unwrap()
        .build()
        .unwrap());

// Create a request
let mut req = AccountInfoRequest::default();
req.account = "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn".to_owned();

// Fetch the account info for an address.
let account_info = block_on(async {
    xrpl
        .account_info(req)
        .await
        .unwrap()
});

assert_eq!(account_info.account_data.balance, CurrencyAmount::xrp(9977));

Implementations§

Source§

impl<T: Transport> XRPL<T>

Source

pub fn new(transport: T) -> Self

Examples found in repository?
examples/galaxy_sign_claim.rs (lines 14-20)
11async fn main() {
12    
13    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
14    let xrpl = XRPL::new(
15        HTTP::builder()
16            .with_endpoint("https://s.altnet.rippletest.net:51234/")
17            .unwrap()
18            .build()
19            .unwrap(),
20    );
21
22    // Create wallet from secret
23    let mut wallet =
24        Wallet::from_secret("spFgCAbejxnqjkeBVjxJ4NBTRzHf9").unwrap();
25    // address: rQUjc7rAsc26qnGtqaZdRMC6xAtz9mpJLo
26
27    let signature = wallet.sign_payment_channel_claim("C079FDE149BABA4A706E8289312B24DC352667AD4797C18C013A955C84D7F89C".to_owned(), BigInt(100000000));
28    println!("{:?}", signature);
29    println!("{:?}", wallet.public_key())
30}
More examples
Hide additional examples
examples/subscription.rs (lines 11-18)
9async fn main() {
10    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
11    let xrpl = XRPL::new(
12        WebSocket::builder()
13            .with_endpoint("wss://xrplcluster.com/")
14            .unwrap()
15            .build()
16            .await
17            .unwrap(),
18    );
19    // Subscribe to ledger events.
20    let ledgers = xrpl
21        .subscribe(SubscribeRequest::Streams(vec!["ledger".to_owned()]))
22        .await
23        .unwrap();
24    // Print each ledger event as it comes through.
25    ledgers
26        .for_each(|event| async move {
27            match event {
28                Ok(SubscriptionEvent::LedgerClosed(ledger_closed)) => {
29                    println!("{}", ledger_closed.ledger_hash);
30                }
31                Err(e) => {
32                    println!("error: {:?}", e);
33                }
34            }
35        })
36        .await;
37}
examples/account_channels.rs (lines 12-18)
4async fn main() {
5    // // Generate testnet credentials.
6    // let creds = testnet::get_testnet_credentials()
7    //     .await
8    //     .expect("error generating testnet credentials");
9    // // Print the account and balance
10    // println!("Credentials: {:?}", creds,);
11    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
12    let xrpl = XRPL::new(
13        HTTP::builder()
14            .with_endpoint("https://s.devnet.rippletest.net:51234")
15            .unwrap()
16            .build()
17            .unwrap(),
18    );
19    // // Create wallet from secret
20    // let mut wallet = Wallet::from_secret(&creds.account.secret).unwrap();
21    // println!("{}", wallet.address());
22
23    // Create an account info request.
24    let mut req = AccountChannelsRequest::default();
25    // Set the account to the testnet credentials.
26    req.account = "rE2xnuTUYf3KyBTULuNM71wEFbn9yAaXYh".to_owned();
27    // Fetch the account info for an address.
28    let account_channels = xrpl.account_channels(req).await.unwrap();
29    // Print the account and balance
30    println!(
31        "Channels: {:?}",
32        account_channels
33    );
34}
examples/account_balance.rs (lines 12-19)
4async fn main() {
5    // // Generate testnet credentials.
6    // let creds = testnet::get_testnet_credentials()
7    //     .await
8    //     .expect("error generating testnet credentials");
9    // // Print the account and balance
10    // println!("Credentials: {:?}", creds,);
11    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
12    let xrpl = XRPL::new(
13        WebSocket::builder()
14            .with_endpoint("wss://xrplcluster.com/")
15            .unwrap()
16            .build()
17            .await
18            .unwrap(),
19    );
20    // // Create wallet from secret
21    // let mut wallet = Wallet::from_secret(&creds.account.secret).unwrap();
22    // println!("{}", wallet.address());
23
24    // Create an account info request.
25    let mut req = AccountInfoRequest::default();
26    // Set the account to the testnet credentials.
27    req.account = "rpD1ocF4rs3crXBjgdco84KhGQGep589YR".to_owned();
28    // Fetch the account info for an address.
29    let account_info = xrpl.account_info(req).await.unwrap();
30    // Print the account and balance
31    println!(
32        "Address {}, Info: {:?}",
33        account_info.account_data.account, account_info
34    );
35}
examples/galaxy_create_payment_channel.rs (lines 17-23)
14async fn main() {
15    
16    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
17    let xrpl = XRPL::new(
18        HTTP::builder()
19            .with_endpoint("https://s.altnet.rippletest.net:51234/")
20            .unwrap()
21            .build()
22            .unwrap(),
23    );
24
25    // Create wallet from secret
26    let mut wallet =
27        Wallet::from_secret("spFgCAbejxnqjkeBVjxJ4NBTRzHf9").unwrap();
28    // address: rQUjc7rAsc26qnGtqaZdRMC6xAtz9mpJLo
29
30    // Create a payment transaction.
31    let mut pay_chan = PaymentChannelCreate::default();
32    pay_chan.amount = BigInt(100000000);
33    pay_chan.destination = "rhXqkowQZBjDTLYcfxDu8vXXaJE3WCXZzw".to_owned(); // Set the destination to the second account.
34    pay_chan.public_key = wallet.public_key();
35    
36    // Convert the pay_chan into a transaction.
37    let mut tx = pay_chan.into_transaction();
38
39    let tx_blob = wallet.fill_and_sign(&mut tx, &xrpl).await.expect("failed to sign");
40
41    println!("Transaction: {:?}", tx);
42
43    // Create a sign_and_submit request.
44    let mut submit_req = SubmitRequest::default();
45    submit_req.tx_blob = tx_blob;
46
47    // Submit the transaction to the ledger.
48    let submit_res = xrpl
49        .submit(submit_req)
50        .await
51        .expect("failed to make submit request");
52    println!("Got response to submit request: {:?}", submit_res);
53
54}
examples/account_submit_payment.rs (lines 21-27)
13async fn main() {
14    // Generate testnet credentials.
15    let creds_one = testnet::get_testnet_credentials()
16        .await
17        .expect("error generating testnet credentials");
18    println!("Created account: {:?}", creds_one);
19
20    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
21    let xrpl = XRPL::new(
22        HTTP::builder()
23            .with_endpoint("https://s.altnet.rippletest.net:51234/")
24            .unwrap()
25            .build()
26            .unwrap(),
27    );
28
29    // Create wallet from secret
30    let mut wallet =
31        Wallet::from_secret(&creds_one.account.secret).unwrap();
32
33    // Create a payment transaction.
34    let mut payment = Payment::default();
35    payment.amount = CurrencyAmount::xrp(100000000);
36    payment.destination = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned(); // Set the destination to the second account.
37
38    // Convert the payment into a transaction.
39    let mut tx = payment.into_transaction();
40
41    let tx_blob = wallet.fill_and_sign(&mut tx, &xrpl).await.unwrap();
42
43    println!("Transaction: {:?}", tx);
44
45    // Create a sign_and_submit request.
46    let mut submit_req = SubmitRequest::default();
47    submit_req.tx_blob = tx_blob;
48
49    // Submit the transaction to the ledger.
50    let submit_res = xrpl
51        .submit(submit_req)
52        .await
53        .expect("failed to make submit request");
54    println!("Got response to submit request: {:?}", submit_res);
55
56    // Create an account info request to see the balance of account two.
57    let mut req = AccountInfoRequest::default();
58    // Set the account to the second set of testnet credentials.
59    req.account = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned();
60    // Fetch the account info for an address.
61    let account_info = xrpl
62        .account_info(req)
63        .await
64        .expect("failed to make account_info request");
65    // Print the account and balance
66    println!(
67        "Address {} has balance of {:?}",
68        account_info.account_data.account, account_info.account_data.balance
69    );
70}
Source

pub async fn account_channels( &self, params: AccountChannelsRequest, ) -> Result<AccountChannelsResponse, Error>

The account_channels method returns information about an account’s Payment Channels. This includes only channels where the specified account is the channel’s source, not the destination. (A channel’s “source” and “owner” are the same.) All information retrieved is relative to a particular version of the ledger.

Examples found in repository?
examples/account_channels.rs (line 28)
4async fn main() {
5    // // Generate testnet credentials.
6    // let creds = testnet::get_testnet_credentials()
7    //     .await
8    //     .expect("error generating testnet credentials");
9    // // Print the account and balance
10    // println!("Credentials: {:?}", creds,);
11    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
12    let xrpl = XRPL::new(
13        HTTP::builder()
14            .with_endpoint("https://s.devnet.rippletest.net:51234")
15            .unwrap()
16            .build()
17            .unwrap(),
18    );
19    // // Create wallet from secret
20    // let mut wallet = Wallet::from_secret(&creds.account.secret).unwrap();
21    // println!("{}", wallet.address());
22
23    // Create an account info request.
24    let mut req = AccountChannelsRequest::default();
25    // Set the account to the testnet credentials.
26    req.account = "rE2xnuTUYf3KyBTULuNM71wEFbn9yAaXYh".to_owned();
27    // Fetch the account info for an address.
28    let account_channels = xrpl.account_channels(req).await.unwrap();
29    // Print the account and balance
30    println!(
31        "Channels: {:?}",
32        account_channels
33    );
34}
Source

pub async fn account_currencies( &self, params: AccountCurrenciesRequest, ) -> Result<AccountCurrenciesResponse, Error>

The account_currencies command retrieves a list of currencies that an account can send or receive, based on its trust lines. (This is not a thoroughly confirmed list, but it can be used to populate user interfaces.)

Source

pub async fn account_info( &self, params: AccountInfoRequest, ) -> Result<AccountInfoResponse, Error>

The account_info command retrieves information about an account, its activity, and its XRP balance. All information retrieved is relative to a particular version of the ledger.

Examples found in repository?
examples/account_balance.rs (line 29)
4async fn main() {
5    // // Generate testnet credentials.
6    // let creds = testnet::get_testnet_credentials()
7    //     .await
8    //     .expect("error generating testnet credentials");
9    // // Print the account and balance
10    // println!("Credentials: {:?}", creds,);
11    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
12    let xrpl = XRPL::new(
13        WebSocket::builder()
14            .with_endpoint("wss://xrplcluster.com/")
15            .unwrap()
16            .build()
17            .await
18            .unwrap(),
19    );
20    // // Create wallet from secret
21    // let mut wallet = Wallet::from_secret(&creds.account.secret).unwrap();
22    // println!("{}", wallet.address());
23
24    // Create an account info request.
25    let mut req = AccountInfoRequest::default();
26    // Set the account to the testnet credentials.
27    req.account = "rpD1ocF4rs3crXBjgdco84KhGQGep589YR".to_owned();
28    // Fetch the account info for an address.
29    let account_info = xrpl.account_info(req).await.unwrap();
30    // Print the account and balance
31    println!(
32        "Address {}, Info: {:?}",
33        account_info.account_data.account, account_info
34    );
35}
More examples
Hide additional examples
examples/account_submit_payment.rs (line 62)
13async fn main() {
14    // Generate testnet credentials.
15    let creds_one = testnet::get_testnet_credentials()
16        .await
17        .expect("error generating testnet credentials");
18    println!("Created account: {:?}", creds_one);
19
20    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
21    let xrpl = XRPL::new(
22        HTTP::builder()
23            .with_endpoint("https://s.altnet.rippletest.net:51234/")
24            .unwrap()
25            .build()
26            .unwrap(),
27    );
28
29    // Create wallet from secret
30    let mut wallet =
31        Wallet::from_secret(&creds_one.account.secret).unwrap();
32
33    // Create a payment transaction.
34    let mut payment = Payment::default();
35    payment.amount = CurrencyAmount::xrp(100000000);
36    payment.destination = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned(); // Set the destination to the second account.
37
38    // Convert the payment into a transaction.
39    let mut tx = payment.into_transaction();
40
41    let tx_blob = wallet.fill_and_sign(&mut tx, &xrpl).await.unwrap();
42
43    println!("Transaction: {:?}", tx);
44
45    // Create a sign_and_submit request.
46    let mut submit_req = SubmitRequest::default();
47    submit_req.tx_blob = tx_blob;
48
49    // Submit the transaction to the ledger.
50    let submit_res = xrpl
51        .submit(submit_req)
52        .await
53        .expect("failed to make submit request");
54    println!("Got response to submit request: {:?}", submit_res);
55
56    // Create an account info request to see the balance of account two.
57    let mut req = AccountInfoRequest::default();
58    // Set the account to the second set of testnet credentials.
59    req.account = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned();
60    // Fetch the account info for an address.
61    let account_info = xrpl
62        .account_info(req)
63        .await
64        .expect("failed to make account_info request");
65    // Print the account and balance
66    println!(
67        "Address {} has balance of {:?}",
68        account_info.account_data.account, account_info.account_data.balance
69    );
70}
Source

pub async fn account_lines( &self, params: AccountLinesRequest, ) -> Result<AccountLinesResponse, Error>

The account_lines method returns information about an account’s trust lines, including balances in all non-XRP currencies and assets. All information retrieved is relative to a particular version of the ledger.

Source

pub async fn account_offers( &self, params: AccountOfferRequest, ) -> Result<AccountOfferResponse, Error>

The account_offers method retrieves a list of offers made by a given account that are outstanding as of a particular ledger version.

Source

pub async fn transaction_entry( &self, params: TransactionEntryRequest, ) -> Result<TransactionEntryResponse, Error>

The transaction_entry method retrieves information on a single transaction from a specific ledger version. (The tx method, by contrast, searches all ledgers for the specified transaction. We recommend using that method instead.)

Source

pub async fn submit( &self, params: SubmitRequest, ) -> Result<SubmitResponse, Error>

The submit method applies a transaction and sends it to the network to be confirmed and included in future ledgers.

Examples found in repository?
examples/galaxy_create_payment_channel.rs (line 49)
14async fn main() {
15    
16    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
17    let xrpl = XRPL::new(
18        HTTP::builder()
19            .with_endpoint("https://s.altnet.rippletest.net:51234/")
20            .unwrap()
21            .build()
22            .unwrap(),
23    );
24
25    // Create wallet from secret
26    let mut wallet =
27        Wallet::from_secret("spFgCAbejxnqjkeBVjxJ4NBTRzHf9").unwrap();
28    // address: rQUjc7rAsc26qnGtqaZdRMC6xAtz9mpJLo
29
30    // Create a payment transaction.
31    let mut pay_chan = PaymentChannelCreate::default();
32    pay_chan.amount = BigInt(100000000);
33    pay_chan.destination = "rhXqkowQZBjDTLYcfxDu8vXXaJE3WCXZzw".to_owned(); // Set the destination to the second account.
34    pay_chan.public_key = wallet.public_key();
35    
36    // Convert the pay_chan into a transaction.
37    let mut tx = pay_chan.into_transaction();
38
39    let tx_blob = wallet.fill_and_sign(&mut tx, &xrpl).await.expect("failed to sign");
40
41    println!("Transaction: {:?}", tx);
42
43    // Create a sign_and_submit request.
44    let mut submit_req = SubmitRequest::default();
45    submit_req.tx_blob = tx_blob;
46
47    // Submit the transaction to the ledger.
48    let submit_res = xrpl
49        .submit(submit_req)
50        .await
51        .expect("failed to make submit request");
52    println!("Got response to submit request: {:?}", submit_res);
53
54}
More examples
Hide additional examples
examples/account_submit_payment.rs (line 51)
13async fn main() {
14    // Generate testnet credentials.
15    let creds_one = testnet::get_testnet_credentials()
16        .await
17        .expect("error generating testnet credentials");
18    println!("Created account: {:?}", creds_one);
19
20    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
21    let xrpl = XRPL::new(
22        HTTP::builder()
23            .with_endpoint("https://s.altnet.rippletest.net:51234/")
24            .unwrap()
25            .build()
26            .unwrap(),
27    );
28
29    // Create wallet from secret
30    let mut wallet =
31        Wallet::from_secret(&creds_one.account.secret).unwrap();
32
33    // Create a payment transaction.
34    let mut payment = Payment::default();
35    payment.amount = CurrencyAmount::xrp(100000000);
36    payment.destination = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned(); // Set the destination to the second account.
37
38    // Convert the payment into a transaction.
39    let mut tx = payment.into_transaction();
40
41    let tx_blob = wallet.fill_and_sign(&mut tx, &xrpl).await.unwrap();
42
43    println!("Transaction: {:?}", tx);
44
45    // Create a sign_and_submit request.
46    let mut submit_req = SubmitRequest::default();
47    submit_req.tx_blob = tx_blob;
48
49    // Submit the transaction to the ledger.
50    let submit_res = xrpl
51        .submit(submit_req)
52        .await
53        .expect("failed to make submit request");
54    println!("Got response to submit request: {:?}", submit_res);
55
56    // Create an account info request to see the balance of account two.
57    let mut req = AccountInfoRequest::default();
58    // Set the account to the second set of testnet credentials.
59    req.account = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned();
60    // Fetch the account info for an address.
61    let account_info = xrpl
62        .account_info(req)
63        .await
64        .expect("failed to make account_info request");
65    // Print the account and balance
66    println!(
67        "Address {} has balance of {:?}",
68        account_info.account_data.account, account_info.account_data.balance
69    );
70}
examples/galaxy_claim.rs (line 56)
4async fn main() {
5    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
6    let xrpl = XRPL::new(
7        HTTP::builder()
8            .with_endpoint("https://s.altnet.rippletest.net:51234/")
9            .unwrap()
10            .build()
11            .unwrap(),
12    );
13
14    // Create wallet from secret
15    let mut wallet = Wallet::from_secret("spoaQBwqU4fZ43euykDwtnBHt8aJr").unwrap();
16    // address: rhXqkowQZBjDTLYcfxDu8vXXaJE3WCXZzw
17
18    // Verify
19    let mut verify_claim = ChannelVerifyRequest::default();
20    verify_claim.channel_id = "C079FDE149BABA4A706E8289312B24DC352667AD4797C18C013A955C84D7F89C".to_owned();
21    verify_claim.signature = "3045022100F24C23106C7BDF3C2CD6FA2991BE2333645BE00E9522CB3B4BBF8ADD97CD7072022073F7AA1E72B388FEB1CCA0014ACEA892143E17B987CCBFDA7AD2F4CEA706EF8A".to_owned();
22    verify_claim.amount = BigInt(100000000);
23    verify_claim.public_key = "0393285ac2827240d69221ba24b0a4b433be74b18f622236dbf2e3141445a9d588".to_owned();
24
25    let verify_res = xrpl.channel_verify(verify_claim).await.unwrap();
26
27    println!("{:?}", verify_res);
28    if !verify_res.signature_verified {
29        return;
30    }
31
32    // Create a payment transaction.
33    let mut pay_claim = PaymentChannelClaim::default();
34    pay_claim.channel = "C079FDE149BABA4A706E8289312B24DC352667AD4797C18C013A955C84D7F89C".to_owned();
35    pay_claim.signature = Some("3045022100F24C23106C7BDF3C2CD6FA2991BE2333645BE00E9522CB3B4BBF8ADD97CD7072022073F7AA1E72B388FEB1CCA0014ACEA892143E17B987CCBFDA7AD2F4CEA706EF8A".to_owned());
36    pay_claim.amount = Some(BigInt(100000000));
37    pay_claim.balance = Some(BigInt(100000000));
38    pay_claim.public_key = Some("0393285ac2827240d69221ba24b0a4b433be74b18f622236dbf2e3141445a9d588".to_owned());
39
40    // Convert the pay_chan into a transaction.
41    let mut tx = pay_claim.into_transaction();
42
43    let tx_blob = wallet
44        .fill_and_sign(&mut tx, &xrpl)
45        .await
46        .expect("failed to sign");
47
48    println!("Transaction: {:?}", tx);
49
50    // Create a sign_and_submit request.
51    let mut submit_req = SubmitRequest::default();
52    submit_req.tx_blob = tx_blob;
53
54    // Submit the transaction to the ledger.
55    let submit_res = xrpl
56        .submit(submit_req)
57        .await
58        .expect("failed to make submit request");
59    println!("Got response to submit request: {:?}", submit_res);
60}
Source

pub async fn sign_and_submit( &self, params: SignAndSubmitRequest, ) -> Result<SubmitResponse, Error>

The sign_and_submit method applies a transaction and sends it to the network to be confirmed and included in future ledgers.

Source

pub async fn fee(&self, params: FeeRequest) -> Result<FeeResponse, Error>

The fee command reports the current state of the open-ledger requirements for the transaction cost. This requires the FeeEscalation amendment to be enabled. New in: rippled 0.31.0.

Source

pub async fn ledger( &self, params: LedgerRequest, ) -> Result<LedgerResponse, Error>

Retrieve information about the public ledger.

Source

pub async fn channel_verify( &self, params: ChannelVerifyRequest, ) -> Result<ChannelVerifyResponse, Error>

The channel_verify method checks the validity of a signature that can be used to redeem a specific amount of XRP from a payment channel.

Examples found in repository?
examples/galaxy_claim.rs (line 25)
4async fn main() {
5    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
6    let xrpl = XRPL::new(
7        HTTP::builder()
8            .with_endpoint("https://s.altnet.rippletest.net:51234/")
9            .unwrap()
10            .build()
11            .unwrap(),
12    );
13
14    // Create wallet from secret
15    let mut wallet = Wallet::from_secret("spoaQBwqU4fZ43euykDwtnBHt8aJr").unwrap();
16    // address: rhXqkowQZBjDTLYcfxDu8vXXaJE3WCXZzw
17
18    // Verify
19    let mut verify_claim = ChannelVerifyRequest::default();
20    verify_claim.channel_id = "C079FDE149BABA4A706E8289312B24DC352667AD4797C18C013A955C84D7F89C".to_owned();
21    verify_claim.signature = "3045022100F24C23106C7BDF3C2CD6FA2991BE2333645BE00E9522CB3B4BBF8ADD97CD7072022073F7AA1E72B388FEB1CCA0014ACEA892143E17B987CCBFDA7AD2F4CEA706EF8A".to_owned();
22    verify_claim.amount = BigInt(100000000);
23    verify_claim.public_key = "0393285ac2827240d69221ba24b0a4b433be74b18f622236dbf2e3141445a9d588".to_owned();
24
25    let verify_res = xrpl.channel_verify(verify_claim).await.unwrap();
26
27    println!("{:?}", verify_res);
28    if !verify_res.signature_verified {
29        return;
30    }
31
32    // Create a payment transaction.
33    let mut pay_claim = PaymentChannelClaim::default();
34    pay_claim.channel = "C079FDE149BABA4A706E8289312B24DC352667AD4797C18C013A955C84D7F89C".to_owned();
35    pay_claim.signature = Some("3045022100F24C23106C7BDF3C2CD6FA2991BE2333645BE00E9522CB3B4BBF8ADD97CD7072022073F7AA1E72B388FEB1CCA0014ACEA892143E17B987CCBFDA7AD2F4CEA706EF8A".to_owned());
36    pay_claim.amount = Some(BigInt(100000000));
37    pay_claim.balance = Some(BigInt(100000000));
38    pay_claim.public_key = Some("0393285ac2827240d69221ba24b0a4b433be74b18f622236dbf2e3141445a9d588".to_owned());
39
40    // Convert the pay_chan into a transaction.
41    let mut tx = pay_claim.into_transaction();
42
43    let tx_blob = wallet
44        .fill_and_sign(&mut tx, &xrpl)
45        .await
46        .expect("failed to sign");
47
48    println!("Transaction: {:?}", tx);
49
50    // Create a sign_and_submit request.
51    let mut submit_req = SubmitRequest::default();
52    submit_req.tx_blob = tx_blob;
53
54    // Submit the transaction to the ledger.
55    let submit_res = xrpl
56        .submit(submit_req)
57        .await
58        .expect("failed to make submit request");
59    println!("Got response to submit request: {:?}", submit_res);
60}
Source

pub async fn tx(&self, params: TxRequest) -> Result<TxResponse, Error>

The tx method retrieves information on a single transaction, by its identifying hash.

Source§

impl<T: DuplexTransport> XRPL<T>

Source

pub async fn subscribe( &self, request: SubscribeRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<SubscriptionEvent, TransportError>>>>, TransportError>

Examples found in repository?
examples/subscription.rs (line 21)
9async fn main() {
10    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
11    let xrpl = XRPL::new(
12        WebSocket::builder()
13            .with_endpoint("wss://xrplcluster.com/")
14            .unwrap()
15            .build()
16            .await
17            .unwrap(),
18    );
19    // Subscribe to ledger events.
20    let ledgers = xrpl
21        .subscribe(SubscribeRequest::Streams(vec!["ledger".to_owned()]))
22        .await
23        .unwrap();
24    // Print each ledger event as it comes through.
25    ledgers
26        .for_each(|event| async move {
27            match event {
28                Ok(SubscriptionEvent::LedgerClosed(ledger_closed)) => {
29                    println!("{}", ledger_closed.ledger_hash);
30                }
31                Err(e) => {
32                    println!("error: {:?}", e);
33                }
34            }
35        })
36        .await;
37}

Auto Trait Implementations§

§

impl<T> Freeze for XRPL<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for XRPL<T>
where T: RefUnwindSafe,

§

impl<T> Send for XRPL<T>
where T: Send,

§

impl<T> Sync for XRPL<T>
where T: Sync,

§

impl<T> Unpin for XRPL<T>
where T: Unpin,

§

impl<T> UnwindSafe for XRPL<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,