Struct KmdClient

Source
pub struct KmdClient { /* private fields */ }
Expand description

Client for interacting with the key management daemon

Implementations§

Source§

impl KmdClient

Source

pub fn new(address: &str, token: &str) -> KmdClient

Examples found in repository?
examples/quickstart.rs (line 10)
3fn main() {
4    let algod_address = "http://localhost:8080";
5    let algod_token = "contents-of-algod.token";
6    let kmd_address = "http://localhost:7833";
7    let kmd_token = "contents-of-kmd.token";
8
9    let algod_client = AlgodClient::new(algod_address, algod_token);
10    let kmd_client = KmdClient::new(kmd_address, kmd_token);
11
12    println!(
13        "Algod versions: {:?}",
14        algod_client.versions().unwrap().versions
15    );
16    println!(
17        "Kmd versions: {:?}",
18        kmd_client.versions().unwrap().versions
19    );
20}
More examples
Hide additional examples
examples/kmd_client.rs (line 9)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let create_wallet_response = kmd_client.create_wallet(
12        "testwallet",
13        "testpassword",
14        "sqlite",
15        MasterDerivationKey([0; 32]),
16    )?;
17    let wallet_id = create_wallet_response.wallet.id;
18
19    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
20    let wallet_handle_token = init_response.wallet_handle_token;
21
22    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
23    println!("Generated address: {}", gen_response.address);
24
25    Ok(())
26}
examples/wallet_restore.rs (line 9)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let backup_phrase = "fire enlist diesel stamp nuclear chunk student stumble call snow flock brush example slab guide choice option recall south kangaroo hundred matrix school above zero";
12    let key_bytes = mnemonic::to_key(backup_phrase)?;
13    let mdk = MasterDerivationKey(key_bytes);
14
15    let create_wallet_response =
16        kmd_client.create_wallet("testwallet", "testpassword", "sqlite", mdk)?;
17    let wallet = create_wallet_response.wallet;
18
19    println!("Created wallet {} with ID: {}", wallet.name, wallet.id);
20
21    Ok(())
22}
examples/wallet_backup.rs (line 9)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let list_response = kmd_client.list_wallets()?;
12
13    let wallet_id = match list_response
14        .wallets
15        .into_iter()
16        .find(|wallet| wallet.name == "testwallet")
17    {
18        Some(wallet) => wallet.id,
19        None => return Err("Wallet not found".into()),
20    };
21
22    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
23    let wallet_handle_token = init_response.wallet_handle_token;
24
25    let export_response =
26        kmd_client.export_master_derivation_key(&wallet_handle_token, "testpassword")?;
27    let mdk = export_response.master_derivation_key;
28
29    // String representation of the mdk, keep in safe place and don't share it
30    let string_to_save = mnemonic::from_key(&mdk.0)?;
31
32    println!("Backup phrase: {}", string_to_save);
33
34    Ok(())
35}
examples/sign_submit_transaction.rs (line 12)
6fn main() -> Result<(), Box<dyn Error>> {
7    let kmd_address = "http://localhost:7833";
8    let kmd_token = "contents-of-kmd.token";
9    let algod_address = "http://localhost:8080";
10    let algod_token = "contents-of-algod.token";
11
12    let kmd_client = KmdClient::new(kmd_address, kmd_token);
13    let algod_client = AlgodClient::new(algod_address, algod_token);
14
15    let list_response = kmd_client.list_wallets()?;
16
17    let wallet_id = match list_response
18        .wallets
19        .into_iter()
20        .find(|wallet| wallet.name == "testwallet")
21    {
22        Some(wallet) => wallet.id,
23        None => return Err("Wallet not found".into()),
24    };
25
26    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
27    let wallet_handle_token = init_response.wallet_handle_token;
28
29    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
30    let from_address = Address::from_string(&gen_response.address)?;
31
32    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
33    let to_address = Address::from_string(&gen_response.address)?;
34
35    let transaction_params = algod_client.transaction_params()?;
36
37    let genesis_id = transaction_params.genesis_id;
38    let genesis_hash = transaction_params.genesis_hash;
39
40    let base = BaseTransaction {
41        sender: from_address,
42        first_valid: transaction_params.last_round,
43        last_valid: transaction_params.last_round + 1000,
44        note: Vec::new(),
45        genesis_id,
46        genesis_hash,
47    };
48
49    let payment = Payment {
50        amount: MicroAlgos(200_000),
51        receiver: to_address,
52        close_remainder_to: None,
53    };
54
55    let transaction = Transaction::new(base, MicroAlgos(1000), TransactionType::Payment(payment))?;
56
57    let sign_response =
58        kmd_client.sign_transaction(&wallet_handle_token, "testpassword", &transaction)?;
59
60    println!(
61        "kmd made signed transaction with {} bytes",
62        sign_response.signed_transaction.len()
63    );
64
65    // Broadcast the transaction to the network
66    // Note this transaction will get rejected because the accounts do not have any tokens
67    let send_response = algod_client.raw_transaction(&sign_response.signed_transaction)?;
68
69    println!("Transaction ID: {}", send_response.tx_id);
70
71    Ok(())
72}
Source

