File tree 1 file changed +25
-2
lines changed
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,17 @@ package action
8
8
9
9
import (
10
10
"encoding/hex"
11
+ "fmt"
12
+ "math/big"
13
+
14
+ "github.com/spf13/cobra"
15
+ "go.uber.org/zap"
11
16
12
17
"github.com/iotexproject/iotex-core/action"
18
+ "github.com/iotexproject/iotex-core/cli/ioctl/cmd/account"
13
19
"github.com/iotexproject/iotex-core/cli/ioctl/cmd/alias"
14
20
"github.com/iotexproject/iotex-core/cli/ioctl/util"
15
21
"github.com/iotexproject/iotex-core/pkg/log"
16
- "github.com/spf13/cobra"
17
- "go.uber.org/zap"
18
22
)
19
23
20
24
// actionTransferCmd represents the action transfer command
@@ -63,6 +67,25 @@ var actionTransferCmd = &cobra.Command{
63
67
log .L ().Error ("failed to make a Transfer instance" , zap .Error (err ))
64
68
return err
65
69
}
70
+ address , err := alias .Address (sender )
71
+ if err != nil {
72
+ return err
73
+ }
74
+ accountMeta , err := account .GetAccountMeta (address )
75
+ if err != nil {
76
+ return err
77
+ }
78
+ balance , ok := big .NewInt (0 ).SetString (accountMeta .Balance , 10 )
79
+ if ! ok {
80
+ return fmt .Errorf ("failed to convert balance into big int" )
81
+ }
82
+ cost , err := tx .Cost ()
83
+ if err != nil {
84
+ return err
85
+ }
86
+ if balance .Cmp (cost ) < 0 {
87
+ return fmt .Errorf ("balance is not enough" )
88
+ }
66
89
return sendAction (
67
90
(& action.EnvelopeBuilder {}).
68
91
SetNonce (nonce ).
You can’t perform that action at this time.
0 commit comments