Merge pull request 'Only support primary domain for Lightning Address' (#158) from chore/well-known_routes into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #158
This commit was merged in pull request #158.
This commit is contained in:
2024-01-29 09:03:37 +00:00
3 changed files with 28 additions and 33 deletions

View File

@@ -1,6 +1,6 @@
class LnurlpayController < ApplicationController
before_action :check_feature_enabled
before_action :find_user_by_address
before_action :check_service_available
before_action :find_user
MIN_SATS = 10
MAX_SATS = 1_000_000
@@ -9,7 +9,7 @@ class LnurlpayController < ApplicationController
def index
render json: {
status: "OK",
callback: "https://accounts.kosmos.org/lnurlpay/#{@user.address}/invoice",
callback: "https://#{Setting.accounts_domain}/lnurlpay/#{@user.cn}/invoice",
tag: "payRequest",
maxSendable: MAX_SATS * 1000, # msat
minSendable: MIN_SATS * 1000, # msat
@@ -69,9 +69,8 @@ class LnurlpayController < ApplicationController
private
def find_user_by_address
address = params[:address].split("@")
@user = User.where(cn: address.first, ou: address.last).first
def find_user
@user = User.where(cn: params[:username], ou: Setting.primary_domain).first
http_status :not_found if @user.nil?
end
@@ -89,7 +88,7 @@ class LnurlpayController < ApplicationController
private
def check_feature_enabled
def check_service_available
http_status :not_found unless Setting.lndhub_enabled?
end
end