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 { ...@@ -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 { 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 { if err != nil {
return err return err
} }
res, err := rpctypes.DecodeTx(reply) txs, err := tx.GetTxGroup()
if err != nil { if err != nil {
return err 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 return nil
} }
......
...@@ -5,14 +5,11 @@ ...@@ -5,14 +5,11 @@
package commands package commands
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/rpc/jsonclient" "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types" rpctypes "github.com/33cn/chain33/rpc/types"
commandtypes "github.com/33cn/chain33/system/dapp/commands/types" commandtypes "github.com/33cn/chain33/system/dapp/commands/types"
...@@ -233,35 +230,26 @@ func addDecodeTxFlags(cmd *cobra.Command) { ...@@ -233,35 +230,26 @@ func addDecodeTxFlags(cmd *cobra.Command) {
} }
func decodeTx(cmd *cobra.Command, args []string) { func decodeTx(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
data, _ := cmd.Flags().GetString("data") data, _ := cmd.Flags().GetString("data")
var tx types.Transaction params := types.ReqDecodeRawTransaction{
bytes, err := common.FromHex(data) TxHex: data,
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
} }
err = types.Decode(bytes, &tx) var res rpctypes.ReplyTxList
if err != nil { ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.DecodeRawTransaction", params, &res)
fmt.Fprintln(os.Stderr, err) ctx.SetResultCb(parseReplyTxList)
return ctx.Run()
} }
res, err := rpctypes.DecodeTx(&tx)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
txResult := commandtypes.DecodeTransaction(res)
result, err := json.MarshalIndent(txResult, "", " ") func parseReplyTxList(view interface{}) (interface{}, error) {
if err != nil { replyTxList := view.(*rpctypes.ReplyTxList)
fmt.Fprintln(os.Stderr, err) var commandtxs commandtypes.TxListResult
return for _, cmdtx := range replyTxList.Txs {
txResult := commandtypes.DecodeTransaction(cmdtx)
commandtxs.Txs = append(commandtxs.Txs, txResult)
} }
return &commandtxs, nil
fmt.Println(string(result))
} }
// GetAddrOverviewCmd get overview of an address // GetAddrOverviewCmd get overview of an address
......
...@@ -141,12 +141,7 @@ func RunChain33(name string) { ...@@ -141,12 +141,7 @@ func RunChain33(name string) {
q := queue.New("channel") q := queue.New("channel")
log.Info("loading mempool module") log.Info("loading mempool module")
var mem queue.Module mem := mempool.New(cfg.Mempool, sub.Mempool)
if !types.IsPara() {
mem = mempool.New(cfg.Mempool, sub.Mempool)
} else {
mem = &util.MockModule{Key: "mempool"}
}
mem.SetQueueClient(q.Client()) mem.SetQueueClient(q.Client())
log.Info("loading execs module") log.Info("loading execs module")
......
...@@ -237,6 +237,12 @@ func (wallet *Wallet) createSendToAddress(addrto string, amount int64, note stri ...@@ -237,6 +237,12 @@ func (wallet *Wallet) createSendToAddress(addrto string, amount int64, note stri
if len(tx.Execer) == 0 { if len(tx.Execer) == 0 {
tx.Execer = []byte(exec) 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() tx.Nonce = rand.Int63()
return tx, nil return tx, nil
} }
......
...@@ -715,9 +715,18 @@ func (wallet *Wallet) ProcMergeBalance(MergeBalance *types.ReqWalletMergeBalance ...@@ -715,9 +715,18 @@ func (wallet *Wallet) ProcMergeBalance(MergeBalance *types.ReqWalletMergeBalance
v := &cty.CoinsAction_Transfer{ v := &cty.CoinsAction_Transfer{
Transfer: &types.AssetsTransfer{Amount: amount, Note: []byte(note)}, Transfer: &types.AssetsTransfer{Amount: amount, Note: []byte(note)},
} }
if types.IsPara() {
v.Transfer.To = MergeBalance.GetTo()
}
transfer := &cty.CoinsAction{Value: v, Ty: cty.CoinsActionTransfer} 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.SetExpire(time.Second * 120)
tx.Sign(int32(SignType), priv) tx.Sign(int32(SignType), priv)
//walletlog.Info("ProcMergeBalance", "tx.Nonce", tx.Nonce, "tx", tx, "index", index) //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