Browse Source

option rename: --tx-gas -> --gas

This change breaks compatibility.  Scripts may need to be adjusted.
The MMGen Project 2 years ago
parent
commit
0448f76b70

+ 1 - 1
mmgen/main_txcreate.py

@@ -44,7 +44,7 @@ opts_data = {
                       {fu} (an integer followed by {fl!r}).
                       See FEE SPECIFICATION below.  If omitted, fee will be
                       calculated using network fee estimation.
--g, --tx-gas=      g  Specify start gas amount in Wei (ETH only)
+-g, --gas=         g  Specify start gas amount in Wei (ETH only)
 -i, --info            Display unspent outputs and exit
 -I, --inputs=      i  Specify transaction inputs (comma-separated list of
                       MMGen IDs or coin addresses).  Note that ALL unspent

+ 1 - 1
mmgen/main_txdo.py

@@ -48,7 +48,7 @@ opts_data = {
                        {fu} (an integer followed by {fl!r}).
                        See FEE SPECIFICATION below.  If omitted, fee will be
                        calculated using network fee estimation.
--g, --tx-gas=        g Specify start gas amount in Wei (ETH only)
+-g, --gas=           g Specify start gas amount in Wei (ETH only)
 -H, --hidden-incog-input-params=f,o  Read hidden incognito data from file
                       'f' at offset 'o' (comma-separated)
 -i, --in-fmt=        f Input is from wallet format 'f' (see FMT CODES below)

+ 7 - 7
mmgen/proto/eth/tx/base.py

@@ -24,23 +24,23 @@ class Base(TxBase.Base):
 	rel_fee_desc = 'gas price'
 	rel_fee_disp = 'gas price in Gwei'
 	txobj  = None # ""
-	tx_gas = ETHAmt(21000,'wei')    # an approximate number, used for fee estimation purposes
+	gas = ETHAmt(21000,'wei')       # an approximate number, used for fee estimation purposes
 	start_gas = ETHAmt(21000,'wei') # the actual startgas amt used in the transaction
-									# for simple sends with no data, tx_gas = start_gas = 21000
+									# for simple sends with no data, gas = start_gas = 21000
 	contract_desc = 'contract'
 	usr_contract_data = HexStr('')
 	disable_fee_check = False
 
-	# given absolute fee in ETH, return gas price in Gwei using tx_gas
+	# given absolute fee in ETH, return gas price in Gwei using self.gas
 	def fee_abs2rel(self,abs_fee,to_unit='Gwei'):
-		ret = ETHAmt(int(abs_fee.toWei() // self.tx_gas.toWei()),'wei')
+		ret = ETHAmt(int(abs_fee.toWei() // self.gas.toWei()),'wei')
 		dmsg(f'fee_abs2rel() ==> {ret} ETH')
 		return ret if to_unit == 'eth' else ret.to_unit(to_unit,show_decimal=True)
 
-	# given rel fee (gasPrice) in wei, return absolute fee using tx_gas (Ethereum-only method)
+	# given rel fee (gasPrice) in wei, return absolute fee using self.gas (Ethereum-only method)
 	def fee_gasPrice2abs(self,rel_fee):
 		assert isinstance(rel_fee,int), f'{rel_fee!r}: incorrect type for fee estimate (not an integer)'
-		return ETHAmt(rel_fee * self.tx_gas.toWei(),'wei')
+		return ETHAmt(rel_fee * self.gas.toWei(),'wei')
 
 	def is_replaceable(self):
 		return True
@@ -64,6 +64,6 @@ class Base(TxBase.Base):
 		return True
 
 class TokenBase(Base):
-	tx_gas = ETHAmt(52000,'wei')
+	gas = ETHAmt(52000,'wei')
 	start_gas = ETHAmt(60000,'wei')
 	contract_desc = 'token contract'

+ 4 - 4
mmgen/proto/eth/tx/new.py

@@ -35,8 +35,8 @@ class New(Base,TxBase.New):
 
 		super().__init__(*args,**kwargs)
 
-		if opt.tx_gas:
-			self.tx_gas = self.start_gas = ETHAmt(int(opt.tx_gas),'wei')
+		if opt.gas:
+			self.gas = self.start_gas = ETHAmt(int(opt.gas),'wei')
 		if opt.contract_data:
 			m = "'--contract-data' option may not be used with token transaction"
 			assert not 'Token' in type(self).__name__, m
@@ -109,10 +109,10 @@ class New(Base,TxBase.New):
 		if not self.disable_fee_check:
 			assert self.usr_fee <= self.proto.max_tx_fee
 
-	# given rel fee and units, return absolute fee using self.tx_gas
+	# given rel fee and units, return absolute fee using self.gas
 	def fee_rel2abs(self,tx_size,units,amt,unit):
 		return ETHAmt(
-			ETHAmt(amt,units[unit]).toWei() * self.tx_gas.toWei(),
+			ETHAmt(amt,units[unit]).toWei() * self.gas.toWei(),
 			from_unit='wei'
 		)
 

+ 1 - 1
mmgen/proto/eth/tx/signed.py

@@ -46,7 +46,7 @@ class Signed(Completed,TxBase.Signed):
 			self.disable_fee_check = True
 		txid = CoinTxID(etx.hash.hex())
 		assert txid == self.coin_txid,"txid in tx.serialized doesn't match value in MMGen transaction file"
-		self.tx_gas = o['startGas'] # approximate, but better than nothing
+		self.gas = o['startGas'] # approximate, but better than nothing
 		self.txobj = o
 		return d # 'token_addr','decimals' required by Token subclass
 

+ 1 - 1
mmgen/proto/eth/tx/unsigned.py

@@ -38,7 +38,7 @@ class Unsigned(Completed,TxBase.Unsigned):
 			'nonce':    ETHNonce(d['nonce']),
 			'chainId':  None if d['chainId'] == 'None' else Int(d['chainId']),
 			'data':     HexStr(d['data']) }
-		self.tx_gas = o['startGas'] # approximate, but better than nothing
+		self.gas = o['startGas'] # approximate, but better than nothing
 		self.txobj = o
 		return d # 'token_addr','decimals' required by Token subclass
 

+ 1 - 1
test/test_py_d/ts_ethdev.py

@@ -922,7 +922,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 		args = [
 			'-B',
 			f'--fee={tx_fee}',
-			f'--tx-gas={gas}',
+			f'--gas={gas}',
 			f'--contract-data={fn}',
 			f'--inputs={dfl_devaddr}',
 			'--yes',