forked from LBRYCommunity/lbry-sdk
round USD fees to nearest penny
This commit is contained in:
parent
3c1fdb5114
commit
ef7bd00f22
1 changed files with 4 additions and 3 deletions
|
@ -2,7 +2,7 @@ import os.path
|
||||||
import json
|
import json
|
||||||
from string import ascii_letters
|
from string import ascii_letters
|
||||||
from typing import List, Tuple, Iterator, TypeVar, Generic
|
from typing import List, Tuple, Iterator, TypeVar, Generic
|
||||||
from decimal import Decimal
|
from decimal import Decimal, ROUND_UP
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
|
|
||||||
from google.protobuf.json_format import MessageToDict
|
from google.protobuf.json_format import MessageToDict
|
||||||
|
@ -301,7 +301,8 @@ class Fee:
|
||||||
self._fee.amount = amount
|
self._fee.amount = amount
|
||||||
self._fee.currency = FeeMessage.BTC
|
self._fee.currency = FeeMessage.BTC
|
||||||
|
|
||||||
PENNIES = Decimal(100.0)
|
PENNIES = Decimal('100.0')
|
||||||
|
PENNY = Decimal('0.01')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def usd(self) -> Decimal:
|
def usd(self) -> Decimal:
|
||||||
|
@ -311,7 +312,7 @@ class Fee:
|
||||||
|
|
||||||
@usd.setter
|
@usd.setter
|
||||||
def usd(self, amount: Decimal):
|
def usd(self, amount: Decimal):
|
||||||
self.pennies = int(amount * self.PENNIES)
|
self.pennies = int(amount.quantize(self.PENNY, ROUND_UP) * self.PENNIES)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pennies(self) -> int:
|
def pennies(self) -> int:
|
||||||
|
|
Loading…
Reference in a new issue