Skip to content

Commit

Permalink
Allow to set upper amount limit for Ligtning Network invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsk committed Nov 14, 2022
1 parent 6213915 commit e06177a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def check_set_node_conf(name, default, node_conf):
tunnel_port = get_opt("tunnel_port", 22)
tor_proxy = get_opt("tor_proxy", None)
onchain_dust_limit = get_opt("onchain_dust_limit", 0.00000546)
ln_upper_limit = get_opt("ln_upper_limit", 0.10000000)
node_info = get_opt("node_info", None)
pollrate = get_opt("pollrate", 15)
payment_timeout = get_opt("payment_timeout", 60 * 60)
Expand Down
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ api_key_path = "SatSale_API_key"
# below this value.
onchain_dust_limit = 0.00000546

# Upper limit for LN payments in BTC. Don't generate Lightning invoices above
# this value.
ln_upper_limit = 0.10000000

# You can display your node uri so users can open channels with you by setting
# node_info="uri" (manually) or true (use `admin.macaroon` to fetch `getinfo`)
#node_info = "uri"
Expand Down
5 changes: 3 additions & 2 deletions satsale.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ def get(self):

btc_value = get_btc_value(base_amount, currency)

if btc_value > 21000000:
if btc_value > 21000000 or (not node.is_onchain and btc_value > config.ln_upper_limit):
logging.warning(
"Requested payment for {} {} BTC value {} too large (above 21M cap)".format(
"Requested payment for {} {} BTC value {} too large".format(
base_amount,
currency,
btc_value
Expand Down Expand Up @@ -189,6 +189,7 @@ def get(self):
"time": time.time(),
"webhook": webhook,
"onchain_dust_limit": config.onchain_dust_limit,
"ln_upper_limit": config.ln_upper_limit,
}

# Get an address / invoice, and create a QR code
Expand Down
2 changes: 1 addition & 1 deletion static/satsale.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function payment(payment_data) {
$('#timer').text(Math.round(invoice.time_left)).html();
$('#paymentDetails').show();

if (invoice.btc_value >= invoice.onchain_dust_limit) {
if (invoice.btc_value >= invoice.onchain_dust_limit && invoice.btc_value <= invoice.ln_upper_limit) {
$('#paymentMethodSwitchButton').show();
}

Expand Down

0 comments on commit e06177a

Please sign in to comment.