Skip to content

Instantly share code, notes, and snippets.

@gabridome
gabridome / addressesfromhwi.sh
Last active December 29, 2021 13:52
Estract first 5 addresses from a Ledger according to BIP49 and 84. Requires HWI and pycoin
#!/bin/sh
##
## This script will extract the first 5 normal addresses and the first 5 change addresses
## from a ledger nano S (not tested but should work with any supported hardware wallets)
## To have more addresses it is sufficient to change the
## `ku -j -s0/0-5`part as desired. So if someone wants 100 addresses after the 20th,
## that part will be `ku -j -s0/20-119`.
## Use at your own risk and check few addresses with other applications.
##
# starting from `listtransactions` the script collects the inputs and
# the output amounts to calculate the fees.
# the inputs are collected with a SQL statement inside outputs table.
lightning-cli listtransactions| jq -c '.transactions[]' | while read object
do export hash=$(jq '.hash'<<<$object)
export inputs=$(jq '.inputs'<<<$object)
export outputs=$(jq '[.outputs[]]'<<<$object)
export satoshis=$(jq '[.[].satoshis[0:-4] |tonumber / 1000]| add' <<< $outputs)
export block=$(jq '.blockheight' <<< $object)
@gabridome
gabridome / c-lightning_snippets.md
Last active September 17, 2020 05:57
Snippets for c-lightning

Simple commands to extract informations from c-lightning

To see the list of lightning transactions you have to aggregate the result of two commands:

export invoices=$(lightning-cli listinvoices|jq '[.invoices[]|select( .status == "paid" )|{"payment_hash":.payment_hash, "time":.paid_at|gmtime|todate, "amount":.msatoshi,"fees":0, "description":.description}]')
export sendpays=$(lightning-cli listsendpays|jq '[.payments[]|select(.status == "complete")|{"payment_hash":.payment_hash,"time":.created_at|gmtime|todate,"amount":(.msatoshi_sent * -1),"fees":(.msatoshi_sent - .msatoshi), "description":"payment"}]')

and then you can join the two results and sort them by "time":

jq --argjson invoices "$invoices" --argjson sendpays "$sendpays" -n '$invoices + $sendpays | sort_by(.time)'
@gabridome
gabridome / c-lightning_on_tor.md
Last active July 21, 2020 03:36
c-lightning on TOR a straightforward way to be visible on tor

C-LIGHTNING connected from inside your firewall in 60 lines

C-lightning is pretty rich in terms of options on how to be visible and/or how to reach other nodes in the lightning network.

The purpose of this article is to put you in the condition to be reached on the Tor network in the most straightforward way I am aware of, leaving more complex and reach configurations to deeper studies. You can find the documentation [here][tordoc].

Setting up an Electrum server reachable only by you on Tor.

This small guide weill help you to set up your own Electrum Server and to make it available on Tor network so that only your client is able to reach it. The necessary steps are:

  1. Set up Tor on your server (it can be your desktop provided that it has the necessary requirements)
  2. Install and have your bitcoin node synchronized
  3. Install Electrs and let it sync with your Bircoin Core node.
  4. Set up an Hidden Service to make the Elelectrum Server Service reachable from outside in an authenticated way
  5. Configure your client to access the authenticated service
@gabridome
gabridome / gist:48f756c52587c0ee53ed32279838eabd
Last active December 10, 2018 10:06
how to verify opentimestamps.org .ots files reproducing the hash operations on the command line on Mac.
the output of the `ots info` command is in the form:
````
$ ots info ../../Downloads/email.html.ots
File sha256 hash: b5054af8078852d17d1653897a99cfd3cf7a0f0d5d33bcd15961ec619c3cb19e
Timestamp:
append 40ee69f78b4e4c4094d6a6e8869c9c93
sha256
-> append 196ac4428094e68d57db4e99100891ae
sha256
measure # wind speed
1 9
2 9
3 6
sum 24
Preceding sum 24
4 5
5 6
6 9
sum 44
measure # wind speed
1 9
2 9
3 6
4 5
5 8
6 6
7 1 <<<<<<<<
8 9
9 8
@gabridome
gabridome / bare-measures.csv
Created March 6, 2018 15:22
wind measures
measure # wind speed
1 9
2 9
3 6
4 5
5 8
6 6
7 9
8 9
9 8
@gabridome
gabridome / gist:851ff00c748abc2c207a
Created April 27, 2015 14:05
gist for onename.io
Verifying that +gabridome is my openname (Bitcoin username). https://onename.com/gabridome