mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
contrib/lightning-pay: helper to make a payment.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
76ac978df4
commit
1b6012879b
32
contrib/lightning-pay
Executable file
32
contrib/lightning-pay
Executable file
@ -0,0 +1,32 @@
|
||||
#! /bin/sh -e
|
||||
# A terrible script to make a payment.
|
||||
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: <destination-id> <amount-in-milli-satoshi> <payment-hash>" >&2
|
||||
exit 1
|
||||
fi
|
||||
DEST="$1"
|
||||
AMOUNT="$2"
|
||||
PHASH="$3"
|
||||
|
||||
if ROUTE=`daemon/lightning-cli getroute $DEST $AMOUNT 1`; then
|
||||
# Strip down to raw array.
|
||||
ROUTE=`echo $ROUTE | sed 's/^{ "route" : \(.*\) }$/\1/'`
|
||||
# Get first amount.
|
||||
PAID=`echo $ROUTE | tr , '\012' | sed -n 's/.*msatoshi[^0-9]*\([0-9]*\).*/\1/p' | head -n1`
|
||||
echo -n "Paying fee $(($PAID - $AMOUNT)) on $AMOUNT ("`echo "scale=3; ($PAID - $AMOUNT) * 100 / $AMOUNT" | bc`"%). Send [Y/n]? "
|
||||
read REPLY
|
||||
case $REPLY in
|
||||
""|y*|Y)
|
||||
daemon/lightning-cli sendpay "$ROUTE" "$PHASH"
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo Not sending.
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo Routing failed >&2
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue
Block a user