Skip to content

Commit

Permalink
if force specified will not check insufficient fund
Browse files Browse the repository at this point in the history
  • Loading branch information
deaswang committed Jan 7, 2021
1 parent fef5d65 commit 9584c72
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions cli/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,17 @@ var sendCmd = &cli.Command{
Params: params,
}

// Funds insufficient check
fromBalance, err := api.WalletBalance(ctx, msg.From)
if err != nil {
return err
}
totalCost := types.BigAdd(types.BigMul(msg.GasFeeCap, types.NewInt(uint64(msg.GasLimit))), msg.Value)
if !cctx.Bool("force") {
// Funds insufficient check
fromBalance, err := api.WalletBalance(ctx, msg.From)
if err != nil {
return err
}
totalCost := types.BigAdd(types.BigMul(msg.GasFeeCap, types.NewInt(uint64(msg.GasLimit))), msg.Value)

if fromBalance.LessThan(totalCost) {
fmt.Printf("From balance %s less than total cost %s\n", types.FIL(fromBalance), types.FIL(totalCost))
if !cctx.Bool("force") {
return fmt.Errorf("--force must be specified for this action to have an effect; " +
"you have been warned")
if fromBalance.LessThan(totalCost) {
fmt.Printf("WARNING: From balance %s less than total cost %s\n", types.FIL(fromBalance), types.FIL(totalCost))
return fmt.Errorf("--force must be specified for this action to have an effect; you have been warned")
}
}

Expand Down

0 comments on commit 9584c72

Please sign in to comment.