From ef7bd00f227ec6f91d6a4b8e6224dcc941694668 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 30 Mar 2019 23:46:14 -0400 Subject: [PATCH] round USD fees to nearest penny --- lbrynet/schema/claim.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lbrynet/schema/claim.py b/lbrynet/schema/claim.py index 58cfec4a7..74c0ac718 100644 --- a/lbrynet/schema/claim.py +++ b/lbrynet/schema/claim.py @@ -2,7 +2,7 @@ import os.path import json from string import ascii_letters from typing import List, Tuple, Iterator, TypeVar, Generic -from decimal import Decimal +from decimal import Decimal, ROUND_UP from binascii import hexlify, unhexlify from google.protobuf.json_format import MessageToDict @@ -301,7 +301,8 @@ class Fee: self._fee.amount = amount self._fee.currency = FeeMessage.BTC - PENNIES = Decimal(100.0) + PENNIES = Decimal('100.0') + PENNY = Decimal('0.01') @property def usd(self) -> Decimal: @@ -311,7 +312,7 @@ class Fee: @usd.setter def usd(self, amount: Decimal): - self.pennies = int(amount * self.PENNIES) + self.pennies = int(amount.quantize(self.PENNY, ROUND_UP) * self.PENNIES) @property def pennies(self) -> int: