Skip to content

Instantly share code, notes, and snippets.

View meeDamian's full-sized avatar
👨‍💻
Lightning Networking

Damian Mee meeDamian

👨‍💻
Lightning Networking
View GitHub Profile
#!/bin/bash
RAWTX=$(bitcoin-cli createrawtransaction '[{"txid": "c09fc1b73260c5b5d0fd270de49c6c56d8fe6dc169cdfda75273c506bd1cb695", "vout": 0}]' '[{"tb1qncs4ju7gqu4hsc29ccyzvzk0dkste5xs03aaq7": 0.00000001}]' 0 true)
SIGNEDTX=$(bitcoin-cli signrawtransactionwithkey "${RAWTX}" '["'$(bitcoin-cli dumpprivkey tb1q9vugfwpwzac9wkzrhcq0zxfkszgy60ydsghp0f)'"]' | jq -r '.hex')
bitcoin-cli decoderawtransaction ${SIGNEDTX} | jq '. | del(.vout) | del(.vin)'
{
"txid": "230de7441de94670a64dfddd141aacb117b0cb2a542451dfb4efad4ea533b6ab",
"hash": "a1a0168b7382bb29c503868105c07b6e8c5db21f6e96d76900f24794b9102c46",
@meeDamian
meeDamian / ipfs-refs-daemon.sh
Created August 18, 2019 18:00 — forked from kyledrake/ipfs-refs-daemon.sh
IPFS replication service with one line of unix shell code!
#!/bin/bash
# First, install ncat: http://nmap.org/ncat/
# Usually comes with the 'nmap' package on distributions.
ncat -k -v -l -p 5555 -c 'ipfs refs local | gzip'
# To retrieve on the client machine:
# nc 127.0.0.1 5555 | gunzip | ipfs pin add -r
#!/usr/bin/env bash
trap "exit" INT
HOSTS=( ln@pi-hdd lnd@pi-other )
echo -e "\nCreating backups for ${#HOSTS[*]} hosts…"
@meeDamian
meeDamian / 7z
Created May 8, 2019 15:48
Compression comparison
/tmp|⇒ /usr/bin/time -l 7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on bitcoin-blocks.7z ~/Library/Application\ Support/Bitcoi
n/blocks
412.70 real 379.01 user 7.50 sys
395800576 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
97211 page reclaims
35 page faults
@meeDamian
meeDamian / README.md
Created April 30, 2019 12:24
Samourai Wallet backend server

If you ever wondered what info about you, Samourai Wallet sends back home, here is how you can see it.

Combine domain with path, to get sth like:

https://api.samouraiwallet.com/v2/multiaddr?active=
@meeDamian
meeDamian / blockchain-growth-btc-bch.sh
Last active April 25, 2019 01:03
Fetches and compares blockchain size growth between BTC & BCH.
#!/bin/bash
BLOCKCHAIN_INFO_URL="https://api.blockchain.info/charts/blocks-size?timespan=2years&format=csv"
VERy_BITCOIN="https://charts.bitcoin.com/bch/api/chart/blockchain-size"
SPLIT_DATE="2017-08-01"
# I use date for two days ago, as depending on your TZ, bc.info might not have the data yet
RECENT_DATE="$(date -v-2d +%F)"
[[1315872000, 5.800000000000, 6.000000000000, 5.650000000000, 5.970000000000, 58.371382380000, 346.097389394400, 5.929230648356], [1315958400, 5.580000000000, 5.720000000000, 5.520000000000, 5.530000000000, 61.145983620000, 341.854813234800, 5.590797514344], [1316044800, 5.120000000000, 5.240000000000, 5.000000000000, 5.130000000000, 80.140795200000, 408.259002164000, 5.094271914137], [1316131200, 4.820000000000, 4.870000000000, 4.800000000000, 4.850000000000, 39.914006800000, 193.763146600000, 4.854515047084], [1316217600, 4.870000000000, 4.870000000000, 4.870000000000, 4.870000000000, 0.300000000000, 1.461000000000, 4.870000000000], [1316304000, 4.870000000000, 4.920000000000, 4.810000000000, 4.920000000000, 119.812800000000, 579.843102741000, 4.839575594102], [1316390400, 4.900000000000, 4.900000000000, 4.900000000000, 4.900000000000, 20.000000000000, 98.000000000000, 4.900000000000], [1316476800, 4.920000000000, 5.660000000000, 4.920000000000, 5.660000000000, 89.280710680000, 481.049262911600, 5.388053693
#!/bin/bash
# [pre-0.17] calculate time differences between all block log entries in `debug.log`
zgrep -ah 'UpdateTip' ~/.bitcoin/debug.lo* | awk '{print $1 " " $2}' | while read -r line; do date -d $line +%s; done | awk 'NR>1{print $1-p} {p=$1}' | while read -r diff; do printf '%dh %dm %ds\n' $((${diff}/3600)) $((${diff}%3600/60)) $((${diff}%60)); done
# [0.17+] same as above
zgrep -ah 'UpdateTip' ~/.bitcoin/debug.lo* | awk '{print $1}' | while read -r line; do date -d $line +%s; done | awk 'NR>1{print $1-p} {p=$1}' | while read -r diff; do printf '%dh %dm %ds\n' $((${diff}/3600)) $((${diff}%3600/60)) $((${diff}%60)); done
# [pre-0.17] get 32 blocks after a longer inactivity persiod (1hr++)
00000020d27652d3c0ee533313c5f8d03de810a02f9b80744dea707843197403000000002ecab671461328cf785c0eb21a51221d888fd394138a9c5c7912a2d6152f8913eaf2ab5bffff001d2cb80baf0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff23030b9515008b0000006376652d323031382d31373134342d6b6873396e650002000000ffffffff01a3edc104000000001976a9142b2399d24a9e9e35487d2f76b57d6e33e72d522f88ac000000000100000002d9bf9d812cfc91e3ff3b7f68e85269f64e7825de0fa61ff9dde117c73b72086a010000008b483045022100e412610b2e2b8370f2eda0cf29fe19c2a4ea35191d8b42656e81bc97026b229e022046ff1df7293f8dbc3efd95b125ebf679a4a68e8de2265990ef7553f1060dc9e301410455fd1c1a6cbfb25b5bba1cf6f850de00d79852be3de51e50c0da683613303c533d079e147dfe07ce4d40df2b776b35184698d14fa107a61e0976b0d9416880c8ffffffffd9bf9d812cfc91e3ff3b7f68e85269f64e7825de0fa61ff9dde117c73b72086a010000008a47304402206fa6ef6c0727ecf8d40b2b4648a93b084396c9819d20a3300e83ac4d110589e8022060c78d44db1d5b5babd1629c55d8058643d11a14da933b4bc5f7a8a2a7da377301410455fd1c1a6cbfb25b5bba1cf6f850de
@meeDamian
meeDamian / pre-setup.log
Created September 22, 2018 07:43
First complete build logs
+ trap wrap_up TERM INT HUP
+ export DEBIAN_FRONTEND=noninteractive
+ DEBIAN_FRONTEND=noninteractive
+ raspi-config nonint do_change_locale en_US.UTF-8
Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.
+ export LANGUAGE=en_US.UTF-8
+ LANGUAGE=en_US.UTF-8
+ export LANG=en_US.UTF-8