mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-19 05:35:17 +01:00
Add ln_listfunds, ln_getroute, ln_withdraw
This commit is contained in:
@@ -29,6 +29,7 @@ action_ln_create_invoice=watcher
|
||||
action_ln_getconnectionstring=watcher
|
||||
action_ln_decodebolt11=watcher
|
||||
action_ln_listpeers=watcher
|
||||
action_ln_getroute=watcher
|
||||
|
||||
# Spender can do what the watcher can do, plus:
|
||||
action_getxnslist=spender
|
||||
@@ -48,8 +49,11 @@ action_ln_newaddr=spender
|
||||
action_ots_stamp=spender
|
||||
action_ots_getfile=spender
|
||||
action_ln_getinvoice=spender
|
||||
action_ln_delinvoice=spender
|
||||
action_ln_decodebolt11=spender
|
||||
action_ln_connectfund=spender
|
||||
action_ln_listfunds=spender
|
||||
action_ln_withdraw=spender
|
||||
|
||||
# Admin can do what the spender can do, plus:
|
||||
|
||||
|
||||
@@ -463,16 +463,53 @@ ln_newaddr() {
|
||||
|
||||
ln_listpeers() {
|
||||
trace "Entering ln_listpeers()..."
|
||||
|
||||
local id=${1}
|
||||
local result
|
||||
|
||||
result=$(./lightning-cli listpeers)
|
||||
result=$(./lightning-cli listpeers ${id})
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
trace "[ln_listpeers] result=${result}"
|
||||
|
||||
echo "${result}"
|
||||
return ${returncode}
|
||||
}
|
||||
ln_listfunds() {
|
||||
trace "Entering ln_listpeers()..."
|
||||
local result
|
||||
result=$(./lightning-cli listfunds)
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
trace "[ln_listfunds] result=${result}"
|
||||
echo "${result}"
|
||||
return ${returncode}
|
||||
}
|
||||
ln_getroute() {
|
||||
trace "Entering ln_getroute()..."
|
||||
# Defaults used from c-lightning documentation
|
||||
local result
|
||||
local id=${1}
|
||||
local msatoshi=${2}
|
||||
local riskfactor=${3}
|
||||
result=$(./lightning-cli getroute -k id=${id} msatoshi=${msatoshi} riskfactor=${riskfactor})
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
trace "[ln_getroute] result=${result}"
|
||||
echo "${result}"
|
||||
return ${returncode}
|
||||
}
|
||||
|
||||
ln_withdraw() {
|
||||
trace "Entering ln_withdraw()..."
|
||||
# Defaults used from c-lightning documentation
|
||||
local result
|
||||
local request=${1}
|
||||
local destination=$(echo "${request}" | jq -r ".destination")
|
||||
local satoshi=$(echo "${request}" | jq -r ".satoshi")
|
||||
local feerate=$(echo "${request}" | jq -r ".feerate")
|
||||
result=$(./lightning-cli withdraw ${destination} ${satoshi} ${feerate})
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
trace "[ln_withdraw] result=${result}"
|
||||
echo "${result}"
|
||||
return ${returncode}
|
||||
}
|
||||
|
||||
|
||||
@@ -417,6 +417,25 @@ main() {
|
||||
response_to_client "${response}" ${?}
|
||||
break
|
||||
;;
|
||||
ln_listfunds)
|
||||
# GET http://192.168.111.152:8080/ln_listfunds
|
||||
response=$(ln_listfunds)
|
||||
response_to_client "${response}" ${?}
|
||||
break
|
||||
;;
|
||||
ln_getroute)
|
||||
# GET http://192.168.111.152:8080/ln_getroute/<node_id>/<msatoshi>/<riskfactor>
|
||||
response=$(ln_getroute $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3) $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f4) $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f5))
|
||||
response_to_client "${response}" ${?}
|
||||
break
|
||||
;;
|
||||
ln_withdraw)
|
||||
# POST http://192.168.111.152:8080/ln_withdraw
|
||||
# BODY {"destination":"segwitAddress","satoshi":"100000","feerate":0}
|
||||
response=$(ln_withdraw "${line}")
|
||||
response_to_client "${response}" ${?}
|
||||
break
|
||||
;;
|
||||
ots_stamp)
|
||||
# POST http://192.168.111.152:8080/ots_stamp
|
||||
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","callbackUrl":"192.168.111.233:1111/callbackUrl"}
|
||||
|
||||
Reference in New Issue
Block a user