MCPcopy Create free account
hub / github.com/bitcoindevkit/bdk-cli / new

Method new

tests/integration.rs:106–148  ·  view source on GitHub ↗

Construct a new [`BdkCli`] struct

(
            network: &str,
            node_datadir: Option<PathBuf>,
            verbosity: bool,
            features: &[&str],
        )

Source from the content-addressed store, hash-verified

104 impl BdkCli {
105 /// Construct a new [`BdkCli`] struct
106 fn new(
107 network: &str,
108 node_datadir: Option<PathBuf>,
109 verbosity: bool,
110 features: &[&str],
111 ) -> Result<Self, IntTestError> {
112 // Build bdk-cli with given features
113 let mut feat = "--features=".to_string();
114 for item in features {
115 feat.push_str(item);
116 feat.push(',');
117 }
118 feat.pop(); // remove the last comma
119 let _build = Command::new("cargo").args(["build", &feat]).output()?;
120
121 let mut bdk_cli = Self {
122 target: "./target/debug/bdk-cli".to_string(),
123 network: network.to_string(),
124 verbosity,
125 recv_desc: None,
126 chang_desc: None,
127 node_datadir,
128 };
129
130 println!("BDK-CLI Config : {bdk_cli:#?}");
131 let bdk_master_key = bdk_cli.key_exec(&["generate"])?;
132 let bdk_xprv = get_value(&bdk_master_key, "xprv")?;
133
134 let bdk_recv_desc =
135 bdk_cli.key_exec(&["derive", "--path", "m/84h/1h/0h/0", "--xprv", &bdk_xprv])?;
136 let bdk_recv_desc = get_value(&bdk_recv_desc, "xprv")?;
137 let bdk_recv_desc = format!("wpkh({bdk_recv_desc})");
138
139 let bdk_chng_desc =
140 bdk_cli.key_exec(&["derive", "--path", "m/84h/1h/0h/1", "--xprv", &bdk_xprv])?;
141 let bdk_chng_desc = get_value(&bdk_chng_desc, "xprv")?;
142 let bdk_chng_desc = format!("wpkh({bdk_chng_desc})");
143
144 bdk_cli.recv_desc = Some(bdk_recv_desc);
145 bdk_cli.chang_desc = Some(bdk_chng_desc);
146
147 Ok(bdk_cli)
148 }
149
150 /// Execute bdk-cli wallet commands with given args
151 fn wallet_exec(&self, args: &[&str]) -> Result<Value, IntTestError> {

Callers

nothing calls this directly

Calls 2

get_valueFunction · 0.85
key_execMethod · 0.80

Tested by

no test coverage detected