Skip to content

Instantly share code, notes, and snippets.

# 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)