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>
impl<T: Transport> XRPL<T>
Sourcepub fn new(transport: T) -> Self
pub fn new(transport: T) -> Self
Examples found in repository?
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
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}
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}
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}
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}
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}
Sourcepub async fn account_channels(
&self,
params: AccountChannelsRequest,
) -> Result<AccountChannelsResponse, Error>
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?
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}
Sourcepub async fn account_currencies(
&self,
params: AccountCurrenciesRequest,
) -> Result<AccountCurrenciesResponse, Error>
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.)
Sourcepub async fn account_info(
&self,
params: AccountInfoRequest,
) -> Result<AccountInfoResponse, Error>
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?
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
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}
Sourcepub async fn account_lines(
&self,
params: AccountLinesRequest,
) -> Result<AccountLinesResponse, Error>
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.
Sourcepub async fn account_offers(
&self,
params: AccountOfferRequest,
) -> Result<AccountOfferResponse, Error>
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.
Sourcepub async fn transaction_entry(
&self,
params: TransactionEntryRequest,
) -> Result<TransactionEntryResponse, Error>
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.)
Sourcepub async fn submit(
&self,
params: SubmitRequest,
) -> Result<SubmitResponse, Error>
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?
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
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}
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}
Sourcepub async fn sign_and_submit(
&self,
params: SignAndSubmitRequest,
) -> Result<SubmitResponse, Error>
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.
Sourcepub async fn fee(&self, params: FeeRequest) -> Result<FeeResponse, Error>
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.
Sourcepub async fn ledger(
&self,
params: LedgerRequest,
) -> Result<LedgerResponse, Error>
pub async fn ledger( &self, params: LedgerRequest, ) -> Result<LedgerResponse, Error>
Retrieve information about the public ledger.
Sourcepub async fn channel_verify(
&self,
params: ChannelVerifyRequest,
) -> Result<ChannelVerifyResponse, Error>
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?
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§impl<T: DuplexTransport> XRPL<T>
impl<T: DuplexTransport> XRPL<T>
Sourcepub async fn subscribe(
&self,
request: SubscribeRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<SubscriptionEvent, TransportError>>>>, TransportError>
pub async fn subscribe( &self, request: SubscribeRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<SubscriptionEvent, TransportError>>>>, TransportError>
Examples found in repository?
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}