From c121163635a0a36ddfa242c737e13dbab5edb587 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 19 Apr 2016 08:49:41 -0700 Subject: [PATCH] ReadSignature* --- signature.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/signature.go b/signature.go index e4921ccf7..40f269f34 100644 --- a/signature.go +++ b/signature.go @@ -40,6 +40,15 @@ func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 } func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) } +func ReadSignatureEd25519(bz []byte) (SignatureEd25519, error) { + sig := struct{ Signature }{} + err := wire.ReadBinaryBytes(bz, &sig) + if err != nil { + return SignatureEd25519{}, err + } + return sig.Signature.(SignatureEd25519), nil +} + //------------------------------------- // Implements Signature @@ -52,3 +61,12 @@ func (sig SignatureSecp256k1) Bytes() []byte { func (sig SignatureSecp256k1) IsZero() bool { return len(sig) == 0 } func (sig SignatureSecp256k1) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) } + +func ReadSignatureSecp256k1(bz []byte) (SignatureSecp256k1, error) { + sig := struct{ Signature }{} + err := wire.ReadBinaryBytes(bz, &sig) + if err != nil { + return nil, err + } + return sig.Signature.(SignatureSecp256k1), nil +}