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

Method convertRaw

model/script/script.go:284–303  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

282}
283
284func (s *Script) convertRaw() {
285 s.data = make([]byte, 0)
286 for _, e := range s.ParsedOpCodes {
287 s.data = append(s.data, e.OpValue)
288 if e.OpValue == opcodes.OP_PUSHDATA1 {
289 s.data = append(s.data, byte(e.Length))
290 } else if e.OpValue == opcodes.OP_PUSHDATA2 {
291 b := make([]byte, 2)
292 binary.LittleEndian.PutUint16(b, uint16(e.Length))
293 s.data = append(s.data, b...)
294 } else if e.OpValue == opcodes.OP_PUSHDATA4 {
295 b := make([]byte, 4)
296 binary.LittleEndian.PutUint32(b, uint32(e.Length))
297 s.data = append(s.data, b...)
298 }
299 if e.OpValue <= opcodes.OP_PUSHDATA4 && e.Length > 0 {
300 s.data = append(s.data, e.Data...)
301 }
302 }
303}
304
305func (s *Script) GetData() []byte {
306 return s.data

Callers 1

NewScriptOpsFunction · 0.95

Calls 2

PutUint16Method · 0.80
PutUint32Method · 0.80

Tested by

no test coverage detected