Skip to content

Instantly share code, notes, and snippets.

View sr-gi's full-sized avatar

Sergi Delgado sr-gi

View GitHub Profile
@sr-gi
sr-gi / Median feerate
Created May 20, 2023 19:17
Median feerate of the last 1040 blocks using mempools API
import math
import requests
import statistics
if __name__ == '__main__':
tip_height = requests.get("https://mempool.space/api/blocks/tip/height").json()
medians = []
feerates = []
@sr-gi
sr-gi / towers-accumulators.md
Last active August 29, 2023 06:10
Thoughts on watchtowers and accumulators

Watchtowers

At a high level, the gist of watchtowers is pretty straightforward: every single time you update your channel, you share revocation information with the tower such that, if you happen to be offline sometime in the future, the tower will have you covered. This is done literally for every payment (actually twice per payment, but that is sort of irrelevant for now), so it is easy to see how storage will easily be built up on the tower side.

If you start digging a bit deeper into how towers actually work, a question is likely to arise sooner than later: how can I be sure the watchtower will act on my behalf? And that is, indeed, a pretty damn good question which answers is likely to disappoint you: you cannot. To sheer some light into why it is worth checking what is the tower's "job":

In a nutshell, the tower should simply look for channel breaches onchain and respond to them if seen. In order to do so, the tower receives data from the user in the form of a locator and the revocation data that

@sr-gi
sr-gi / bitcoind_mock.rs
Created September 30, 2021 13:06
Simple BitcoindMock
use jsonrpc_http_server::jsonrpc_core::{IoHandler, Params, Value};
use jsonrpc_http_server::{Server, ServerBuilder};
use std::thread;
static TXID_HEX: &str = "338bda693c4a26e0d41a01f7f2887aaf48bf0bdf93e6415c9110b29349349d3e";
pub static TX_HEX: &str = "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff54038e830a1b4d696e656420627920416e74506f6f6c373432c2005b005e7a0ae3fabe6d6d7841cd582ead8ea5dd8e3de1173cae6fcd2a53c7362ebb7fb6f815604fe07cbe0200000000000000ac0e060005f90000ffffffff04d9476026000000001976a91411dbe48cc6b617f9c6adaf4d9ed5f625b1c7cb5988ac0000000000000000266a24aa21a9ed7248c6efddd8d99bfddd7f499f0b915bffa8253003cc934df1ff14a81301e2340000000000000000266a24b9e11b6d7054937e13f39529d6ad7e685e9dd4efa426f247d5f5a5bed58cdddb2d0fa60100000000000000002b6a2952534b424c4f434b3a054a68aa5368740e8b3e3c67bce45619c2cfd07d4d4f0936a5612d2d0034fa0a0120000000000000000000000000000000000000000000000000000000000000000000000000";
struct BitcoindMock {
server: Server,
}

Keybase proof

I hereby claim:

  • I am sr-gi on github.
  • I am sr_gi (https://keybase.io/sr_gi) on keybase.
  • I have a public key ASCPmZvcbUgBBnxgBbdk1e79gj1yiJoK4VQq8BrTEeer3wo

To claim this, I am signing this object: