Decode
This commit is contained in:
@@ -25,7 +25,7 @@ import sha3
|
||||
from eth_abi import encode_single
|
||||
|
||||
# local imports
|
||||
from cic_tools.eth.checksum import to_checksum
|
||||
from cic_tools.eth.address import to_checksum
|
||||
from cic_tools.eth.method import (
|
||||
jsonrpc_template,
|
||||
erc20_balance,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import sys
|
||||
|
||||
# local imports
|
||||
from cic_tools.eth.checksum import to_checksum
|
||||
from cic_tools.eth.address import to_checksum
|
||||
|
||||
|
||||
print(to_checksum(sys.argv[1]))
|
||||
|
||||
51
cic_tools/eth/runnable/decode.py
Normal file
51
cic_tools/eth/runnable/decode.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!python3
|
||||
|
||||
"""Decode raw transaction
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# third-party imports
|
||||
from cic_tools.eth.tx import unpack_signed
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_abi_dir = os.environ.get('ETH_ABI_DIR', '/usr/share/local/cic/solidity/abi')
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-i', '--chain-id', dest='i', type=str, help='Numeric network id')
|
||||
argparser.add_argument('tx', type=str, help='hex-encoded signed raw transaction')
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.v:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
|
||||
(chain_name, chain_id) = args.i.split(':')
|
||||
|
||||
|
||||
def main():
|
||||
tx_raw = args.tx
|
||||
if tx_raw[:2] == '0x':
|
||||
tx_raw = tx_raw[2:]
|
||||
tx_raw_bytes = bytes.fromhex(tx_raw)
|
||||
tx = unpack_signed(tx_raw_bytes, int(chain_id))
|
||||
for k in tx.keys():
|
||||
print('{}: {}'.format(k, tx[k]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user