-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_functions.txt
77 lines (55 loc) · 3.41 KB
/
example_functions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
fn main() {
// let mut my_wallet = wallet::Wallet::new();
// Bip 84 test vector
// let mnemonic: Vec<String> = ["abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "abandon".to_owned(), "about".to_owned()].to_vec();
// let seed = my_wallet.seed_from_mnemonic(mnemonic, None);
// BIP 32 test vector 1
// let seed = "000102030405060708090a0b0c0d0e0f".to_owned();
// BIP 32 test vector 2
// let seed = "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542".to_owned();
// println!("\nSeed: {}", seed);
println!();
// println!("Chain m:");
// my_wallet.create_master_keys_from_seed(hex::decode(&seed).unwrap());
// my_wallet.get_keys_from_derivation_path("m/84'/0'/0'/0/0");
// my_wallet.get_keys_from_derivation_path("M/84/0/0/0/0");
// Bip 84 test vector
// let master_private_key = "1837c1be8e2995ec11cda2b066151be2cfb48adf9e47b151d46adab3a21cdf67".to_owned();
// let master_public_key = "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494".to_owned();
// let master_chain_code = "7923408dadd3c7b56eed15567707ae5e5dca089de972e07f3b860450e2a3b70e".to_owned();
// BIP 32 test vector 1
// let master_private_key = "e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35".to_owned();
// let master_public_key = "0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2".to_owned();
// let master_chain_code = "873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508".to_owned();
// BIP 32 test vector 2
// let master_private_key = "4b03d6fc340455b363f51020ad3ecca4f0850280cf436c70c727923f6db46c3e".to_owned();
// let master_public_key = "03cbcaa9c98c877a26977d00825c956a238e8dddfbd322cce4f74b0b5bd6ace4a7".to_owned();
// let master_chain_code = "60499f801b896d83179a4374aeb7822aaeaceaa0db1f85ee3e904c4defbd9689".to_owned();
// let master_private_key_bytes = hex::decode(&master_private_key).unwrap();
// let master_public_key_bytes = hex::decode(&master_public_key).unwrap();
// let master_chain_code_bytes = hex::decode(&master_chain_code).unwrap();
// =========== private parent key -> private child key derivation =================
println!();
// println!("Chain m/0:");
// my_wallet.master_keys.private_key = master_private_key;
// my_wallet.master_keys.public_key = master_public_key;
// my_wallet.master_keys.chain_code = master_chain_code;
// my_wallet.get_keys_from_derivation_path("m/0");
// =========== public parent key -> public child key derivation =================
println!();
// my_wallet.master_keys.private_key = master_private_key;
// my_wallet.master_keys.public_key = master_public_key;
// my_wallet.master_keys.chain_code = master_chain_code;
// // error because K -> K not defined for hardened keys
// println!("Chain M/0':");
// my_wallet.get_keys_from_derivation_path("M/0'");
// println!("Chain M/0:");
// my_wallet.get_keys_from_derivation_path("M/0");
// ===================== Bech32 addresses ==================================
// test_encode_bech32m_address(
// helpers::get_hash160("0313e8842189afb5316c3c1acfcca696a85ec3741d17767f953bc70394b3839365".to_owned()),
// 1u8,
// EncodingType::BECH32M
// );
// test_decode_bech32m_address();
}