def atomic_to_decimal(amount: int) -> Decimal: """ Convert an integer atomic monero amount into a normal Decimal amount >>> MoneroRPC.atomic_to_decimal(10000000000000) Decimal('10') """ return atomic_to_decimal(amount)
def balance(self, address: str = None, memo: str = None, memo_case: bool = False) -> Decimal: total_bal = Decimal('0') with self.wallet(self.symbol) as w: # type: MoneroRPC account_id = self.account_id(symbol=self.symbol) bal = w.get_balance(account_index=account_id) # log.debug('Balance data: %s', bal) if address is None: return atomic_to_decimal(bal['balance']) for a in bal['per_subaddress']: log.debug('Sub-address: %s', a) if a['address'] == address: total_bal += atomic_to_decimal(a['balance']) return total_bal
def decimal_amount(self) -> Decimal: """Return the atomic integer :py:attr:`.amount` as a normal Decimal amount""" return atomic_to_decimal(self.amount)