pub fn versions(&self) -> Result<VersionsResponse, Error>

Retrieves the current version

Examples found in repository?
examples/quickstart.rs (line 18)
3fn main() {
4    let algod_address = "http://localhost:8080";
5    let algod_token = "contents-of-algod.token";
6    let kmd_address = "http://localhost:7833";
7    let kmd_token = "contents-of-kmd.token";
8
9    let algod_client = AlgodClient::new(algod_address, algod_token);
10    let kmd_client = KmdClient::new(kmd_address, kmd_token);
11
12    println!(
13        "Algod versions: {:?}",
14        algod_client.versions().unwrap().versions
15    );
16    println!(
17        "Kmd versions: {:?}",
18        kmd_client.versions().unwrap().versions
19    );
20}
Source

pub fn list_wallets(&self) -> Result<ListWalletsResponse, Error>

List all of the wallets that kmd is aware of

Examples found in repository?
examples/wallet_backup.rs (line 11)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let list_response = kmd_client.list_wallets()?;
12
13    let wallet_id = match list_response
14        .wallets
15        .into_iter()
16        .find(|wallet| wallet.name == "testwallet")
17    {
18        Some(wallet) => wallet.id,
19        None => return Err("Wallet not found".into()),
20    };
21
22    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
23    let wallet_handle_token = init_response.wallet_handle_token;
24
25    let export_response =
26        kmd_client.export_master_derivation_key(&wallet_handle_token, "testpassword")?;
27    let mdk = export_response.master_derivation_key;
28
29    // String representation of the mdk, keep in safe place and don't share it
30    let string_to_save = mnemonic::from_key(&mdk.0)?;
31
32    println!("Backup phrase: {}", string_to_save);
33
34    Ok(())
35}
More examples
Hide additional examples
examples/sign_submit_transaction.rs (line 15)
6fn main() -> Result<(), Box<dyn Error>> {
7    let kmd_address = "http://localhost:7833";
8    let kmd_token = "contents-of-kmd.token";
9    let algod_address = "http://localhost:8080";
10    let algod_token = "contents-of-algod.token";
11
12    let kmd_client = KmdClient::new(kmd_address, kmd_token);
13    let algod_client = AlgodClient::new(algod_address, algod_token);
14
15    let list_response = kmd_client.list_wallets()?;
16
17    let wallet_id = match list_response
18        .wallets
19        .into_iter()
20        .find(|wallet| wallet.name == "testwallet")
21    {
22        Some(wallet) => wallet.id,
23        None => return Err("Wallet not found".into()),
24    };
25
26    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
27    let wallet_handle_token = init_response.wallet_handle_token;
28
29    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
30    let from_address = Address::from_string(&gen_response.address)?;
31
32    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
33    let to_address = Address::from_string(&gen_response.address)?;
34
35    let transaction_params = algod_client.transaction_params()?;
36
37    let genesis_id = transaction_params.genesis_id;
38    let genesis_hash = transaction_params.genesis_hash;
39
40    let base = BaseTransaction {
41        sender: from_address,
42        first_valid: transaction_params.last_round,
43        last_valid: transaction_params.last_round + 1000,
44        note: Vec::new(),
45        genesis_id,
46        genesis_hash,
47    };
48
49    let payment = Payment {
50        amount: MicroAlgos(200_000),
51        receiver: to_address,
52        close_remainder_to: None,
53    };
54
55    let transaction = Transaction::new(base, MicroAlgos(1000), TransactionType::Payment(payment))?;
56
57    let sign_response =
58        kmd_client.sign_transaction(&wallet_handle_token, "testpassword", &transaction)?;
59
60    println!(
61        "kmd made signed transaction with {} bytes",
62        sign_response.signed_transaction.len()
63    );
64
65    // Broadcast the transaction to the network
66    // Note this transaction will get rejected because the accounts do not have any tokens
67    let send_response = algod_client.raw_transaction(&sign_response.signed_transaction)?;
68
69    println!("Transaction ID: {}", send_response.tx_id);
70
71    Ok(())
72}
Source

