OSDN Git Service

rename get-raw-transaction to decode-raw-transaction
authoroysheng <oysheng@bytom.io>
Fri, 4 May 2018 05:43:59 +0000 (13:43 +0800)
committeroysheng <oysheng@bytom.io>
Fri, 4 May 2018 05:49:17 +0000 (13:49 +0800)
api/api.go
api/query.go
cmd/bytomcli/commands/bytomcli.go
cmd/bytomcli/commands/transaction.go

index fc20940..10d8bb6 100644 (file)
@@ -219,7 +219,7 @@ func (a *API) buildHandler() {
 
        m.Handle("/get-unconfirmed-transaction", jsonHandler(a.getUnconfirmedTx))
        m.Handle("/list-unconfirmed-transactions", jsonHandler(a.listUnconfirmedTxs))
-       m.Handle("/get-raw-transaction", jsonHandler(a.getRawTransaction))
+       m.Handle("/decode-raw-transaction", jsonHandler(a.decodeRawTransaction))
 
        m.Handle("/get-block-hash", jsonHandler(a.getBestBlockHash))
        m.Handle("/get-block-header", jsonHandler(a.getBlockHeader))
index 956ff63..0a566ac 100644 (file)
@@ -169,11 +169,11 @@ type RawTx struct {
        TimeRange uint64                   `json:"time_range"`
        Inputs    []*query.AnnotatedInput  `json:"inputs"`
        Outputs   []*query.AnnotatedOutput `json:"outputs"`
-       Fee       uint64                   `json:"fee"`
+       Fee       int64                    `json:"fee"`
 }
 
-// POST /get-raw-transaction
-func (a *API) getRawTransaction(ctx context.Context, ins struct {
+// POST /decode-raw-transaction
+func (a *API) decodeRawTransaction(ctx context.Context, ins struct {
        Tx types.Tx `json:"raw_transaction"`
 }) Response {
        tx := &RawTx{
@@ -205,7 +205,7 @@ func (a *API) getRawTransaction(ctx context.Context, ins struct {
                }
        }
 
-       tx.Fee = totalInputBtm - totalOutputBtm
+       tx.Fee = int64(totalInputBtm) - int64(totalOutputBtm)
        return NewSuccessResponse(tx)
 }
 
index 5635e00..7690d7c 100644 (file)
@@ -128,7 +128,7 @@ func AddCommands() {
 
        BytomcliCmd.AddCommand(getUnconfirmedTransactionCmd)
        BytomcliCmd.AddCommand(listUnconfirmedTransactionsCmd)
-       BytomcliCmd.AddCommand(getRawTransactionCmd)
+       BytomcliCmd.AddCommand(decodeRawTransactionCmd)
 
        BytomcliCmd.AddCommand(listUnspentOutputsCmd)
        BytomcliCmd.AddCommand(listBalancesCmd)
index ee8a661..38b5101 100644 (file)
@@ -275,22 +275,22 @@ var estimateTransactionGasCmd = &cobra.Command{
        },
 }
 
-var getRawTransactionCmd = &cobra.Command{
-       Use:   "get-raw-transaction <raw_transaction>",
-       Short: "get the transaction by raw_transaction",
+var decodeRawTransactionCmd = &cobra.Command{
+       Use:   "decode-raw-transaction <raw_transaction>",
+       Short: "decode the raw transaction",
        Args:  cobra.ExactArgs(1),
        Run: func(cmd *cobra.Command, args []string) {
                var ins = struct {
                        Tx types.Tx `json:"raw_transaction"`
                }{}
 
-               err := json.Unmarshal([]byte(args[0]), &ins)
+               err := ins.Tx.UnmarshalText([]byte(args[0]))
                if err != nil {
                        jww.ERROR.Println(err)
                        os.Exit(util.ErrLocalExe)
                }
 
-               data, exitCode := util.ClientCall("/get-raw-transaction", &ins)
+               data, exitCode := util.ClientCall("/decode-raw-transaction", &ins)
                if exitCode != util.Success {
                        os.Exit(exitCode)
                }