From ef66ac57b6fb0a07c3d62567e472133245d1d9e6 Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Mon, 30 Dec 2024 18:58:11 -0600 Subject: [PATCH] fix: custom CBOR marshaling for UtxoId --- protocol/localstatequery/queries.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/protocol/localstatequery/queries.go b/protocol/localstatequery/queries.go index b05c8a50..b31fc6e1 100644 --- a/protocol/localstatequery/queries.go +++ b/protocol/localstatequery/queries.go @@ -529,6 +529,23 @@ func (u *UtxoId) UnmarshalCBOR(data []byte) error { return nil } +func (u *UtxoId) MarshalCBOR() ([]byte, error) { + var tmpData []any + if u.DatumHash == ledger.NewBlake2b256(nil) { + tmpData = []any{ + u.Hash, + u.Idx, + } + } else { + tmpData = []any{ + u.Hash, + u.Idx, + u.DatumHash, + } + } + return cbor.Encode(tmpData) +} + // TODO /* result [{* utxo => value }]