pub fn create_wallet( &self, wallet_name: &str, wallet_password: &str, wallet_driver_name: &str, master_derivation_key: MasterDerivationKey, ) -> Result<CreateWalletResponse, Error>

Creates a wallet

Examples found in repository?
examples/kmd_client.rs (lines 11-16)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let create_wallet_response = kmd_client.create_wallet(
12        "testwallet",
13        "testpassword",
14        "sqlite",
15        MasterDerivationKey([0; 32]),
16    )?;
17    let wallet_id = create_wallet_response.wallet.id;
18
19    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
20    let wallet_handle_token = init_response.wallet_handle_token;
21
22    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
23    println!("Generated address: {}", gen_response.address);
24
25    Ok(())
26}
More examples
Hide additional examples
examples/wallet_restore.rs (line 16)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let backup_phrase = "fire enlist diesel stamp nuclear chunk student stumble call snow flock brush example slab guide choice option recall south kangaroo hundred matrix school above zero";
12    let key_bytes = mnemonic::to_key(backup_phrase)?;
13    let mdk = MasterDerivationKey(key_bytes);
14
15    let create_wallet_response =
16        kmd_client.create_wallet("testwallet", "testpassword", "sqlite", mdk)?;
17    let wallet = create_wallet_response.wallet;
18
19    println!("Created wallet {} with ID: {}", wallet.name, wallet.id);
20
21    Ok(())
22}
Source

pub fn init_wallet_handle( &self, wallet_id: &str, wallet_password: &str, ) -> Result<InitWalletHandleResponse, Error>

Unlock the wallet and return a wallet token that can be used for subsequent operations

These tokens expire periodically and must be renewed. You can see how much time remains until expiration with get_wallet and renew it with renew_wallet_handle. When you’re done, you can invalidate the token with release_wallet_handle

