diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index 7cf3596f342..d64c927e652 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -287,11 +287,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 + any *codectypes.Any + err error + ) modeInfo, rawSigs[i] = SignatureDataToModeInfoAndSig(sig.Data) - any, err := codectypes.NewAnyWithValue(sig.PubKey) - if err != nil { - return err + if sig.PubKey != nil { + any, err = codectypes.NewAnyWithValue(sig.PubKey) + if err != nil { + return err + } } signerInfos[i] = &tx.SignerInfo{ PublicKey: any, diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index f7122dd3921..b4c1556e5c3 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -123,6 +123,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()