Usage:
lnaddress user@example.com 1000 "Thanks a lot!"
Probably not 100% compliant with LUDS but should almost fulfill LUD-01, LUD-06, and LUD-12.
Author: Joel Lehtonen, https://github.com/zouppen/
Usage:
lnaddress user@example.com 1000 "Thanks a lot!"
Probably not 100% compliant with LUDS but should almost fulfill LUD-01, LUD-06, and LUD-12.
Author: Joel Lehtonen, https://github.com/zouppen/
#!/bin/sh -eu | |
usage () { | |
echo "Usage: $0 user@example.com amount_msat comment" >&2 | |
echo "Converts Lightning Address to LN invoice" >&2 | |
exit 1 | |
} | |
test $# -eq 3 || usage | |
# Convert address to URI | |
url="$(echo "$1" | sed -nre 's|^([^@]+)@([^@]+)|https://\2/.well-known/lnurlp/\1|p')" | |
test -n "$url" || usage | |
# Fetch callback | |
export json_cb="$(curl --no-progress-meter --fail-with-body "$url")" | |
cb_url="$(jq -rn 'env.json_cb | fromjson | .callback // (.reason + "\n" | halt_error)')" | |
# Try to convert it to LN URI | |
export json_ln="$(curl --no-progress-meter --fail-with-body -G --data-urlencode "amount=$2" --data-urlencode "comment=$3" "$cb_url")" | |
# Extract invoice, if any | |
jq -rn 'env.json_ln | fromjson | .pr // (.reason + "\n" | halt_error)' |