improve cli insufficient funds error messages (#15648)

(cherry picked from commit b20bf8ebb0)

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2021-03-03 05:38:19 +00:00
committed by GitHub
parent 280437bad2
commit 7ae3b55dde
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))