MCPcopy Create free account
hub / github.com/btcsuite/btcd / AddOps

Method AddOps

txscript/scriptbuilder.go:110–126  ·  view source on GitHub ↗

AddOps pushes the passed opcodes to the end of the script. The script will not be modified if pushing the opcodes would cause the script to exceed the maximum allowed script engine size.

(opcodes []byte)

Source from the content-addressed store, hash-verified

108// not be modified if pushing the opcodes would cause the script to exceed the
109// maximum allowed script engine size.
110func (b *ScriptBuilder) AddOps(opcodes []byte) *ScriptBuilder {
111 if b.err != nil {
112 return b
113 }
114
115 // Pushes that would cause the script to exceed the largest allowed
116 // script size would result in a non-canonical script.
117 if len(b.script)+len(opcodes) > MaxScriptSize {
118 str := fmt.Sprintf("adding opcodes would exceed the maximum "+
119 "allowed canonical script length of %d", MaxScriptSize)
120 b.err = ErrScriptNotCanonical(str)
121 return b
122 }
123
124 b.script = append(b.script, opcodes...)
125 return b
126}
127
128// canonicalDataSize returns the number of bytes the canonical encoding of the
129// data will take.

Callers 3

mergeScriptsFunction · 0.95
SignTxOutputFunction · 0.95
TestScriptBuilderAddOpFunction · 0.95

Calls 1

ErrScriptNotCanonicalTypeAlias · 0.85

Tested by 1

TestScriptBuilderAddOpFunction · 0.76