Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def decode_hex: | |
def decode: if . < 58 then .-48 elif . < 91 then .-55 else .-87 end; | |
def decode_byte: map(decode) | (.[0] * 16) + .[1]; | |
def pairs: explode | range(0;length;2) as $i | [.[$i], .[$i+1]]; | |
def filter: if (. < 32 or (. >= 128 and . <= 159)) then 46 else . end; | |
[pairs|decode_byte|filter] | implode; |
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 | |
BLOCK=$(bitcoin-cli getblockcount) | |
for ((i=BLOCK; i>=1; i--)) | |
do | |
echo $i | |
bitcoin-cli getblock $(bitcoin-cli getblockhash $i) 3 | jq -L $HOME -r 'include ".jq/decode_hex"; | |
.tx[] | select(any(.vout[]; .scriptPubKey.type == "nulldata" and .value != 0)) | .txid + " " + (.vout[0].value * 1e8 | tostring) + " " + (.vout[0].scriptPubKey.hex[4:] | decode_hex)' | |
done |
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 | |
CURRENTHEIGHT=$(bitcoin-cli getblockchaininfo | jq -r .blocks) | |
DIFFICULTY=1 | |
for ((HEIGHT = 0 ; HEIGHT < CURRENTHEIGHT ; HEIGHT += 2016)) | |
do | |
NEW_DIFFICULTY=$(bitcoin-cli getblock $(bitcoin-cli getblockhash $HEIGHT) | jq -r .difficulty) | |
ADJUSTMENT=$(bc <<< "scale=16 ; ((($NEW_DIFFICULTY * 100 / $DIFFICULTY)) - 100)" | awk '{printf("%.2f \n",$1)}') | |
echo $((HEIGHT / 2016)) $HEIGHT $NEW_DIFFICULTY $ADJUSTMENT | |
DIFFICULTY=$NEW_DIFFICULTY | |
done |
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 | |
TIME=$(date -d "$1" +"%s") | |
function getBlockTime { | |
echo $(bitcoin-cli getblockheader $(bitcoin-cli getblockhash $1) | jq -r .time) | |
} | |
function binarySearch { | |
L=$1 |
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
BOXES = [[ '₿', '₿'], // Box A | |
[ '₿', '💩'], // Box B | |
['💩', '💩']] // Box C | |
var count = 0, success = 0; | |
while(count <= 1_000_000) { | |
// You choose a box at random | |
var drawbox = Math.floor(Math.random() * 3); |
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
for (block_height = 0; block_height < 6_930_000; block_height += 210_000) { | |
epoch = Math.floor(block_height / 210_000) + 1 | |
coin = 100_000_000 | |
reward = Math.floor(100 * coin / Math.pow(2, epoch)) | |
supply = 0 | |
for (i = 1; i <= epoch; i++) { | |
supply += Math.floor(100 * coin / Math.pow(2, i)) * 210_000 |
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
#!/usr/bin/env node | |
var input = process.argv[2].split(':') | |
var result = (BigInt(input[0]) << 40n) + (BigInt(input[1]) << 16n) + (BigInt(input[2])) | |
console.log(result.toString()) |
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 | |
BLOCKCHAININFO=$(bitcoin-cli getblockchaininfo) | |
CURRENTHEIGHT=$(echo $BLOCKCHAININFO | jq -r .blocks) | |
CURRENTTIME=$(echo $BLOCKCHAININFO | jq -r .mediantime) | |
BLOCKS=$((CURRENTHEIGHT%2016)) | |
REMAINING=$((2016-BLOCKS)) | |
LOOKBACKHEIGHT=$((CURRENTHEIGHT-REMAINING)) | |
LOOKBACKBLOCK=$(bitcoin-cli getblock $(bitcoin-cli getblockhash $LOOKBACKHEIGHT)) | |
LOOKBACKTIME=$(echo $LOOKBACKBLOCK | jq -r .mediantime) | |
LOOKBACKDELTA=$((CURRENTTIME-LOOKBACKTIME)) |
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 | |
BLOCKCHAININFO=$(bitcoin-cli getblockchaininfo) | |
CURRENTHEIGHT=$(echo $BLOCKCHAININFO | jq -r .blocks) | |
CURRENTTIME=$(echo $BLOCKCHAININFO | jq -r .mediantime) | |
BLOCKS=$((CURRENTHEIGHT%2016)) | |
STARTHEIGHT=$((CURRENTHEIGHT-BLOCKS)) | |
STARTBLOCK=$(bitcoin-cli getblock $(bitcoin-cli getblockhash $STARTHEIGHT)) | |
STARTTIME=$(echo $STARTBLOCK | jq -r .mediantime) | |
AVERAGETIME=$(((CURRENTTIME-STARTTIME)/BLOCKS)) | |
PERCENT=$(awk "BEGIN {print -100+(60000/$AVERAGETIME)}") |
NewerOlder