Created
September 2, 2024 06:52
-
-
Save RCasatta/b89dc7799476fb4ef8b2ea1570462e2f to your computer and use it in GitHub Desktop.
Core lightning, pay via a specific channel or with full channels. Shell script using `lightning-cli` and `jq`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
$ cat pay-using-channel.sh | |
#!/bin/sh | |
CHANNEL=$1 | |
BOLT11=$2 | |
[ -z "$CHANNEL" ] && echo "first program argument should be a short channel id and it is unset or set to the empty string" && exit 1 | |
[ -z "$BOLT11" ] && echo "second program argument should be a bolt11 invoice and it is unset or set to the empty string" && exit 1 | |
EXCLUDE=$(./exclude-all-channels-but.sh $CHANNEL) | |
lightning-cli pay -k bolt11=$BOLT11 exclude="${EXCLUDE}" | |
$ cat exclude-all-channels-but.sh | |
#!/bin/sh | |
CMD=${TEST_CMD:-lightning-cli listfunds} | |
$CMD | jq -c "[.channels.[] | select(.state==\"CHANNELD_NORMAL\") | select(.short_channel_id!=\"$1\") | (.short_channel_id + \"/0\"), (.short_channel_id + \"/1\") ]" | |
$ cat half-empty-channels.sh | |
#!/bin/sh | |
CMD=${TEST_CMD:-lightning-cli listfunds} | |
$CMD | jq -c "[.channels.[] | select(.state==\"CHANNELD_NORMAL\") | select(.short_channel_id!=\"$1\") | select(.our_amount_msat/.amount_msat<0.6) | (.short_channel_id + \"/0\"), (.short_channel_id + \"/1\") ]" | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment