improve cli insufficient funds error messages

This commit is contained in:
Jack May
2021-03-02 11:13:41 -08:00
committed by Michael Vines
parent 00f2b039b4
commit b20bf8ebb0
3 changed files with 25 additions and 14 deletions

View File

@@ -107,15 +107,22 @@ where
return Err(CliError::InsufficientFundsForSpendAndFee(
lamports_to_sol(spend),
lamports_to_sol(fee),
*from_pubkey,
));
}
} else {
if from_balance < spend {
return Err(CliError::InsufficientFundsForSpend(lamports_to_sol(spend)));
return Err(CliError::InsufficientFundsForSpend(
lamports_to_sol(spend),
*from_pubkey,
));
}
if !check_account_for_balance_with_commitment(rpc_client, fee_pubkey, fee, commitment)?
{
return Err(CliError::InsufficientFundsForFee(lamports_to_sol(fee)));
return Err(CliError::InsufficientFundsForFee(
lamports_to_sol(fee),
*fee_pubkey,
));
}
}
Ok((message, spend))