@@ -121,12 +121,14 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
121
121
Descriptor :: Bare ( ..) => None ,
122
122
Descriptor :: Pk ( ..) => None ,
123
123
Descriptor :: Pkh ( ref pk) => Some ( bitcoin:: Address :: p2pkh ( & pk. to_public_key ( ) , network) ) ,
124
- Descriptor :: Wpkh ( ref pk) => {
125
- Some ( bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , network) )
126
- }
127
- Descriptor :: ShWpkh ( ref pk) => {
128
- Some ( bitcoin:: Address :: p2shwpkh ( & pk. to_public_key ( ) , network) )
129
- }
124
+ Descriptor :: Wpkh ( ref pk) => Some (
125
+ bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , network)
126
+ . expect ( "wpkh descriptors have compressed keys" ) ,
127
+ ) ,
128
+ Descriptor :: ShWpkh ( ref pk) => Some (
129
+ bitcoin:: Address :: p2shwpkh ( & pk. to_public_key ( ) , network)
130
+ . expect ( "shwpkh descriptors have compressed keys" ) ,
131
+ ) ,
130
132
Descriptor :: Sh ( ref miniscript) => {
131
133
Some ( bitcoin:: Address :: p2sh ( & miniscript. encode ( ) , network) )
132
134
}
@@ -152,12 +154,14 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
152
154
addr. script_pubkey ( )
153
155
}
154
156
Descriptor :: Wpkh ( ref pk) => {
155
- let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin ) ;
157
+ let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin )
158
+ . expect ( "wpkh descriptors have compressed keys" ) ;
156
159
addr. script_pubkey ( )
157
160
}
158
161
Descriptor :: ShWpkh ( ref pk) => {
159
162
let addr =
160
- bitcoin:: Address :: p2shwpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin ) ;
163
+ bitcoin:: Address :: p2shwpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin )
164
+ . expect ( "shwpkh descriptors have compressed keys" ) ;
161
165
addr. script_pubkey ( )
162
166
}
163
167
Descriptor :: Sh ( ref miniscript) => miniscript. encode ( ) . to_p2sh ( ) ,
@@ -185,7 +189,8 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
185
189
Descriptor :: Wsh ( ..) | Descriptor :: Wpkh ( ..) => Script :: new ( ) ,
186
190
// segwit+p2sh
187
191
Descriptor :: ShWpkh ( ref pk) => {
188
- let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin ) ;
192
+ let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin )
193
+ . expect ( "wpkh descriptors have compressed keys" ) ;
189
194
let redeem_script = addr. script_pubkey ( ) ;
190
195
script:: Builder :: new ( )
191
196
. push_slice ( & redeem_script[ ..] )
@@ -211,7 +216,8 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
211
216
| Descriptor :: Pkh ( ..)
212
217
| Descriptor :: Wpkh ( ..) => self . script_pubkey ( ) ,
213
218
Descriptor :: ShWpkh ( ref pk) => {
214
- let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin ) ;
219
+ let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin )
220
+ . expect ( "shwpkh descriptors have compressed keys" ) ;
215
221
addr. script_pubkey ( )
216
222
}
217
223
Descriptor :: Sh ( ref d) => d. encode ( ) ,
@@ -292,7 +298,8 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
292
298
let mut sig_vec = sig. 0 . serialize_der ( ) . to_vec ( ) ;
293
299
sig_vec. push ( sig. 1 . as_u32 ( ) as u8 ) ;
294
300
let addr =
295
- bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin ) ;
301
+ bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin )
302
+ . expect ( "wpkh descriptors have compressed keys" ) ;
296
303
let redeem_script = addr. script_pubkey ( ) ;
297
304
298
305
txin. script_sig = script:: Builder :: new ( )
@@ -926,21 +933,21 @@ mod tests {
926
933
let descriptor = Descriptor :: < bitcoin:: PublicKey > :: from_str ( "wsh(after(1000))" ) . unwrap ( ) ;
927
934
let script = descriptor. witness_script ( ) ;
928
935
929
- let actual_instructions: Vec < _ > = script. iter ( false ) . collect ( ) ;
936
+ let actual_instructions: Vec < _ > = script. instructions ( ) . collect ( ) ;
930
937
let check = actual_instructions. last ( ) . unwrap ( ) ;
931
938
932
- assert_eq ! ( check, & Instruction :: Op ( OP_CLTV ) )
939
+ assert_eq ! ( check, & Ok ( Instruction :: Op ( OP_CLTV ) ) )
933
940
}
934
941
935
942
#[ test]
936
943
fn older_is_csv ( ) {
937
944
let descriptor = Descriptor :: < bitcoin:: PublicKey > :: from_str ( "wsh(older(1000))" ) . unwrap ( ) ;
938
945
let script = descriptor. witness_script ( ) ;
939
946
940
- let actual_instructions: Vec < _ > = script. iter ( false ) . collect ( ) ;
947
+ let actual_instructions: Vec < _ > = script. instructions ( ) . collect ( ) ;
941
948
let check = actual_instructions. last ( ) . unwrap ( ) ;
942
949
943
- assert_eq ! ( check, & Instruction :: Op ( OP_CSV ) )
950
+ assert_eq ! ( check, & Ok ( Instruction :: Op ( OP_CSV ) ) )
944
951
}
945
952
946
953
#[ test]
0 commit comments