During a talk with @theStack, it was noted that the AmountWithFeeExceedsBalance
error inside WalletModel::prepareTransaction
is never thrown.
This is because createTransaction
does not retrieve the fee if the process fails due to insufficient funds since #20640. The fee return argument is set only at the end of the process, when the transaction creation is successful. Therefore, if the transaction creation fails, the fee is not available inside WalletModel::prepareTransaction
to trigger the AmountWithFeeExceedsBalance
error.
This PR re-implements the feature inside createTransaction
and adds test coverage for it.