@@ -123,7 +123,7 @@ pub(super) mod sigops {
123
123
All ,
124
124
} ,
125
125
script:: { self , Instruction } ,
126
- Transaction , TxOut , Witness ,
126
+ Transaction , TxIn , TxOut , Witness ,
127
127
} ;
128
128
use std:: collections:: HashMap ;
129
129
@@ -263,20 +263,23 @@ pub(super) mod sigops {
263
263
264
264
#[ inline]
265
265
fn count_with_prevout (
266
- prevout : & TxOut ,
267
- script_sig : & script:: Script ,
266
+ input : & TxIn ,
267
+ script_pubkey : & script:: Script ,
268
268
witness : & Witness ,
269
269
) -> usize {
270
270
let mut n = 0 ;
271
271
272
- let script = if prevout . script_pubkey . is_witness_program ( ) {
273
- prevout . script_pubkey . clone ( )
274
- } else if prevout . script_pubkey . is_p2sh ( )
275
- && is_push_only ( script_sig)
276
- && !script_sig. is_empty ( )
272
+ let script = if script_pubkey. is_witness_program ( ) {
273
+ script_pubkey. clone ( )
274
+ } else if script_pubkey. is_p2sh ( )
275
+ && is_push_only ( & input . script_sig )
276
+ && !input . script_sig . is_empty ( )
277
277
{
278
278
script:: Script :: from_byte_iter (
279
- last_pushdata ( script_sig) . unwrap ( ) . iter ( ) . map ( |v| Ok ( * v) ) ,
279
+ last_pushdata ( & input. script_sig )
280
+ . unwrap ( )
281
+ . iter ( )
282
+ . map ( |v| Ok ( * v) ) ,
280
283
)
281
284
. unwrap ( )
282
285
} else {
@@ -293,7 +296,31 @@ pub(super) mod sigops {
293
296
}
294
297
295
298
for ( input, prevout) in tx. input . iter ( ) . zip ( previous_outputs. iter ( ) ) {
296
- n += count_with_prevout ( prevout, & input. script_sig , & input. witness ) ;
299
+ #[ cfg( feature = "liquid" ) ]
300
+ let ( script_pubkey, witness) = {
301
+ let script_pubkey = if input. is_pegin {
302
+ if input. witness . pegin_witness . len ( ) < 4 {
303
+ continue ;
304
+ }
305
+ script:: Script :: from_byte_iter (
306
+ input. witness . pegin_witness [ 3 ] . iter ( ) . map ( |v| Ok ( * v) ) ,
307
+ )
308
+ . unwrap ( )
309
+ } else {
310
+ prevout. script_pubkey . clone ( )
311
+ } ;
312
+
313
+ ( script_pubkey, & input. witness )
314
+ } ;
315
+ #[ cfg( not( feature = "liquid" ) ) ]
316
+ let ( script_pubkey, witness) = { ( & prevout. script_pubkey , & input. witness ) } ;
317
+
318
+ n += count_with_prevout (
319
+ input,
320
+ #[ cfg_attr( not( feature = "liquid" ) , allow( clippy:: needless_borrow) ) ]
321
+ & script_pubkey,
322
+ witness,
323
+ ) ;
297
324
}
298
325
n
299
326
}
0 commit comments