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 when the process fails due to insufficient funds since #20640. The fee return arg is set only at the end of the process, when the transaction is successfully created. 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.