OSDN Git Service

versoin1.1.9 (#594)
[bytom/vapor.git] / cmd / utxomerge / main.go
1 package main
2
3 import (
4         log "github.com/sirupsen/logrus"
5         "github.com/spf13/cobra"
6         "github.com/tendermint/tmlibs/cli"
7
8         "github.com/bytom/vapor/toolbar/mergeutxo"
9 )
10
11 var RootCmd = &cobra.Command{
12         Use:   "utxomerge",
13         Short: "merge utxo.",
14         RunE:  runReward,
15 }
16
17 var (
18         hostPort, accountID, password, address string
19         amount                                 uint64
20 )
21
22 func init() {
23         RootCmd.Flags().StringVar(&hostPort, "host_port", "http://127.0.0.1:9889", "The url for the node. Default:http://127.0.0.1:9889")
24         RootCmd.Flags().StringVar(&accountID, "account_id", "", "The accountID of utxo needs to be merged")
25         RootCmd.Flags().StringVar(&password, "password", "", "Password of the account")
26         RootCmd.Flags().StringVar(&address, "address", "", "The received address after merging utxo")
27         RootCmd.Flags().Uint64Var(&amount, "amount", 0, "Total amount of merged utxo")
28 }
29
30 func runReward(cmd *cobra.Command, args []string) error {
31         log.Info("This tool belongs to an open-source project, we can not guarantee this tool is bug-free. Please check the code before using, developers will not be responsible for any asset loss due to bug!")
32         txIDs, err := mergeutxo.MergeUTXO(hostPort, accountID, password, address, amount)
33         if err != nil {
34                 log.Fatal(err)
35         }
36
37         log.Info("Merge utxo successfully. txID: ", txIDs)
38
39         return nil
40 }
41
42 func main() {
43         cmd := cli.PrepareBaseCmd(RootCmd, "merge_utxo", "./")
44         cmd.Execute()
45 }