88// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
99// You may not use this file except in accordance with one or both of these
1010// licenses.
11-
11+ #! [ allow ( unused ) ]
1212extern crate bdk_wallet;
13- extern crate bitcoin;
14- extern crate miniscript;
15- extern crate serde_json;
13+ // extern crate bitcoin;
14+ // extern crate miniscript;
15+ // extern crate serde_json;
1616
1717use std:: error:: Error ;
1818use std:: str:: FromStr ;
@@ -32,47 +32,52 @@ use bdk_wallet::{KeychainKind, Wallet};
3232/// This example demonstrates the interaction between a bdk wallet and miniscript policy.
3333#[ allow( clippy:: print_stdout) ]
3434fn main ( ) -> Result < ( ) , Box < dyn Error > > {
35- // We start with a miniscript policy string
36- let policy_str = "or(
37- 10@thresh(4,
38- pk(029ffbe722b147f3035c87cb1c60b9a5947dd49c774cc31e94773478711a929ac0),pk(025f05815e3a1a8a83bfbb03ce016c9a2ee31066b98f567f6227df1d76ec4bd143),pk(025625f41e4a065efc06d5019cbbd56fe8c07595af1231e7cbc03fafb87ebb71ec),pk(02a27c8b850a00f67da3499b60562673dcf5fdfb82b7e17652a7ac54416812aefd),pk(03e618ec5f384d6e19ca9ebdb8e2119e5bef978285076828ce054e55c4daf473e2)
39- ),1@and(
40- older(4209713),
41- thresh(2,
42- pk(03deae92101c790b12653231439f27b8897264125ecb2f46f48278603102573165),pk(033841045a531e1adf9910a6ec279589a90b3b8a904ee64ffd692bd08a8996c1aa),pk(02aebf2d10b040eb936a6f02f44ee82f8b34f5c1ccb20ff3949c2b28206b7c1068)
43- )
44- )
45- )"
46- . replace ( & [ ' ' , '\n' , '\t' ] [ ..] , "" ) ;
35+ // // We start with a miniscript policy string
36+ // let policy_str = "or(
37+ // 10@thresh(4,
38+ // pk(029ffbe722b147f3035c87cb1c60b9a5947dd49c774cc31e94773478711a929ac0),
39+ // pk(025f05815e3a1a8a83bfbb03ce016c9a2ee31066b98f567f6227df1d76ec4bd143),
40+ // pk(025625f41e4a065efc06d5019cbbd56fe8c07595af1231e7cbc03fafb87ebb71ec),
41+ // pk(02a27c8b850a00f67da3499b60562673dcf5fdfb82b7e17652a7ac54416812aefd),
42+ // pk(03e618ec5f384d6e19ca9ebdb8e2119e5bef978285076828ce054e55c4daf473e2) ),1@and(
43+ // older(4209713),
44+ // thresh(2,
45+ //
46+ // pk(03deae92101c790b12653231439f27b8897264125ecb2f46f48278603102573165),
47+ // pk(033841045a531e1adf9910a6ec279589a90b3b8a904ee64ffd692bd08a8996c1aa),
48+ // pk(02aebf2d10b040eb936a6f02f44ee82f8b34f5c1ccb20ff3949c2b28206b7c1068) )
49+ // )
50+ // )"
51+ // .replace(&[' ', '\n', '\t'][..], "");
4752
48- println ! ( "Compiling policy: \n {policy_str}" ) ;
53+ // println!("Compiling policy: \n{policy_str}");
4954
50- // Parse the string as a [`Concrete`] type miniscript policy.
51- let policy = Concrete :: < String > :: from_str ( & policy_str) ?;
55+ // // Parse the string as a [`Concrete`] type miniscript policy.
56+ // let policy = Concrete::<String>::from_str(&policy_str)?;
5257
53- // Create a `wsh` type descriptor from the policy.
54- // `policy.compile()` returns the resulting miniscript from the policy.
55- let descriptor = Descriptor :: new_wsh ( policy. compile ( ) ?) ?. to_string ( ) ;
58+ // // Create a `wsh` type descriptor from the policy.
59+ // // `policy.compile()` returns the resulting miniscript from the policy.
60+ // let descriptor = Descriptor::new_wsh(policy.compile()?)?.to_string();
5661
57- println ! ( "Compiled into Descriptor: \n {descriptor}" ) ;
62+ // println!("Compiled into Descriptor: \n{descriptor}");
5863
59- // Create a new wallet from descriptors
60- let mut wallet = Wallet :: create_single ( descriptor)
61- . network ( Network :: Regtest )
62- . create_wallet_no_persist ( ) ?;
64+ // // Create a new wallet from descriptors
65+ // let mut wallet = Wallet::create_single(descriptor)
66+ // .network(Network::Regtest)
67+ // .create_wallet_no_persist()?;
6368
64- println ! (
65- "First derived address from the descriptor: \n {}" ,
66- wallet. next_unused_address( KeychainKind :: External ) ,
67- ) ;
69+ // println!(
70+ // "First derived address from the descriptor: \n{}",
71+ // wallet.next_unused_address(KeychainKind::External),
72+ // );
6873
69- // BDK also has it's own `Policy` structure to represent the spending condition in a more
70- // human readable json format.
71- let spending_policy = wallet. policies ( KeychainKind :: External ) ?;
72- println ! (
73- "The BDK spending policy: \n {}" ,
74- serde_json:: to_string_pretty( & spending_policy) ?
75- ) ;
74+ // // BDK also has it's own `Policy` structure to represent the spending condition in a more
75+ // // human readable json format.
76+ // let spending_policy = wallet.policies(KeychainKind::External)?;
77+ // println!(
78+ // "The BDK spending policy: \n{}",
79+ // serde_json::to_string_pretty(&spending_policy)?
80+ // );
7681
7782 Ok ( ( ) )
7883}
0 commit comments