Browse Source

Add helper methods for nil checks in structs

pull/1782/head
Ethan Frey 8 years ago
parent
commit
b6a2c5949f
3 changed files with 12 additions and 0 deletions
  1. +4
    -0
      priv_key.go
  2. +4
    -0
      pub_key.go
  3. +4
    -0
      signature.go

+ 4
- 0
priv_key.go View File

@ -53,6 +53,10 @@ func (p *PrivKeyS) UnmarshalJSON(data []byte) (err error) {
return
}
func (p PrivKeyS) Empty() bool {
return p.PrivKey == nil
}
func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error) {
err = wire.ReadBinaryBytes(privKeyBytes, &privKey)
return


+ 4
- 0
pub_key.go View File

@ -55,6 +55,10 @@ func (p *PubKeyS) UnmarshalJSON(data []byte) (err error) {
return
}
func (p PubKeyS) Empty() bool {
return p.PubKey == nil
}
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) {
err = wire.ReadBinaryBytes(pubKeyBytes, &pubKey)
return


+ 4
- 0
signature.go View File

@ -51,6 +51,10 @@ func (p *SignatureS) UnmarshalJSON(data []byte) (err error) {
return
}
func (p SignatureS) Empty() bool {
return p.Signature == nil
}
func SignatureFromBytes(sigBytes []byte) (sig Signature, err error) {
err = wire.ReadBinaryBytes(sigBytes, &sig)
return


Loading…
Cancel
Save