Skip to content

Instantly share code, notes, and snippets.

View mutatrum's full-sized avatar
💭
hodl.camp

mutatrum mutatrum

💭
hodl.camp
View GitHub Profile
map $http_accept_language $header_lang {
default en-US;
~*^en-US en-US;
~*^en en-US;
~*^ar ar;
~*^cs cs;
~*^de de;
~*^es es;
~*^fa fa;
~*^fr fr;
@mutatrum
mutatrum / taproot_time.sh
Last active August 25, 2021 22:33
Estimate taproot activation date
#!/bin/bash
CURRENT_BLOCK="$(bitcoin-cli getblockcount)"
CURRENT_BLOCK_HASH="$(bitcoin-cli getblockhash $CURRENT_BLOCK)"
CURRENT_BLOCK_TIME="$(bitcoin-cli getblock $CURRENT_BLOCK_HASH | jq '.mediantime')"
TAPROOT_BLOCK="$(bitcoin-cli getblockchaininfo | jq '.softforks.taproot.bip9.min_activation_height')"
BLOCK_DELTA="$(($TAPROOT_BLOCK-$CURRENT_BLOCK))"
PREVIOUS_BLOCK="$(($CURRENT_BLOCK-$BLOCK_DELTA))"
PREVIOUS_BLOCK_HASH="$(bitcoin-cli getblockhash $PREVIOUS_BLOCK)"
PREVIOUS_BLOCK_TIME="$(bitcoin-cli getblock $PREVIOUS_BLOCK_HASH | jq '.mediantime')"
DELTA_TIME="$(($CURRENT_BLOCK_TIME-$PREVIOUS_BLOCK_TIME))"
@mutatrum
mutatrum / taproot.sh
Last active June 12, 2021 16:44
Print a taproot signalling block diagram
#!/bin/bash
BLOCKCHAININFO=$(bitcoin-cli getblockchaininfo)
BLOCKS=$(echo "$BLOCKCHAININFO" | jq .blocks)
TAPROOT=$(echo "$BLOCKCHAININFO" | jq .softforks.taproot.bip9)
SINCE=$(echo "$TAPROOT" | jq .since)
PERIOD=$(echo "$TAPROOT" | jq .statistics.period)
BLOCKS=$(echo "$BLOCKCHAININFO" | jq .blocks)
PERIOD_COUNT=$(((BLOCKS - SINCE) / PERIOD))
SINCE=$((SINCE + (PERIOD * PERIOD_COUNT)))
ELAPSED=$(echo "$TAPROOT" | jq .statistics.elapsed)
@mutatrum
mutatrum / lndgraph.js
Created March 5, 2021 13:07
Find depth of BOS nodes in LND node graph
const fs = require('fs');
// Fill in your own node alias
const NAME = '<nodealias>';
console.log('start');
// lncli describegraph > graph.json
var graph = JSON.parse(fs.readFileSync('graph.json'));
// https://bos.lightning.jorijn.com/data/export.json
const fs = require('fs');
const readline = require('readline');
var english = fs.readFileSync('english.txt', 'utf8').split("\n")
const readInterface = readline.createInterface({
input: fs.createReadStream('coinbase.txt'),
console: false
});
#!/bin/bash
HEIGHT=$(bitcoin-cli getblockcount)
echo "$HEIGHT"
for ((i=1; i<=$HEIGHT; i++ ))
do
COINBASE=$(bitcoin-cli decoderawtransaction $(bitcoin-cli getrawtransaction $(bitcoin-cli getblock $(bitcoin-cli getblockhash $i) | jq -r '.tx[0]')) | jq -r '.vin[0].coinbase' | xxd -r -p | tr -cd '[:print:]')
echo "$COINBASE"
Eligius<5Benedictus Iesus in sanctissimo altaris Sacramento.
Eligius5<Benedictus Deus in Angelis suis, et in Sanctis suis. Amen.
Eligius%ZLTO my God, I am heartily sorry for having offended Thee and I detest all my sins...
EligiusLS...because of Thy just punishments, but most of all because they offend Thee, ...
EligiusA;...my God, who art all good and deserving of all my love.
Eligius(AI firmly resolve, with the help of Thy grace, to sin no more...
EligiusD/...and avoid the near occasions of sin. Amen.
EligiusLOO my God! I firmly believe that Thou art one God in three Divine persons, ...
EligiusELO...Father, Son, and Holy Ghost; I believe that Thy Divine Son became man, ...
Eligiusr;LT...and died for our sins, and that he will come to, judge the living and the dead.
@mutatrum
mutatrum / getbitcoinpdf.sh
Created January 21, 2021 16:15
Get bitcoin.pdf from the bitcoin blockchain in one line
bitcoin-cli getrawtransaction 54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713 | sed 's/0100000000000000/\n/g' | tail -n +2 | cut -c7-136,139-268,271-400 | tr -d '\n' | cut -c17-368600 | xxd -p -r > bitcoin.pdf
@mutatrum
mutatrum / umbrel.sh
Created January 11, 2021 09:21
Installing Umbrel on an Odroid HC4
# first boot
ssh root@odroid
# dependencies
apt-get update
apt-get full-upgrade
apt-get install fswatch jq rsync curl python3 python3-pip
apt autoremove
# swapfile
@mutatrum
mutatrum / BitcoinJTest.java
Created April 16, 2020 15:59
Using bitcoinj to derive legacy, segwit and bech32 addresses from account xpub
import org.bitcoinj.core.*;
import org.bitcoinj.crypto.*;
import org.bitcoinj.params.*;
import org.bitcoinj.script.*;
import org.junit.*;
public class BitcoinJTest
{
private static NetworkParameters params = MainNetParams.get();