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

Function ScriptNumSerialize

logic/lscript/lscript_test.go:55–82  ·  view source on GitHub ↗
(n int64)

Source from the content-addressed store, hash-verified

53}
54
55func ScriptNumSerialize(n int64) []byte {
56 if n == 0 {
57 return []byte{}
58 }
59 var res []byte
60 neg := false
61 if n < 0 {
62 neg = true
63 n = -n
64 }
65
66 for n > 0 {
67 res = append(res, byte(n&0xff))
68 n >>= 8
69 }
70
71 if res[len(res)-1]&0x80 != 0 {
72 if neg {
73 res = append(res, 0x80)
74 } else {
75 res = append(res, 0)
76 }
77 } else if neg {
78 res[len(res)-1] |= 0x80
79 }
80
81 return res
82}
83
84func appendData(res, w []byte) []byte {
85 if len(w) < opcodes.OP_PUSHDATA1 {

Callers 1

parseScriptFromFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected