github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/auth/spec/03_messages.md (about)

     1  <!--
     2  order: 3
     3  -->
     4  
     5  # Messages
     6  
     7  TODO make this file conform to typical messages spec
     8  
     9  ## Handlers
    10  
    11  The auth module presently has no transaction handlers of its own, but does expose
    12  the special `AnteHandler`, used for performing basic validity checks on a transaction,
    13  such that it could be thrown out of the mempool. Note that the ante handler is called on
    14  `CheckTx`, but *also* on `DeliverTx`, as Tendermint proposers presently have the ability
    15  to include in their proposed block transactions which fail `CheckTx`.
    16  
    17  ### Ante Handler
    18  
    19  ```go
    20  anteHandler(ak AccountKeeper, fck FeeCollectionKeeper, tx sdk.Tx)
    21    if !tx.(StdTx)
    22      fail with "not a StdTx"
    23  
    24    if isCheckTx and tx.Fee < config.SubjectiveMinimumFee
    25      fail with "insufficient fee for mempool inclusion"
    26  
    27    if tx.ValidateBasic() != nil
    28      fail with "tx failed ValidateBasic"
    29  
    30    if tx.Fee > 0
    31      account = GetAccount(tx.GetSigners()[0])
    32      coins := acount.GetCoins()
    33      if coins < tx.Fee
    34        fail with "insufficient fee to pay for transaction"
    35      account.SetCoins(coins - tx.Fee)
    36      fck.AddCollectedFees(tx.Fee)
    37  
    38    for index, signature in tx.GetSignatures()
    39      account = GetAccount(tx.GetSigners()[index])
    40      bytesToSign := StdSignBytes(chainID, acc.GetAccountNumber(),
    41        acc.GetSequence(), tx.Fee, tx.Msgs, tx.Memo)
    42      if !signature.Verify(bytesToSign)
    43        fail with "invalid signature"
    44  
    45    return
    46  ```