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
ded031ee
Commit
ded031ee
authored
Jul 31, 2019
by
jiangpeng
Committed by
vipwzw
Aug 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
privacy:support fork in test net
parent
4ea2a651
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
exec.go
plugin/dapp/privacy/executor/exec.go
+1
-1
kv.go
plugin/dapp/privacy/executor/kv.go
+11
-2
privacy.go
plugin/dapp/privacy/executor/privacy.go
+7
-8
No files found.
plugin/dapp/privacy/executor/exec.go
View file @
ded031ee
...
...
@@ -149,7 +149,7 @@ func (p *privacy) Exec_Privacy2Public(payload *ty.Privacy2Public, tx *types.Tran
func
(
p
*
privacy
)
createAccountDB
(
exec
,
symbol
string
)
(
*
account
.
DB
,
error
)
{
if
exec
==
"coins"
{
if
exec
==
"
"
||
exec
==
"
coins"
{
return
p
.
GetCoinsAccount
(),
nil
}
...
...
plugin/dapp/privacy/executor/kv.go
View file @
ded031ee
...
...
@@ -20,14 +20,23 @@ const (
invalidIndex
=
-
1
)
//计算隐私资产utxo的前缀, 和exec,token相关
func
calcUtxoAssetPrefix
(
exec
,
token
string
)
string
{
//只有coins资产的key不加exec前缀, 主要考虑是不加分叉兼容历史隐私交易
if
exec
==
""
||
exec
==
"coins"
{
return
token
}
return
exec
+
":"
+
token
}
//CalcPrivacyOutputKey 该key对应的是types.KeyOutput
//该kv会在store中设置
func
CalcPrivacyOutputKey
(
exec
,
token
string
,
amount
int64
,
txhash
string
,
outindex
int
)
(
key
[]
byte
)
{
return
[]
byte
(
fmt
.
Sprintf
(
privacyOutputKeyPrefix
+
"-%s-%
s-%d-%s-%d"
,
exec
,
token
,
amount
,
txhash
,
outindex
))
return
[]
byte
(
fmt
.
Sprintf
(
privacyOutputKeyPrefix
+
"-%s-%
d-%s-%d"
,
calcUtxoAssetPrefix
(
exec
,
token
)
,
amount
,
txhash
,
outindex
))
}
func
calcPrivacyKeyImageKey
(
exec
,
token
string
,
keyimage
[]
byte
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
privacyKeyImagePrefix
+
"-%s-%s
-%s"
,
exec
,
token
,
common
.
ToHex
(
keyimage
)))
return
[]
byte
(
fmt
.
Sprintf
(
privacyKeyImagePrefix
+
"-%s-%s
"
,
calcUtxoAssetPrefix
(
exec
,
token
)
,
common
.
ToHex
(
keyimage
)))
}
//CalcPrivacyUTXOkeyHeight 在本地数据库中设置一条可以找到对应amount的对应的utxo的global index
...
...
plugin/dapp/privacy/executor/privacy.go
View file @
ded031ee
...
...
@@ -208,6 +208,11 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
return
err
}
privacylog
.
Debug
(
"PrivacyTrading CheckTx"
,
"txhash"
,
txhashstr
,
"action type "
,
action
.
Ty
)
assertExec
:=
action
.
GetAssertExec
()
token
:=
action
.
GetTokenName
()
if
token
==
""
{
return
types
.
ErrInvalidParam
}
if
pty
.
ActionPublic2Privacy
==
action
.
Ty
{
return
nil
}
...
...
@@ -220,12 +225,6 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
//如果是私到私 或者私到公,交易费扣除则需要utxo实现,交易费并不生成真正的UTXO,也是即时燃烧掉而已
var
amount
int64
keyinput
:=
input
.
Keyinput
assertExec
:=
action
.
GetAssertExec
()
token
:=
action
.
GetTokenName
()
if
assertExec
==
""
||
token
==
""
{
return
types
.
ErrInvalidParam
}
if
action
.
Ty
==
pty
.
ActionPrivacy2Public
&&
action
.
GetPrivacy2Public
()
!=
nil
{
amount
=
action
.
GetPrivacy2Public
()
.
Amount
...
...
@@ -269,8 +268,8 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
return
pty
.
ErrPubkeysOfUTXO
}
//
平行链下的隐私交易,utxo不需要燃烧,fee只收取主链的bty,和utxo无关联
if
assertExec
==
"coins"
&&
!
types
.
IsPara
(
)
{
//
只有主链coins隐私转账才收取特殊交易费, assertExec空情况适配老版本
if
!
types
.
IsPara
()
&&
(
assertExec
==
""
||
assertExec
==
"coins"
)
{
for
_
,
output
:=
range
output
.
Keyoutput
{
totalOutput
+=
output
.
Amount
...
...
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