Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signature verification failed; please verify account number and chain-id: unauthorized #14789

Closed
TheArchitect123 opened this issue Jan 26, 2023 · 5 comments

Comments

@TheArchitect123
Copy link

TheArchitect123 commented Jan 26, 2023

I'm trying to broadcast a transaction via the api
/cosmos/tx/v1beta1/txs.

I'm serialising the entire transaction as a protobuf, and the simulation api works fine.
If I broadcast a transaction via /cosmos/tx/v1beta1/txs/simulate, I get the following response:


{
  "gas_info": {
    "gas_wanted": "50000000",
    "gas_used": "56369"
  },
  "result": {
    "data": "Ch4KHC9jb3Ntb3MuYmFuay52MWJldGExLk1zZ1NlbmQ=",
    "log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp\"},{\"key\":\"amount\",\"value\":\"100uluna\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v\"},{\"key\":\"amount\",\"value\":\"100uluna\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.bank.v1beta1.MsgSend\"},{\"key\":\"sender\",\"value\":\"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v\"},{\"key\":\"module\",\"value\":\"bank\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp\"},{\"key\":\"sender\",\"value\":\"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v\"},{\"key\":\"amount\",\"value\":\"100uluna\"}]}]}]",
    "events": [
      {
        "type": "message",
        "attributes": [
          {
            "key": "YWN0aW9u",
            "value": "L2Nvc21vcy5iYW5rLnYxYmV0YTEuTXNnU2VuZA==",
            "index": false
          }
        ]
      },
      {
        "type": "coin_spent",
        "attributes": [
          {
            "key": "c3BlbmRlcg==",
            "value": "dGVycmExeDQ2cnFheTRkM2Nzc3E4Z3h4dnF6OHh0Nm53bHo0dGQyMGszOHY=",
            "index": false
          },
          {
            "key": "YW1vdW50",
            "value": "MTAwdWx1bmE=",
            "index": false
          }
        ]
      },
      {
        "type": "coin_received",
        "attributes": [
          {
            "key": "cmVjZWl2ZXI=",
            "value": "dGVycmExN2xtYW02emd1YXpzNXE1dTZ6NW1teDc2dWo2M2dsZG5zZTJwZHA=",
            "index": false
          },
          {
            "key": "YW1vdW50",
            "value": "MTAwdWx1bmE=",
            "index": false
          }
        ]
      },
      {
        "type": "transfer",
        "attributes": [
          {
            "key": "cmVjaXBpZW50",
            "value": "dGVycmExN2xtYW02emd1YXpzNXE1dTZ6NW1teDc2dWo2M2dsZG5zZTJwZHA=",
            "index": false
          },
          {
            "key": "c2VuZGVy",
            "value": "dGVycmExeDQ2cnFheTRkM2Nzc3E4Z3h4dnF6OHh0Nm53bHo0dGQyMGszOHY=",
            "index": false
          },
          {
            "key": "YW1vdW50",
            "value": "MTAwdWx1bmE=",
            "index": false
          }
        ]
      },
      {
        "type": "message",
        "attributes": [
          {
            "key": "c2VuZGVy",
            "value": "dGVycmExeDQ2cnFheTRkM2Nzc3E4Z3h4dnF6OHh0Nm53bHo0dGQyMGszOHY=",
            "index": false
          }
        ]
      },
      {
        "type": "message",
        "attributes": [
          {
            "key": "bW9kdWxl",
            "value": "YmFuaw==",
            "index": false
          }
        ]
      }
    ]
  }
}

However if I try to upload the transaction via "/cosmos/tx/v1beta1/txs." I get the following response.
"signature verification failed; please verify account number and chain-id: unauthorized"

Here's a Json of the model that I pass the Cosmos Rest Backend.

{
   "body":{
      "messages":[
         {
            "typeUrl":"/cosmos.bank.v1beta1.MsgSend",
            "value":"Cix0ZXJyYTF4NDZycWF5NGQzY3NzcThneHh2cXo4eHQ2bndsejR0ZDIwazM4dhIsdGVycmExN2xtYW02emd1YXpzNXE1dTZ6NW1teDc2dWo2M2dsZG5zZTJwZHAaDAoFdWx1bmESAzEwMA=="
         }
      ],
      "memo":"",
      "timeoutHeight":0,
      "extensionOptions":[
         
      ],
      "nonCriticalExtensionOptions":[
         
      ]
   },
   "authInfo":{
      "signerInfos":[
         {
            "publicKey":{
               "typeUrl":"/cosmos.crypto.secp256k1.PubKey",
               "value":"CiECOzOoUkNEBhsSNky6IP4KGrNtRIar9FG7fOvRHqIkHls="
            },
            "modeInfo":{
               "single":{
                  "mode":"SignModeDirect"
               }
            },
            "sequence":278
         }
      ],
      "fee":{
         "amounts":[
            {
               "denom":"uluna",
               "amount":"1756317"
            }
         ],
         "gasLimit":62005,
         "payer":"",
         "granter":"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v"
      }
   },
   "signatures":[
      "CmBNRVVDSVFDeHFIQ3ZjbkJJcmVrb01BRVlMMWg4dkVuYUJ1Qyt6bWZmalVYVmJFRXFEZ0lnRHRYM3NvaThQbS9RTjU2cmtVcDBTM2R4U21RUVR1eXBEcUJMWXYwejRncz0SRgofL2Nvc21vcy5jcnlwdG8uc2VjcDI1NmsxLlB1YktleRIjCiECOzOoUkNEBhsSNky6IP4KGrNtRIar9FG7fOvRHqIkHlsZAAAAAADgY0AhAAAAAABgcUA="
   ]
}

Then I upload the entire transaction as the following JSON object:

{
   "mode":"BROADCAST_MODE_BLOCK",
   "tx_bytes":"Co0BCooBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEmoKLHRlcnJhMXg0NnJxYXk0ZDNjc3NxOGd4eHZxejh4dDZud2x6NHRkMjBrMzh2Eix0ZXJyYTE3bG1hbTZ6Z3VhenM1cTV1Nno1bW14NzZ1ajYzZ2xkbnNlMnBkcBoMCgV1bHVuYRIDMTAwEpkBClEKRgofL2Nvc21vcy5jcnlwdG8uc2VjcDI1NmsxLlB1YktleRIjCiECOzOoUkNEBhsSNky6IP4KGrNtRIar9FG7fOvRHqIkHlsSBAoCCAEYlgISRAoQCgV1bHVuYRIHMTc1NjMxNxC15AMiLHRlcnJhMXg0NnJxYXk0ZDNjc3NxOGd4eHZxejh4dDZud2x6NHRkMjBrMzh2GvwBQ21CTlJWVkRTVkZFVVc1RmMwRlhXREpPYkRVM1dYZ3paRWRrT1ZwWGFuSjBiMUJIYzNaclFsSk9ZVWw0TnpkUFJGZENRVWxuVjBWM2JTOU9lR1UxZFdwVE9EWjJVMll5TVdKemVWZ3pRbXRHYUc5bGRscGxSRVZUZDI5V2FEbGpPRDBTUmdvZkwyTnZjMjF2Y3k1amNubHdkRzh1YzJWamNESTFObXN4TGxCMVlrdGxlUklqQ2lFQ096T29Va05FQmhzU05reTZJUDRLR3JOdFJJYXI5Rkc3Zk92UkhxSWtIbHNaQUFBQUFBRGdZMEFoQUFBQUFBQmdjVUE9",
   "sequences":[
      "278"
   ],
   "fee_granter":"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v"
}

Version

v0.45.1

Steps to Reproduce

Simply protobuf serialise the transaction Tx Object, and pass it into the Json (final entry) above, and run a post on the api:
/cosmos/tx/v1beta1/txs.

Then you will get the message:
"signature verification failed; please verify account number and chain-id: unauthorized"

So I'm not sure what I'm doing wrong here.
I'm using ECDSA Signing to generate the signature with the private key, and running verification is successful.
The public/private keys look correct, and everything matches the data that cosmos looks like it requires for a successful broadcast.

So I'm not sure what's going on?

@TheArchitect123
Copy link
Author

Here's the JSON of the Proto before serialisation:

{
   "body":{
      "messages":[
         {
            "typeUrl":"/cosmos.bank.v1beta1.MsgSend",
            "value":"Cix0ZXJyYTF4NDZycWF5NGQzY3NzcThneHh2cXo4eHQ2bndsejR0ZDIwazM4dhIsdGVycmExN2xtYW02emd1YXpzNXE1dTZ6NW1teDc2dWo2M2dsZG5zZTJwZHAaDAoFdWx1bmESAzEwMA=="
         }
      ],
      "memo":"",
      "timeoutHeight":0,
      "extensionOptions":[
         
      ],
      "nonCriticalExtensionOptions":[
         
      ]
   },
   "authInfo":{
      "signerInfos":[
         {
            "publicKey":{
               "typeUrl":"/cosmos.crypto.secp256k1.PubKey",
               "value":"CiECOzOoUkNEBhsSNky6IP4KGrNtRIar9FG7fOvRHqIkHls="
            },
            "modeInfo":{
               "single":{
                  "mode":"SignModeDirect"
               }
            },
            "sequence":278
         }
      ],
      "fee":{
         "amounts":[
            {
               "denom":"uluna",
               "amount":"1736376"
            }
         ],
         "gasLimit":61301,
         "payer":"",
         "granter":"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v"
      }
   },
   "signatures":[
      {
         "signature":"MEQCICZRcyMmeHMAoHhLg7YKq/B2lroqFxZlBJzhndZ+ZxbEAiAdo0DdijBTXsCxp/JKTQeE11loKpG1BOwV6HgX7PJ9DQ==",
         "publicKey":{
            "typeUrl":"/cosmos.crypto.secp256k1.PubKey",
            "value":"CiECOzOoUkNEBhsSNky6IP4KGrNtRIar9FG7fOvRHqIkHls="
         },
         "accNumber":159.0,
         "sequence":278.0
      }
   ]
}

@fuluomin
Copy link

have you resolved it? I have the same question

@tac0turtle
Copy link
Member

hey how are you broadcasting the transaction. I use cli predominantly and it asks me for chain-id when i forget.

@fuluomin
Copy link

hey how are you broadcasting the transaction. I use cli predominantly and it asks me for chain-id when i forget.

I use c++ to send rpc request,it sometimes can be success,sometime the above problems occur

@TheArchitect123 TheArchitect123 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@ekkis
Copy link

ekkis commented May 8, 2024

I'm getting this error in trying to upload a contract in Secret Network, according to their guide: https://docs.scrt.network/secret-network-documentation/development/development-concepts/create-your-own-snip-20-token-on-secret-network

I'm guessing it's not a Secret issue but a Cosmos problem. this was closed but no resolution was posted. is there one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants