Skip to content

Instantly share code, notes, and snippets.

@justinmoon
justinmoon / gist:8128e66fc11d90ae5732f2491570bfc5
Last active February 8, 2024 04:45
Recovering from a lost BTCPay password w/o SMTP set up

You setup a btcpay server account, forgot to setup SMTP (or set it up wrong) and then forgot your password. Now you can't get back in. Here's how I recovered from this situation:

  1. Create a new user according to these instructions. But this isn't enough because (1) Your new user isn't a member of any stores and (2) for me at least this new user couldn't setup SMTP ...

  2. There is a postgres table called UserStore which tracks membership of users in stores. When you execute the following command in postgres

select * from "UserStore";
@justinmoon
justinmoon / btcpay-migration.md
Last active January 9, 2024 19:37
Transferring BTCPayServer data from one server to another

First, update your old BTCPayServer to the newest version. This way there aren't any database schema conflicts with the your server.

SSH to old server you are migrating from. Create a dump of the your database's schema and data

docker exec generated_postgres_1 pg_dumpall -c -U postgres > backup.sql

Try opening that backup.sql file in your text editor of choice. You will see it's just a series of SQL statements which:

{"members":[[0,"ws://localhost:4001/"],[1,"ws://localhost:4011/"],[2,"ws://localhost:4021/"],[3,"ws://localhost:4031/"]]}
@justinmoon
justinmoon / htlc_intercepter.rs
Last active October 20, 2022 21:12
LND HTLC Interceptor in Rust
///
/// To use this demo:
/// - create a 3 node network in polar (https://lightningpolar.com/) -- Alice, Bob and Carol
/// - Create channels between Alice and Carol, and between Alice and Bob.
/// - Create an invoice from Carol. Use the `decodepayreq` and `lookupinvoice` lncli commands to get preimage associated with Carol's invoice
/// - Run this program with Alice's LND credentials, and the preimage from step above. For instance:
/// `cargo run --example subscribe_htlcs 127.0.0.1 10003 /Users/justin/.polar/networks/2/volumes/lnd/alice/tls.cert /Users/justin/.polar/networks/2/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon <preimage>`
/// - Have Bob pay the invoice via Polar UI
/// - This program should output HTLC information. Polar should print success message.
///

setting up developer environment

Instructions.

Our developer environment is amazing, but it downloads a few gigabytes of data to get set up

fedimint-cli

# pull docker image
@justinmoon
justinmoon / gist:3ff2722f0d136c55f2c1166a03a174f7
Created September 26, 2022 02:37
9/27/2022 Fedimint Dev Call
- https://github.com/fedimint/fedimint/issues/613
@justinmoon
justinmoon / tweak.md
Last active July 5, 2022 13:47
BDK + Minimint

About Minimint

Minimint is similar to Liquid. But instead of 1 monolithic codebase, it is very modular. So it's more like a "framework for building federations". One module implements "Chaumian ecash", another integrates with Lightning, another is an on-chain wallet.

The on-chain wallet module currently has a public descriptor like this: wsh(sortedmulti(3,02b5b951e6426bc30ba6e7e1cb9cfae06c2658c043614c0fa37a7c4a649a4a3056,026ad269307053e5a11f7ab73209e89791ae31cabfa00b5fa2811bb25633eec6d6,034c71c3f3c2a8ecf07477158be4d9f37b44694b2987f6487c3884857002348fd1,033d94f61ac8bd8fc460a91f7b61e45a16b51d10097200f17fb0998a7483cc8f19))#cc9uhqy3. Each federation server controls one of these keys. When a user deposits into the federation, they

(1) Tweak each pubkey in this descriptor with some random number X.

(2) Deposit to this address associated with this tweaked

@justinmoon
justinmoon / start.md
Last active February 7, 2022 23:02
How To Start A Startup by Paul Graham

How To Start A Startup by Paul Graham

(original is here, hosting in gist so that I can link to specific section)

You need three things to create a successful startup: to start with good people, to make something customers actually want, and to spend as little money as possible. Most startups that fail do it because they fail at one of these. A startup that does all three will probably succeed.

And that's kind of exciting, when you think about it, because all three are doable. Hard, but doable. And since a startup that succeeds ordinarily makes its founders rich, that implies getting rich is doable too. Hard, but doable.

If there is one message I'd like to get across about startups, that's it. There is no magically difficult step that requires brilliance to solve.

@justinmoon
justinmoon / collapser.html
Created June 16, 2015 21:05
Jinja2 filter: collapse nested dictionary into HTML table
{% macro render_nested(json, key) -%}
<table>
{% if json.get(key) %}
{% for key, value in json.get(key).items() recursive %}
{% if value is mapping %}
{{ loop(value.items()) }}
{% else %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
The following builds are still in progress:
/gnu/store/zy0i43ccvlyhqjqr5p3nqzaqglj9xhvh-gcc-glibc-2.27-9.3.0.drv
/gnu/store/kzm3l7cxyljsaw92pkj9j57wyvaa6w8p-gcc-5.5.0.tar.xz.drv
/gnu/store/cbgd81mxj931fldfz7gmikh9ma9dfk68-gcc-9.3.0.tar.xz.drv
building /gnu/store/5w32y22c4mcb6rnbrg4s00abyhvj2yw7-ld-wrapper-x86_64-linux-gnu-0.drv...
The following builds are still in progress:
/gnu/store/zy0i43ccvlyhqjqr5p3nqzaqglj9xhvh-gcc-glibc-2.27-9.3.0.drv
/gnu/store/kzm3l7cxyljsaw92pkj9j57wyvaa6w8p-gcc-5.5.0.tar.xz.drv
/gnu/store/cbgd81mxj931fldfz7gmikh9ma9dfk68-gcc-9.3.0.tar.xz.drv