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
563677cd
Commit
563677cd
authored
May 14, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into add_rpc_test
parents
f1eb4a2f
2ad7ca35
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
237 additions
and
70 deletions
+237
-70
para.go
plugin/consensus/para/para.go
+11
-4
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+62
-30
paranode_test.go
plugin/consensus/para/paranode_test.go
+11
-13
build.sh
plugin/dapp/privacy/cmd/build.sh
+4
-0
test-rpc.sh
plugin/dapp/privacy/cmd/build/test-rpc.sh
+135
-0
privacy.go
plugin/dapp/privacy/commands/privacy.go
+2
-2
rpc.go
plugin/dapp/privacy/rpc/rpc.go
+4
-4
rpc_channel_test.go
plugin/dapp/privacy/rpc/rpc_channel_test.go
+1
-1
rpc_test.go
plugin/dapp/privacy/rpc/rpc_test.go
+1
-1
privacybizpolicy_test.go
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
+2
-2
privacystore.go
plugin/dapp/privacy/wallet/privacystore.go
+4
-13
No files found.
plugin/consensus/para/para.go
View file @
563677cd
...
...
@@ -156,6 +156,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
commitMsgNotify
:
make
(
chan
int64
,
1
),
delMsgNotify
:
make
(
chan
int64
,
1
),
mainBlockAdd
:
make
(
chan
*
types
.
BlockDetail
,
1
),
minerSwitch
:
make
(
chan
bool
,
1
),
quit
:
make
(
chan
struct
{}),
}
c
.
SetChild
(
para
)
...
...
@@ -816,16 +817,22 @@ func checkMinerTx(current *types.BlockDetail) error {
// Query_CreateNewAccount 通知para共识模块钱包创建了一个新的账户
func
(
client
*
client
)
Query_CreateNewAccount
(
acc
*
types
.
Account
)
(
types
.
Message
,
error
)
{
plog
.
Info
(
"Query_CreateNewAccount"
,
"acc"
,
acc
)
if
acc
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
plog
.
Info
(
"Query_CreateNewAccount"
,
"acc"
,
acc
.
Addr
)
// 需要para共识这边处理新创建的账户是否是超级节点发送commit共识交易的账户
// 需要实现具体处理 to be。。。。
client
.
commitMsgClient
.
onWalletAccount
(
acc
)
return
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
[]
byte
(
"OK"
)},
nil
}
// Query_WalletStatus 通知para共识模块钱包锁状态有变化
func
(
client
*
client
)
Query_WalletStatus
(
walletStatus
*
types
.
WalletStatus
)
(
types
.
Message
,
error
)
{
plog
.
Info
(
"Query_WalletStatus"
,
"walletStatus"
,
walletStatus
)
if
walletStatus
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
plog
.
Info
(
"Query_WalletStatus"
,
"walletStatus"
,
walletStatus
.
IsWalletLock
)
// 需要para共识这边根据walletStatus.IsWalletLock锁的状态开启/关闭发送共识交易
// 需要实现具体处理 to be。。。。
client
.
commitMsgClient
.
onWalletStatus
(
walletStatus
)
return
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
[]
byte
(
"OK"
)},
nil
}
plugin/consensus/para/paracommitmsg.go
View file @
563677cd
...
...
@@ -19,6 +19,7 @@ import (
var
(
consensusInterval
=
16
//about 1 new block interval
minerInterval
=
2
)
type
commitMsgClient
struct
{
...
...
@@ -27,6 +28,7 @@ type commitMsgClient struct {
commitMsgNotify
chan
int64
delMsgNotify
chan
int64
mainBlockAdd
chan
*
types
.
BlockDetail
minerSwitch
chan
bool
currentTx
*
types
.
Transaction
checkTxCommitTimes
int32
privateKey
crypto
.
PrivKey
...
...
@@ -41,16 +43,13 @@ func (client *commitMsgClient) handler() {
var
sendingHeight
int64
//当前发送的最大高度
var
sendingMsgs
[]
*
pt
.
ParacrossNodeStatus
var
readTick
<-
chan
time
.
Time
var
ticker
*
time
.
Ticker
client
.
paraClient
.
wg
.
Add
(
1
)
consensusCh
:=
make
(
chan
*
pt
.
ParacrossStatus
,
1
)
go
client
.
getConsensusHeight
(
consensusCh
)
client
.
paraClient
.
wg
.
Add
(
1
)
priKeyCh
:=
make
(
chan
crypto
.
PrivKey
,
1
)
go
client
.
fetchPrivacyKey
(
priKeyCh
)
client
.
paraClient
.
wg
.
Add
(
1
)
sendMsgCh
:=
make
(
chan
*
types
.
Transaction
,
1
)
go
client
.
sendCommitMsg
(
sendMsgCh
)
...
...
@@ -155,7 +154,7 @@ out:
case
rsp
:=
<-
consensusCh
:
consensHeight
:=
rsp
.
Height
plog
.
Info
(
"para consensus rcv"
,
"notify"
,
notification
,
"sending"
,
len
(
sendingMsgs
),
"consensHeigt"
,
rsp
.
Height
,
"finished"
,
finishHeight
,
"sync"
,
isSync
,
"consensBlockHash"
,
common
.
ToHex
(
rsp
.
BlockHash
))
"consensHeigt"
,
rsp
.
Height
,
"finished"
,
finishHeight
,
"sync"
,
isSync
,
"
miner"
,
readTick
!=
nil
,
"
consensBlockHash"
,
common
.
ToHex
(
rsp
.
BlockHash
))
if
notification
==
nil
||
isRollback
{
continue
...
...
@@ -194,13 +193,23 @@ out:
isSync
=
true
}
case
key
,
ok
:=
<-
priKeyCh
:
if
!
ok
{
priKeyCh
=
nil
case
miner
:=
<-
client
.
minerSwitch
:
plog
.
Info
(
"para consensus mining"
,
"miner"
,
miner
)
//停止挖矿
if
!
miner
{
readTick
=
nil
if
ticker
!=
nil
{
ticker
.
Stop
()
}
plog
.
Info
(
"para consensus stop mining"
)
continue
}
client
.
privateKey
=
key
readTick
=
time
.
Tick
(
time
.
Second
*
2
)
//开启挖矿
if
readTick
==
nil
{
ticker
=
time
.
NewTicker
(
time
.
Second
*
time
.
Duration
(
minerInterval
))
readTick
=
ticker
.
C
plog
.
Info
(
"para consensus start mining"
)
}
case
<-
client
.
quit
:
break
out
...
...
@@ -575,51 +584,74 @@ func (client *commitMsgClient) getConsensusStatus(block *types.Block) (*pt.Parac
}
func
(
client
*
commitMsgClient
)
fetchPrivacyKey
(
ch
chan
crypto
.
PrivKey
)
{
defer
client
.
paraClient
.
wg
.
Done
()
if
client
.
paraClient
.
authAccount
==
""
{
close
(
ch
)
func
(
client
*
commitMsgClient
)
onWalletStatus
(
status
*
types
.
WalletStatus
)
{
if
status
==
nil
||
client
.
paraClient
.
authAccount
==
""
{
return
}
if
!
status
.
IsWalletLock
&&
client
.
privateKey
==
nil
{
client
.
fetchPriKey
()
plog
.
Info
(
"para commit fetchPriKey"
)
}
if
client
.
privateKey
==
nil
{
plog
.
Info
(
"para commit wallet status prikey null"
,
"status"
,
status
.
IsWalletLock
)
return
}
req
:=
&
types
.
ReqString
{
Data
:
client
.
paraClient
.
authAccount
}
out
:
for
{
select
{
case
client
.
minerSwitch
<-
!
status
.
IsWalletLock
:
case
<-
client
.
quit
:
break
out
case
<-
time
.
NewTimer
(
time
.
Second
*
2
)
.
C
:
}
}
func
(
client
*
commitMsgClient
)
onWalletAccount
(
acc
*
types
.
Account
)
{
if
acc
==
nil
||
client
.
paraClient
.
authAccount
==
""
||
client
.
paraClient
.
authAccount
!=
acc
.
Addr
||
client
.
privateKey
!=
nil
{
return
}
err
:=
client
.
fetchPriKey
()
if
err
!=
nil
{
plog
.
Error
(
"para commit fetchPriKey"
,
"err"
,
err
.
Error
())
return
}
select
{
case
client
.
minerSwitch
<-
true
:
case
<-
client
.
quit
:
}
}
func
(
client
*
commitMsgClient
)
fetchPriKey
()
error
{
req
:=
&
types
.
ReqString
{
Data
:
client
.
paraClient
.
authAccount
}
msg
:=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"wallet"
,
types
.
EventDumpPrivkey
,
req
)
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
if
err
!=
nil
{
plog
.
Error
(
"para commit send msg"
,
"err"
,
err
.
Error
())
break
out
return
err
}
resp
,
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Wait
(
msg
)
if
err
!=
nil
{
plog
.
Error
(
"para commit msg sign to wallet"
,
"err"
,
err
.
Error
())
continue
return
err
}
str
:=
resp
.
GetData
()
.
(
*
types
.
ReplyString
)
.
Data
pk
,
err
:=
common
.
FromHex
(
str
)
if
err
!=
nil
&&
pk
==
nil
{
panic
(
err
)
return
err
}
secp
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
if
err
!=
nil
{
panic
(
err
)
return
err
}
priKey
,
err
:=
secp
.
PrivKeyFromBytes
(
pk
)
if
err
!=
nil
{
panic
(
err
)
}
ch
<-
priKey
close
(
ch
)
break
out
}
plog
.
Error
(
"para commit msg get priKey"
,
"err"
,
err
.
Error
())
return
err
}
client
.
privateKey
=
priKey
plog
.
Info
(
"para commit fetchPriKey success"
)
return
nil
}
plugin/consensus/para/paranode_test.go
View file @
563677cd
...
...
@@ -50,42 +50,40 @@ func TestParaNode(t *testing.T) {
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
detail
.
Receipt
.
Ty
,
int32
(
types
.
ExecOk
))
testParaQuery
(
para
)
for
i
:=
0
;
i
<
3
;
i
++
{
tx
=
util
.
CreateTxWithExecer
(
para
.
Para
.
GetGenesisKey
(),
"user.p.guodun.none"
)
para
.
Para
.
SendTxRPC
(
tx
)
para
.
Para
.
WaitHeight
(
int64
(
i
)
+
1
)
}
testParaQuery
(
para
)
}
func
testParaQuery
(
para
*
node
.
ParaNode
)
{
var
param
types
.
ReqWalletImportPrivkey
param
.
Label
=
"Importprivkey"
param
.
Privkey
=
"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
var
acc
types
.
Account
acc
.
Addr
=
"1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF"
para
.
Para
.
GetAPI
()
.
Notify
(
"consensus"
,
types
.
EventConsensusQuery
,
&
types
.
ChainExecutor
{
Driver
:
"para"
,
FuncName
:
"CreateNewAccount"
,
Param
:
types
.
Encode
(
&
param
),
Param
:
types
.
Encode
(
&
acc
),
})
var
param1
types
.
ReqNewAccount
param1
.
Label
=
"NewAccount"
var
walletsatus
types
.
WalletStatus
walletsatus
.
IsWalletLock
=
true
para
.
Para
.
GetAPI
()
.
Notify
(
"consensus"
,
types
.
EventConsensusQuery
,
&
types
.
ChainExecutor
{
Driver
:
"para"
,
FuncName
:
"
CreateNewAccount
"
,
Param
:
types
.
Encode
(
&
param1
),
FuncName
:
"
WalletStatus
"
,
Param
:
types
.
Encode
(
&
walletsatus
),
})
var
walletsatus
types
.
WalletStatus
walletsatus
.
IsWalletLock
=
true
walletsatus
.
IsWalletLock
=
false
para
.
Para
.
GetAPI
()
.
Notify
(
"consensus"
,
types
.
EventConsensusQuery
,
&
types
.
ChainExecutor
{
Driver
:
"para"
,
FuncName
:
"WalletStatus"
,
Param
:
types
.
Encode
(
&
walletsatus
),
})
}
plugin/dapp/privacy/cmd/build.sh
View file @
563677cd
...
...
@@ -9,3 +9,7 @@ OUT_DIR="${1}/$strapp"
mkdir
-p
"
${
OUT_DIR
}
"
cp
./build/
*
"
${
OUT_DIR
}
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
mkdir
-p
"
${
OUT_TESTDIR
}
"
cp
./build/test-rpc.sh
"
${
OUT_TESTDIR
}
"
plugin/dapp/privacy/cmd/build/test-rpc.sh
0 → 100755
View file @
563677cd
#!/usr/bin/env bash
# shellcheck disable=SC2128
set
-e
set
-o
pipefail
MAIN_HTTP
=
""
PARA_HTTP
=
""
CASE_ERR
=
""
#color
RED
=
'\033[1;31m'
GRE
=
'\033[1;32m'
NOC
=
'\033[0m'
echo_rst
()
{
if
[
"
$2
"
==
true
]
;
then
echo
-e
"
${
GRE
}
$1
ok
${
NOC
}
"
else
echo
-e
"
${
RED
}
$1
fail
${
NOC
}
"
CASE_ERR
=
"FAIL"
fi
}
privacy_CreateRawTransaction
()
{
local
ip
=
$1
req
=
'"method":"privacy.CreateRawTransaction","params":[{"pubkeypair":"0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb", "tokenname":"BTY", "type":1, "amount":100000000}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'.error|not'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
privacy_GetPrivacyTxByAddr
()
{
local
ip
=
$1
req
=
'"method":"privacy.GetPrivacyTxByAddr","params":[{"tokenname":"BTY","sendRecvFlag":0,"from":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'.error|not'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
privacy_ShowPrivacyKey
()
{
local
ip
=
$1
req
=
'"method":"privacy.ShowPrivacyKey", "params":[{"data":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
privacy_ShowPrivacyAccountInfo
()
{
local
ip
=
$1
req
=
'"method":"privacy.ShowPrivacyAccountInfo", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY", "displaymode":1}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'(.error|not) and (.result|[has("utxos", "ftxos", "displaymode"), true] | unique | length == 1)'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
privacy_ShowPrivacyAccountSpend
()
{
local
ip
=
$1
req
=
'"method":"privacy.ShowPrivacyAccountSpend", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY"}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'(.error|not) and .result.utxoHaveTxHashs'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
privacy_RescanUtxos
()
{
local
ip
=
$1
req
=
'"method":"privacy.RescanUtxos", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"], "flag":0}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'(.error|not) and (.result|[has("flag", "repRescanResults"), true] | unique | length == 1)'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
privacy_EnablePrivacy
()
{
local
ip
=
$1
req
=
'"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]'
echo
"#request:
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
$ip
"
)
echo
"#response:
$resp
"
ok
=
$(
jq
'(.error|not) and .result.results[0].IsOK'
<<<
"
$resp
"
)
echo_rst
"
$FUNCNAME
"
"
$ok
"
}
function
run_test
()
{
local
ip
=
$1
privacy_EnablePrivacy
"
$ip
"
privacy_ShowPrivacyKey
"
$ip
"
privacy_CreateRawTransaction
"
$ip
"
privacy_ShowPrivacyAccountInfo
"
$ip
"
privacy_ShowPrivacyAccountSpend
"
$ip
"
privacy_RescanUtxos
"
$ip
"
privacy_GetPrivacyTxByAddr
"
$ip
"
}
function
main
()
{
local
ip
=
$1
MAIN_HTTP
=
"http://
$ip
:8801"
PARA_HTTP
=
"http://
$ip
:8901"
echo
"=========== # privacy rpc test ============="
echo
"main_ip=
$MAIN_HTTP
para_ip=
$PARA_HTTP
"
run_test
"
$MAIN_HTTP
"
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
-e
"
${
RED
}
=============Privacy Rpc Test Fail=============
${
NOC
}
"
exit
1
else
echo
-e
"
${
GRE
}
=============Prviacy Rpc Test Pass==============
${
NOC
}
"
fi
}
main
"
$1
"
plugin/dapp/privacy/commands/privacy.go
View file @
563677cd
...
...
@@ -75,7 +75,7 @@ func showPrivacyKey(cmd *cobra.Command, args []string) {
Data
:
addr
,
}
var
res
pty
.
ReplyPrivacyPkPair
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.ShowPrivacy
k
ey"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.ShowPrivacy
K
ey"
,
params
,
&
res
)
ctx
.
Run
()
}
...
...
@@ -601,7 +601,7 @@ func listPrivacyTxsFlags(cmd *cobra.Command, args []string) {
Seedtxhash
:
[]
byte
(
seedtxhash
),
}
var
res
rpctypes
.
WalletTxDetails
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.
PrivacyTxList
"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.
GetPrivacyTxByAddr
"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseWalletTxListRes
)
ctx
.
Run
()
}
...
...
plugin/dapp/privacy/rpc/rpc.go
View file @
563677cd
...
...
@@ -85,8 +85,8 @@ func (c *Jrpc) ShowPrivacyAccountSpend(in *pty.ReqPrivBal4AddrToken, result *jso
return
err
}
// ShowPrivacy
k
ey display privacy key for json rpc
func
(
c
*
Jrpc
)
ShowPrivacy
k
ey
(
in
*
types
.
ReqString
,
result
*
json
.
RawMessage
)
error
{
// ShowPrivacy
K
ey display privacy key for json rpc
func
(
c
*
Jrpc
)
ShowPrivacy
K
ey
(
in
*
types
.
ReqString
,
result
*
json
.
RawMessage
)
error
{
reply
,
err
:=
c
.
cli
.
ShowPrivacyKey
(
context
.
Background
(),
in
)
if
err
!=
nil
{
return
err
...
...
@@ -106,8 +106,8 @@ func (c *Jrpc) CreateUTXOs(in *pty.ReqCreateUTXOs, result *interface{}) error {
return
nil
}
//
PrivacyTxList
get all privacy transaction list by param
func
(
c
*
Jrpc
)
PrivacyTxList
(
in
*
pty
.
ReqPrivacyTransactionList
,
result
*
interface
{})
error
{
//
GetPrivacyTxByAddr
get all privacy transaction list by param
func
(
c
*
Jrpc
)
GetPrivacyTxByAddr
(
in
*
pty
.
ReqPrivacyTransactionList
,
result
*
interface
{})
error
{
if
in
.
Direction
!=
0
&&
in
.
Direction
!=
1
{
return
types
.
ErrInvalidParam
}
...
...
plugin/dapp/privacy/rpc/rpc_channel_test.go
View file @
563677cd
...
...
@@ -69,7 +69,7 @@ func testShowPrivacyKey(t *testing.T, jrpc *jsonclient.JSONClient) error {
params
:=
types
.
ReqString
{
Data
:
"1JSRSwp16NvXiTjYBYK9iUQ9wqp3sCxz2p"
,
}
err
:=
jrpc
.
Call
(
"privacy.ShowPrivacy
k
ey"
,
params
,
&
res
)
err
:=
jrpc
.
Call
(
"privacy.ShowPrivacy
K
ey"
,
params
,
&
res
)
return
err
}
...
...
plugin/dapp/privacy/rpc/rpc_test.go
View file @
563677cd
...
...
@@ -32,7 +32,7 @@ func TestChain33_PrivacyTxList(t *testing.T) {
actual
:=
&
pty
.
ReqPrivacyTransactionList
{}
api
.
On
(
"ExecWalletFunc"
,
"privacy"
,
"PrivacyTransactionList"
,
actual
)
.
Return
(
nil
,
errors
.
New
(
"error value"
))
var
testResult
interface
{}
err
:=
testChain33
.
PrivacyTxList
(
actual
,
&
testResult
)
err
:=
testChain33
.
GetPrivacyTxByAddr
(
actual
,
&
testResult
)
t
.
Log
(
err
)
assert
.
Equal
(
t
,
nil
,
testResult
)
assert
.
NotNil
(
t
,
err
)
...
...
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
View file @
563677cd
...
...
@@ -462,7 +462,7 @@ func Test_ShowPrivacyAccountSpend(t *testing.T) {
Addr
:
testAddrs
[
0
],
Token
:
types
.
BTY
,
},
needError
:
types
.
ErrNotFound
,
//
needError: types.ErrNotFound,
},
}
for
index
,
testCase
:=
range
testCases
{
...
...
@@ -491,7 +491,7 @@ func Test_PrivacyTransactionList(t *testing.T) {
Count
:
10
,
Address
:
testAddrs
[
0
],
},
needError
:
types
.
ErrTxNotExist
,
//
needError: types.ErrTxNotExist,
},
}
for
index
,
testCase
:=
range
testCases
{
...
...
plugin/dapp/privacy/wallet/privacystore.go
View file @
563677cd
...
...
@@ -243,10 +243,6 @@ func (store *privacyStore) getWalletPrivacyTxDetails(param *privacytypes.ReqPriv
}
txbytes
=
append
(
txbytes
,
value
)
}
if
len
(
txbytes
)
==
0
{
bizlog
.
Error
(
"getWalletPrivacyTxDetails does not exist tx!"
)
return
nil
,
types
.
ErrTxNotExist
}
}
else
{
list
:=
store
.
NewListHelper
()
...
...
@@ -267,11 +263,6 @@ func (store *privacyStore) getWalletPrivacyTxDetails(param *privacytypes.ReqPriv
}
txbytes
=
append
(
txbytes
,
value
)
}
if
len
(
txbytes
)
==
0
{
bizlog
.
Error
(
"getWalletPrivacyTxDetails does not exist tx!"
)
return
nil
,
types
.
ErrTxNotExist
}
}
txDetails
:=
new
(
types
.
WalletTxDetails
)
...
...
@@ -714,10 +705,10 @@ func (store *privacyStore) listSpendUTXOs(token, addr string) (*privacytypes.UTX
prefix
:=
calcSTXOPrefix4Addr
(
token
,
addr
)
list
:=
store
.
NewListHelper
()
Key4FTXOsInTxs
:=
list
.
PrefixScan
(
prefix
)
if
len
(
Key4FTXOsInTxs
)
==
0
{
bizlog
.
Error
(
"listSpendUTXOs "
,
"addr not exist"
,
addr
)
return
nil
,
types
.
ErrNotFound
}
//
if len(Key4FTXOsInTxs) == 0 {
//
bizlog.Error("listSpendUTXOs ", "addr not exist", addr)
//
return nil, types.ErrNotFound
//
}
var
utxoHaveTxHashs
privacytypes
.
UTXOHaveTxHashs
utxoHaveTxHashs
.
UtxoHaveTxHashs
=
make
([]
*
privacytypes
.
UTXOHaveTxHash
,
0
)
...
...
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