Skip to content

Instantly share code, notes, and snippets.

View garethtdavies's full-sized avatar

Gareth Davies garethtdavies

View GitHub Profile
@garethtdavies
garethtdavies / zcash_migration.sql
Last active July 21, 2019 23:21
Google BigQuery Zcash Migration Transactions
SELECT
block_number,
`hash`,
input_value,
output_value,
fee,
i.type AS input_type,
o.type AS output_type,
block_timestamp
FROM
@garethtdavies
garethtdavies / zcash-migration-blocksi.py
Last active July 22, 2019 04:28
zcash-migration-blocksci
import blocksci
chain = blocksci.Blockchain("/home/gareth/blocksci/zcash-data")
migration_tx = 0
for blk in chain[500000:571501]:
for tx in blk:
if (tx.is_saplingshielded and tx.is_sproutshielded):
print(tx.hash)
@garethtdavies
garethtdavies / shielded-transactions-blocksci.py
Created July 23, 2019 23:11
Outputs all shielded transactions from BlockSci
import blocksci
import csv
chain = blocksci.Blockchain("/home/gareth/blocksci/zcash-data")
migration_tx = 0
sprout_tx = 0
sprout_fully_shielded = 0
sapling_tx = 0
sapling_fully_shielded = 0
@garethtdavies
garethtdavies / fully-shielded-sapling-tx.json
Created August 11, 2019 20:27
Fully Shielded Sapling Transaction
{
"txid": "5328354a0b14c95b1f8ac26ec99c7b365638cd877a04aa3fb27d19deedc90fb7",
"overwintered": true,
"version": 4,
"versiongroupid": "892f2085",
"locktime": 0,
"expiryheight": 572130,
"vin": [
],
"vout": [
@garethtdavies
garethtdavies / SnarkProducers.py
Last active August 31, 2019 04:04
Parses the Coda GraphQL API to get public keys for those producing SNARK work
# A super quick "unofficial" script to parse the GraphQL API to get public keys for those producing SNARK work
# Install dependencies and run with `python3 SnarkProducers.py`
# You'll need to be running the GraphQL API see here for quick setup https://codaprotocol.com/docs/developers/graphql-api/
# and here for a detailed overview https://garethtdavies.com/crypto/first-steps-with-coda-graphql-api.html and update line 14 if required
# Your results may vary depending on how many blocks your node has seen
# Dependencies
# >=Python 3.5
# pip3 install git+https://github.com/CodaProtocol/coda-python-client.git
# pip3 install pandas
@garethtdavies
garethtdavies / mongo-memo.json
Created September 8, 2019 20:19
Extract matching memo data from Coda blocks
db.getCollection("blocks").find({
"transactions.userCommands": {
"$elemMatch": {
"memo": "2pn2vgS9sRdjnwZqRDndxVdGzeocYEwyJcHC1zbTgqrkmTnCFTA4MU"
}
}
});
@garethtdavies
garethtdavies / transaction_timer.py
Last active September 10, 2019 21:56
Time a Coda transaction
import asyncio
import time
import CodaClient
import datetime
coda = CodaClient.Client(graphql_host="localhost", graphql_port="8000")
# This currently responds to all tx for the provided public key on L#33 - it could be filtered to listen for payment id
async def blockReceived(message):
receivedTime = datetime.datetime.now()
@garethtdavies
garethtdavies / zcash-metrics.py
Last active December 4, 2020 04:58
Outputs aggregated metrics from the Zcash blockchain
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Output stats from Zcash blockchain using Blocksci
Uses https://github.com/cryptolu/BlockSci for Zcash Blocksci adaptation
Credit @st4d https://github.com/str4d for transaction type detection
"""
import blocksci
import os
@garethtdavies
garethtdavies / crash.txt
Created April 3, 2020 22:48
Coda docker
docker run --publish 3085:3085 -it codaprotocol/coda-demo:0.0.12-beta-wallet-custom-onboarding-2-f193685
2020-04-03 22:46:24 UTC [Info] Coda daemon is booting up; built with commit "f19368523b05d6cb430fe3f6ca1b6c9252b36bb4" on branch "wallet/custom-onboarding-2"
2020-04-03 22:46:24 UTC [Info] Daemon will expire at "2024-12-10 14:00:00-07:00"
2020-04-03 22:46:24 UTC [Info] Booting may take several seconds, please wait
2020-04-03 22:46:24 UTC [Info] Looking for the genesis tar file "coda_genesis_f1936852_5f69e1300e9b0392.tar.gz"
2020-04-03 22:46:24 UTC [Info] Found genesis tar file at "/var/lib/coda" and extracted it to $path
path: "/root/.coda-config/coda_genesis_f1936852_5f69e1300e9b0392"
2020-04-03 22:46:24 UTC [Info] Successfully retrieved genesis ledger and genesis proof from "/var/lib/coda"
2020-04-03 22:46:25 UTC [Fatal] Unhandled top-level exception: $exn
Generating crash report
@garethtdavies
garethtdavies / docker-run-command.sh
Last active June 10, 2020 14:04
Docker Run Coda Daemon
docker run -d --name coda \
-e "CODA_PRIVKEY_PASS=xxxxxx" \
--mount type=bind,source="$(pwd)"/keys,target=/root/keys \
-p 8302:8302 \
-p 8303:8303 \
-p 3085:3085 \
--restart always \
codaprotocol/coda-daemon:0.0.12-beta-feature-bump-genesis-timestamp-3e9b174 daemon \
-block-producer-key /root/keys/my-wallet \
-coinbase-receiver <PUBLIC_KEY> \