From 8e457707f0aee5ea53624ea72276981ac7270da1 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 1 Sep 2021 16:56:47 +0000 Subject: [PATCH] BTCAmt: remove 'min_coin_unit' attribute --- examples/halving-calculator.py | 2 +- mmgen/altcoins/eth/obj.py | 1 - mmgen/obj.py | 6 ++---- mmgen/tx.py | 4 ++-- mmgen/xmrwallet.py | 4 ++-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/examples/halving-calculator.py b/examples/halving-calculator.py index 15300600..0824a159 100755 --- a/examples/halving-calculator.py +++ b/examples/halving-calculator.py @@ -63,7 +63,7 @@ async def main(): bdr = (cur['time'] - old['time']) / sample_size t_rem = remaining * int(bdr) - sub = cur['subsidy'] * proto.coin_amt.min_coin_unit + sub = cur['subsidy'] * proto.coin_amt.satoshi print( f'Current block: {tip}\n' diff --git a/mmgen/altcoins/eth/obj.py b/mmgen/altcoins/eth/obj.py index 073ffe19..0df201b5 100755 --- a/mmgen/altcoins/eth/obj.py +++ b/mmgen/altcoins/eth/obj.py @@ -33,7 +33,6 @@ class ETHAmt(BTCAmt): Gwei = Decimal('0.000000001') szabo = Decimal('0.000001') finney = Decimal('0.001') - min_coin_unit = wei units = ('wei','Kwei','Mwei','Gwei','szabo','finney') amt_fs = '4.18' diff --git a/mmgen/obj.py b/mmgen/obj.py index 521c23d1..47e17237 100755 --- a/mmgen/obj.py +++ b/mmgen/obj.py @@ -456,12 +456,10 @@ class BTCAmt(Decimal,Hilite,InitErrors): max_prec = 8 max_amt = 21000000 satoshi = Decimal('0.00000001') - min_coin_unit = satoshi amt_fs = '4.8' units = ('satoshi',) forbidden_types = (float,int) - # NB: 'from_decimal' rounds down to precision of 'min_coin_unit' def __new__(cls,num,from_unit=None,from_decimal=False): if type(num) == cls: return num @@ -546,9 +544,9 @@ class BCHAmt(BTCAmt): pass class B2XAmt(BTCAmt): pass class LTCAmt(BTCAmt): max_amt = 84000000 class XMRAmt(BTCAmt): - units = ('min_coin_unit','atomic') - min_coin_unit = atomic = Decimal('0.000000000001') max_prec = 12 + atomic = Decimal('0.000000000001') + units = ('atomic',) from .altcoins.eth.obj import ETHAmt,ETHNonce diff --git a/mmgen/tx.py b/mmgen/tx.py index ea78d46b..3f0808c5 100755 --- a/mmgen/tx.py +++ b/mmgen/tx.py @@ -116,7 +116,7 @@ class DeserializedTX(dict,MMGenObject): return int(bytes_le[::-1].hex(),16) def bytes2coin_amt(bytes_le): - return proto.coin_amt(bytes2int(bytes_le) * proto.coin_amt.min_coin_unit) + return proto.coin_amt(bytes2int(bytes_le) * proto.coin_amt.satoshi) def bshift(n,skip=False,sub_null=False): ret = tx[self.idx:self.idx+n] @@ -461,7 +461,7 @@ class MMGenTX: # convert absolute BTC fee to satoshis-per-byte using estimated size def fee_abs2rel(self,abs_fee,to_unit=None): - unit = getattr(self.proto.coin_amt,to_unit or 'min_coin_unit') + unit = getattr(self.proto.coin_amt,to_unit or 'satoshi') return int(abs_fee // unit // self.estimate_size()) def get_hex_locktime(self): diff --git a/mmgen/xmrwallet.py b/mmgen/xmrwallet.py index 003cc9d2..feb0a4ec 100755 --- a/mmgen/xmrwallet.py +++ b/mmgen/xmrwallet.py @@ -250,9 +250,9 @@ class MoneroWalletOps: uarg_info = xmrwallet_uarg_info def fmt_amt(amt): - return self.proto.coin_amt(amt,from_unit='min_coin_unit').fmt(fs='5.12',color=True) + return self.proto.coin_amt(amt,from_unit='atomic').fmt(fs='5.12',color=True) def hl_amt(amt): - return self.proto.coin_amt(amt,from_unit='min_coin_unit').hl() + return self.proto.coin_amt(amt,from_unit='atomic').hl() id_cur = None for cls in classes: