Skip to content

Instantly share code, notes, and snippets.

Avatar

Yan Pritzker skwp

View GitHub Profile
View htc_contest_5k_followers.rb
replies = %w(
05nelsonm_
0xtail1
12coast
1Jeremycrypto
216musicscene
2357_is_prime
APOSTOL11778943
Arpiht3
BPDesignStudio
@skwp
skwp / bitcoin_contest.rb
Created Jan 29, 2019
Bitcoin Hash Based Contest
View bitcoin_contest.rb
# Takes a list of people and a set of block hashes and picks people from the list based on their
# position when the block hash is taken modulo the number of participants.
# This assumes there won't be two of the same answer. If there are, the code can be modified to pick the next person in the list, or something like that
contest_participants = %w(
@MSPcrypto
@vinod5473
@Crypto_celt
@HoldingsMidwest
@belair6909
View add-nodes.sh
function bitcoinAddnode() {
nodeToAdd=$1
dnsLookup $nodeToAdd
bitcoinExec "addnode $ip:$BITCOIN_PORT add"
}
for peer in $newline_peerlist; do
bitcoinAddnode $peer
done
@skwp
skwp / ban-on-boot.sh
Created Nov 29, 2018
ban-on-boot.sh
View ban-on-boot.sh
function bitcoinExec() {
command=$1
log "Bitcoin Exec: $command"
bitcoinExecResult=$(docker exec bitcoin /usr/local/bin/bitcoin-cli
-rpcuser=$TAG_rpcuser \
-rpcpassword=$TAG_rpcpassword \
$command)
}
function bitcoinBan() {
thingToBan=$1
@skwp
skwp / Dockerfile
Created Oct 26, 2018
bitcoin Dockerfile
View Dockerfile
FROM ubuntu:14.04
RUN apt-get -y update && apt-get -y install vim curl htop libgoogle-perftools-dev && apt-get -y autoremove
COPY bin/bitcoin-cli /usr/local/bin
COPY bin/bitcoind /usr/local/bin
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:bitcoin/bitcoin
RUN apt-get update --fix-missing && apt-get install -y --force-yes libdb4.8-dev libdb4.8++-dev libboost-all-dev libminiupnpc-dev libevent-dev
View btcrpc.sh
#!/usr/bin/env bash
# Runs a command against the btc node running in docker
# Usage: ./btcrpc [command]
command=$@
if [[ -z "$command" ]]; then
echo "Usage: ./btcrpc [command]"
echo "Example: ./btcrpc getmininginfo"
exit 1
fi
if [[ -z "$rpcpassword" ]]; then
View restore-chainstate.sh
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
network=$1
filename=$2
if [[ -z "$network" ]]; then
echo "Usage: ./restore-chainstate network [filename]"
echo "Restores chainstate. Example: ./restore-chainstate test1 2018-05-07/bitcoin.tgz"
echo "If filename is omitted, will restore to whatever was in /tmp/bitcoin.tgz, typically what we booted with"
fi
stop_command="btcstop"
View btcrestore.sh
#!/usr/bin/env bash
BUCKET=our.s3.bucket.com
FILE=$1
if [[ ! -z "$FILE" ]]; then
/usr/local/bin/aws s3 cp s3://$BUCKET/bitcoin-backups/$FILE /tmp/restore.tgz
else
echo "File not specified, will restore backup we started with (assumed to be in /tmp/bitcoin.tgz)"
cp /tmp/bitcoin.tgz /tmp/restore.tgz
fi
# Save the peers
View btcbackup.sh
#!/usr/bin/env bash
BUCKET=our.s3.bucket.com
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
docker stop bitcoin
tar --exclude='.lock' --exclude='debug.log' --exclude='peers.dat' --exclude='banlist.dat' -czvf /tmp/bitcoin.tgz /var/bitcoin/
/usr/local/bin/aws s3 cp /tmp/bitcoin.tgz s3://$BUCKET/bitcoin-backups/$DATE/$(hostname)/bitcoin.tgz
docker start bitcoin
View list-nodes.sh
#!/usr/bin/env bash
#Find the ip addresses of running instances
# set -f disables file globbing so wthat we can invoke ./list-nodes test1 '*'
# otherwise the star is expanded and messes with the command
set -f
network_name=$1
role=$2