2022-12-10 13:38:47 +00:00
|
|
|
# Nimbus
|
2024-10-04 14:34:31 +00:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-12-10 13:38:47 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
|
|
|
import
|
|
|
|
eth/[common, rlp],
|
|
|
|
stew/byteutils,
|
2024-10-04 14:34:31 +00:00
|
|
|
eth/common/transaction_utils,
|
2022-12-15 06:30:18 +00:00
|
|
|
../../nimbus/transaction,
|
|
|
|
../../nimbus/common/evmforks
|
2022-12-10 13:38:47 +00:00
|
|
|
|
|
|
|
proc parseTx(hexLine: string) =
|
|
|
|
try:
|
|
|
|
let
|
|
|
|
bytes = hexToSeqByte(hexLine)
|
2022-12-15 06:30:18 +00:00
|
|
|
tx = decodeTx(bytes)
|
2024-10-04 14:34:31 +00:00
|
|
|
address = tx.recoverSender().expect("valid signature")
|
2022-12-10 13:38:47 +00:00
|
|
|
|
2022-12-15 06:30:18 +00:00
|
|
|
tx.validate(FkLondon)
|
|
|
|
|
2022-12-10 13:38:47 +00:00
|
|
|
# everything ok
|
|
|
|
echo "0x", address.toHex
|
|
|
|
|
|
|
|
except RlpError as ex:
|
|
|
|
echo "err: ", ex.msg
|
|
|
|
except ValueError as ex:
|
|
|
|
echo "err: ", ex.msg
|
2022-12-15 06:30:18 +00:00
|
|
|
except Exception:
|
|
|
|
# TODO: rlp.hasData assertion should be
|
|
|
|
# changed into RlpError
|
|
|
|
echo "err: malformed rlp"
|
2022-12-10 13:38:47 +00:00
|
|
|
|
|
|
|
proc main() =
|
|
|
|
for hexLine in stdin.lines:
|
|
|
|
parseTx(hexLine)
|
|
|
|
|
|
|
|
main()
|