Skip to content

Commit eedb336

Browse files
authored
fix: custom CBOR marshaling for UtxoId (#817)
1 parent 28cadd7 commit eedb336

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

protocol/localstatequery/queries.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,23 @@ func (u *UtxoId) UnmarshalCBOR(data []byte) error {
529529
return nil
530530
}
531531

532+
func (u *UtxoId) MarshalCBOR() ([]byte, error) {
533+
var tmpData []any
534+
if u.DatumHash == ledger.NewBlake2b256(nil) {
535+
tmpData = []any{
536+
u.Hash,
537+
u.Idx,
538+
}
539+
} else {
540+
tmpData = []any{
541+
u.Hash,
542+
u.Idx,
543+
u.DatumHash,
544+
}
545+
}
546+
return cbor.Encode(tmpData)
547+
}
548+
532549
// TODO
533550
/*
534551
result [{* utxo => value }]

0 commit comments

Comments
 (0)