@@ -27,34 +27,39 @@ fn main() {
2727 let htlc_policy = Concrete :: < bitcoin:: PublicKey > :: from_str ( & format ! ( "or(10@and(sha256({secret_hash}),pk({redeem_identity})),1@and(older({expiry}),pk({refund_identity})))" ,
2828 secret_hash = "1111111111111111111111111111111111111111111111111111111111111111" ,
2929 redeem_identity = "022222222222222222222222222222222222222222222222222222222222222222" ,
30- refund_identity = "022222222222222222222222222222222222222222222222222222222222222222 " ,
30+ refund_identity = "020202020202020202020202020202020202020202020202020202020202020202 " ,
3131 expiry = "4444"
3232 ) ) . unwrap ( ) ;
3333
3434 let htlc_descriptor = Descriptor :: Wsh ( htlc_policy. compile ( ) . unwrap ( ) ) ;
3535
36+ // Check whether the descriptor is safe
37+ // This checks whether all spend paths are accessible in bitcoin network.
38+ // It maybe possible that some of the spend require more than 100 elements in Wsh scripts
39+ // Or they contain a combination of timelock and heightlock.
40+ assert ! ( htlc_descriptor. check_safety( ) . is_ok( ) ) ;
3641 assert_eq ! (
3742 format!( "{}" , htlc_descriptor) ,
38- "wsh(andor(pk(022222222222222222222222222222222222222222222222222222222222222222),sha256(1111111111111111111111111111111111111111111111111111111111111111),and_v(v:pkh(4377a5acd66dc5cb67148a24818d1e51fa183bd2 ),older(4444))))"
43+ "wsh(andor(pk(022222222222222222222222222222222222222222222222222222222222222222),sha256(1111111111111111111111111111111111111111111111111111111111111111),and_v(v:pkh(51814f108670aced2d77c1805ddd6634bc9d4731 ),older(4444))))"
3944 ) ;
4045
4146 assert_eq ! (
4247 format!( "{}" , htlc_descriptor. lift( ) . unwrap( ) ) ,
43- "or(and(pkh(4377a5acd66dc5cb67148a24818d1e51fa183bd2),pkh(4377a5acd66dc5cb67148a24818d1e51fa183bd2 ),older(4444)),sha256(1111111111111111111111111111111111111111111111111111111111111111))"
48+ "or(and(pkh(4377a5acd66dc5cb67148a24818d1e51fa183bd2),pkh(51814f108670aced2d77c1805ddd6634bc9d4731 ),older(4444)),sha256(1111111111111111111111111111111111111111111111111111111111111111))"
4449 ) ;
4550
4651 assert_eq ! (
4752 format!( "{:x}" , htlc_descriptor. script_pubkey( ) ) ,
48- "00203c0a59874cb570ff3093bcd67e846c967127c9e3fcd30f0a20857b504599e50a "
53+ "0020d853877af928a8d2a569c9c0ed14bd16f6a80ce9cccaf8a6150fd8f7f8867ae2 "
4954 ) ;
5055
5156 assert_eq ! (
5257 format!( "{:x}" , htlc_descriptor. witness_script( ) ) ,
53- "21022222222222222222222222222222222222222222222222222222222222222222ac6476a9144377a5acd66dc5cb67148a24818d1e51fa183bd288ad025c11b26782012088a82011111111111111111111111111111111111111111111111111111111111111118768 "
58+ "21022222222222222222222222222222222222222222222222222222222222222222ac6476a91451814f108670aced2d77c1805ddd6634bc9d473188ad025c11b26782012088a82011111111111111111111111111111111111111111111111111111111111111118768 "
5459 ) ;
5560
5661 assert_eq ! (
5762 format!( "{}" , htlc_descriptor. address( Network :: Bitcoin ) . unwrap( ) ) ,
58- "bc1q8s99np6vk4c07vynhnt8aprvjecj0j0rlnfs7z3qs4a4q3veu59q8x3k8x "
63+ "bc1qmpfcw7he9z5d9ftfe8qw699azmm2sr8fen903fs4plv007yx0t3qxfmqv5 "
5964 ) ;
6065}
0 commit comments