pub struct Wallet { /* private fields */ }Implementations§
Source§impl Wallet
impl Wallet
Sourcepub fn new_random() -> Result<Self, Error>
pub fn new_random() -> Result<Self, Error>
Sourcepub fn from_secret(secret: &str) -> Result<Self, Error>
pub fn from_secret(secret: &str) -> Result<Self, Error>
Examples found in repository?
examples/galaxy_sign_claim.rs (line 24)
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
examples/galaxy_create_payment_channel.rs (line 27)
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 (line 31)
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 15)
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}pub fn set_sequence(&mut self, sequence: u32)
pub fn set_fee(&mut self, drops: BigInt)
pub fn set_max_fee(&mut self, drops: BigInt)
pub fn set_ledger_offset<T: TryInto<BigInt>>( &mut self, ledger_offset: u32, ) -> Result<(), Error>
Sourcepub async fn fill_and_sign<T: Transport>(
&mut self,
tx: &mut Transaction,
xrpl: &XRPL<T>,
) -> Result<String, Error>
pub async fn fill_and_sign<T: Transport>( &mut self, tx: &mut Transaction, xrpl: &XRPL<T>, ) -> Result<String, Error>
Examples found in repository?
examples/galaxy_create_payment_channel.rs (line 39)
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
examples/account_submit_payment.rs (line 41)
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 44)
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}pub async fn auto_fill_fields<T: Transport>( &mut self, tx: &mut Transaction, xrpl: &XRPL<T>, ) -> Result<(), Error>
pub fn sign(&self, tx: &mut Transaction) -> Result<String, Error>
Sourcepub fn public_key(&self) -> String
pub fn public_key(&self) -> String
Examples found in repository?
examples/galaxy_sign_claim.rs (line 29)
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
examples/galaxy_create_payment_channel.rs (line 34)
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}pub fn private_key(&self) -> String
pub fn sign_message<T: Serialize>(&self, message: T) -> Result<String, Error>
Sourcepub fn sign_payment_channel_claim(
&self,
channel: String,
amount: BigInt,
) -> Result<String, Error>
pub fn sign_payment_channel_claim( &self, channel: String, amount: BigInt, ) -> Result<String, Error>
Examples found in repository?
examples/galaxy_sign_claim.rs (line 27)
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}Auto Trait Implementations§
impl Freeze for Wallet
impl RefUnwindSafe for Wallet
impl Send for Wallet
impl Sync for Wallet
impl Unpin for Wallet
impl UnwindSafe for Wallet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more