if force specified will not check insufficient fund

This commit is contained in:
Frank 2021-01-07 11:30:53 +08:00
parent fef5d65c0f
commit 9584c72026

View File

@ -148,18 +148,17 @@ var sendCmd = &cli.Command{
Params: params, Params: params,
} }
// Funds insufficient check if !cctx.Bool("force") {
fromBalance, err := api.WalletBalance(ctx, msg.From) // Funds insufficient check
if err != nil { fromBalance, err := api.WalletBalance(ctx, msg.From)
return err if err != nil {
} return err
totalCost := types.BigAdd(types.BigMul(msg.GasFeeCap, types.NewInt(uint64(msg.GasLimit))), msg.Value) }
totalCost := types.BigAdd(types.BigMul(msg.GasFeeCap, types.NewInt(uint64(msg.GasLimit))), msg.Value)
if fromBalance.LessThan(totalCost) { if fromBalance.LessThan(totalCost) {
fmt.Printf("From balance %s less than total cost %s\n", types.FIL(fromBalance), types.FIL(totalCost)) fmt.Printf("WARNING: 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")
return fmt.Errorf("--force must be specified for this action to have an effect; " +
"you have been warned")
} }
} }