Fix constructors

This commit is contained in:
Aleksandr Bezobchuk 2020-03-24 18:55:53 -04:00
parent ef29fef514
commit 486fa5b4b0
No known key found for this signature in database
GPG Key ID: 7DAC30FBD99879B0
2 changed files with 10 additions and 3 deletions

View File

@ -122,9 +122,11 @@ func (tx Transaction) GetSignatures() []sdk.Signature {
// SetSignatures sets the transaction's signatures. It will overwrite any
// existing signatures set.
func (tx *Transaction) SetSignatures(sdkSigs ...sdk.Signature) {
sigs := make([]auth.StdSignature, len(tx.Signatures))
sigs := make([]auth.StdSignature, len(sdkSigs))
for i, sig := range sdkSigs {
sigs[i] = auth.NewStdSignature(sig.GetPubKey(), sig.GetSignature())
if sig != nil {
sigs[i] = auth.NewStdSignature(sig.GetPubKey(), sig.GetSignature())
}
}
tx.Signatures = sigs

View File

@ -59,7 +59,12 @@ func (fee StdFee) GasPrices() sdk.DecCoins {
}
func NewStdSignature(pk crypto.PubKey, sig []byte) StdSignature {
return StdSignature{PubKey: pk.Bytes(), Signature: sig}
var pkBz []byte
if pk != nil {
pkBz = pk.Bytes()
}
return StdSignature{PubKey: pkBz, Signature: sig}
}
// GetSignature returns the raw signature bytes.