Skip to content

Instantly share code, notes, and snippets.

@SachinMeier
SachinMeier / lnd_test.go
Last active February 11, 2023 00:44
Chaincode Labs LND challenge
func assertAmountRouted(amt btcutil.Amount, router, sndr, rcvr *lntest.HarnessNode) func() error {
return func() error {
listReq := &lnrpc.ListChannelsRequest{}
ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
sndrListChannels, err := sndr.ListChannels(ctxt, listReq)
if err != nil {
return fmt.Errorf("unable to query for %s's channel "+
"list: %v", sndr.Name(), err)
@SachinMeier
SachinMeier / rawapi.py
Last active February 10, 2022 06:11
The simplest code to execute GET and POST calls to any RESTful API, JSON API, or raw data API
import requests
BASE_URL = 'https://example.com/api/'
def post_api(endpoint, data):
url = BASE_URL + endpoint
try:
response = requests.post(url, data)
except Exception as e:
response = e
@SachinMeier
SachinMeier / blockstream-client.py
Last active February 5, 2022 02:01
Simple Python API Client for Blockstream API
import requests
from io import BytesIO
import time
import asyncio
# --------------- API UTIL -----------------
MAIN_URL = 'https://blockstream.info/'
TEST_URL = 'https://blockstream.info/testnet/'
def post_api(endpoint, data, testnet=False):
@SachinMeier
SachinMeier / run script
Created February 2, 2022 21:44
Easily run a terminal command an arbitrary number of times
#!/bin/bash
num=$1
shift
for ((i=1; i<=num; i++))
do
$@
done
# Example: `run 5 go test pkg/main/*.go`
# Example: `run 10 echo redrum`
@SachinMeier
SachinMeier / ofac-reader.py
Last active January 29, 2022 08:45
Script to parse OFAC's SDN List for Bitcoin addresses
import requests
import re
BASE_URL = "https://www.treasury.gov/ofac/downloads/sdnlist.txt"
def get_ofac_page():
url = BASE_URL
try:
response = requests.get(url)
return response.text
@SachinMeier
SachinMeier / timecast
Last active September 7, 2021 02:38
Broadcast a Bitcoin Transaction starting at a specific block height with this command: `$ timecast <BLOCK_HEIGHT> <TRANSACTION_HEX>`. This is most useful for timelocked transactions, which will not be relayed until they are valid. NOTE: You use your own node by default, but by commenting out line 11 and uncommenting line 10, you can use Blockstr…
#!/bin/bash
TARGET=$1
TXN=$2
echo $TARGET
echo $TXN
while true; do
# BLOCK_HEIGHT=$(curl https://blockstream.info/api/blocks/tip/height)

Keybase proof

I hereby claim:

  • I am pillagr on github.
  • I am pillagr (https://keybase.io/pillagr) on keybase.
  • I have a public key ASAQMyPrOW4yJoT1ac7GVnbFIvZUAyy1V2xGEZEr2BErqAo

To claim this, I am signing this object: