diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc9d67dc4fe..eeb4d6657bfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### 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. + ## [v0.50.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.3) - 2023-01-15 ### Features diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index 4d13c11e876f..628c9618fcd5 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -340,11 +340,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, diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index 3ea3ae0c3b42..2fb88905beb2 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -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()