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))
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{
}
}
- tx.Fee = totalInputBtm - totalOutputBtm
+ tx.Fee = int64(totalInputBtm) - int64(totalOutputBtm)
return NewSuccessResponse(tx)
}
BytomcliCmd.AddCommand(getUnconfirmedTransactionCmd)
BytomcliCmd.AddCommand(listUnconfirmedTransactionsCmd)
- BytomcliCmd.AddCommand(getRawTransactionCmd)
+ BytomcliCmd.AddCommand(decodeRawTransactionCmd)
BytomcliCmd.AddCommand(listUnspentOutputsCmd)
BytomcliCmd.AddCommand(listBalancesCmd)
},
}
-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)
}