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)
| 108 | // not be modified if pushing the opcodes would cause the script to exceed the |
| 109 | // maximum allowed script engine size. |
| 110 | func (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. |