First tests of go-data encoding

This commit is contained in:
Ethan Frey
2017-02-22 23:43:26 +01:00
parent e6d35ee641
commit 1bc1947e3f
3 changed files with 78 additions and 65 deletions

View File

@ -91,7 +91,7 @@ func (p *SignatureEd25519) UnmarshalJSON(enc []byte) error {
//-------------------------------------
// Implements Signature
type SignatureSecp256k1 data.Bytes
type SignatureSecp256k1 []byte
func (sig SignatureSecp256k1) Bytes() []byte {
return wire.BinaryBytes(struct{ Signature }{sig})
@ -108,3 +108,10 @@ func (sig SignatureSecp256k1) Equals(other Signature) bool {
return false
}
}
func (p SignatureSecp256k1) MarshalJSON() ([]byte, error) {
return data.Encoder.Marshal(p)
}
func (p *SignatureSecp256k1) UnmarshalJSON(enc []byte) error {
return data.Encoder.Unmarshal((*[]byte)(p), enc)
}