@@ -123,7 +123,7 @@ pub(super) mod sigops {
123123 All ,
124124 } ,
125125 script:: { self , Instruction } ,
126- Transaction , TxOut , Witness ,
126+ Transaction , TxIn , TxOut , Witness ,
127127 } ;
128128 use std:: collections:: HashMap ;
129129
@@ -263,20 +263,23 @@ pub(super) mod sigops {
263263
264264 #[ inline]
265265 fn count_with_prevout (
266- prevout : & TxOut ,
267- script_sig : & script:: Script ,
266+ input : & TxIn ,
267+ script_pubkey : & script:: Script ,
268268 witness : & Witness ,
269269 ) -> usize {
270270 let mut n = 0 ;
271271
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 ( )
277277 {
278278 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) ) ,
280283 )
281284 . unwrap ( )
282285 } else {
@@ -293,7 +296,31 @@ pub(super) mod sigops {
293296 }
294297
295298 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+ ) ;
297324 }
298325 n
299326 }
0 commit comments