Skip to content

Instantly share code, notes, and snippets.

@d4amenace
d4amenace / c-lightning_snippets.md
Created July 20, 2020 23:24 — forked from gabridome/c-lightning_snippets.md
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)'
@d4amenace
d4amenace / c-lightning_snippets.md
Created July 20, 2020 23:24 — forked from gabridome/c-lightning_snippets.md
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)'