"""dripfund2.py: in the first funded block, find the tx(s) whose input or logs name the wallets (disperse / bridge)."""
import sys, re
s = open("/root/fwa1/v3dead.py").read(); k = s.index("def post"); k = k + re.search(r"\n(?=\S)", s[k:]).start()
exec(s[:k])
def call(m, p): return post({"jsonrpc": "2.0", "id": 1, "method": m, "params": p}).get("result")
blk = int(sys.argv[1]); ws = [w.lower()[2:] for w in sys.argv[2:]]
b = call("eth_getBlockByNumber", [hex(blk), True]); print("txs in block", len(b["transactions"]))
for t in b["transactions"]:
    inp = (t.get("input") or "").lower(); hit = [w for w in ws if w in inp]
    if hit or (t.get("to") or "").lower()[2:] in ws or t["from"].lower()[2:] in ws:
        print("tx", t["hash"], "from", t["from"].lower(), "to", (t.get("to") or "").lower(), "value", int(t["value"], 16) / 1e18, "names", ["0x" + h for h in hit], "input bytes", len(inp) // 2)
lg = call("eth_getLogs", [{"fromBlock": hex(blk), "toBlock": hex(blk)}]) or []
for l in lg:
    blob = "".join(l["topics"]).lower() + l["data"].lower(); hit = [w for w in ws if w in blob]
    if hit: print("log tx", l["transactionHash"], "contract", l["address"].lower(), "names", ["0x" + h for h in hit])
