mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 13:14:56 +01:00
Empty description on ln_pay means don't check if same description
This commit is contained in:
@@ -189,6 +189,7 @@ ln_pay() {
|
|||||||
local expected_description=$(echo "${request}" | jq ".expected_description")
|
local expected_description=$(echo "${request}" | jq ".expected_description")
|
||||||
trace "[ln_pay] expected_description=${expected_description}"
|
trace "[ln_pay] expected_description=${expected_description}"
|
||||||
|
|
||||||
|
# Let's first decode the bolt11 string to make sure we are paying the good invoice
|
||||||
trace "[ln_pay] ./lightning-cli decodepay ${bolt11}"
|
trace "[ln_pay] ./lightning-cli decodepay ${bolt11}"
|
||||||
result=$(./lightning-cli decodepay ${bolt11})
|
result=$(./lightning-cli decodepay ${bolt11})
|
||||||
returncode=$?
|
returncode=$?
|
||||||
@@ -201,13 +202,18 @@ ln_pay() {
|
|||||||
local invoice_description=$(echo "${result}" | jq ".description")
|
local invoice_description=$(echo "${result}" | jq ".description")
|
||||||
trace "[ln_pay] invoice_description=${invoice_description}"
|
trace "[ln_pay] invoice_description=${invoice_description}"
|
||||||
|
|
||||||
|
# The amount must match
|
||||||
if [ "${expected_msatoshi}" != "${invoice_msatoshi}" ]; then
|
if [ "${expected_msatoshi}" != "${invoice_msatoshi}" ]; then
|
||||||
result="{\"result\":\"error\",\"expected_msatoshi\":${expected_msatoshi},\"invoice_msatoshi\":${invoice_msatoshi}}"
|
result="{\"result\":\"error\",\"expected_msatoshi\":${expected_msatoshi},\"invoice_msatoshi\":${invoice_msatoshi}}"
|
||||||
returncode=1
|
returncode=1
|
||||||
elif [ "${expected_description}" != "${invoice_description}" ]; then
|
elif [ "${expected_description}" != '""' ] && [ "${expected_description}" != "${invoice_description}" ]; then
|
||||||
|
# If expected description is empty, we accept any description on the invoice. Amount is the important thing.
|
||||||
|
|
||||||
result="{\"result\":\"error\",\"expected_description\":${expected_description},\"invoice_description\":${invoice_description}}"
|
result="{\"result\":\"error\",\"expected_description\":${expected_description},\"invoice_description\":${invoice_description}}"
|
||||||
returncode=1
|
returncode=1
|
||||||
else
|
else
|
||||||
|
# Amount and description is as expected, let's pay!
|
||||||
|
|
||||||
trace "[ln_pay] ./lightning-cli pay ${bolt11}"
|
trace "[ln_pay] ./lightning-cli pay ${bolt11}"
|
||||||
result=$(./lightning-cli pay ${bolt11})
|
result=$(./lightning-cli pay ${bolt11})
|
||||||
returncode=$?
|
returncode=$?
|
||||||
|
|||||||
Reference in New Issue
Block a user