Last active
December 17, 2015 21:38
-
-
Save SamWhited/5675687 to your computer and use it in GitHub Desktop.
Send a small ammount of money via bitcoin after making a git commit so that the blockchain can be used to verify the time at which the commit was made (https://www.btproof.com/)
This file contains hidden or 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
#!/bin/bash | |
# What this does: | |
# | |
# This is an untested (I have no idea what the syntax is for bitcoind, so this probably doesn't actually work; | |
# it's just an idea) post-commit hook for sending a bitcoin transaction. This allows one to use the bitcoin | |
# blockchain for trusted timestamping of git commits. This might be useful if you expect a bogus copyright claim, | |
# or want to make sure you have proof that you started a project before working for a company or going to a school | |
# that likes to seize intellectual property from their employees and claim it was developed on their dime. | |
# | |
# For more information: https://www.btproof.com/ | |
VERSION_BYTE='00' | |
BT_USER=$(git config bt.user.name || echo 'user') | |
BT_HOST=$(git config bt.server.host || echo '127.0.0.1') | |
BT_PORT=$(git config bt.server.port || echo '8332') | |
BT_SEND=$(git config bt.amount || echo '0.00000001') | |
BT_ADDR=$(hash_to_address) | |
# Base58 copied from some script online. Lost the link; sorry. | |
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z}) | |
EncodeBase58() { | |
# 58 =0x3A | |
bc <<<"ibase=16; n=${1^^}; while(n>0) { n%3A ; n/=3A }" | | |
tac | | |
while read n | |
do echo -n ${base58[n]} | |
done | |
} | |
hash_to_address() { | |
hash=${VERSION_BYTE}$(git rev-parse HEAD | openssl rmd160 | cut -d ' ' -f 2) | |
checksum=$(echo ${hash} | sha256sum | cut -d ' ' -f 1 | sha256sum | cut -d ' ' -f 1) | |
checksum=${checksum:0:8} | |
echo $(EncodeBase58 "${hash}${checksum}") | |
} | |
curl --user $BT_USER --data-binary \ | |
'{"jsonrpc": "1.0", "id":"gitbtproof", "method": "sendtoaddress", "params": ["'${BT_ADDR}'" "'${BT_SEND}'"] }' \ | |
-H 'content-type: text/plain;' http://$BT_HOST:$BT_PORT/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment