MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetSigOpCount

Method GetSigOpCount

test/functional/test_framework/script.py:666–684  ·  view source on GitHub ↗

Get the SigOp count. fAccurate - Accurately count CHECKMULTISIG, see BIP16 for details. Note that this is consensus-critical.

(self, fAccurate)

Source from the content-addressed store, hash-verified

664 return "CScript([%s])" % ', '.join(ops)
665
666 def GetSigOpCount(self, fAccurate):
667 """Get the SigOp count.
668
669 fAccurate - Accurately count CHECKMULTISIG, see BIP16 for details.
670
671 Note that this is consensus-critical.
672 """
673 n = 0
674 lastOpcode = OP_INVALIDOPCODE
675 for (opcode, data, sop_idx) in self.raw_iter():
676 if opcode in (OP_CHECKSIG, OP_CHECKSIGVERIFY):
677 n += 1
678 elif opcode in (OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY):
679 if fAccurate and (OP_1 <= lastOpcode <= OP_16):
680 n += opcode.decode_op_n()
681 else:
682 n += 20
683 lastOpcode = opcode
684 return n
685
686
687SIGHASH_DEFAULT = 0 # Taproot-only default, semantics same as SIGHASH_ALL

Callers 2

test_spendersMethod · 0.45
get_legacy_sigopcount_txFunction · 0.45

Calls 2

raw_iterMethod · 0.95
decode_op_nMethod · 0.45

Tested by 1

test_spendersMethod · 0.36