You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/rust/descriptors/src/main.rs
+15-18Lines changed: 15 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -5,29 +5,26 @@ use bdk_wallet::bitcoin::Network;
5
5
use bdk_wallet::template::{Bip86,DescriptorTemplate};
6
6
use bdk_wallet::KeychainKind;
7
7
8
-
// The codeblocks in https://bookofbdk.com pull their code from these examples. Since we do not want an indent on the
9
-
// codeblocks on the website, we also remove the indents here.
10
-
11
8
fnmain(){
12
-
// --8<-- [start:main]
13
-
letmut seed:[u8;32] = [0u8;32];
14
-
rand::thread_rng().fill_bytes(&mut seed);
9
+
// --8<-- [start:main]
10
+
letmut seed:[u8;32] = [0u8;32];
11
+
rand::thread_rng().fill_bytes(&mut seed);
15
12
16
-
let network:Network = Network::Signet;
17
-
let xprv:Xpriv = Xpriv::new_master(network,&seed).unwrap();
18
-
println!("Generated Master Private Key:\n{}\nWarning: be very careful with private keys when using MainNet! We are logging these values for convenience only because this is an example on SigNet.\n", xprv);
13
+
let network:Network = Network::Signet;
14
+
let xprv:Xpriv = Xpriv::new_master(network,&seed).unwrap();
15
+
println!("Generated Master Private Key:\n{}\nWarning: be very careful with private keys when using MainNet! We are logging these values for convenience only because this is an example on SigNet.\n", xprv);
let mnemonic = Mnemonic::parse(recovery_phrase).expect("Invalid seed! Be sure to replace the value of RECOVERY_PHRASE with your own 12 word seed phrase.");
16
-
let seed = mnemonic.to_seed("");
17
-
let xprv = Xpriv::new_master(Network::Signet,&seed).expect("Failed to create master key");
let mnemonic = Mnemonic::parse(recovery_phrase).expect("Invalid seed! Be sure to replace the value of RECOVERY_PHRASE with your own 12 word seed phrase.");
13
+
let seed = mnemonic.to_seed("");
14
+
let xprv = Xpriv::new_master(Network::Signet,&seed).expect("Failed to create master key");
18
15
19
-
println!("# Master Private Key\n{xprv}\nWarning: be very careful with seeds and private keys when using MainNet! We are logging these values for convenience and demonstration purposes only.\n");
16
+
println!("# Master Private Key\n{xprv}\nWarning: be very careful with seeds and private keys when using MainNet! We are logging these values for convenience and demonstration purposes only.\n");
Copy file name to clipboardExpand all lines: examples/rust/starter-example/src/main.rs
+83-86Lines changed: 83 additions & 86 deletions
Original file line number
Diff line number
Diff line change
@@ -17,96 +17,93 @@ const STOP_GAP: usize = 20;
17
17
constPARALLEL_REQUESTS:usize = 1;
18
18
constDB_PATH:&str = "starter.sqlite3";
19
19
20
-
// The codeblocks in https://bookofbdk.com pull their code from these examples. Since we do not want an indent on the
21
-
// codeblocks on the website, we also remove the indents here.
22
-
23
20
#[allow(deprecated)]
24
21
fnmain(){
25
22
println!("\nWelcome to the Book of BDK Starter Example Wallet!");
26
-
// --8<-- [start:descriptors]
27
-
let descriptor:&str = "tr([12071a7c/86'/1'/0']tpubDCaLkqfh67Qr7ZuRrUNrCYQ54sMjHfsJ4yQSGb3aBr1yqt3yXpamRBUwnGSnyNnxQYu7rqeBiPfw3mjBcFNX4ky2vhjj9bDrGstkfUbLB9T/0/*)#z3x5097m";
28
-
let change_descriptor:&str = "tr([12071a7c/86'/1'/0']tpubDCaLkqfh67Qr7ZuRrUNrCYQ54sMjHfsJ4yQSGb3aBr1yqt3yXpamRBUwnGSnyNnxQYu7rqeBiPfw3mjBcFNX4ky2vhjj9bDrGstkfUbLB9T/1/*)#n9r4jswr";
29
-
// --8<-- [end:descriptors]
30
-
31
-
// --8<-- [start:wallet]
32
-
// Initiate the connection to the database
33
-
letmut conn = Connection::open(DB_PATH).expect("Can't open database");
let descriptor:&str = "tr([12071a7c/86'/1'/0']tpubDCaLkqfh67Qr7ZuRrUNrCYQ54sMjHfsJ4yQSGb3aBr1yqt3yXpamRBUwnGSnyNnxQYu7rqeBiPfw3mjBcFNX4ky2vhjj9bDrGstkfUbLB9T/0/*)#z3x5097m";
25
+
let change_descriptor:&str = "tr([12071a7c/86'/1'/0']tpubDCaLkqfh67Qr7ZuRrUNrCYQ54sMjHfsJ4yQSGb3aBr1yqt3yXpamRBUwnGSnyNnxQYu7rqeBiPfw3mjBcFNX4ky2vhjj9bDrGstkfUbLB9T/1/*)#n9r4jswr";
26
+
// --8<-- [end:descriptors]
27
+
28
+
// --8<-- [start:wallet]
29
+
// Initiate the connection to the database
30
+
letmut conn = Connection::open(DB_PATH).expect("Can't open database");
0 commit comments