Skip to content

Instantly share code, notes, and snippets.

Avatar

fiatjaf fiatjaf

View GitHub Profile
@fiatjaf
fiatjaf / save_tweets.py
Created Jan 9, 2021
Save all tweets from someone using https://www.allmytweets.net/ (actually it's limited to 1800 I think)
View save_tweets.py
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 / requirements.txt
Created Dec 25, 2020
RSKBLOCK merge mine scanner
View requirements.txt
bitcoin-requests
@fiatjaf
fiatjaf / nSequence.bash
Last active Dec 18, 2020
list all relative locktime usage across an interval of blocks
View nSequence.bash
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 / channels-balance-state.jq
Last active Aug 16, 2020
jq snippets for c-lightning
View channels-balance-state.jq
# 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 / lightning-daemon-features
Last active Apr 4, 2020
lightning node versions
View lightning-daemon-features
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-as-htlcs-idea.txt
Last active Mar 3, 2020
lightning network improved
View channels-as-htlcs-idea.txt
HTLCs below the dust limit are not possible, because they're uneconomical.
So currently whenever a payment below the dust limit is to be made Lightning peers adjust their commitment transactions to pay that amount as fees in case the channel is closed. That's a form of reserving that amount and incentivizing peers to resolve the payment, either successfully (in case it goes to the receiving node's balance) or not (it then goes back to the sender's balance).
SOLUTION
I didn't think too much about if it is possible to do what I think can be done in the current implementation on Lightning channels, but in the context of Eltoo it seems possible.
Eltoo channels have UPDATE transactions that can be published to the blockchain and SETTLEMENT transactions that spend them (after a relative time) to each peer. The barebones script for UPDATE transactions is something like (copied from the paper, because I don't understand these things):
@fiatjaf
fiatjaf / trust-minimized-bmm-miner.txt
Last active Feb 21, 2020
merged-mined parallel chains without native currency
View trust-minimized-bmm-miner.txt
+------+ +-------+ +---------+
+-------> | | +-------------------------> | | - - - - - - - - - - - - - - -> |potential|
| BMM | | BMM | | BMM |
|block | | block | | block |
| | | | - - - - - -> | | +---- - - -
+------+ +-------+ | +---------+ |
tx A
| |
v
@fiatjaf
fiatjaf / christmas2009.md
Created Dec 24, 2019
Mensagem de Natal 2009, Olavo de Carvalho
View christmas2009.md

Christmas 2009

Musically, some prefer Tristan and Isolde, but in the matter of dramatic power and richness of meaning, Wotan’s final aria in The Valkyrie, “Leb Wohl” (Farewell), is doubtless the pinnacle of Richard Wagner’s work. What does that have to do with Christmas? Hold on a while, and let me recall the scene.

Pressured by his wife Fricka, who urges him to fulfill his duties as maintainer of the cosmic order, Wotan, the Germanic counterpart of Zeus, unwillingly promises to punish by death his grandson Siegmund—guilty of adultery and incest with his sister Sieglinde. To achieve this goal, Wotan sends his dearest daughter, Brünnhilde, to the place where Sieglinde’s husband will fight a duel with Siegmund, to ensure that Siegmund, deprived of all divine assistance, is killed in the duel. At the decisive moment, Brünnhilde allows herself to be overcome with compassion for Siegmund, and disobeying the order she received, attempts to protect him. Wotan has to intervene personally, breaking Si

@fiatjaf
fiatjaf / flask-lnurl.py
Last active Dec 26, 2019
lnurl snippets
View flask-lnurl.py
import hashlib
import json
from flask import Flask, jsonify, request
app = Flask(__name__)
BASE_URL = 'https://myservice.com'
@app.route('/lnurl-one')
def lnurl_one():
return jsonify({
@fiatjaf
fiatjaf / .gitignore
Last active May 16, 2020
hsm_secret and custom invoices with lnurl on c-lightning
View .gitignore
venv
*.swo
*.swp
__pycache__