commit 700c52089ee669cf17348dc32c4163ad270fd650
parent 76c8ff58fc04e98d34db3fd08699f3f4be7c0cec
Author: nolash <dev@holbrook.no>
Date: Mon, 18 Oct 2021 13:31:18 +0200
Merge branch 'master' of file:///home/lash/src/client/cic/grassrootseconomics/chainlib-eth
Diffstat:
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/chainlib/eth/address.py b/chainlib/eth/address.py
@@ -42,3 +42,7 @@ class AddressChecksum:
:returns: Checksum address
"""
return to_checksum_address(v)
+
+
+def is_same_address(a, b):
+ return uniform(strip_0x(a)) == uniform(strip_0x(b))
diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py
@@ -45,7 +45,10 @@ from chainlib.error import SignerMissingException
from chainlib.chain import ChainSpec
from chainlib.eth.runnable.util import decode_for_puny_humans
from chainlib.eth.jsonrpc import to_blockheight_param
+<<<<<<< HEAD
from chainlib.eth.address import to_checksum_address
+=======
+>>>>>>> d6b258f2140f5ce555f765a90c14a65a5f3fc6de
logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py
@@ -26,6 +26,7 @@ from chainlib.eth.gas import Gas
from chainlib.eth.gas import balance as gas_balance
from chainlib.chain import ChainSpec
from chainlib.eth.runnable.util import decode_for_puny_humans
+from chainlib.eth.address import is_same_address
import chainlib.eth.cli
logging.basicConfig(level=logging.WARNING)
@@ -73,27 +74,27 @@ def main():
g = Gas(chain_spec, signer=signer, gas_oracle=rpc.get_gas_oracle(), nonce_oracle=rpc.get_nonce_oracle())
recipient = to_checksum_address(config.get('_RECIPIENT'))
- if not config.true('_UNSAFE') and recipient != add_0x(config.get('_RECIPIENT')):
+ if not config.true('_UNSAFE') and is_checksum_address(recipient):
raise ValueError('invalid checksum address')
logg.info('gas transfer from {} to {} value {}'.format(signer_address, recipient, value))
if logg.isEnabledFor(logging.DEBUG):
try:
- sender_balance = balance(signer_address, rpc.id_generator)
+ sender_balance = balance(add_0x(signer_address), rpc.id_generator)
recipient_balance = balance(add_0x(recipient), rpc.id_generator)
logg.debug('sender {} balance before: {}'.format(signer_address, sender_balance))
logg.debug('recipient {} balance before: {}'.format(recipient, recipient_balance))
except urllib.error.URLError:
pass
- (tx_hash_hex, o) = g.create(signer_address, recipient, value, data=config.get('_DATA'), id_generator=rpc.id_generator)
+ (tx_hash_hex, o) = g.create(signer_address, add_0x(recipient), value, data=config.get('_DATA'), id_generator=rpc.id_generator)
if send:
conn.do(o)
if block_last:
r = conn.wait(tx_hash_hex)
if logg.isEnabledFor(logging.DEBUG):
- sender_balance = balance(signer_address, rpc.id_generator)
+ sender_balance = balance(add_0x(signer_address), rpc.id_generator)
recipient_balance = balance(add_0x(recipient), rpc.id_generator)
logg.debug('sender {} balance after: {}'.format(signer_address, sender_balance))
logg.debug('recipient {} balance after: {}'.format(recipient, recipient_balance))