Browse Source

BTCAmt: remove 'min_coin_unit' attribute

The MMGen Project 3 years ago
parent
commit
8e457707f0
5 changed files with 7 additions and 10 deletions
  1. 1 1
      examples/halving-calculator.py
  2. 0 1
      mmgen/altcoins/eth/obj.py
  3. 2 4
      mmgen/obj.py
  4. 2 2
      mmgen/tx.py
  5. 2 2
      mmgen/xmrwallet.py

+ 1 - 1
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'

+ 0 - 1
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'
 

+ 2 - 4
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
 

+ 2 - 2
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):

+ 2 - 2
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: