MCPcopy Create free account
hub / github.com/copernet/copernicus / GetSigOpCount

Method GetSigOpCount

model/script/script.go:663–692  ·  view source on GitHub ↗
(flags uint32, accurate bool)

Source from the content-addressed store, hash-verified

661}
662
663func (s *Script) GetSigOpCount(flags uint32, accurate bool) int {
664 n := 0
665 var lastOpcode byte
666 for _, e := range s.ParsedOpCodes {
667 opcode := e.OpValue
668
669 switch opcode {
670 case opcodes.OP_CHECKSIG:
671 fallthrough
672 case opcodes.OP_CHECKSIGVERIFY:
673 n++
674 case opcodes.OP_CHECKDATASIG:
675 fallthrough
676 case opcodes.OP_CHECKDATASIGVERIFY:
677 if flags&ScriptEnableCheckDataSig != 0 {
678 n++
679 }
680 case opcodes.OP_CHECKMULTISIG:
681 fallthrough
682 case opcodes.OP_CHECKMULTISIGVERIFY:
683 if accurate && lastOpcode >= opcodes.OP_1 && lastOpcode <= opcodes.OP_16 {
684 n += DecodeOPN(lastOpcode)
685 } else {
686 n += MaxPubKeysPerMultiSig
687 }
688 }
689 lastOpcode = opcode
690 }
691 return n
692}
693
694func (s *Script) GetPubKeyP2SHSigOpCount(flags uint32, scriptSig *Script) int {
695 if flags&ScriptVerifyP2SH == 0 || !s.IsPayToScriptHash() {

Calls 1

DecodeOPNFunction · 0.85