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

Method AddOp

txscript/scriptbuilder.go:89–105  ·  view source on GitHub ↗

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

(opcode byte)

Source from the content-addressed store, hash-verified

87// be modified if pushing the opcode would cause the script to exceed the
88// maximum allowed script engine size.
89func (b *ScriptBuilder) AddOp(opcode byte) *ScriptBuilder {
90 if b.err != nil {
91 return b
92 }
93
94 // Pushes that would cause the script to exceed the largest allowed
95 // script size would result in a non-canonical script.
96 if len(b.script)+1 > MaxScriptSize {
97 str := fmt.Sprintf("adding an opcode would exceed the maximum "+
98 "allowed canonical script length of %d", MaxScriptSize)
99 b.err = ErrScriptNotCanonical(str)
100 return b
101 }
102
103 b.script = append(b.script, opcode)
104 return b
105}
106
107// AddOps pushes the passed opcodes to the end of the script. The script will
108// not be modified if pushing the opcodes would cause the script to exceed the

Callers 15

createCoinbaseTxFunction · 0.95
finalizeNonWitnessInputFunction · 0.95
OpReturnScriptFunction · 0.95
TestScriptBuilderAllocFunction · 0.95
TestScriptBuilderAddOpFunction · 0.95
TestExceedMaxScriptSizeFunction · 0.95
TestErroredScriptFunction · 0.95
parseShortFormFunction · 0.95
genComplexScriptFunction · 0.95
TestDebugEngineFunction · 0.95
processScriptFunction · 0.95

Calls 1

ErrScriptNotCanonicalTypeAlias · 0.85

Tested by 14

TestScriptBuilderAllocFunction · 0.76
TestScriptBuilderAddOpFunction · 0.76
TestExceedMaxScriptSizeFunction · 0.76
TestErroredScriptFunction · 0.76
parseShortFormFunction · 0.76
genComplexScriptFunction · 0.76
TestDebugEngineFunction · 0.76
createCSVOutputFunction · 0.64
spendCSVOutputFunction · 0.64
TestUseBlockHashFunction · 0.64