-
-
Save amiller/aed9d766f0887d314d757760725e8ab7 to your computer and use it in GitHub Desktop.
Checks whether coinholder poll participants are using ephemeral t-addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Script for checking up on whether participants are following the suggestion to | |
using ephemeral t-addresses. | |
See the post: | |
"Coin Holder Polling - Instructions" Sep 24, 2021 | |
https://forum.zcashcommunity.com/t/coin-holder-polling-instructions/40170 | |
1. Loop over a list of transactions in zecwallet-light format, | |
sent to the viewkey address. Inspect the memo field to check if it's a vote. | |
2. Fetch the transaction inputs, using zcha.in api. We're looking for a t-address | |
as one of the inputs. | |
3. Fetch the current balance of the t-address. The final balance when the poll concludes | |
may be different. | |
4. Fetch the list of transactions IDs associated with this t-addresses. | |
Does it have a history? | |
You'd need to import the viewing key with: | |
$ zecwallet-cli import {viewkey} | |
zxviews1q0lfzpc7qqqqpqyp35tvhhl3gkwtfp06g3kulvraxqyr4zr8xxaxu895x5g64ss4t5uspgxwes4gqdppdqjkdlzgjetgjssz7mnq7e2axmn5k6xtn6fk658sylx97ng3ndfatv8qy3xry0l3agk49wraq8mhmfq6xaxzut4zgtrexx8llzzhyduw4egkszzgqldjx55xnckcrnrymcm3l4enpefkypptr6v8cezmmqjp78xjjres36hn47v2uujvj63fadrv6jw3q7gtf2vtj | |
https://forum.zcashcommunity.com/t/coin-holder-polling-instructions/40170 | |
Run with | |
$ zecwallet-cli list | python eccpoll-audit.py | |
""" | |
import json, sys | |
import requests | |
import time | |
import csv | |
import re | |
viewaddress = "zs1j54w96syddfnrh2ehx40lyy7zej67z496nrqtg39r6jv00ks4pjyt57xz59kzy289c2rkdr6rhe" | |
# Loop over all received transactions | |
with open('result-eccpoll-audit.csv', 'w') as csvfile: | |
rows = [] | |
for r in json.load(sys.stdin): | |
# Step 1. Figure out which transactions are votes to this poll | |
if r['address'] != viewaddress: | |
continue | |
# No minimum to vote? | |
# if r['amount'] < 0.0000: | |
# continue | |
# print() | |
# print(r['txid']) | |
memo = r['memo'] | |
# print(memo) | |
# Step 2. Get the transaction details, especially tx inputs, via zcha.in api | |
url = "https://api.zcha.in/v2/mainnet/transactions/%s" % (r['txid'],) | |
resp = requests.get(url) | |
time.sleep(0.2) | |
tx = json.loads(resp.content) | |
if len(tx['vin']) < 1: | |
# No t-address input found | |
continue | |
# print(len(tx['vin']), 'inputs') | |
txin = tx['vin'][0] | |
assert len(txin['retrievedVout']['scriptPubKey']['addresses']) == 1 | |
# Must be some non standard transaction? | |
# Only look at the first address | |
addr = txin['retrievedVout']['scriptPubKey']['addresses'][0] | |
# Step 3. Access the current balance using zchain api | |
url = "https://api.zcha.in/v2/mainnet/accounts/%s" % (addr,) | |
resp = requests.get(url) | |
time.sleep(0.2) | |
account = json.loads(resp.content) | |
balance = account['balance'] | |
# Step 4: How recent is this? | |
txtime = tx['timestamp'] | |
firstSeen = account['firstSeen'] | |
sentCount = account["sentCount"] | |
age = (txtime - firstSeen)/3600./24. | |
# Analysis | |
print() | |
print(r['txid']) | |
print(addr, 'balance:', balance, 'sentCount:', sentCount, 'age:', age) | |
print('memo:', memo) | |
if sentCount > 2: | |
print('🚨🚨 T-ADDR SENT MORE THAN TWICE 🚨🚨') | |
if age > 1: # days | |
print('🚨🚨 T-ADDR USED 1+ DAYS BEFORE VOTING 🚨🚨') | |
# rows.append([addr, balance, memo, r['txid'], sentCount, ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment