Commit 4875a477 authored by sanghg's avatar sanghg Committed by vipwzw

修复隐私合约中golint的警告

修改commands、autotest中的golint警告
parent e4481593
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"github.com/33cn/chain33/cmd/autotest/types" "github.com/33cn/chain33/cmd/autotest/types"
) )
//pub2priv case //CreateUtxosCase pub2priv case
type CreateUtxosCase struct { type CreateUtxosCase struct {
types.BaseCase types.BaseCase
From string `toml:"from"` From string `toml:"from"`
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved. // Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package autotest package autotest
import ( import (
"strconv" "strconv"
. "github.com/33cn/chain33/cmd/autotest/types" "github.com/33cn/chain33/cmd/autotest/types"
) )
//pub2priv case //PrivToPrivCase pub2priv case
type PrivToPrivCase struct { type PrivToPrivCase struct {
BaseCase types.BaseCase
From string `toml:"from"` From string `toml:"from"`
To string `toml:"to"` To string `toml:"to"`
Amount string `toml:"amount"` Amount string `toml:"amount"`
} }
// PrivToPrivPack privacy to privacy package
type PrivToPrivPack struct { type PrivToPrivPack struct {
BaseCasePack types.BaseCasePack
} }
func (testCase *PrivToPrivCase) SendCommand(packID string) (PackFunc, error) { // SendCommand send command
func (testCase *PrivToPrivCase) SendCommand(packID string) (types.PackFunc, error) {
return DefaultSend(testCase, &PrivToPrivPack{}, packID) return types.DefaultSend(testCase, &PrivToPrivPack{}, packID)
} }
// GetCheckHandlerMap get check handler map
func (pack *PrivToPrivPack) GetCheckHandlerMap() interface{} { func (pack *PrivToPrivPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2) funcMap := make(types.CheckHandlerMapDiscard, 2)
funcMap["utxo"] = pack.checkUtxo funcMap["utxo"] = pack.checkUtxo
return funcMap return funcMap
} }
...@@ -42,16 +46,16 @@ func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool { ...@@ -42,16 +46,16 @@ func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
amount, _ := strconv.ParseFloat(interCase.Amount, 64) amount, _ := strconv.ParseFloat(interCase.Amount, 64)
fee, _ := strconv.ParseFloat(txInfo["tx"].(map[string]interface{})["fee"].(string), 64) fee, _ := strconv.ParseFloat(txInfo["tx"].(map[string]interface{})["fee"].(string), 64)
utxoInput := CalcTxUtxoAmount(inputLog, "keyinput") utxoInput := types.CalcTxUtxoAmount(inputLog, "keyinput")
utxoOutput := CalcTxUtxoAmount(outputLog, "keyoutput") utxoOutput := types.CalcTxUtxoAmount(outputLog, "keyoutput")
fromAvail, err1 := CalcUtxoAvailAmount(interCase.From, pack.TxHash) fromAvail, err1 := types.CalcUtxoAvailAmount(interCase.From, pack.TxHash)
fromSpend, err2 := CalcUtxoSpendAmount(interCase.From, pack.TxHash) fromSpend, err2 := types.CalcUtxoSpendAmount(interCase.From, pack.TxHash)
toAvail, err3 := CalcUtxoAvailAmount(interCase.To, pack.TxHash) toAvail, err3 := types.CalcUtxoAvailAmount(interCase.To, pack.TxHash)
utxoCheck := IsBalanceEqualFloat(fromAvail, utxoInput-amount-fee) && utxoCheck := types.IsBalanceEqualFloat(fromAvail, utxoInput-amount-fee) &&
IsBalanceEqualFloat(toAvail, amount) && types.IsBalanceEqualFloat(toAvail, amount) &&
IsBalanceEqualFloat(fromSpend, utxoInput) types.IsBalanceEqualFloat(fromSpend, utxoInput)
pack.FLog.Info("Private2PrivateUtxoDetail", "TestID", pack.PackID, pack.FLog.Info("Private2PrivateUtxoDetail", "TestID", pack.PackID,
"FromAddr", interCase.From, "ToAddr", interCase.To, "Fee", fee, "FromAddr", interCase.From, "ToAddr", interCase.To, "Fee", fee,
...@@ -59,5 +63,5 @@ func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool { ...@@ -59,5 +63,5 @@ func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
"FromAvailable", fromAvail, "FromSpend", fromSpend, "ToAvailable", toAvail, "FromAvailable", fromAvail, "FromSpend", fromSpend, "ToAvailable", toAvail,
"CalcFromAvailErr", err1, "CalcFromSpendErr", err2, "CalcToAvailErr", err3) "CalcFromAvailErr", err1, "CalcFromSpendErr", err2, "CalcToAvailErr", err3)
return IsBalanceEqualFloat(fee, utxoInput-utxoOutput) && utxoCheck return types.IsBalanceEqualFloat(fee, utxoInput-utxoOutput) && utxoCheck
} }
// Copyright Fuzamei Corp. 2018 All Rights Reserved. // Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package autotest package autotest
import ( import (
"strconv" "strconv"
. "github.com/33cn/chain33/cmd/autotest/types" "github.com/33cn/chain33/cmd/autotest/types"
) )
//pub2priv case //PrivToPubCase pub2priv case
type PrivToPubCase struct { type PrivToPubCase struct {
BaseCase types.BaseCase
From string `toml:"from"` From string `toml:"from"`
To string `toml:"to"` To string `toml:"to"`
Amount string `toml:"amount"` Amount string `toml:"amount"`
} }
// PrivToPubPack privacy to public package
type PrivToPubPack struct { type PrivToPubPack struct {
BaseCasePack types.BaseCasePack
} }
func (testCase *PrivToPubCase) SendCommand(packID string) (PackFunc, error) { // SendCommand send command
func (testCase *PrivToPubCase) SendCommand(packID string) (types.PackFunc, error) {
return DefaultSend(testCase, &PrivToPubPack{}, packID) return types.DefaultSend(testCase, &PrivToPubPack{}, packID)
} }
// GetCheckHandlerMap get check handler map
func (pack *PrivToPubPack) GetCheckHandlerMap() interface{} { func (pack *PrivToPubPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2) funcMap := make(types.CheckHandlerMapDiscard, 2)
funcMap["balance"] = pack.checkBalance funcMap["balance"] = pack.checkBalance
funcMap["utxo"] = pack.checkUtxo funcMap["utxo"] = pack.checkUtxo
return funcMap return funcMap
...@@ -52,8 +56,8 @@ func (pack *PrivToPubPack) checkBalance(txInfo map[string]interface{}) bool { ...@@ -52,8 +56,8 @@ func (pack *PrivToPubPack) checkBalance(txInfo map[string]interface{}) bool {
"ToPrev", logPub["prev"].(map[string]interface{})["balance"].(string), "ToPrev", logPub["prev"].(map[string]interface{})["balance"].(string),
"ToCurr", logPub["current"].(map[string]interface{})["balance"].(string)) "ToCurr", logPub["current"].(map[string]interface{})["balance"].(string))
return CheckBalanceDeltaWithAddr(logFee, from, -fee) && return types.CheckBalanceDeltaWithAddr(logFee, from, -fee) &&
CheckBalanceDeltaWithAddr(logPub, interCase.To, amount) types.CheckBalanceDeltaWithAddr(logPub, interCase.To, amount)
} }
func (pack *PrivToPubPack) checkUtxo(txInfo map[string]interface{}) bool { func (pack *PrivToPubPack) checkUtxo(txInfo map[string]interface{}) bool {
...@@ -65,19 +69,19 @@ func (pack *PrivToPubPack) checkUtxo(txInfo map[string]interface{}) bool { ...@@ -65,19 +69,19 @@ func (pack *PrivToPubPack) checkUtxo(txInfo map[string]interface{}) bool {
amount, _ := strconv.ParseFloat(interCase.Amount, 64) amount, _ := strconv.ParseFloat(interCase.Amount, 64)
fee, _ := strconv.ParseFloat(txInfo["tx"].(map[string]interface{})["fee"].(string), 64) fee, _ := strconv.ParseFloat(txInfo["tx"].(map[string]interface{})["fee"].(string), 64)
utxoInput := CalcTxUtxoAmount(inputLog, "keyinput") utxoInput := types.CalcTxUtxoAmount(inputLog, "keyinput")
utxoOutput := CalcTxUtxoAmount(outputLog, "keyoutput") utxoOutput := types.CalcTxUtxoAmount(outputLog, "keyoutput")
//get available utxo with addr //get available utxo with addr
availUtxo, err1 := CalcUtxoAvailAmount(interCase.From, pack.TxHash) availUtxo, err1 := types.CalcUtxoAvailAmount(interCase.From, pack.TxHash)
//get spend utxo with addr //get spend utxo with addr
spendUtxo, err2 := CalcUtxoSpendAmount(interCase.From, pack.TxHash) spendUtxo, err2 := types.CalcUtxoSpendAmount(interCase.From, pack.TxHash)
utxoCheck := IsBalanceEqualFloat(availUtxo, utxoOutput) && IsBalanceEqualFloat(spendUtxo, utxoInput) utxoCheck := types.IsBalanceEqualFloat(availUtxo, utxoOutput) && types.IsBalanceEqualFloat(spendUtxo, utxoInput)
pack.FLog.Info("Private2PubUtxoDetail", "TestID", pack.PackID, "Fee", fee, pack.FLog.Info("Private2PubUtxoDetail", "TestID", pack.PackID, "Fee", fee,
"TransferAmount", interCase.Amount, "UtxoInput", utxoInput, "UtxoOutput", utxoOutput, "TransferAmount", interCase.Amount, "UtxoInput", utxoInput, "UtxoOutput", utxoOutput,
"FromAddr", interCase.From, "UtxoAvailable", availUtxo, "UtxoSpend", spendUtxo, "FromAddr", interCase.From, "UtxoAvailable", availUtxo, "UtxoSpend", spendUtxo,
"CalcAvailErr", err1, "CalcSpendErr", err2) "CalcAvailErr", err1, "CalcSpendErr", err2)
return IsBalanceEqualFloat(amount, utxoInput-utxoOutput-fee) && utxoCheck return types.IsBalanceEqualFloat(amount, utxoInput-utxoOutput-fee) && utxoCheck
} }
// Copyright Fuzamei Corp. 2018 All Rights Reserved. // Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package autotest package autotest
import ( import (
"reflect" "reflect"
. "github.com/33cn/chain33/cmd/autotest/types" "github.com/33cn/chain33/cmd/autotest/types"
. "github.com/33cn/chain33/system/dapp/coins/autotest" ca "github.com/33cn/chain33/system/dapp/coins/autotest"
. "github.com/33cn/plugin/plugin/dapp/token/autotest" ta "github.com/33cn/plugin/plugin/dapp/token/autotest"
) )
type privacyAutoTest struct { type privacyAutoTest struct {
SimpleCaseArr []SimpleCase `toml:"SimpleCase,omitempty"` SimpleCaseArr []types.SimpleCase `toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr []TokenPreCreateCase `toml:"TokenPreCreateCase,omitempty"` TokenPreCreateCaseArr []ta.TokenPreCreateCase `toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr []TokenFinishCreateCase `toml:"TokenFinishCreateCase,omitempty"` TokenFinishCreateCaseArr []ta.TokenFinishCreateCase `toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr []TransferCase `toml:"TransferCase,omitempty"` TransferCaseArr []ca.TransferCase `toml:"TransferCase,omitempty"`
PubToPrivCaseArr []PubToPrivCase `toml:"PubToPrivCase,omitempty"` PubToPrivCaseArr []PubToPrivCase `toml:"PubToPrivCase,omitempty"`
PrivToPrivCaseArr []PrivToPrivCase `toml:"PrivToPrivCase,omitempty"` PrivToPrivCaseArr []PrivToPrivCase `toml:"PrivToPrivCase,omitempty"`
PrivToPubCaseArr []PrivToPubCase `toml:"PrivToPubCase,omitempty"` PrivToPubCaseArr []PrivToPubCase `toml:"PrivToPubCase,omitempty"`
CreateUtxosCaseArr []CreateUtxosCase `toml:"CreateUtxosCase,omitempty"` CreateUtxosCaseArr []CreateUtxosCase `toml:"CreateUtxosCase,omitempty"`
} }
func init() { func init() {
RegisterAutoTest(privacyAutoTest{}) types.RegisterAutoTest(privacyAutoTest{})
} }
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved. // Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package autotest package autotest
import ( import (
"strconv" "strconv"
. "github.com/33cn/chain33/cmd/autotest/types" "github.com/33cn/chain33/cmd/autotest/types"
) )
//PubToPrivCase pub2priv case //PubToPrivCase pub2priv case
type PubToPrivCase struct { type PubToPrivCase struct {
BaseCase types.BaseCase
From string `toml:"from"` From string `toml:"from"`
To string `toml:"to"` To string `toml:"to"`
Amount string `toml:"amount"` Amount string `toml:"amount"`
...@@ -19,19 +20,19 @@ type PubToPrivCase struct { ...@@ -19,19 +20,19 @@ type PubToPrivCase struct {
// PubToPrivPack public to privacy package // PubToPrivPack public to privacy package
type PubToPrivPack struct { type PubToPrivPack struct {
BaseCasePack types.BaseCasePack
} }
// SendCommand send command // SendCommand send command
func (testCase *PubToPrivCase) SendCommand(packID string) (PackFunc, error) { func (testCase *PubToPrivCase) SendCommand(packID string) (types.PackFunc, error) {
return DefaultSend(testCase, &PubToPrivPack{}, packID) return types.DefaultSend(testCase, &PubToPrivPack{}, packID)
} }
// GetCheckHandlerMap get check handler map // GetCheckHandlerMap get check handler map
func (pack *PubToPrivPack) GetCheckHandlerMap() interface{} { func (pack *PubToPrivPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2) funcMap := make(types.CheckHandlerMapDiscard, 2)
funcMap["balance"] = pack.checkBalance funcMap["balance"] = pack.checkBalance
funcMap["utxo"] = pack.checkUtxo funcMap["utxo"] = pack.checkUtxo
return funcMap return funcMap
...@@ -53,8 +54,8 @@ func (pack *PubToPrivPack) checkBalance(txInfo map[string]interface{}) bool { ...@@ -53,8 +54,8 @@ func (pack *PubToPrivPack) checkBalance(txInfo map[string]interface{}) bool {
"FromPrev", logSend["prev"].(map[string]interface{})["balance"].(string), "FromPrev", logSend["prev"].(map[string]interface{})["balance"].(string),
"FromCurr", logSend["current"].(map[string]interface{})["balance"].(string)) "FromCurr", logSend["current"].(map[string]interface{})["balance"].(string))
return CheckBalanceDeltaWithAddr(logFee, interCase.From, -fee) && return types.CheckBalanceDeltaWithAddr(logFee, interCase.From, -fee) &&
CheckBalanceDeltaWithAddr(logSend, interCase.From, -amount) types.CheckBalanceDeltaWithAddr(logSend, interCase.From, -amount)
} }
func (pack *PubToPrivPack) checkUtxo(txInfo map[string]interface{}) bool { func (pack *PubToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
...@@ -65,14 +66,14 @@ func (pack *PubToPrivPack) checkUtxo(txInfo map[string]interface{}) bool { ...@@ -65,14 +66,14 @@ func (pack *PubToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
amount, _ := strconv.ParseFloat(interCase.Amount, 64) amount, _ := strconv.ParseFloat(interCase.Amount, 64)
//get available utxo with addr //get available utxo with addr
availUtxo, err := CalcUtxoAvailAmount(interCase.To, pack.TxHash) availUtxo, err := types.CalcUtxoAvailAmount(interCase.To, pack.TxHash)
totalOutput := CalcTxUtxoAmount(outputLog, "keyoutput") totalOutput := types.CalcTxUtxoAmount(outputLog, "keyoutput")
availCheck := IsBalanceEqualFloat(availUtxo, amount) availCheck := types.IsBalanceEqualFloat(availUtxo, amount)
pack.FLog.Info("Pub2PrivateUtxoDetail", "TestID", pack.PackID, pack.FLog.Info("Pub2PrivateUtxoDetail", "TestID", pack.PackID,
"TransferAmount", interCase.Amount, "UtxoOutput", totalOutput, "TransferAmount", interCase.Amount, "UtxoOutput", totalOutput,
"ToAddr", interCase.To, "UtxoAvailable", availUtxo, "CalcAvailErr", err) "ToAddr", interCase.To, "UtxoAvailable", availUtxo, "CalcAvailErr", err)
return availCheck && IsBalanceEqualFloat(totalOutput, amount) return availCheck && types.IsBalanceEqualFloat(totalOutput, amount)
} }
...@@ -24,6 +24,7 @@ var ( ...@@ -24,6 +24,7 @@ var (
defMixCount int32 = 16 defMixCount int32 = 16
) )
// PrivacyCmd 添加隐私交易的命令
func PrivacyCmd() *cobra.Command { func PrivacyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "privacy", Use: "privacy",
...@@ -32,25 +33,25 @@ func PrivacyCmd() *cobra.Command { ...@@ -32,25 +33,25 @@ func PrivacyCmd() *cobra.Command {
} }
cmd.AddCommand( cmd.AddCommand(
ShowPrivacyKeyCmd(), showPrivacyKeyCmd(),
ShowPrivacyAccountSpendCmd(), showPrivacyAccountSpendCmd(),
Public2PrivacyCmd(), public2PrivacyCmd(),
Privacy2PrivacyCmd(), privacy2PrivacyCmd(),
Privacy2PublicCmd(), privacy2PublicCmd(),
ShowAmountsOfUTXOCmd(), showAmountsOfUTXOCmd(),
ShowUTXOs4SpecifiedAmountCmd(), showUTXOs4SpecifiedAmountCmd(),
CreateUTXOsCmd(), createUTXOsCmd(),
ShowPrivacyAccountInfoCmd(), showPrivacyAccountInfoCmd(),
ListPrivacyTxsCmd(), listPrivacyTxsCmd(),
RescanUtxosOptCmd(), rescanUtxosOptCmd(),
EnablePrivacyCmd(), enablePrivacyCmd(),
) )
return cmd return cmd
} }
// ShowPrivacyKeyCmd show privacy key by address // showPrivacyKeyCmd show privacy key by address
func ShowPrivacyKeyCmd() *cobra.Command { func showPrivacyKeyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showpk", Use: "showpk",
Short: "Show privacy key by address", Short: "Show privacy key by address",
...@@ -77,8 +78,8 @@ func showPrivacyKey(cmd *cobra.Command, args []string) { ...@@ -77,8 +78,8 @@ func showPrivacyKey(cmd *cobra.Command, args []string) {
ctx.Run() ctx.Run()
} }
// Public2PrivacyCmd public address to privacy address // public2PrivacyCmd public address to privacy address
func Public2PrivacyCmd() *cobra.Command { func public2PrivacyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "pub2priv", Use: "pub2priv",
Short: "Public to privacy from pubkeypair amout note", Short: "Public to privacy from pubkeypair amout note",
...@@ -142,7 +143,7 @@ func public2Privacy(cmd *cobra.Command, args []string) { ...@@ -142,7 +143,7 @@ func public2Privacy(cmd *cobra.Command, args []string) {
} }
// privacy address to privacy address // privacy address to privacy address
func Privacy2PrivacyCmd() *cobra.Command { func privacy2PrivacyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "priv2priv", Use: "priv2priv",
Short: "Privacy to privacy from toviewpubkey tospendpubkey amout note", Short: "Privacy to privacy from toviewpubkey tospendpubkey amout note",
...@@ -208,7 +209,7 @@ func privacy2Privacy(cmd *cobra.Command, args []string) { ...@@ -208,7 +209,7 @@ func privacy2Privacy(cmd *cobra.Command, args []string) {
} }
// privacy address to public address // privacy address to public address
func Privacy2PublicCmd() *cobra.Command { func privacy2PublicCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "priv2pub", Use: "priv2pub",
Short: "Public to privacy from toviewpubkey tospendpubkey amout note", Short: "Public to privacy from toviewpubkey tospendpubkey amout note",
...@@ -274,7 +275,7 @@ func privacy2Public(cmd *cobra.Command, args []string) { ...@@ -274,7 +275,7 @@ func privacy2Public(cmd *cobra.Command, args []string) {
ctx.Run() ctx.Run()
} }
func ShowPrivacyAccountSpendCmd() *cobra.Command { func showPrivacyAccountSpendCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showpas", Use: "showpas",
Short: "Show privacy account spend command", Short: "Show privacy account spend command",
...@@ -346,7 +347,7 @@ func parseShowPrivacyAccountSpendRes(arg interface{}) (interface{}, error) { ...@@ -346,7 +347,7 @@ func parseShowPrivacyAccountSpendRes(arg interface{}) (interface{}, error) {
return rets, nil return rets, nil
} }
func ShowAmountsOfUTXOCmd() *cobra.Command { func showAmountsOfUTXOCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showau", Use: "showau",
Short: "Show Amount of UTXO", Short: "Show Amount of UTXO",
...@@ -382,7 +383,7 @@ func parseShowAmountOfUTXORes(arg interface{}) (interface{}, error) { ...@@ -382,7 +383,7 @@ func parseShowAmountOfUTXORes(arg interface{}) (interface{}, error) {
return res, nil return res, nil
} }
func ShowUTXOs4SpecifiedAmountCmd() *cobra.Command { func showUTXOs4SpecifiedAmountCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showutxo4a", Use: "showutxo4a",
Short: "Show specified amount UTXOs", Short: "Show specified amount UTXOs",
...@@ -432,7 +433,7 @@ func parseShowUTXOs4SpecifiedAmountRes(arg interface{}) (interface{}, error) { ...@@ -432,7 +433,7 @@ func parseShowUTXOs4SpecifiedAmountRes(arg interface{}) (interface{}, error) {
return ret, nil return ret, nil
} }
func CreateUTXOsCmd() *cobra.Command { func createUTXOsCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "createutxos", Use: "createutxos",
Short: "Create specified count UTXOs with specified amount", Short: "Create specified count UTXOs with specified amount",
...@@ -482,8 +483,8 @@ func createUTXOs(cmd *cobra.Command, args []string) { ...@@ -482,8 +483,8 @@ func createUTXOs(cmd *cobra.Command, args []string) {
ctx.Run() ctx.Run()
} }
// ShowPrivacyAccountInfoCmd // showPrivacyAccountInfoCmd
func ShowPrivacyAccountInfoCmd() *cobra.Command { func showPrivacyAccountInfoCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "showpai", Use: "showpai",
Short: "Show privacy account information", Short: "Show privacy account information",
...@@ -573,7 +574,7 @@ func parseshowPrivacyAccountInfo(arg interface{}) (interface{}, error) { ...@@ -573,7 +574,7 @@ func parseshowPrivacyAccountInfo(arg interface{}) (interface{}, error) {
return ret, nil return ret, nil
} }
func ListPrivacyTxsCmd() *cobra.Command { func listPrivacyTxsCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "list_txs", Use: "list_txs",
Short: "List privacy transactions in wallet", Short: "List privacy transactions in wallet",
...@@ -637,24 +638,24 @@ func parseWalletTxListRes(arg interface{}) (interface{}, error) { ...@@ -637,24 +638,24 @@ func parseWalletTxListRes(arg interface{}) (interface{}, error) {
return result, nil return result, nil
} }
func RescanUtxosOptCmd() *cobra.Command { func rescanUtxosOptCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "rescanOpt", Use: "rescanOpt",
Short: "rescan Utxos in wallet and query rescan utxos status", Short: "rescan Utxos in wallet and query rescan utxos status",
Run: RescanUtxosOpt, Run: rescanUtxosOpt,
} }
RescanUtxosOptFlags(cmd) rescanUtxosOptFlags(cmd)
return cmd return cmd
} }
func RescanUtxosOptFlags(cmd *cobra.Command) { func rescanUtxosOptFlags(cmd *cobra.Command) {
cmd.Flags().StringP("addr", "a", "", "privacy rescanOpt -a [all-addr0-addr1] (all indicate all wallet address)") cmd.Flags().StringP("addr", "a", "", "privacy rescanOpt -a [all-addr0-addr1] (all indicate all wallet address)")
cmd.MarkFlagRequired("addr") cmd.MarkFlagRequired("addr")
// //
cmd.Flags().Int32P("flag", "f", 0, "Rescan or query rescan flag (0: Rescan, 1: query rescan)") cmd.Flags().Int32P("flag", "f", 0, "Rescan or query rescan flag (0: Rescan, 1: query rescan)")
} }
func RescanUtxosOpt(cmd *cobra.Command, args []string) { func rescanUtxosOpt(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
address, _ := cmd.Flags().GetString("addr") address, _ := cmd.Flags().GetString("addr")
flag, _ := cmd.Flags().GetInt32("flag") flag, _ := cmd.Flags().GetInt32("flag")
...@@ -677,41 +678,41 @@ func RescanUtxosOpt(cmd *cobra.Command, args []string) { ...@@ -677,41 +678,41 @@ func RescanUtxosOpt(cmd *cobra.Command, args []string) {
func parseRescanUtxosOpt(arg interface{}) (interface{}, error) { func parseRescanUtxosOpt(arg interface{}) (interface{}, error) {
res := arg.(*pty.RepRescanUtxos) res := arg.(*pty.RepRescanUtxos)
var result showRescanResults
if 0 == res.Flag { if 0 == res.Flag {
str := "start rescan UTXO" str := "start rescan UTXO"
return str, nil return str, nil
} else { }
for _, v := range res.RepRescanResults {
str, ok := pty.RescanFlagMapint2string[v.Flag] var result showRescanResults
if ok { for _, v := range res.RepRescanResults {
showRescanResult := &ShowRescanResult{ str, ok := pty.RescanFlagMapint2string[v.Flag]
Addr: v.Addr, if ok {
FlagString: str, showRescanResult := &ShowRescanResult{
} Addr: v.Addr,
result.RescanResults = append(result.RescanResults, showRescanResult) FlagString: str,
} }
result.RescanResults = append(result.RescanResults, showRescanResult)
} }
return &result, nil
} }
return &result, nil
} }
func EnablePrivacyCmd() *cobra.Command { func enablePrivacyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "enable", Use: "enable",
Short: "enable privacy address in wallet", Short: "enable privacy address in wallet",
Run: EnablePrivacy, Run: enablePrivacy,
} }
EnablePrivacyFlags(cmd) enablePrivacyFlags(cmd)
return cmd return cmd
} }
func EnablePrivacyFlags(cmd *cobra.Command) { func enablePrivacyFlags(cmd *cobra.Command) {
cmd.Flags().StringP("addr", "a", "", "privacy enable -a [all-addr0-addr1] (all indicate enable all wallet address)") cmd.Flags().StringP("addr", "a", "", "privacy enable -a [all-addr0-addr1] (all indicate enable all wallet address)")
cmd.MarkFlagRequired("addr") cmd.MarkFlagRequired("addr")
} }
func EnablePrivacy(cmd *cobra.Command, args []string) { func enablePrivacy(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
address, _ := cmd.Flags().GetString("addr") address, _ := cmd.Flags().GetString("addr")
...@@ -725,7 +726,7 @@ func EnablePrivacy(cmd *cobra.Command, args []string) { ...@@ -725,7 +726,7 @@ func EnablePrivacy(cmd *cobra.Command, args []string) {
} }
var res pty.RepEnablePrivacy var res pty.RepEnablePrivacy
ctx := jsonclient.NewRpcCtx(rpcLaddr, "privacy.EnablePrivacy", params, &res) ctx := jsonclient.NewRpcCtx(rpcLaddr, "privacy.enablePrivacy", params, &res)
ctx.SetResultCb(parseEnablePrivacy) ctx.SetResultCb(parseEnablePrivacy)
ctx.Run() ctx.Run()
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package commands package commands
// PrivacyAccountResult display privacy account result
type PrivacyAccountResult struct { type PrivacyAccountResult struct {
Token string `json:"Token,omitempty"` Token string `json:"Token,omitempty"`
Txhash string `json:"Txhash,omitempty"` Txhash string `json:"Txhash,omitempty"`
...@@ -12,6 +13,7 @@ type PrivacyAccountResult struct { ...@@ -12,6 +13,7 @@ type PrivacyAccountResult struct {
OnetimePubKey string `json:"OnetimePubKey,omitempty"` OnetimePubKey string `json:"OnetimePubKey,omitempty"`
} }
// PrivacyAccountInfoResult display privacy account information result
type PrivacyAccountInfoResult struct { type PrivacyAccountInfoResult struct {
AvailableDetail []*PrivacyAccountResult `json:"AvailableDetail,omitempty"` AvailableDetail []*PrivacyAccountResult `json:"AvailableDetail,omitempty"`
FrozenDetail []*PrivacyAccountResult `json:"FrozenDetail,omitempty"` FrozenDetail []*PrivacyAccountResult `json:"FrozenDetail,omitempty"`
...@@ -20,11 +22,13 @@ type PrivacyAccountInfoResult struct { ...@@ -20,11 +22,13 @@ type PrivacyAccountInfoResult struct {
TotalAmount string `json:"TotalAmount,omitempty"` TotalAmount string `json:"TotalAmount,omitempty"`
} }
// PrivacyAccountSpendResult display privacy account spend result
type PrivacyAccountSpendResult struct { type PrivacyAccountSpendResult struct {
Txhash string `json:"Txhash,omitempty"` Txhash string `json:"Txhash,omitempty"`
Res []*PrivacyAccountResult `json:"Spend,omitempty"` Res []*PrivacyAccountResult `json:"Spend,omitempty"`
} }
// ShowRescanResult display rescan utxos result
type ShowRescanResult struct { type ShowRescanResult struct {
Addr string `json:"addr"` Addr string `json:"addr"`
FlagString string `json:"FlagString"` FlagString string `json:"FlagString"`
...@@ -34,10 +38,12 @@ type showRescanResults struct { ...@@ -34,10 +38,12 @@ type showRescanResults struct {
RescanResults []*ShowRescanResult `json:"ShowRescanResults,omitempty"` RescanResults []*ShowRescanResult `json:"ShowRescanResults,omitempty"`
} }
// ShowEnablePrivacy display enable privacy
type ShowEnablePrivacy struct { type ShowEnablePrivacy struct {
Results []*ShowPriAddrResult `json:"results"` Results []*ShowPriAddrResult `json:"results"`
} }
// ShowPriAddrResult display privacy address result
type ShowPriAddrResult struct { type ShowPriAddrResult struct {
Addr string `json:"addr"` Addr string `json:"addr"`
IsOK bool `json:"IsOK"` IsOK bool `json:"IsOK"`
......
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