Only transaction that has the correct sequence can broadcast successfully.
So for #1, the error means the sequence number of this transaction is not match the sequence of the sender account.
For #2, the node uses the public key of the sender account to verify the signature. When verification failed, the node responds to this error. So you can decode the signature to verify that signerInfos (X Y Z) and signedDoc in the signature must match with the info when you sign.
To get sequence of sender account, you can call LCD (REST) or RPC.
Example (Aura Serenity Network):
{
"account": {
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "aura1hctj3tpmucmuv02umf9252enjedkce7mml69k8",
"pub_key": {
"@type": "/cosmos.crypto.secp256k1.PubKey",
"key": "AnoOQm4UTbzswwES5Mo+/LHFbT9653fDecq4Rrc+2jnA"
},
"account_number": "20755",
"sequence": "27"
}
}
- RPC:
aurad q account aura1hctj3tpmucmuv02umf9252enjedkce7mml69k8 --node https://rpc.serenity.aura.network:443
'@type': /cosmos.auth.v1beta1.BaseAccount
account_number: "20755"
address: aura1hctj3tpmucmuv02umf9252enjedkce7mml69k8
pub_key:
'@type': /cosmos.crypto.secp256k1.PubKey
key: AnoOQm4UTbzswwES5Mo+/LHFbT9653fDecq4Rrc+2jnA
sequence: "27"