Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit d9ae824

Browse files
committed
[#1839] Fix math logic for Moderator Fixed Fee plus Percentage
1 parent e4fef18 commit d9ae824

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/moderation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ func (n *OpenBazaarNode) GetModeratorFee(transactionTotal *big.Int, txCurrencyCo
221221
}
222222
f := big.NewFloat(float64(profile.ModeratorInfo.Fee.Percentage))
223223
f.Mul(f, big.NewFloat(0.01))
224-
t.Mul(t, f)
225-
total, _ := t.Int(transactionTotal)
226-
if fixed.Add(fixed, total).Cmp(transactionTotal) > 0 {
224+
percentAmt, _ := new(big.Float).Mul(t, f).Int(nil)
225+
feeTotal := new(big.Int).Add(fixed, percentAmt)
226+
if feeTotal.Cmp(transactionTotal) > 0 {
227227
return big.NewInt(0), errors.New("Fixed moderator fee exceeds transaction amount")
228228
}
229-
return fixed.Add(fixed, total), nil
229+
return feeTotal, nil
230230
default:
231231
return big.NewInt(0), errors.New("Unrecognized fee type")
232232
}

0 commit comments

Comments
 (0)