mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-19 05:35:17 +01:00
ln_connectfund finished
This commit is contained in:
@@ -178,11 +178,16 @@ ln_decodebolt11() {
|
|||||||
ln_connectfund() {
|
ln_connectfund() {
|
||||||
trace "Entering ln_connectfund()..."
|
trace "Entering ln_connectfund()..."
|
||||||
|
|
||||||
|
# {"peer":"nodeId@ip:port","msatoshi":"100000","callbackUrl":"https://callbackUrl/?channelReady=f3y2c3cvm4uzg2gq"}
|
||||||
|
|
||||||
local result
|
local result
|
||||||
local returncode
|
local returncode
|
||||||
local tx
|
local tx
|
||||||
local txid
|
local txid
|
||||||
local nodeId
|
local nodeId
|
||||||
|
local data
|
||||||
|
local channel_id
|
||||||
|
local msg
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local peer=$(echo "${request}" | jq ".peer" | tr -d '"')
|
local peer=$(echo "${request}" | jq ".peer" | tr -d '"')
|
||||||
@@ -234,19 +239,39 @@ ln_connectfund() {
|
|||||||
# { "code" : 301, "message" : "Cannot afford transaction" }
|
# { "code" : 301, "message" : "Cannot afford transaction" }
|
||||||
|
|
||||||
# Let's find what to watch
|
# Let's find what to watch
|
||||||
txid=$(echo "${result}" | jq ".txid" | tr -d '"')
|
txid=$(echo "${result}" | jq ".txid")
|
||||||
tx=$(echo "${result}" | jq ".tx" | tr -d '"')
|
tx=$(echo "${result}" | jq ".tx")
|
||||||
|
channel_id=$(echo "${result}" | jq ".channel_id")
|
||||||
|
|
||||||
|
data="{\"txid\":${txid},\"xconfCallbackURL\":\"${callback_url}\",\"nbxconf\":6}"
|
||||||
|
|
||||||
|
result=$(watchtxidrequest "${data}")
|
||||||
|
returncode=$?
|
||||||
|
trace_rc ${returncode}
|
||||||
|
trace "[ln_connectfund] result=${result}"
|
||||||
|
|
||||||
|
if [ "${returncode}" -eq "0" ]; then
|
||||||
|
result="{\"result\":\"success\",\"txid\":${txid},\"channel_id\":${channel_id}}"
|
||||||
|
else
|
||||||
|
trace "[ln_connectfund] Error watching txid, result=${result}"
|
||||||
|
result="{\"result\":\"failed\",\"message\":\"Failed at watching txid\"}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Error funding
|
# Error funding
|
||||||
trace "[ln_connectfund] Error funding, result=${result}"
|
trace "[ln_connectfund] Error funding, result=${result}"
|
||||||
|
msg=$(echo "${result}" | jq ".message")
|
||||||
|
result="{\"result\":\"failed\",\"message\":${msg}}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Error connecting
|
# Error connecting
|
||||||
trace "[ln_connectfund] Error connecting, result=${result}"
|
trace "[ln_connectfund] Error connecting, result=${result}"
|
||||||
|
msg=$(echo "${result}" | jq ".message")
|
||||||
|
result="{\"result\":\"failed\",\"message\":${msg}}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "${result}"
|
||||||
|
|
||||||
|
return ${returncode}
|
||||||
}
|
}
|
||||||
|
|
||||||
ln_pay() {
|
ln_pay() {
|
||||||
|
|||||||
@@ -307,6 +307,7 @@ main()
|
|||||||
ln_connectfund)
|
ln_connectfund)
|
||||||
# POST http://192.168.111.152:8080/ln_connectfund
|
# POST http://192.168.111.152:8080/ln_connectfund
|
||||||
# BODY {"peer":"nodeId@ip:port","msatoshi":"100000","callbackUrl":"https://callbackUrl/?channelReady=f3y2c3cvm4uzg2gq"}
|
# BODY {"peer":"nodeId@ip:port","msatoshi":"100000","callbackUrl":"https://callbackUrl/?channelReady=f3y2c3cvm4uzg2gq"}
|
||||||
|
# curl -H "Content-Type: application/json" -d '{"peer":"nodeId@ip:port","msatoshi":"100000","callbackUrl":"https://callbackUrl/?channelReady=f3y2c3cvm4uzg2gq"}' proxy:8888/ln_connectfund
|
||||||
|
|
||||||
response=$(ln_connectfund "${line}")
|
response=$(ln_connectfund "${line}")
|
||||||
response_to_client "${response}" ${?}
|
response_to_client "${response}" ${?}
|
||||||
|
|||||||
Reference in New Issue
Block a user