Commit 1f9fdfdf authored by jiangpeng's avatar jiangpeng

modify privacy tx fee

parent 12653f8f
......@@ -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
......
......@@ -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{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment