Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
4875a477
Commit
4875a477
authored
Nov 20, 2018
by
sanghg
Committed by
vipwzw
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复隐私合约中golint的警告
修改commands、autotest中的golint警告
parent
e4481593
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
103 deletions
+120
-103
createutxosCase.go
plugin/dapp/privacy/autotest/createutxosCase.go
+1
-1
privToPrivCase.go
plugin/dapp/privacy/autotest/privToPrivCase.go
+20
-16
privToPubCase.go
plugin/dapp/privacy/autotest/privToPubCase.go
+19
-15
privacy.go
plugin/dapp/privacy/autotest/privacy.go
+13
-12
pubToPriv.go
plugin/dapp/privacy/autotest/pubToPriv.go
+13
-12
privacy.go
plugin/dapp/privacy/commands/privacy.go
+48
-47
types.go
plugin/dapp/privacy/commands/types.go
+6
-0
No files found.
plugin/dapp/privacy/autotest/createutxosCase.go
View file @
4875a477
...
...
@@ -10,7 +10,7 @@ import (
"github.com/33cn/chain33/cmd/autotest/types"
)
//pub2priv case
//
CreateUtxosCase
pub2priv case
type
CreateUtxosCase
struct
{
types
.
BaseCase
From
string
`toml:"from"`
...
...
plugin/dapp/privacy/autotest/privToPrivCase.go
View file @
4875a477
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
//pub2priv case
//
PrivToPrivCase
pub2priv case
type
PrivToPrivCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
To
string
`toml:"to"`
Amount
string
`toml:"amount"`
}
// PrivToPrivPack privacy to privacy package
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
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"utxo"
]
=
pack
.
checkUtxo
return
funcMap
}
...
...
@@ -42,16 +46,16 @@ func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
amount
,
_
:=
strconv
.
ParseFloat
(
interCase
.
Amount
,
64
)
fee
,
_
:=
strconv
.
ParseFloat
(
txInfo
[
"tx"
]
.
(
map
[
string
]
interface
{})[
"fee"
]
.
(
string
),
64
)
utxoInput
:=
CalcTxUtxoAmount
(
inputLog
,
"keyinput"
)
utxoOutput
:=
CalcTxUtxoAmount
(
outputLog
,
"keyoutput"
)
utxoInput
:=
types
.
CalcTxUtxoAmount
(
inputLog
,
"keyinput"
)
utxoOutput
:=
types
.
CalcTxUtxoAmount
(
outputLog
,
"keyoutput"
)
fromAvail
,
err1
:=
CalcUtxoAvailAmount
(
interCase
.
From
,
pack
.
TxHash
)
fromSpend
,
err2
:=
CalcUtxoSpendAmount
(
interCase
.
From
,
pack
.
TxHash
)
toAvail
,
err3
:=
CalcUtxoAvailAmount
(
interCase
.
To
,
pack
.
TxHash
)
fromAvail
,
err1
:=
types
.
CalcUtxoAvailAmount
(
interCase
.
From
,
pack
.
TxHash
)
fromSpend
,
err2
:=
types
.
CalcUtxoSpendAmount
(
interCase
.
From
,
pack
.
TxHash
)
toAvail
,
err3
:=
types
.
CalcUtxoAvailAmount
(
interCase
.
To
,
pack
.
TxHash
)
utxoCheck
:=
IsBalanceEqualFloat
(
fromAvail
,
utxoInput
-
amount
-
fee
)
&&
IsBalanceEqualFloat
(
toAvail
,
amount
)
&&
IsBalanceEqualFloat
(
fromSpend
,
utxoInput
)
utxoCheck
:=
types
.
IsBalanceEqualFloat
(
fromAvail
,
utxoInput
-
amount
-
fee
)
&&
types
.
IsBalanceEqualFloat
(
toAvail
,
amount
)
&&
types
.
IsBalanceEqualFloat
(
fromSpend
,
utxoInput
)
pack
.
FLog
.
Info
(
"Private2PrivateUtxoDetail"
,
"TestID"
,
pack
.
PackID
,
"FromAddr"
,
interCase
.
From
,
"ToAddr"
,
interCase
.
To
,
"Fee"
,
fee
,
...
...
@@ -59,5 +63,5 @@ func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
"FromAvailable"
,
fromAvail
,
"FromSpend"
,
fromSpend
,
"ToAvailable"
,
toAvail
,
"CalcFromAvailErr"
,
err1
,
"CalcFromSpendErr"
,
err2
,
"CalcToAvailErr"
,
err3
)
return
IsBalanceEqualFloat
(
fee
,
utxoInput
-
utxoOutput
)
&&
utxoCheck
return
types
.
IsBalanceEqualFloat
(
fee
,
utxoInput
-
utxoOutput
)
&&
utxoCheck
}
plugin/dapp/privacy/autotest/privToPubCase.go
View file @
4875a477
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
//pub2priv case
//
PrivToPubCase
pub2priv case
type
PrivToPubCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
To
string
`toml:"to"`
Amount
string
`toml:"amount"`
}
// PrivToPubPack privacy to public package
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
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
funcMap
[
"utxo"
]
=
pack
.
checkUtxo
return
funcMap
...
...
@@ -52,8 +56,8 @@ func (pack *PrivToPubPack) checkBalance(txInfo map[string]interface{}) bool {
"ToPrev"
,
logPub
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"ToCurr"
,
logPub
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
return
CheckBalanceDeltaWithAddr
(
logFee
,
from
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logPub
,
interCase
.
To
,
amount
)
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
from
,
-
fee
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logPub
,
interCase
.
To
,
amount
)
}
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
)
fee
,
_
:=
strconv
.
ParseFloat
(
txInfo
[
"tx"
]
.
(
map
[
string
]
interface
{})[
"fee"
]
.
(
string
),
64
)
utxoInput
:=
CalcTxUtxoAmount
(
inputLog
,
"keyinput"
)
utxoOutput
:=
CalcTxUtxoAmount
(
outputLog
,
"keyoutput"
)
utxoInput
:=
types
.
CalcTxUtxoAmount
(
inputLog
,
"keyinput"
)
utxoOutput
:=
types
.
CalcTxUtxoAmount
(
outputLog
,
"keyoutput"
)
//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
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
,
"TransferAmount"
,
interCase
.
Amount
,
"UtxoInput"
,
utxoInput
,
"UtxoOutput"
,
utxoOutput
,
"FromAddr"
,
interCase
.
From
,
"UtxoAvailable"
,
availUtxo
,
"UtxoSpend"
,
spendUtxo
,
"CalcAvailErr"
,
err1
,
"CalcSpendErr"
,
err2
)
return
IsBalanceEqualFloat
(
amount
,
utxoInput
-
utxoOutput
-
fee
)
&&
utxoCheck
return
types
.
IsBalanceEqualFloat
(
amount
,
utxoInput
-
utxoOutput
-
fee
)
&&
utxoCheck
}
plugin/dapp/privacy/autotest/privacy.go
View file @
4875a477
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"reflect"
.
"github.com/33cn/chain33/cmd/autotest/types"
.
"github.com/33cn/chain33/system/dapp/coins/autotest"
.
"github.com/33cn/plugin/plugin/dapp/token/autotest"
"github.com/33cn/chain33/cmd/autotest/types"
ca
"github.com/33cn/chain33/system/dapp/coins/autotest"
ta
"github.com/33cn/plugin/plugin/dapp/token/autotest"
)
type
privacyAutoTest
struct
{
SimpleCaseArr
[]
SimpleCase
`toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr
[]
TokenPreCreateCase
`toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr
[]
TokenFinishCreateCase
`toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
PubToPrivCaseArr
[]
PubToPrivCase
`toml:"PubToPrivCase,omitempty"`
PrivToPrivCaseArr
[]
PrivToPrivCase
`toml:"PrivToPrivCase,omitempty"`
PrivToPubCaseArr
[]
PrivToPubCase
`toml:"PrivToPubCase,omitempty"`
CreateUtxosCaseArr
[]
CreateUtxosCase
`toml:"CreateUtxosCase,omitempty"`
SimpleCaseArr
[]
types
.
SimpleCase
`toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr
[]
ta
.
TokenPreCreateCase
`toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr
[]
ta
.
TokenFinishCreateCase
`toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr
[]
ca
.
TransferCase
`toml:"TransferCase,omitempty"`
PubToPrivCaseArr
[]
PubToPrivCase
`toml:"PubToPrivCase,omitempty"`
PrivToPrivCaseArr
[]
PrivToPrivCase
`toml:"PrivToPrivCase,omitempty"`
PrivToPubCaseArr
[]
PrivToPubCase
`toml:"PrivToPubCase,omitempty"`
CreateUtxosCaseArr
[]
CreateUtxosCase
`toml:"CreateUtxosCase,omitempty"`
}
func
init
()
{
RegisterAutoTest
(
privacyAutoTest
{})
types
.
RegisterAutoTest
(
privacyAutoTest
{})
}
...
...
plugin/dapp/privacy/autotest/pubToPriv.go
View file @
4875a477
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
//PubToPrivCase pub2priv case
type
PubToPrivCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
To
string
`toml:"to"`
Amount
string
`toml:"amount"`
...
...
@@ -19,19 +20,19 @@ type PubToPrivCase struct {
// PubToPrivPack public to privacy package
type
PubToPrivPack
struct
{
BaseCasePack
types
.
BaseCasePack
}
// 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
func
(
pack
*
PubToPrivPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
funcMap
[
"utxo"
]
=
pack
.
checkUtxo
return
funcMap
...
...
@@ -53,8 +54,8 @@ func (pack *PubToPrivPack) checkBalance(txInfo map[string]interface{}) bool {
"FromPrev"
,
logSend
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"FromCurr"
,
logSend
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
return
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
amount
)
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
amount
)
}
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
)
//get available utxo with addr
availUtxo
,
err
:=
CalcUtxoAvailAmount
(
interCase
.
To
,
pack
.
TxHash
)
totalOutput
:=
CalcTxUtxoAmount
(
outputLog
,
"keyoutput"
)
availCheck
:=
IsBalanceEqualFloat
(
availUtxo
,
amount
)
availUtxo
,
err
:=
types
.
CalcUtxoAvailAmount
(
interCase
.
To
,
pack
.
TxHash
)
totalOutput
:=
types
.
CalcTxUtxoAmount
(
outputLog
,
"keyoutput"
)
availCheck
:=
types
.
IsBalanceEqualFloat
(
availUtxo
,
amount
)
pack
.
FLog
.
Info
(
"Pub2PrivateUtxoDetail"
,
"TestID"
,
pack
.
PackID
,
"TransferAmount"
,
interCase
.
Amount
,
"UtxoOutput"
,
totalOutput
,
"ToAddr"
,
interCase
.
To
,
"UtxoAvailable"
,
availUtxo
,
"CalcAvailErr"
,
err
)
return
availCheck
&&
IsBalanceEqualFloat
(
totalOutput
,
amount
)
return
availCheck
&&
types
.
IsBalanceEqualFloat
(
totalOutput
,
amount
)
}
plugin/dapp/privacy/commands/privacy.go
View file @
4875a477
...
...
@@ -24,6 +24,7 @@ var (
defMixCount
int32
=
16
)
// PrivacyCmd 添加隐私交易的命令
func
PrivacyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"privacy"
,
...
...
@@ -32,25 +33,25 @@ func PrivacyCmd() *cobra.Command {
}
cmd
.
AddCommand
(
S
howPrivacyKeyCmd
(),
S
howPrivacyAccountSpendCmd
(),
P
ublic2PrivacyCmd
(),
P
rivacy2PrivacyCmd
(),
P
rivacy2PublicCmd
(),
S
howAmountsOfUTXOCmd
(),
S
howUTXOs4SpecifiedAmountCmd
(),
C
reateUTXOsCmd
(),
S
howPrivacyAccountInfoCmd
(),
L
istPrivacyTxsCmd
(),
R
escanUtxosOptCmd
(),
E
nablePrivacyCmd
(),
s
howPrivacyKeyCmd
(),
s
howPrivacyAccountSpendCmd
(),
p
ublic2PrivacyCmd
(),
p
rivacy2PrivacyCmd
(),
p
rivacy2PublicCmd
(),
s
howAmountsOfUTXOCmd
(),
s
howUTXOs4SpecifiedAmountCmd
(),
c
reateUTXOsCmd
(),
s
howPrivacyAccountInfoCmd
(),
l
istPrivacyTxsCmd
(),
r
escanUtxosOptCmd
(),
e
nablePrivacyCmd
(),
)
return
cmd
}
//
S
howPrivacyKeyCmd show privacy key by address
func
S
howPrivacyKeyCmd
()
*
cobra
.
Command
{
//
s
howPrivacyKeyCmd show privacy key by address
func
s
howPrivacyKeyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"showpk"
,
Short
:
"Show privacy key by address"
,
...
...
@@ -77,8 +78,8 @@ func showPrivacyKey(cmd *cobra.Command, args []string) {
ctx
.
Run
()
}
//
P
ublic2PrivacyCmd public address to privacy address
func
P
ublic2PrivacyCmd
()
*
cobra
.
Command
{
//
p
ublic2PrivacyCmd public address to privacy address
func
p
ublic2PrivacyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"pub2priv"
,
Short
:
"Public to privacy from pubkeypair amout note"
,
...
...
@@ -142,7 +143,7 @@ func public2Privacy(cmd *cobra.Command, args []string) {
}
// privacy address to privacy address
func
P
rivacy2PrivacyCmd
()
*
cobra
.
Command
{
func
p
rivacy2PrivacyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"priv2priv"
,
Short
:
"Privacy to privacy from toviewpubkey tospendpubkey amout note"
,
...
...
@@ -208,7 +209,7 @@ func privacy2Privacy(cmd *cobra.Command, args []string) {
}
// privacy address to public address
func
P
rivacy2PublicCmd
()
*
cobra
.
Command
{
func
p
rivacy2PublicCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"priv2pub"
,
Short
:
"Public to privacy from toviewpubkey tospendpubkey amout note"
,
...
...
@@ -274,7 +275,7 @@ func privacy2Public(cmd *cobra.Command, args []string) {
ctx
.
Run
()
}
func
S
howPrivacyAccountSpendCmd
()
*
cobra
.
Command
{
func
s
howPrivacyAccountSpendCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"showpas"
,
Short
:
"Show privacy account spend command"
,
...
...
@@ -346,7 +347,7 @@ func parseShowPrivacyAccountSpendRes(arg interface{}) (interface{}, error) {
return
rets
,
nil
}
func
S
howAmountsOfUTXOCmd
()
*
cobra
.
Command
{
func
s
howAmountsOfUTXOCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"showau"
,
Short
:
"Show Amount of UTXO"
,
...
...
@@ -382,7 +383,7 @@ func parseShowAmountOfUTXORes(arg interface{}) (interface{}, error) {
return
res
,
nil
}
func
S
howUTXOs4SpecifiedAmountCmd
()
*
cobra
.
Command
{
func
s
howUTXOs4SpecifiedAmountCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"showutxo4a"
,
Short
:
"Show specified amount UTXOs"
,
...
...
@@ -432,7 +433,7 @@ func parseShowUTXOs4SpecifiedAmountRes(arg interface{}) (interface{}, error) {
return
ret
,
nil
}
func
C
reateUTXOsCmd
()
*
cobra
.
Command
{
func
c
reateUTXOsCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"createutxos"
,
Short
:
"Create specified count UTXOs with specified amount"
,
...
...
@@ -482,8 +483,8 @@ func createUTXOs(cmd *cobra.Command, args []string) {
ctx
.
Run
()
}
//
S
howPrivacyAccountInfoCmd
func
S
howPrivacyAccountInfoCmd
()
*
cobra
.
Command
{
//
s
howPrivacyAccountInfoCmd
func
s
howPrivacyAccountInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"showpai"
,
Short
:
"Show privacy account information"
,
...
...
@@ -573,7 +574,7 @@ func parseshowPrivacyAccountInfo(arg interface{}) (interface{}, error) {
return
ret
,
nil
}
func
L
istPrivacyTxsCmd
()
*
cobra
.
Command
{
func
l
istPrivacyTxsCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"list_txs"
,
Short
:
"List privacy transactions in wallet"
,
...
...
@@ -637,24 +638,24 @@ func parseWalletTxListRes(arg interface{}) (interface{}, error) {
return
result
,
nil
}
func
R
escanUtxosOptCmd
()
*
cobra
.
Command
{
func
r
escanUtxosOptCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"rescanOpt"
,
Short
:
"rescan Utxos in wallet and query rescan utxos status"
,
Run
:
R
escanUtxosOpt
,
Run
:
r
escanUtxosOpt
,
}
R
escanUtxosOptFlags
(
cmd
)
r
escanUtxosOptFlags
(
cmd
)
return
cmd
}
func
R
escanUtxosOptFlags
(
cmd
*
cobra
.
Command
)
{
func
r
escanUtxosOptFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"privacy rescanOpt -a [all-addr0-addr1] (all indicate all wallet address)"
)
cmd
.
MarkFlagRequired
(
"addr"
)
//
cmd
.
Flags
()
.
Int32P
(
"flag"
,
"f"
,
0
,
"Rescan or query rescan flag (0: Rescan, 1: query rescan)"
)
}
func
R
escanUtxosOpt
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
r
escanUtxosOpt
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
flag
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"flag"
)
...
...
@@ -677,41 +678,41 @@ func RescanUtxosOpt(cmd *cobra.Command, args []string) {
func
parseRescanUtxosOpt
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
pty
.
RepRescanUtxos
)
var
result
showRescanResults
if
0
==
res
.
Flag
{
str
:=
"start rescan UTXO"
return
str
,
nil
}
else
{
for
_
,
v
:=
range
res
.
RepRescanResults
{
str
,
ok
:=
pty
.
RescanFlagMapint2string
[
v
.
Flag
]
if
ok
{
showRescanResult
:=
&
ShowRescanResult
{
Addr
:
v
.
Addr
,
FlagString
:
str
,
}
result
.
RescanResults
=
append
(
result
.
RescanResults
,
showRescanResult
)
}
var
result
showRescanResults
for
_
,
v
:=
range
res
.
RepRescanResults
{
str
,
ok
:=
pty
.
RescanFlagMapint2string
[
v
.
Flag
]
if
ok
{
showRescanResult
:=
&
ShowRescanResult
{
Addr
:
v
.
Addr
,
FlagString
:
str
,
}
result
.
RescanResults
=
append
(
result
.
RescanResults
,
showRescanResult
)
}
return
&
result
,
nil
}
return
&
result
,
nil
}
func
E
nablePrivacyCmd
()
*
cobra
.
Command
{
func
e
nablePrivacyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"enable"
,
Short
:
"enable privacy address in wallet"
,
Run
:
E
nablePrivacy
,
Run
:
e
nablePrivacy
,
}
E
nablePrivacyFlags
(
cmd
)
e
nablePrivacyFlags
(
cmd
)
return
cmd
}
func
E
nablePrivacyFlags
(
cmd
*
cobra
.
Command
)
{
func
e
nablePrivacyFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"privacy enable -a [all-addr0-addr1] (all indicate enable all wallet address)"
)
cmd
.
MarkFlagRequired
(
"addr"
)
}
func
E
nablePrivacy
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
e
nablePrivacy
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
...
...
@@ -725,7 +726,7 @@ func EnablePrivacy(cmd *cobra.Command, args []string) {
}
var
res
pty
.
RepEnablePrivacy
ctx
:=
jsonclient
.
NewRpcCtx
(
rpcLaddr
,
"privacy.
E
nablePrivacy"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewRpcCtx
(
rpcLaddr
,
"privacy.
e
nablePrivacy"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseEnablePrivacy
)
ctx
.
Run
()
}
...
...
plugin/dapp/privacy/commands/types.go
View file @
4875a477
...
...
@@ -4,6 +4,7 @@
package
commands
// PrivacyAccountResult display privacy account result
type
PrivacyAccountResult
struct
{
Token
string
`json:"Token,omitempty"`
Txhash
string
`json:"Txhash,omitempty"`
...
...
@@ -12,6 +13,7 @@ type PrivacyAccountResult struct {
OnetimePubKey
string
`json:"OnetimePubKey,omitempty"`
}
// PrivacyAccountInfoResult display privacy account information result
type
PrivacyAccountInfoResult
struct
{
AvailableDetail
[]
*
PrivacyAccountResult
`json:"AvailableDetail,omitempty"`
FrozenDetail
[]
*
PrivacyAccountResult
`json:"FrozenDetail,omitempty"`
...
...
@@ -20,11 +22,13 @@ type PrivacyAccountInfoResult struct {
TotalAmount
string
`json:"TotalAmount,omitempty"`
}
// PrivacyAccountSpendResult display privacy account spend result
type
PrivacyAccountSpendResult
struct
{
Txhash
string
`json:"Txhash,omitempty"`
Res
[]
*
PrivacyAccountResult
`json:"Spend,omitempty"`
}
// ShowRescanResult display rescan utxos result
type
ShowRescanResult
struct
{
Addr
string
`json:"addr"`
FlagString
string
`json:"FlagString"`
...
...
@@ -34,10 +38,12 @@ type showRescanResults struct {
RescanResults
[]
*
ShowRescanResult
`json:"ShowRescanResults,omitempty"`
}
// ShowEnablePrivacy display enable privacy
type
ShowEnablePrivacy
struct
{
Results
[]
*
ShowPriAddrResult
`json:"results"`
}
// ShowPriAddrResult display privacy address result
type
ShowPriAddrResult
struct
{
Addr
string
`json:"addr"`
IsOK
bool
`json:"IsOK"`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment