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
1f9fdfdf
Commit
1f9fdfdf
authored
Jan 24, 2019
by
jiangpeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify privacy tx fee
parent
12653f8f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
privacy.go
plugin/dapp/privacy/executor/privacy.go
+4
-6
privacy.go
plugin/dapp/privacy/wallet/privacy.go
+19
-7
No files found.
plugin/dapp/privacy/executor/privacy.go
View file @
1f9fdfdf
...
...
@@ -224,12 +224,6 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
if
action
.
Ty
==
pty
.
ActionPrivacy2Public
&&
action
.
GetPrivacy2Public
()
!=
nil
{
amount
=
action
.
GetPrivacy2Public
()
.
Amount
}
if
tx
.
Fee
<
pty
.
PrivacyTxFee
{
privacylog
.
Error
(
"PrivacyTrading CheckTx"
,
"txhash"
,
txhashstr
,
"fee set:"
,
tx
.
Fee
,
"required:"
,
pty
.
PrivacyTxFee
,
" error ErrPrivacyTxFeeNotEnough"
)
return
pty
.
ErrPrivacyTxFeeNotEnough
}
var
ringSignature
types
.
RingSignature
if
err
:=
types
.
Decode
(
tx
.
Signature
.
Signature
,
&
ringSignature
);
err
!=
nil
{
privacylog
.
Error
(
"PrivacyTrading CheckTx"
,
"txhash"
,
txhashstr
,
"Decode tx.Signature.Signature error "
,
err
)
...
...
@@ -276,6 +270,10 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
//平行链下的隐私交易,utxo不需要燃烧,fee只收取主链的bty,和utxo无关联
if
!
types
.
IsPara
()
{
if
tx
.
Fee
<
pty
.
PrivacyTxFee
{
privacylog
.
Error
(
"PrivacyTrading CheckTx"
,
"txhash"
,
txhashstr
,
"fee set:"
,
tx
.
Fee
,
"required:"
,
pty
.
PrivacyTxFee
,
" error ErrPrivacyTxFeeNotEnough"
)
return
pty
.
ErrPrivacyTxFeeNotEnough
}
var
feeAmount
int64
if
action
.
Ty
==
pty
.
ActionPrivacy2Privacy
{
feeAmount
=
totalInput
-
totalOutput
...
...
plugin/dapp/privacy/wallet/privacy.go
View file @
1f9fdfdf
...
...
@@ -606,15 +606,14 @@ func (policy *privacyPolicy) createPublic2PrivacyTx(req *types.ReqCreateTransact
Nonce
:
policy
.
getWalletOperate
()
.
Nonce
(),
To
:
address
.
ExecAddress
(
types
.
ExecName
(
privacytypes
.
PrivacyX
)),
}
tx
.
SetExpire
(
time
.
Duration
(
req
.
Expire
))
tx
.
Signature
=
&
types
.
Signature
{
Signature
:
types
.
Encode
(
&
privacytypes
.
PrivacySignatureParam
{
ActionType
:
action
.
Ty
,
}),
}
txSize
:=
types
.
Size
(
tx
)
+
types
.
SignatureSize
realFee
:=
int64
((
txSize
+
1023
)
>>
types
.
Size1Kshiftlen
)
*
types
.
GInt
(
"MinFee"
)
tx
.
Fee
=
realFee
tx
.
Fee
=
int64
((
txSize
+
1023
)
>>
types
.
Size1Kshiftlen
)
*
types
.
GInt
(
"MinFee"
)
return
tx
,
nil
}
...
...
@@ -622,7 +621,8 @@ func (policy *privacyPolicy) createPrivacy2PrivacyTx(req *types.ReqCreateTransac
//需要燃烧的utxo
utxoBurnedAmount
:=
privacytypes
.
PrivacyTxFee
if
types
.
IsPara
()
{
isPara
:=
types
.
IsPara
()
if
isPara
{
utxoBurnedAmount
=
0
}
buildInfo
:=
&
buildInputInfo
{
...
...
@@ -683,7 +683,13 @@ func (policy *privacyPolicy) createPrivacy2PrivacyTx(req *types.ReqCreateTransac
Nonce
:
policy
.
getWalletOperate
()
.
Nonce
(),
To
:
address
.
ExecAddress
(
types
.
ExecName
(
privacytypes
.
PrivacyX
)),
}
// 创建交易成功,将已经使用掉的UTXO冻结
tx
.
SetExpire
(
time
.
Duration
(
req
.
Expire
))
if
isPara
{
txSize
:=
types
.
Size
(
tx
)
+
types
.
SignatureSize
tx
.
Fee
=
int64
((
txSize
+
1023
)
>>
types
.
Size1Kshiftlen
)
*
types
.
GInt
(
"MinFee"
)
}
// 创建交易成功,将已经使用掉的UTXO冻结,需要注意此处获取的txHash和交易发送时的一致
policy
.
saveFTXOInfo
(
tx
,
req
.
GetTokenname
(),
req
.
GetFrom
(),
hex
.
EncodeToString
(
tx
.
Hash
()),
selectedUtxo
)
tx
.
Signature
=
&
types
.
Signature
{
Signature
:
types
.
Encode
(
&
privacytypes
.
PrivacySignatureParam
{
...
...
@@ -699,7 +705,8 @@ func (policy *privacyPolicy) createPrivacy2PublicTx(req *types.ReqCreateTransact
//需要燃烧的utxo
utxoBurnedAmount
:=
privacytypes
.
PrivacyTxFee
if
types
.
IsPara
()
{
isPara
:=
types
.
IsPara
()
if
isPara
{
utxoBurnedAmount
=
0
}
buildInfo
:=
&
buildInputInfo
{
...
...
@@ -759,7 +766,12 @@ func (policy *privacyPolicy) createPrivacy2PublicTx(req *types.ReqCreateTransact
Nonce
:
policy
.
getWalletOperate
()
.
Nonce
(),
To
:
address
.
ExecAddress
(
types
.
ExecName
(
privacytypes
.
PrivacyX
)),
}
// 创建交易成功,将已经使用掉的UTXO冻结
tx
.
SetExpire
(
time
.
Duration
(
req
.
Expire
))
if
isPara
{
txSize
:=
types
.
Size
(
tx
)
+
types
.
SignatureSize
tx
.
Fee
=
int64
((
txSize
+
1023
)
>>
types
.
Size1Kshiftlen
)
*
types
.
GInt
(
"MinFee"
)
}
// 创建交易成功,将已经使用掉的UTXO冻结,需要注意此处获取的txHash和交易发送时的一致
policy
.
saveFTXOInfo
(
tx
,
req
.
GetTokenname
(),
req
.
GetFrom
(),
hex
.
EncodeToString
(
tx
.
Hash
()),
selectedUtxo
)
tx
.
Signature
=
&
types
.
Signature
{
Signature
:
types
.
Encode
(
&
privacytypes
.
PrivacySignatureParam
{
...
...
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