Wallet

Struct Wallet 

Source
pub struct Wallet { /* private fields */ }

Implementations§

Source§

impl Wallet

Source

pub fn new_random() -> Result<Self, Error>

Examples found in repository?
examples/wallet.rs (line 5)
4async fn main() {
5    let w = Wallet::new_random().unwrap();
6    println!("{:?}", w.address());
7}
Source

pub fn address(&self) -> String

Examples found in repository?
examples/wallet.rs (line 6)
4async fn main() {
5    let w = Wallet::new_random().unwrap();
6    println!("{:?}", w.address());
7}
Source

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
Hide additional 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}
Source

pub fn set_sequence(&mut self, sequence: u32)

Source

pub fn set_fee(&mut self, drops: BigInt)

Source

pub fn set_max_fee(&mut self, drops: BigInt)

Source

pub fn set_ledger_offset<T: TryInto<BigInt>>( &mut self, ledger_offset: u32, ) -> Result<(), Error>

Source

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
Hide additional 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}
Source

pub async fn auto_fill_fields<T: Transport>( &mut self, tx: &mut Transaction, xrpl: &XRPL<T>, ) -> Result<(), Error>

Source

pub fn sign(&self, tx: &mut Transaction) -> Result<String, Error>

Source

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
Hide additional 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}
Source

pub fn private_key(&self) -> String

Source

pub fn sign_message<T: Serialize>(&self, message: T) -> Result<String, Error>

Source

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> 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,