Commit a28e3aaf authored by kingwang's avatar kingwang Committed by 33cn

update 04/25

parent 8be1cb21
......@@ -936,17 +936,33 @@ func (c *Chain33) GetFatalFailure(in *types.ReqNil, result *interface{}) error {
}
// DecodeRawTransaction decode rawtransaction
// DecodeRawTransaction 考虑交易组的解析统一返回ReplyTxList列表
func (c *Chain33) DecodeRawTransaction(in *types.ReqDecodeRawTransaction, result *interface{}) error {
reply, err := c.cli.DecodeRawTransaction(in)
tx, err := c.cli.DecodeRawTransaction(in)
if err != nil {
return err
}
res, err := rpctypes.DecodeTx(reply)
txs, err := tx.GetTxGroup()
if err != nil {
return err
}
*result = res
var rpctxs rpctypes.ReplyTxList
if txs == nil {
res, err := rpctypes.DecodeTx(tx)
if err != nil {
return err
}
rpctxs.Txs = append(rpctxs.Txs, res)
} else {
for _, rpctx := range txs.GetTxs() {
res, err := rpctypes.DecodeTx(rpctx)
if err != nil {
return err
}
rpctxs.Txs = append(rpctxs.Txs, res)
}
}
*result = &rpctxs
return nil
}
......
......@@ -5,14 +5,11 @@
package commands
import (
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
commandtypes "github.com/33cn/chain33/system/dapp/commands/types"
......@@ -233,35 +230,26 @@ func addDecodeTxFlags(cmd *cobra.Command) {
}
func decodeTx(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
data, _ := cmd.Flags().GetString("data")
var tx types.Transaction
bytes, err := common.FromHex(data)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
params := types.ReqDecodeRawTransaction{
TxHex: data,
}
err = types.Decode(bytes, &tx)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
res, err := rpctypes.DecodeTx(&tx)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
txResult := commandtypes.DecodeTransaction(res)
var res rpctypes.ReplyTxList
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.DecodeRawTransaction", params, &res)
ctx.SetResultCb(parseReplyTxList)
ctx.Run()
}
result, err := json.MarshalIndent(txResult, "", " ")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
func parseReplyTxList(view interface{}) (interface{}, error) {
replyTxList := view.(*rpctypes.ReplyTxList)
var commandtxs commandtypes.TxListResult
for _, cmdtx := range replyTxList.Txs {
txResult := commandtypes.DecodeTransaction(cmdtx)
commandtxs.Txs = append(commandtxs.Txs, txResult)
}
fmt.Println(string(result))
return &commandtxs, nil
}
// GetAddrOverviewCmd get overview of an address
......
......@@ -141,12 +141,7 @@ func RunChain33(name string) {
q := queue.New("channel")
log.Info("loading mempool module")
var mem queue.Module
if !types.IsPara() {
mem = mempool.New(cfg.Mempool, sub.Mempool)
} else {
mem = &util.MockModule{Key: "mempool"}
}
mem := mempool.New(cfg.Mempool, sub.Mempool)
mem.SetQueueClient(q.Client())
log.Info("loading execs module")
......
......@@ -237,6 +237,12 @@ func (wallet *Wallet) createSendToAddress(addrto string, amount int64, note stri
if len(tx.Execer) == 0 {
tx.Execer = []byte(exec)
}
if types.IsPara() {
tx.Execer = []byte(types.GetTitle() + string(tx.Execer))
tx.To = address.ExecAddress(string(tx.Execer))
}
tx.Nonce = rand.Int63()
return tx, nil
}
......
......@@ -715,9 +715,18 @@ func (wallet *Wallet) ProcMergeBalance(MergeBalance *types.ReqWalletMergeBalance
v := &cty.CoinsAction_Transfer{
Transfer: &types.AssetsTransfer{Amount: amount, Note: []byte(note)},
}
if types.IsPara() {
v.Transfer.To = MergeBalance.GetTo()
}
transfer := &cty.CoinsAction{Value: v, Ty: cty.CoinsActionTransfer}
//初始化随机数
tx := &types.Transaction{Execer: []byte("coins"), Payload: types.Encode(transfer), Fee: wallet.FeeAmount, To: addrto, Nonce: wallet.random.Int63()}
exec := []byte("coins")
toAddr := addrto
if types.IsPara() {
exec = []byte(types.GetTitle() + "coins")
toAddr = address.ExecAddress(string(exec))
}
tx := &types.Transaction{Execer: exec, Payload: types.Encode(transfer), Fee: wallet.FeeAmount, To: toAddr, Nonce: wallet.random.Int63()}
tx.SetExpire(time.Second * 120)
tx.Sign(int32(SignType), priv)
//walletlog.Info("ProcMergeBalance", "tx.Nonce", tx.Nonce, "tx", tx, "index", index)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment