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
556879c1
Unverified
Commit
556879c1
authored
Jan 24, 2019
by
vipwzw
Committed by
GitHub
Jan 24, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #265 from bysomeone/modify-privacy-txFee
modify privacy tx fee
parents
12653f8f
16afdc44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
15 deletions
+35
-15
privacy.go
plugin/dapp/privacy/executor/privacy.go
+4
-6
privacy.go
plugin/dapp/privacy/wallet/privacy.go
+31
-9
No files found.
plugin/dapp/privacy/executor/privacy.go
View file @
556879c1
...
...
@@ -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 @
556879c1
...
...
@@ -577,7 +577,7 @@ func (policy *privacyPolicy) createTransaction(req *types.ReqCreateTransaction)
func
(
policy
*
privacyPolicy
)
createPublic2PrivacyTx
(
req
*
types
.
ReqCreateTransaction
)
(
*
types
.
Transaction
,
error
)
{
viewPubSlice
,
spendPubSlice
,
err
:=
parseViewSpendPubKeyPair
(
req
.
GetPubkeypair
())
if
err
!=
nil
{
bizlog
.
Error
(
"parse view spend public key pair failed. err "
,
err
)
bizlog
.
Error
(
"
createPublic2PrivacyTx"
,
"
parse view spend public key pair failed. err "
,
err
)
return
nil
,
err
}
amount
:=
req
.
GetAmount
()
...
...
@@ -585,7 +585,7 @@ func (policy *privacyPolicy) createPublic2PrivacyTx(req *types.ReqCreateTransact
spendPublic
:=
(
*
[
32
]
byte
)(
unsafe
.
Pointer
(
&
spendPubSlice
[
0
]))
privacyOutput
,
err
:=
generateOuts
(
viewPublic
,
spendPublic
,
nil
,
nil
,
amount
,
amount
,
0
)
if
err
!=
nil
{
bizlog
.
Error
(
"generate output failed. err "
,
err
)
bizlog
.
Error
(
"
createPublic2PrivacyTx"
,
"
generate output failed. err "
,
err
)
return
nil
,
err
}
...
...
@@ -606,15 +606,18 @@ 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
,
}),
}
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
bizlog
.
Error
(
"createPublic2PrivacyTx"
,
"calc fee failed"
,
err
)
return
nil
,
err
}
txSize
:=
types
.
Size
(
tx
)
+
types
.
SignatureSize
realFee
:=
int64
((
txSize
+
1023
)
>>
types
.
Size1Kshiftlen
)
*
types
.
GInt
(
"MinFee"
)
tx
.
Fee
=
realFee
return
tx
,
nil
}
...
...
@@ -622,7 +625,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 +687,16 @@ 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
{
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
bizlog
.
Error
(
"createPrivacy2PrivacyTx"
,
"calc fee failed"
,
err
)
return
nil
,
err
}
}
// 创建交易成功,将已经使用掉的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 +712,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 +773,15 @@ 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
{
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
bizlog
.
Error
(
"createPrivacy2PublicTx"
,
"calc fee failed"
,
err
)
return
nil
,
err
}
}
// 创建交易成功,将已经使用掉的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