fix: allow empty public keys when setting signatures (#19106)
This commit is contained in:
parent
8f39bfb4e4
commit
e621eb6b1b
@ -49,3 +49,5 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* [#18817](https://github.com/cosmos/cosmos-sdk/pull/18817) SigVerification, GasConsumption, IncreaseSequence ante decorators have all been joined into one SigVerification decorator. Gas consumption during TX validation flow has reduced.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#19106](https://github.com/cosmos/cosmos-sdk/pull/19106) Allow empty public keys when setting signatures. Public keys aren't needed for every transaction.
|
||||
|
||||
@ -352,11 +352,17 @@ func (w *wrapper) SetSignatures(signatures ...signing.SignatureV2) error {
|
||||
rawSigs := make([][]byte, n)
|
||||
|
||||
for i, sig := range signatures {
|
||||
var modeInfo *tx.ModeInfo
|
||||
var (
|
||||
modeInfo *tx.ModeInfo
|
||||
pubKey *codectypes.Any
|
||||
err error
|
||||
)
|
||||
modeInfo, rawSigs[i] = SignatureDataToModeInfoAndSig(sig.Data)
|
||||
pubKey, err := codectypes.NewAnyWithValue(sig.PubKey)
|
||||
if err != nil {
|
||||
return err
|
||||
if sig.PubKey != nil {
|
||||
pubKey, err = codectypes.NewAnyWithValue(sig.PubKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
signerInfos[i] = &tx.SignerInfo{
|
||||
PublicKey: pubKey,
|
||||
|
||||
@ -127,6 +127,20 @@ func TestTxBuilder(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestSetSignaturesNoPublicKey(t *testing.T) {
|
||||
_, pubkey, _ := testdata.KeyTestPubAddr()
|
||||
txBuilder := newBuilder(nil)
|
||||
sig2 := signing.SignatureV2{
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
|
||||
Signature: legacy.Cdc.MustMarshal(pubkey),
|
||||
},
|
||||
Sequence: 1,
|
||||
}
|
||||
err := txBuilder.SetSignatures(sig2)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestBuilderValidateBasic(t *testing.T) {
|
||||
// keys and addresses
|
||||
_, pubKey1, addr1 := testdata.KeyTestPubAddr()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user