Skip to content

Instantly share code, notes, and snippets.

@vindard
vindard / one-liners.sh
Created July 25, 2023 13:41
Some one-liners I use to do tasks on my linux box
# To clean up all my docker volumes
docker volume rm $(docker volume ls | awk 'NR>1 {print $2}')

Verifying that I control the following Nostr public key: npub12zkknmund6ynu2yaptqamn0q29uje7ms3mqq6uu05v9d7t6tguyqcsaz8h

@vindard
vindard / BOBSpace-workshop-notes.md
Last active April 27, 2023 23:01
Some links and things that came up from today's workshop at BOB Space
@vindard
vindard / stablesats-rates-demo.py
Created October 13, 2022 15:16
Sketching out all the different conversion methods we can get from stablesats
import math
btc = 10_000_000
usd = 200_000
btcusd = btc/usd
def cents_from_sats(sats, rate):
return sats / btcusd
def sats_from_cents(cents):
@vindard
vindard / 1st-arb-demo.ts
Last active September 28, 2022 12:29
A test to demonstrate an arb opportunity we discovered
it.only("arbitrage BTC/USD with $0.01 strategy", async () => {
const ONE_CENT = { amount: 1n, currency: WalletCurrency.Usd } as UsdPaymentAmount
const ONE_SAT = { amount: 1n, currency: WalletCurrency.Btc } as BtcPaymentAmount
const getUsdForBtcEquivalent = async (
btcAmount: BtcPaymentAmount,
): Promise<CurrencyBaseAmount> => {
// console.log({ btcAmount })
const lnInvoice = await Wallets.addInvoiceForSelf({
walletId: walletIdB,
@vindard
vindard / index.ts
Created April 22, 2022 15:54
Test the conditional equivalence of 2 conditional statements
// Live run here: https://replit.com/@vindard/Conditional-Equivalence-TS
type fn = (a: boolean, b: boolean) => boolean
const test = (fn1: fn, fn2: fn) => {
const check = (a: boolean, b: boolean) => fn1(a, b) === fn2(a, b)
const cases: {[key: string]: [boolean, boolean]} = {
ft: [false, true],
ff: [false, false],
tt: [true, true],
@vindard
vindard / next-word
Last active April 18, 2022 01:04
BIP39 English word list
#!/bin/bash
./words $(python -c 'from random import random; print(round(random()*2048))')
@vindard
vindard / hash-from-preimage.ts
Last active February 14, 2022 18:02
Convert a Lightning Network preimage to its payment hash
import { createHash } from "crypto"
const hashFromPreImage = (preImage) => {
const preImageBuf = Buffer.from(preImage, "hex")
const sha256 = (buffer: Buffer) => createHash("sha256").update(buffer).digest("hex")
return sha256(preImageBuf)
}
@vindard
vindard / decode-macaroon.md
Last active July 19, 2022 08:08
Decode macaroon from hex string and write to file that can be parsed by lncli.

Decoding macaroon strings

Macaroons generated from the $ lncli bakemacaroon method are output as hex-encoded strings by default. To decode these to a binary file for easy usage with lncli these are a few options included here for bash and python.

The output file from these can be passed to the --macaroonpath flag directly when using $ lncli.

@vindard
vindard / README.md
Last active March 29, 2022 19:20
Galoy graphql api demo for #LightningHackdayIST

Description

This gist contains 3 files that can be imported into postman to play with our api:

  • grapqhql_api collection which has our queries and mutations
  • devnet environment variables for local testing (uses regtest network)
  • staging environment variables for testing against our staging endpoint (uses testnet network)