1+ // SPDX-License-Identifier: CC0-1.0
2+ //! This is not an example and will surely panic if executed, the purpose of this is using the
3+ //! compiled binary with tools like `cargo bloat` that cannot work with libraries.
4+ //!
5+ //! Ideal properties:
6+ //!
7+ //! * Call all the library API surface.
8+ //! * Depend on user input so that functions are not stripped out on the base of static input.
9+ //! * Use results so that calls are not stripped out.
10+ //!
11+
12+ use std:: str:: FromStr ;
13+ use miniscript:: { DefiniteDescriptorKey , Descriptor , DescriptorPublicKey , MiniscriptKey } ;
14+ use secp256k1:: Secp256k1 ;
15+ fn main ( ) {
16+ let empty = "" . to_string ( ) ;
17+ let mut args = std:: env:: args ( ) . collect :: < Vec < _ > > ( ) ;
18+ let i = args. pop ( ) . unwrap_or ( empty) ;
19+
20+ let d = Descriptor :: < DescriptorPublicKey > :: from_str ( & i) . unwrap ( ) ;
21+ use_descriptor ( d. clone ( ) ) ;
22+ use_descriptor ( Descriptor :: < DefiniteDescriptorKey > :: from_str ( & i) . unwrap ( ) ) ;
23+ use_descriptor ( Descriptor :: < bitcoin:: PublicKey > :: from_str ( & i) . unwrap ( ) ) ;
24+ use_descriptor ( Descriptor :: < String > :: from_str ( & i) . unwrap ( ) ) ;
25+
26+ let a = d. at_derivation_index ( 0 ) . unwrap ( ) . address ( bitcoin:: Network :: Bitcoin ) . unwrap ( ) ;
27+ println ! ( "{}" , a) ;
28+
29+ let secp = Secp256k1 :: new ( ) ;
30+ let ( d, m) = Descriptor :: parse_descriptor ( & secp, & i) . unwrap ( ) ;
31+ use_descriptor ( d) ;
32+ println ! ( "{:?}" , m) ;
33+ }
34+
35+ fn use_descriptor < K : MiniscriptKey > ( d : Descriptor < K > ) {
36+ println ! ( "{}" , d) ;
37+ println ! ( "{:?}" , d) ;
38+ println ! ( "{:?}" , d. desc_type( ) ) ;
39+ println ! ( "{:?}" , d. sanity_check( ) ) ;
40+ }
0 commit comments