mirror of
https://github.com/luxfi/utxo.git
synced 2026-10-30 15:13:57 +00:00
TxID is an ids.ID — [32]byte, bytes_fixed[32] on the wire — and the derived codec refuses a fixed array outright, so a reply holding one cannot cross the op-call plane at all. zap_gen.go is generated by zip.Codecs from the same layout the plane encodes against, so the bytes are the ones already spoken. go.sum recorded hashes for luxfi/vm v1.3.1 and luxfi/consensus v1.36.2 that no longer match what those tags serve, so nothing here built. The luxfi entries are re-recorded and vm moves to v1.3.14, which is what the node already runs.
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
// Code generated by zip; DO NOT EDIT.
|
|
|
|
package utxo
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
zap "github.com/zap-proto/go"
|
|
)
|
|
|
|
// ---- UTXOID ------------------------------------------------------------
|
|
|
|
const (
|
|
uTXOIDTxIDAt = 0
|
|
uTXOIDOutputIndexAt = 32
|
|
uTXOIDSymbolAt = 36
|
|
uTXOIDSize = 40
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*UTXOID)(nil)
|
|
|
|
// MarshalZAP writes UTXOID from constant offsets.
|
|
func (x *UTXOID) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(uTXOIDSize + 256)
|
|
ob := b.StartObject(uTXOIDSize)
|
|
ob.SetBytesFixed(uTXOIDTxIDAt, x.TxID[:])
|
|
ob.SetUint32(uTXOIDOutputIndexAt, uint32(x.OutputIndex))
|
|
ob.SetBool(uTXOIDSymbolAt, bool(x.Symbol))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads UTXOID out of the buffer that arrived.
|
|
func (x *UTXOID) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("UTXOID: %w", err)
|
|
}
|
|
o := m.Root()
|
|
copy(x.TxID[:], o.BytesFixed(uTXOIDTxIDAt, 32))
|
|
x.OutputIndex = uint32(o.Uint32(uTXOIDOutputIndexAt))
|
|
x.Symbol = bool(o.Bool(uTXOIDSymbolAt))
|
|
return nil
|
|
}
|