From c2a28d5dfd7a0580332ee8091604147183abeadd Mon Sep 17 00:00:00 2001 From: ZenGround0 Date: Thu, 6 Feb 2020 22:59:42 -0500 Subject: [PATCH] Added standard (un)marshalBinary methods --- address.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/address.go b/address.go index 177fbb7..1af464d 100644 --- a/address.go +++ b/address.go @@ -355,6 +355,19 @@ func hash(ingest []byte, cfg *blake2b.Config) []byte { return hasher.Sum(nil) } +func (a Address) MarshalBinary() ([]byte, error) { + return a.Bytes(), nil +} + +func (a *Address) UnmarshalBinary(b []byte) error { + newAddr, err := NewFromBytes(b) + if err != nil { + return err + } + *a = newAddr + return nil +} + func (a Address) MarshalCBOR(w io.Writer) error { if a == Undef { return fmt.Errorf("cannot marshal undefined address")