2016-06-02 17:15:36 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
[ -z "$1" ] && (
|
|
|
|
echo "usage: "
|
2017-07-26 18:57:31 +02:00
|
|
|
echo " eclair-cli help"
|
2016-06-02 17:15:36 +02:00
|
|
|
) && exit 1
|
|
|
|
|
2017-07-26 18:57:31 +02:00
|
|
|
URL="http://localhost:8080"
|
|
|
|
CURL_OPTS="-sS -X POST -H \"Content-Type: application/json\""
|
2016-06-02 17:15:36 +02:00
|
|
|
|
2017-07-26 18:57:31 +02:00
|
|
|
case $1 in
|
|
|
|
"help")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"help\", \"params\" : [] }' $URL" | jq -r ".result[]"
|
|
|
|
;;
|
|
|
|
"getinfo")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"getinfo\", \"params\" : [] }' $URL" | jq ".result"
|
|
|
|
;;
|
|
|
|
"channels")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"channels\", \"params\" : [] }' $URL" | jq ".result[]"
|
|
|
|
;;
|
2017-12-22 21:01:40 +01:00
|
|
|
"channels")
|
|
|
|
if [ $# -ge 2 ]
|
|
|
|
then
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"channels\", \"params\" : [\"${2?"missing node id"}\"] }' $URL" | jq ".result[]"
|
|
|
|
else
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"channels\", \"params\" : [] }' $URL" | jq ".result[]"
|
|
|
|
fi
|
2017-12-15 15:05:22 +01:00
|
|
|
;;
|
2017-07-26 18:57:31 +02:00
|
|
|
"channel")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"channel\", \"params\" : [\"${2?"missing channel id"}\"] }' $URL" | jq ".result | { nodeid, channelId, state, balanceMsat: .data.commitments.localCommit.spec.toLocalMsat, capacitySat: .data.commitments.commitInput.txOut.amount.amount }"
|
|
|
|
;;
|
2017-12-22 23:06:35 +01:00
|
|
|
"connect")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"open\", \"params\" : [\"${2?"missing uri"}\"] }' $URL" | jq -r "if .error == null then .result else .error.message end"
|
|
|
|
;;
|
2017-07-26 18:57:31 +02:00
|
|
|
"open")
|
2017-12-22 23:06:35 +01:00
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"open\", \"params\" : [\"${2?"missing node id"}\", ${3?"missing amount (sat)"}, ${4?"missing push amount (msat)"}] }' $URL" | jq -r "if .error == null then .result else .error.message end"
|
2017-07-26 18:57:31 +02:00
|
|
|
;;
|
|
|
|
"close")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"close\", \"params\" : [\"${2?"missing channel id"}\"] }' $URL"
|
|
|
|
;;
|
|
|
|
"receive")
|
2017-11-27 20:46:17 +01:00
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"receive\", \"params\" : [${2?"missing amount"}, \"${3?"missing description"}\"] }' $URL" | jq -r "if .error == null then .result else .error.message end"
|
2017-07-26 18:57:31 +02:00
|
|
|
;;
|
|
|
|
"send")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"send\", \"params\" : [\"${2?"missing request"}\"] }' $URL" | jq -r "if .error == null then .result else .error.message end"
|
|
|
|
;;
|
2017-11-27 20:46:17 +01:00
|
|
|
"allnodes")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"allnodes\", \"params\" : [] }' $URL" | jq ".result"
|
|
|
|
;;
|
|
|
|
"allchannels")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"allchannels\", \"params\" : [] }' $URL" | jq ".result"
|
2017-07-26 18:57:31 +02:00
|
|
|
;;
|
|
|
|
"peers")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"peers\", \"params\" : [] }' $URL" | jq ".result"
|
|
|
|
;;
|
2017-12-22 21:01:40 +01:00
|
|
|
"checkpayment")
|
|
|
|
eval curl "$CURL_OPTS -d '{ \"method\": \"checkpayment\", \"params\" : [\"${2?"missing payment request or payment hash"}\"] }' $URL" | jq ".result"
|
|
|
|
;;
|
2016-06-02 17:15:36 +02:00
|
|
|
esac
|