Skip to content

Instantly share code, notes, and snippets.

@tyzbit
Created June 29, 2019 03:37
Show Gist options
  • Save tyzbit/7196619abe2072fa0e79d4f48fca735a to your computer and use it in GitHub Desktop.
Save tyzbit/7196619abe2072fa0e79d4f48fca735a to your computer and use it in GitHub Desktop.
Use arrow keys to browse through your LND's forwarding history
#!/bin/bash
## change if necessary to point to your node
lncli="lncli --rpcserver localhost:10009"
function fwdinghistory() {
$lncli fwdinghistory \
--start_time=$start \
--end_time=$end \
--index_offset=$offset \
--max_events=$events \
| jq '.forwarding_events[].timestamp |= (. | tonumber | strftime("%F %T")) |
.total_event_count = '$offset' + (.forwarding_events | length) |
.forwarding_events[].amt_in |= (. | tonumber) |
.forwarding_events[].amt_out |= (. | tonumber)'
}
start=1
end=$(date +%s)
offset=0
events=6
nav_help="[ Use left and right arrow keys to navigate ]\n"
clear
echo -e "$nav_help"
fwdinghistory
while read -r -sn1 key; do
case "$key" in
# arrow right
'C')
let offset=offset+$events
;;
# arrow left
'D')
let offset=offset-$events
;;
'q') break
;;
esac
clear
echo -e "$nav_help"
fwdinghistory
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment