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
f18b8d76
Commit
f18b8d76
authored
Mar 19, 2021
by
jiangpeng
Committed by
vipwzw
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
privacy:update rpc PrivacyTransactionList
parent
0559134e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
59 deletions
+40
-59
test-rpc.sh
plugin/dapp/privacy/cmd/test/test-rpc.sh
+1
-1
privacy.go
plugin/dapp/privacy/commands/privacy.go
+7
-7
privacy.proto
plugin/dapp/privacy/proto/privacy.proto
+9
-4
rpc_channel_test.go
plugin/dapp/privacy/rpc/rpc_channel_test.go
+1
-2
privacy.pb.go
plugin/dapp/privacy/types/privacy.pb.go
+0
-0
keys.go
plugin/dapp/privacy/wallet/keys.go
+2
-3
privacybizpolicy_test.go
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
+1
-1
privacystore.go
plugin/dapp/privacy/wallet/privacystore.go
+19
-41
No files found.
plugin/dapp/privacy/cmd/test/test-rpc.sh
View file @
f18b8d76
...
...
@@ -14,7 +14,7 @@ privacy_CreateRawTransaction() {
}
privacy_GetPrivacyTxByAddr
()
{
chain33_Http
'{"method":"privacy.GetPrivacyTxByAddr","params":[{"assetExec":"coins", "
tokenname":"BTY","sendRecvFlag":0,"from
":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]}'
${
MAIN_HTTP
}
'.error|not'
"
$FUNCNAME
"
chain33_Http
'{"method":"privacy.GetPrivacyTxByAddr","params":[{"assetExec":"coins", "
assetSymbol":"BTY","sendRecvFlag":0,"address
":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]}'
${
MAIN_HTTP
}
'.error|not'
"
$FUNCNAME
"
}
privacy_ShowPrivacyKey
()
{
...
...
plugin/dapp/privacy/commands/privacy.go
View file @
f18b8d76
...
...
@@ -549,12 +549,12 @@ func addListPrivacyTxsFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"account address"
)
cmd
.
MarkFlagRequired
(
"addr"
)
//
cmd
.
Flags
()
.
Int32P
(
"sendrecv"
,
""
,
0
,
"send or recv flag (0: send, 1: recv), default 0"
)
cmd
.
Flags
()
.
Int32P
(
"sendrecv"
,
"
f
"
,
0
,
"send or recv flag (0: send, 1: recv), default 0"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
10
,
"number of transactions, default 10"
)
cmd
.
Flags
()
.
StringP
(
"exec"
,
"e"
,
"coins"
,
"asset executor(coins, token, paracross), default coins"
)
cmd
.
Flags
()
.
StringP
(
"
token"
,
""
,
types
.
BTY
,
"token name.(BTY supported
)"
)
cmd
.
Flags
()
.
StringP
(
"
symbol"
,
"s"
,
types
.
BTY
,
"asset sysmbol.(BTY default
)"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
1
,
"query direction (0: pre page, 1: next page), valid with seedtxhash param"
)
cmd
.
Flags
()
.
StringP
(
"
seedtxhash"
,
""
,
""
,
"seed trasnaction hash
"
)
cmd
.
Flags
()
.
StringP
(
"
txHeightIndex"
,
"x"
,
""
,
"start tx height index string
"
)
}
func
listPrivacyTxsFlags
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
@@ -563,17 +563,17 @@ func listPrivacyTxsFlags(cmd *cobra.Command, args []string) {
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
sendRecvFlag
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"sendrecv"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"token
"
)
seedtxhash
,
_
:=
cmd
.
Flags
()
.
GetString
(
"seedtxhash
"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol
"
)
txHeightIndex
,
_
:=
cmd
.
Flags
()
.
GetString
(
"txHeightIndex
"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
params
:=
pty
.
ReqPrivacyTransactionList
{
AssetExec
:
exec
,
Tokenname
:
tokenname
,
AssetSymbol
:
symbol
,
SendRecvFlag
:
sendRecvFlag
,
Direction
:
direction
,
Count
:
count
,
Address
:
addr
,
S
eedtxhash
:
[]
byte
(
seedtxhash
)
,
S
tartTxHeightIndex
:
txHeightIndex
,
}
var
res
rpctypes
.
WalletTxDetails
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.GetPrivacyTxByAddr"
,
params
,
&
res
)
...
...
plugin/dapp/privacy/proto/privacy.proto
View file @
f18b8d76
...
...
@@ -344,16 +344,21 @@ message ReqCreateCacheTxKey {
// get privacy transaction list in wallet
message
ReqPrivacyTransactionList
{
// support BTY
string
tokenname
=
1
;
// 1:sendtx 2:recvtx
int32
sendRecvFlag
=
2
;
// 列表顺序,0降1升
int32
direction
=
3
;
// 单次列表数量
int32
count
=
4
;
string
from
=
5
;
// 交易相关的地址,发送方或接收方
string
address
=
6
;
bytes
seedtxhash
=
7
;
// 资产执行器
string
assetExec
=
8
;
// 资产符号
string
assetSymbol
=
9
;
// 指定列表请求开始位置
string
startTxHeightIndex
=
10
;
}
message
ReqRescanUtxos
{
...
...
plugin/dapp/privacy/rpc/rpc_channel_test.go
View file @
f18b8d76
...
...
@@ -122,12 +122,11 @@ func testShowUTXOs4SpecifiedAmount(t *testing.T, jrpc *jsonclient.JSONClient) er
func
testListPrivacyTxs
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
params
:=
pty
.
ReqPrivacyTransactionList
{
Tokenname
:
types
.
BTY
,
AssetSymbol
:
types
.
BTY
,
SendRecvFlag
:
1
,
Direction
:
1
,
Count
:
16
,
Address
:
"13cS5G1BDN2YfGudsxRxr7X25yu6ZdgxMU"
,
Seedtxhash
:
[]
byte
(
"0xa64296792f90f364371e0b66fdac622080ceb7b2537ff9152e189aa9e88e61bd"
),
}
var
res
rpctypes
.
WalletTxDetails
err
:=
jrpc
.
Call
(
"privacy.GetPrivacyTxByAddr"
,
params
,
&
res
)
...
...
plugin/dapp/privacy/types/privacy.pb.go
View file @
f18b8d76
This diff is collapsed.
Click to expand it.
plugin/dapp/privacy/wallet/keys.go
View file @
f18b8d76
...
...
@@ -107,9 +107,8 @@ func calcFTXOsKeyPrefix(assetExec, token, addr string) []byte {
// calcSendPrivacyTxKey 计算以指定地址作为发送地址的交易信息索引
// addr为发送地址
// key为通过calcTxKey(heightstr)计算出来的值
func
calcSendPrivacyTxKey
(
assetExec
,
tokenname
,
addr
,
key
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%s-%s-%s-%s"
,
SendPrivacyTx
,
assetExec
,
tokenname
,
addr
,
key
))
func
calcSendPrivacyTxKey
(
assetExec
,
assetSymbol
,
addr
,
txHeightIndex
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%s-%s-%s-%s"
,
SendPrivacyTx
,
assetExec
,
assetSymbol
,
addr
,
txHeightIndex
))
}
// calcRecvPrivacyTxKey 计算以指定地址作为接收地址的交易信息索引
...
...
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
View file @
f18b8d76
...
...
@@ -457,7 +457,7 @@ func Test_PrivacyTransactionList(t *testing.T) {
},
{
req
:
&
ty
.
ReqPrivacyTransactionList
{
Tokenname
:
types
.
BTY
,
AssetSymbol
:
types
.
BTY
,
SendRecvFlag
:
1
,
Direction
:
0
,
Count
:
10
,
...
...
plugin/dapp/privacy/wallet/privacystore.go
View file @
f18b8d76
...
...
@@ -222,68 +222,46 @@ func (store *privacyStore) getWalletPrivacyTxDetails(param *privacytypes.ReqPriv
bizlog
.
Error
(
"procPrivacyTransactionList"
,
"invalid sendrecvflag "
,
param
.
SendRecvFlag
)
return
nil
,
types
.
ErrInvalidParam
}
var
txbytes
[][]
byte
list
:=
store
.
NewListHelper
()
if
len
(
param
.
Seedtxhash
)
==
0
{
var
txKeyBytes
[][]
byte
if
len
(
param
.
StartTxHeightIndex
)
==
0
{
var
keyPrefix
[]
byte
if
param
.
SendRecvFlag
==
sendTx
{
keyPrefix
=
calcSendPrivacyTxKey
(
param
.
AssetExec
,
param
.
Tokenname
,
param
.
Address
,
""
)
keyPrefix
=
calcSendPrivacyTxKey
(
param
.
AssetExec
,
param
.
AssetSymbol
,
param
.
Address
,
""
)
}
else
{
keyPrefix
=
calcRecvPrivacyTxKey
(
param
.
AssetExec
,
param
.
Tokenname
,
param
.
Address
,
""
)
}
txkeybytes
:=
list
.
IteratorScanFromLast
(
keyPrefix
,
param
.
Count
,
db
.
ListDESC
)
for
_
,
keybyte
:=
range
txkeybytes
{
value
,
err
:=
store
.
Get
(
keybyte
)
if
err
!=
nil
{
bizlog
.
Error
(
"getWalletPrivacyTxDetails"
,
"db Get error"
,
err
)
continue
}
if
nil
==
value
{
continue
}
txbytes
=
append
(
txbytes
,
value
)
keyPrefix
=
calcRecvPrivacyTxKey
(
param
.
AssetExec
,
param
.
AssetSymbol
,
param
.
Address
,
""
)
}
txKeyBytes
=
list
.
IteratorScanFromLast
(
keyPrefix
,
param
.
Count
,
db
.
ListDESC
)
}
else
{
list
:=
store
.
NewListHelper
()
var
txkeybytes
[][]
byte
if
param
.
SendRecvFlag
==
sendTx
{
tx
keybytes
=
list
.
IteratorScan
([]
byte
(
SendPrivacyTx
),
calcSendPrivacyTxKey
(
param
.
AssetExec
,
param
.
Tokenname
,
param
.
Address
,
string
(
param
.
Seedtxhash
)
),
param
.
Count
,
param
.
Direction
)
tx
KeyBytes
=
list
.
IteratorScan
([]
byte
(
SendPrivacyTx
),
calcSendPrivacyTxKey
(
param
.
AssetExec
,
param
.
AssetSymbol
,
param
.
Address
,
param
.
StartTxHeightIndex
),
param
.
Count
,
param
.
Direction
)
}
else
{
tx
keybytes
=
list
.
IteratorScan
([]
byte
(
RecvPrivacyTx
),
calcRecvPrivacyTxKey
(
param
.
AssetExec
,
param
.
Tokenname
,
param
.
Address
,
string
(
param
.
Seedtxhash
)
),
param
.
Count
,
param
.
Direction
)
tx
KeyBytes
=
list
.
IteratorScan
([]
byte
(
RecvPrivacyTx
),
calcRecvPrivacyTxKey
(
param
.
AssetExec
,
param
.
AssetSymbol
,
param
.
Address
,
param
.
StartTxHeightIndex
),
param
.
Count
,
param
.
Direction
)
}
for
_
,
keybyte
:=
range
txkeybytes
{
value
,
err
:=
store
.
Get
(
keybyte
)
if
err
!=
nil
{
bizlog
.
Error
(
"getWalletPrivacyTxDetails"
,
"db Get error"
,
err
)
continue
}
if
nil
==
value
{
txDetails
:=
&
types
.
WalletTxDetails
{}
for
_
,
keyByte
:=
range
txKeyBytes
{
value
,
err
:=
store
.
Get
(
keyByte
)
if
err
!=
nil
||
value
==
nil
{
bizlog
.
Error
(
"getWalletPrivacyTxDetails"
,
"db Get error"
,
err
)
continue
}
txbytes
=
append
(
txbytes
,
value
)
}
}
txDetails
:=
new
(
types
.
WalletTxDetails
)
txDetails
.
TxDetails
=
make
([]
*
types
.
WalletTxDetail
,
len
(
txbytes
))
for
index
,
txdetailbyte
:=
range
txbytes
{
var
txdetail
types
.
WalletTxDetail
err
:=
proto
.
Unmarshal
(
txdetailbyte
,
&
txdetail
)
txDetail
:=
&
types
.
WalletTxDetail
{}
err
=
types
.
Decode
(
value
,
txDetail
)
if
err
!=
nil
{
bizlog
.
Error
(
"getWalletPrivacyTxDetails"
,
"proto.Unmarshal err:"
,
err
)
return
nil
,
types
.
ErrUnmarshal
}
txhash
:=
txdetail
.
GetTx
()
.
Hash
()
txdetail
.
Txhash
=
txhash
if
txdetail
.
GetTx
()
.
IsWithdraw
()
{
txDetail
.
Txhash
=
txDetail
.
GetTx
()
.
Hash
()
if
txDetail
.
GetTx
()
.
IsWithdraw
()
{
//swap from and to
tx
detail
.
Fromaddr
,
txdetail
.
Tx
.
To
=
txdetail
.
Tx
.
To
,
txd
etail
.
Fromaddr
tx
Detail
.
Fromaddr
,
txDetail
.
Tx
.
To
=
txDetail
.
Tx
.
To
,
txD
etail
.
Fromaddr
}
txDetails
.
TxDetails
[
index
]
=
&
txdetail
txDetails
.
TxDetails
=
append
(
txDetails
.
TxDetails
,
txDetail
)
}
return
txDetails
,
nil
}
...
...
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