Exemplo n.º 1
0
// Append a PushData operation.
// notice the length of data is NOT encoded as a "stackInt"(stackItem representing a integer)
func (s *Script) AppendPushData(p []byte) {
	switch {
	case len(p) < int(OP_PUSHDATA1):
		s.AppendOp(Opcode(len(p)))
	case len(p) <= 0xff:
		s.AppendOp(OP_PUSHDATA1)
		s.AppendData([]byte{byte(len(p))})
	case len(p) <= 0xffff:
		s.AppendOp(OP_PUSHDATA2)
		s.AppendData(klib.Uint16ToBytes(uint16(len(p))))
	default:
		s.AppendOp(OP_PUSHDATA4)
		s.AppendData(klib.Uint32ToBytes(uint32(len(p))))
	}
	s.AppendData(p)
}
Exemplo n.º 2
0
func getKdbKey(h *klib.Hash256, i uint32) []byte {
	p := klib.Uint32ToBytes(i)
	return append(p, h[:]...)
}