Fix to support BigInt for '--value' of 'rpc sendtx transfer' CLI command
@@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "strconv"
"strings"
"time"
@@ -459,9 +460,21 @@ func NewSendTxCmd(parentCmd *cobra.Command, parentVc *viper.Viper) *cobra.Comman
Short: "Coin Transfer Transaction",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
- val, err := cmd.Flags().GetInt64("value")
- if err != nil {
+ var value jsonrpc.HexInt
+ valStr := cmd.Flag("value").Value.String()
+ if valInt64, err := strconv.ParseInt(valStr, 0, 64);err == nil {
+ value = jsonrpc.HexInt(common.FormatInt(valInt64))
+ }else{
+ if strings.HasPrefix(valStr, "0x") {
+ valStr = valStr[2:]
+ }
+ if b, err := hex.DecodeString(valStr); err != nil {
return err
+ }else{
+ var valHexInt common.HexInt
+ valHexInt.SetBytes(b)
+ value = jsonrpc.HexInt(valHexInt.String())
+ }
}
stepLimit := vc.GetInt64("step_limit")
nid, err := common.ParseInt(vc.GetString("nid"), 64)
@@ -473,7 +486,7 @@ func NewSendTxCmd(parentCmd *cobra.Command, parentVc *viper.Viper) *cobra.Comman
Version: jsonrpc.HexInt(common.FormatInt(jsonrpc.APIVersion3)),
FromAddress: jsonrpc.Address(rpcWallet.Address().String()),
ToAddress: jsonrpc.Address(cmd.Flag("to").Value.String()),
- Value: jsonrpc.HexInt(common.FormatInt(val)),
+ Value: value,
StepLimit: jsonrpc.HexInt(common.FormatInt(stepLimit)),
NetworkID: jsonrpc.HexInt(common.FormatInt(nid)),
//Nonce: "",
@@ -498,7 +511,7 @@ func NewSendTxCmd(parentCmd *cobra.Command, parentVc *viper.Viper) *cobra.Comman
rootCmd.AddCommand(transferCmd)
transferFlags := transferCmd.Flags()
transferFlags.String("to", "", "ToAddress")
- transferFlags.Int64("value", 0, "Value")
+ transferFlags.String("value", "", "Value")
transferFlags.String("message", "", "Message")
MarkAnnotationRequired(transferFlags, "to", "value")