Examples found in repository?
examples/kmd_client.rs (line 19)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let create_wallet_response = kmd_client.create_wallet(
12        "testwallet",
13        "testpassword",
14        "sqlite",
15        MasterDerivationKey([0; 32]),
16    )?;
17    let wallet_id = create_wallet_response.wallet.id;
18
19    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
20    let wallet_handle_token = init_response.wallet_handle_token;
21
22    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
23    println!("Generated address: {}", gen_response.address);
24
25    Ok(())
26}
More examples
Hide additional examples
examples/wallet_backup.rs (line 22)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let list_response = kmd_client.list_wallets()?;
12
13    let wallet_id = match list_response
14        .wallets
15        .into_iter()
16        .find(|wallet| wallet.name == "testwallet")
17    {
18        Some(wallet) => wallet.id,
19        None => return Err("Wallet not found".into()),
20    };
21
22    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
23    let wallet_handle_token = init_response.wallet_handle_token;
24
25    let export_response =
26        kmd_client.export_master_derivation_key(&wallet_handle_token, "testpassword")?;
27    let mdk = export_response.master_derivation_key;
28
29    // String representation of the mdk, keep in safe place and don't share it
30    let string_to_save = mnemonic::from_key(&mdk.0)?;
31
32    println!("Backup phrase: {}", string_to_save);
33
34    Ok(())
35}
examples/sign_submit_transaction.rs (line 26)
6fn main() -> Result<(), Box<dyn Error>> {
7    let kmd_address = "http://localhost:7833";
8    let kmd_token = "contents-of-kmd.token";
9    let algod_address = "http://localhost:8080";
10    let algod_token = "contents-of-algod.token";
11
12    let kmd_client = KmdClient::new(kmd_address, kmd_token);
13    let algod_client = AlgodClient::new(algod_address, algod_token);
14
15    let list_response = kmd_client.list_wallets()?;
16
17    let wallet_id = match list_response
18        .wallets
19        .into_iter()
20        .find(|wallet| wallet.name == "testwallet")
21    {
22        Some(wallet) => wallet.id,
23        None => return Err("Wallet not found".into()),
24    };
25
26    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
27    let wallet_handle_token = init_response.wallet_handle_token;
28
29    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
30    let from_address = Address::from_string(&gen_response.address)?;
31
32    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
33    let to_address = Address::from_string(&gen_response.address)?;
34
35    let transaction_params = algod_client.transaction_params()?;
36
37    let genesis_id = transaction_params.genesis_id;
38    let genesis_hash = transaction_params.genesis_hash;
39
40    let base = BaseTransaction {
41        sender: from_address,
42        first_valid: transaction_params.last_round,
43        last_valid: transaction_params.last_round + 1000,
44        note: Vec::new(),
45        genesis_id,
46        genesis_hash,
47    };
48
49    let payment = Payment {
50        amount: MicroAlgos(200_000),
51        receiver: to_address,
52        close_remainder_to: None,
53    };
54
55    let transaction = Transaction::new(base, MicroAlgos(1000), TransactionType::Payment(payment))?;
56
57    let sign_response =
58        kmd_client.sign_transaction(&wallet_handle_token, "testpassword", &transaction)?;
59
60    println!(
61        "kmd made signed transaction with {} bytes",
62        sign_response.signed_transaction.len()
63    );
64
65    // Broadcast the transaction to the network
66    // Note this transaction will get rejected because the accounts do not have any tokens
67    let send_response = algod_client.raw_transaction(&sign_response.signed_transaction)?;
68
69    println!("Transaction ID: {}", send_response.tx_id);
70
71    Ok(())
72}
Source

pub fn release_wallet_handle( &self, wallet_handle: &str, ) -> Result<ReleaseWalletHandleResponse, Error>

Release a wallet handle token

Source

pub fn renew_wallet_handle( &self, wallet_handle: &str, ) -> Result<RenewWalletHandleResponse, Error>

Renew a wallet handle token

Source

pub fn rename_wallet( &self, wallet_id: &str, wallet_password: &str, new_name: &str, ) -> Result<RenameWalletResponse, Error>

Rename a wallet

Source

pub fn get_wallet( &self, wallet_handle: &str, ) -> Result<GetWalletResponse, Error>

Get wallet info

Source

pub fn export_master_derivation_key( &self, wallet_handle: &str, wallet_password: &str, ) -> Result<ExportMasterDerivationKeyResponse, Error>

Export the master derivation key from a wallet

Examples found in repository?
examples/wallet_backup.rs (line 26)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let list_response = kmd_client.list_wallets()?;
12
13    let wallet_id = match list_response
14        .wallets
15        .into_iter()
16        .find(|wallet| wallet.name == "testwallet")
17    {
18        Some(wallet) => wallet.id,
19        None => return Err("Wallet not found".into()),
20    };
21
22    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
23    let wallet_handle_token = init_response.wallet_handle_token;
24
25    let export_response =
26        kmd_client.export_master_derivation_key(&wallet_handle_token, "testpassword")?;
27    let mdk = export_response.master_derivation_key;
28
29    // String representation of the mdk, keep in safe place and don't share it
30    let string_to_save = mnemonic::from_key(&mdk.0)?;
31
32    println!("Backup phrase: {}", string_to_save);
33
34    Ok(())
35}
Source

