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

Method GetPubKeyP2SHSigOpCount

model/script/script.go:694–715  ·  view source on GitHub ↗
(flags uint32, scriptSig *Script)

Source from the content-addressed store, hash-verified

692}
693
694func (s *Script) GetPubKeyP2SHSigOpCount(flags uint32, scriptSig *Script) int {
695 if flags&ScriptVerifyP2SH == 0 || !s.IsPayToScriptHash() {
696 return s.GetSigOpCount(flags, true)
697 }
698
699 if scriptSig.badOpCode {
700 return 0
701 }
702
703 // This is a pay-to-script-hash scriptPubKey;
704 // get the last item that the scriptSig
705 // pushes onto the stack:
706 for _, e := range scriptSig.ParsedOpCodes {
707 if e.OpValue > opcodes.OP_16 {
708 return 0
709 }
710 }
711
712 lastOps := scriptSig.ParsedOpCodes[len(scriptSig.ParsedOpCodes)-1]
713 tempScript := NewScriptRaw(lastOps.Data)
714 return tempScript.GetSigOpCount(flags, true)
715}
716
717func EncodeOPN(n int) (int, error) {
718 if n < 0 || n > 16 {

Callers 1

getP2SHSigOpCountFunction · 0.80

Calls 3

IsPayToScriptHashMethod · 0.95
GetSigOpCountMethod · 0.95
NewScriptRawFunction · 0.85

Tested by

no test coverage detected