Skip to content

Instantly share code, notes, and snippets.

View harding's full-sized avatar

David A. Harding harding

View GitHub Profile
## Objective: mine the Bitcoin genesis block
from struct import pack
from hashlib import sha256
from codecs import decode
from binascii import hexlify
## Bitcoin uses the SHA256d hash function, which is the SHA256 function
## run twice (double).
def sha256d(data):
@harding
harding / bip100-fork.py
Created October 14, 2015 23:32
Code to scan for BIP100 coinbase strings
## (python3) Objective: count the number of blocks voting for BIP100 or
## using the BVnnnnnnn convention
# Requires: sudo pip3 install json-rpc
## WARNING: read and understand the following link before writing
## production JSON-parsing code for Bitcoin:
## https://en.bitcoin.it/wiki/Proper_Money_Handling_%28JSON-RPC%29
import requests
@harding
harding / scan-for-txes-over-10x.py
Created May 31, 2017 15:05
Scan for transactions with combined output values over 10,000 BTC
from bitcoin import rpc
from bitcoin.core import x, lx, b2x, b2lx
#from multiprocessing.dummy import Pool
from multiprocessing import Pool
from retrying import retry
threshold = 10000e8 # satoshis
high_height = rpc.Proxy().getinfo()["blocks"]
@harding
harding / top-feerate-txes.txt
Created July 15, 2017 13:47
The first 10 transactions in the past 50 blocks
The first transaction is the coinbase. The rest are probably
the highest feerate transactions in the block because Bitcoin Core
and most other nodes sort the transactions in block by modified_feerate
(feerate factoring in unconfirmed ancestor/descendant transactions).
Code:
height=$( bitcoin-cli getblockchaininfo | jq .blocks ) ; for i in $( seq $((height-(49))) $height ) ; do echo -e "\nBlock $i" ; bitcoin-cli getblock $( bitcoin-cli getblockhash $i ) | jq -r '.tx[]' | head -n 10 ; done > top-feerate-txes.txt
Block 475862
0ed65347f618c257309d29c1d921aeddccaf1b502580b2b098dbc30b9710c396
@harding
harding / foo.sh
Created July 15, 2017 12:07
Get in-block fees
sudo apt-get install jq num-utils
height=$( bitcoin-cli getblockchaininfo | jq .blocks ) ; for i in $( seq $((height-1008)) $height ) ; do echo -n "$i " ; bitcoin-cli getrawtransaction $( bitcoin-cli getblock $( bitcoin-cli getblockhash $i ) | jq -r '.tx[0]' ) true | jq '.vout[].value' | sed '$a-12.5' | numsum ; done > block-fees.dat

Keybase proof

I hereby claim:

  • I am harding on github.
  • I am dharding (https://keybase.io/dharding) on keybase.
  • I have a public key ASAc0D2AK_qMWWCV97ThMppvd62MCSIIjZN4T2BUtAjS7wo

To claim this, I am signing this object:

@harding
harding / arbitrary-data.txt
Created March 19, 2018 18:16
Response to a journalist about including arbitrary data in the block chain
On Mon, Mar 19, 2018 at 10:07:12AM -0700, [redacted] wrote:
> Hi David,
> I'm working on a piece about how the Bitcoin blockchain can accommodate
> arbitrary data, potentially making it illegal in certain countries and
> circumstances. The paper about this can be found here:
>
> https://fc18.ifca.ai/preproceedings/6.pdf
>
> I'm wondering whether you might be available to comment before 1pm PT today.
>
@harding
harding / count-nodes.sh
Created July 21, 2018 13:09
Quick script to count nodes in Luke's seeder data
#!/bin/bash -eu
DATA=node-count.data
while git checkout HEAD~30
do
date=$( git log -1 --date=unix | grep ^Date | awk '{ print $2 }' )
echo -n "$date " >> $DATA
## $8 is the 30d uptime; 5..100 shows nodes with uptime >= 5%
2018-10-20 19:30 UTC
## Trial 1
Nmap done: 8440 IP addresses (4486 hosts up) scanned in 446.64 seconds
$ grep Ports.*/tcp/ NODE_SCAN_RESULTS.data -c
4486
$ grep Ports.*/open/tcp/ NODE_SCAN_RESULTS.data -c
@harding
harding / bitcoin-core-pr-reviews-2019-05-01.txt
Created May 1, 2019 18:06
First meeting for the Bitcoin Core PR Review Club, hosted by John Newbery
13:01 <@jnewbery> Hi folks!
13:01 < harding> Hi!
13:01 < dmkathayat> Hello!
13:01 < schmidty> hola
13:01 < amiti> hi!
13:01 < bilthon> hi there
13:01 <@jnewbery> We usually start Bitcoin Core IRC meetings with a 'hi' so it's clear who's at keyboard. Feel free to say hi here!
13:01 < kcalvinalvin> Hi
13:01 < peevsie> hi!
13:02 < emzy> Hi