pub fn import_key( &self, wallet_handle: &str, private_key: [u8; 32], ) -> Result<ImportKeyResponse, Error>

Import an externally generated key into the wallet

Source

pub fn export_key( &self, wallet_handle: &str, wallet_password: &str, address: &str, ) -> Result<ExportKeyResponse, Error>

Export the Ed25519 seed associated with the passed address

Note the first 32 bytes of the returned value is the seed, the second 32 bytes is the public key

Source

pub fn generate_key( &self, wallet_handle: &str, ) -> Result<GenerateKeyResponse, Error>

Generates a key and adds it to the wallet, returning the public key

Examples found in repository?
examples/kmd_client.rs (line 22)
5fn main() -> Result<(), Box<dyn Error>> {
6    let kmd_address = "http://localhost:8080";
7    let kmd_token = "contents-of-kmd.token";
8
9    let kmd_client = KmdClient::new(kmd_address, kmd_token);
10
11    let create_wallet_response = kmd_client.create_wallet(
12        "testwallet",
13        "testpassword",
14        "sqlite",
15        MasterDerivationKey([0; 32]),
16    )?;
17    let wallet_id = create_wallet_response.wallet.id;
18
19    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
20    let wallet_handle_token = init_response.wallet_handle_token;
21
22    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
23    println!("Generated address: {}", gen_response.address);
24
25    Ok(())
26}
More examples
Hide additional examples
examples/sign_submit_transaction.rs (line 29)
6fn main() -> Result<(), Box<dyn Error>> {
7    let kmd_address = "http://localhost:7833";
8    let kmd_token = "contents-of-kmd.token";
9    let algod_address = "http://localhost:8080";
10    let algod_token = "contents-of-algod.token";
11
12    let kmd_client = KmdClient::new(kmd_address, kmd_token);
13    let algod_client = AlgodClient::new(algod_address, algod_token);
14
15    let list_response = kmd_client.list_wallets()?;
16
17    let wallet_id = match list_response
18        .wallets
19        .into_iter()
20        .find(|wallet| wallet.name == "testwallet")
21    {
22        Some(wallet) => wallet.id,
23        None => return Err("Wallet not found".into()),
24    };
25
26    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
27    let wallet_handle_token = init_response.wallet_handle_token;
28
29    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
30    let from_address = Address::from_string(&gen_response.address)?;
31
32    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
33    let to_address = Address::from_string(&gen_response.address)?;
34
35    let transaction_params = algod_client.transaction_params()?;
36
37    let genesis_id = transaction_params.genesis_id;
38    let genesis_hash = transaction_params.genesis_hash;
39
40    let base = BaseTransaction {
41        sender: from_address,
42        first_valid: transaction_params.last_round,
43        last_valid: transaction_params.last_round + 1000,
44        note: Vec::new(),
45        genesis_id,
46        genesis_hash,
47    };
48
49    let payment = Payment {
50        amount: MicroAlgos(200_000),
51        receiver: to_address,
52        close_remainder_to: None,
53    };
54
55    let transaction = Transaction::new(base, MicroAlgos(1000), TransactionType::Payment(payment))?;
56
57    let sign_response =
58        kmd_client.sign_transaction(&wallet_handle_token, "testpassword", &transaction)?;
59
60    println!(
61        "kmd made signed transaction with {} bytes",
62        sign_response.signed_transaction.len()
63    );
64
65    // Broadcast the transaction to the network
66    // Note this transaction will get rejected because the accounts do not have any tokens
67    let send_response = algod_client.raw_transaction(&sign_response.signed_transaction)?;
68
69    println!("Transaction ID: {}", send_response.tx_id);
70
71    Ok(())
72}
Source

pub fn delete_key( &self, wallet_handle: &str, wallet_password: &str, address: &str, ) -> Result<DeleteKeyResponse, Error>

Deletes the key from the wallet

Source

pub fn list_keys(&self, wallet_handle: &str) -> Result<ListKeysResponse, Error>

List all of the public keys in the wallet

Source

pub fn sign_transaction( &self, wallet_handle: &str, wallet_password: &str, transaction: &Transaction, ) -> Result<SignTransactionResponse, Error>

Sign a transaction

Examples found in repository?
examples/sign_submit_transaction.rs (line 58)
6fn main() -> Result<(), Box<dyn Error>> {
7    let kmd_address = "http://localhost:7833";
8    let kmd_token = "contents-of-kmd.token";
9    let algod_address = "http://localhost:8080";
10    let algod_token = "contents-of-algod.token";
11
12    let kmd_client = KmdClient::new(kmd_address, kmd_token);
13    let algod_client = AlgodClient::new(algod_address, algod_token);
14
15    let list_response = kmd_client.list_wallets()?;
16
17    let wallet_id = match list_response
18        .wallets
19        .into_iter()
20        .find(|wallet| wallet.name == "testwallet")
21    {
22        Some(wallet) => wallet.id,
23        None => return Err("Wallet not found".into()),
24    };
25
26    let init_response = kmd_client.init_wallet_handle(&wallet_id, "testpassword")?;
27    let wallet_handle_token = init_response.wallet_handle_token;
28
29    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
30    let from_address = Address::from_string(&gen_response.address)?;
31
32    let gen_response = kmd_client.generate_key(&wallet_handle_token)?;
33    let to_address = Address::from_string(&gen_response.address)?;
34
35    let transaction_params = algod_client.transaction_params()?;
36
37    let genesis_id = transaction_params.genesis_id;
38    let genesis_hash = transaction_params.genesis_hash;
39
40    let base = BaseTransaction {
41        sender: from_address,
42        first_valid: transaction_params.last_round,
43        last_valid: transaction_params.last_round + 1000,
44        note: Vec::new(),
45        genesis_id,
46        genesis_hash,
47    };
48
49    let payment = Payment {
50        amount: MicroAlgos(200_000),
51        receiver: to_address,
52        close_remainder_to: None,
53    };
54
55    let transaction = Transaction::new(base, MicroAlgos(1000), TransactionType::Payment(payment))?;
56
57    let sign_response =
58        kmd_client.sign_transaction(&wallet_handle_token, "testpassword", &transaction)?;
59
60    println!(
61        "kmd made signed transaction with {} bytes",
62        sign_response.signed_transaction.len()
63    );
64
65    // Broadcast the transaction to the network
66    // Note this transaction will get rejected because the accounts do not have any tokens
67    let send_response = algod_client.raw_transaction(&sign_response.signed_transaction)?;
68
69    println!("Transaction ID: {}", send_response.tx_id);
70
71    Ok(())
72}
Source

pub fn list_multisig( &self, wallet_handle: &str, ) -> Result<ListMultisigResponse, Error>

Lists all of the multisig accounts whose preimages this wallet stores

Source

pub fn import_multisig( &self, wallet_handle: &str, version: u8, threshold: u8, pks: &[Ed25519PublicKey], ) -> Result<ImportMultisigResponse, Error>

Import a multisig account

Source

pub fn export_multisig( &self, wallet_handle: &str, address: &str, ) -> Result<ExportMultisigResponse, Error>

Export multisig address metadata

Source

pub fn delete_multisig( &self, wallet_handle: &str, wallet_password: &str, address: &str, ) -> Result<DeleteMultisigResponse, Error>

Delete a multisig from the wallet

Source

pub fn sign_multisig_transaction( &self, wallet_handle: &str, wallet_password: &str, transaction: &Transaction, public_key: Ed25519PublicKey, partial_multisig: Option<MultisigSignature>, ) -> Result<SignMultisigTransactionResponse, Error>

Start a multisig signature or add a signature to a partially completed multisig signature

Auto Trait Implementations§

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

Source§

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

Source§

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

Source§

fn vzip(self) -> V

Source§

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