Skip to content

Instantly share code, notes, and snippets.

View fiatjaf's full-sized avatar

fiatjaf_ fiatjaf

View GitHub Profile
@fiatjaf
fiatjaf / lightning-daemon-features
Last active April 4, 2020 02:26
lightning node versions
c-lightning 0.6 88
c-lightning 0.6.1 8a
c-lightning 0.6.2 8a
c-lightning 0.6.3 88
c-lightning 0.7.0 8a
c-lightning 0.7.1 aa
c-lightning 0.7.2.1 aa
c-lightning 0.7.3 28a2
c-lightning 0.8.0 02aaa2
c-lightning 0.8.1 02aaa2
@fiatjaf
fiatjaf / channels-balance-state.jq
Last active August 16, 2020 02:44
jq snippets for c-lightning
# use with:
# bash -c 'version=$(curl -s https://api.github.com/gists/e20c109af9b07a871aacac37b4102c91 | jq -rc .history[0].version); curl -s https://gist.githubusercontent.com/fiatjaf/e20c109af9b07a871aacac37b4102c91/raw/$version/channels-balance-state.jq > /tmp/clsnippet.jq; lightning-cli listfunds | jq -f /tmp/clsnippet.jq'
#
# lightning-cli listfunds | jq '
.channels
| sort_by(.channel_sat) | reverse
| map
(
{ peer: .peer_id
, scid: .short_channel_id
@fiatjaf
fiatjaf / nSequence.bash
Last active December 18, 2020 12:29
list all relative locktime usage across an interval of blocks
for (( b=661000; b<=661884; b++ )) do
x=`bitcoin-cli getblock $(bitcoin-cli getblockhash $b) 2 | jq -c '.tx | map(select(.version > 1)) | map(.vin | map(.sequence | select((. < 2147483648) and (. > 0)))) | reduce .[] as $ns ([]; . + $ns) | reduce .[] as $n ({}; .["\($n)"] = (.["\($n)"] // 0) + 1)'`
if [ "$x" != '{}' ]
then echo $b: $x
fi
done
@fiatjaf
fiatjaf / requirements.txt
Created December 25, 2020 22:08
RSKBLOCK merge mine scanner
bitcoin-requests
@fiatjaf
fiatjaf / save_tweets.py
Created January 9, 2021 01:16
Save all tweets from someone using https://www.allmytweets.net/ (actually it's limited to 1800 I think)
import requests
username = 'alexberenson'
def write_tweets(f, tweets):
for tweet in tweets:
text = tweet["full_text"]
for url in tweet["entities"]["urls"]:
text = text.replace(url["url"], url["expanded_url"])
@fiatjaf
fiatjaf / connect.sh
Created May 24, 2021 17:27
establish a lightning connection to some node and get an `init` message back
# just copy and paste this somewhere changing the target node id, ip and address.
# you must have python3 and virtualenv, which can be installed with 'sudo apt install python3-virtualenv' on ubuntu
# it will download the pyln.proto library to a virtualenv and run the script below passed as a string
python3 -m venv venv
./venv/bin/pip install pyln.proto
./venv/bin/python -c '
import sys
from pyln.proto.wire import connect, PrivateKey, PublicKey
from binascii import unhexlify
@fiatjaf
fiatjaf / drivechain-checklist.md
Created June 27, 2021 19:39
Drivechain Checklist

Drivechain Checklist

Check the boxes you understand and agree with. If you check more than 75% of the boxes you're a Drivechain maximalist. Otherwise you need treatment, join https://t.me/DCinsiders and ask for help.

  • Sidechains are chains independent of Bitcoin consensus. They don't add any burden to the Bitcoin full nodes.
  • Sidechains use bitcoins (BTC) as their base currency, not any shitcoin.
  • Sidechains can have different rules, implement different features, be developed by different teams.
  • Using a sidechain is completely optional.
  • Sidechains are expected to be blindly merge-mined with Bitcoin, which means they increase the Bitcoin security budget without adding any burden to the normal Bitcoin miners.
  • There are useful features that can be implemented in sidechains that we can't implement in Bitcoin today (and we don't want either, because it would clog the Bitcoin main chain which is already too small and want it to remain small).
@fiatjaf
fiatjaf / Caddyfile
Created September 14, 2021 00:25
exposing eclair to the world
http://eclair.yourdomain.com {
@whitelisted {
path /createinvoice
}
@blacklisted {
not path /createinvoice
}
reverse_proxy @whitelisted http://localhost:8877 {
@fiatjaf
fiatjaf / f.lua
Last active January 19, 2022 23:46
title = 'Free Tunnel Server'
description = [[
- Manages tunnel clients.
- Starts the LNbits main tunnel service.
This one is the free version, anyone can take a subdomain and keep it for free forever.
]]
models = {
@fiatjaf
fiatjaf / results.txt
Created August 18, 2022 12:03
Compiling a ScalaJS app with ESModule and CommonJSModule and sbt-esBuild
Results of transpiling and bundling a project that uses Laminar and handful of Scala libraries plus 4 reasonably-sized npm dependencies:
ESModule:
- fastLinkJS => 3.8MB
- fastLinkJS / esBuild => 4.1MB
- fullLinkJS => 3.6MB
- fullLinkJS / esBuild => 2.0MB
CommonJSModule:
- fastLinkJS => 3.8MB