From bca6b167eb40a225d9044a46b4dc1456592c07ba Mon Sep 17 00:00:00 2001 From: Rima <153289003+casks-mutters@users.noreply.github.com> Date: Thu, 11 Dec 2025 03:04:44 -0500 Subject: [PATCH] Chore: validate `--rpc` and `--private-key` arguments for correctness ## Summary The script currently does not perform validation on the `--rpc` argument (URL) or `--private-key`. If the RPC URL or private key is invalid, the script may fail with unclear errors. ## Proposed Changes - Add validation to check if `--rpc` is a valid URL (using `urllib` or `Web3`). - Ensure the `--private-key` is in the correct hexadecimal format, and show an error message if it is invalid. ## Motivation - Helps users avoid misconfiguration errors. - Improves error handling and user feedback. --- attestation_tool.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 attestation_tool.py diff --git a/attestation_tool.py b/attestation_tool.py new file mode 100644 index 0000000..93264dc --- /dev/null +++ b/attestation_tool.py @@ -0,0 +1,11 @@ +from urllib.parse import urlparse + +# RPC validation +if not urlparse(args.rpc).scheme: + print("❌ Invalid RPC URL format.", file=sys.stderr) + sys.exit(2) + +# Private key validation +if args.sign and (len(pk) != 64 or not all(c in "0123456789abcdef" for c in pk.lower())): + print("❌ Invalid PRIVATE_KEY format. Should be 64 hexadecimal characters.", file=sys.stderr) + sys.exit(2)