Add keysend support for Lightning Address

Allow keysend payments to user addresses. Useful for Podcasting 2.0/v4v.
This commit is contained in:
Râu Cao
2023-02-19 17:45:27 +08:00
parent 84337c3a7d
commit c7fe1bc3bc
4 changed files with 41 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
class LnurlpayController < ApplicationController
before_action :check_feature_enabled
before_action :find_user_by_address
MIN_SATS = 10
@@ -17,6 +18,20 @@ class LnurlpayController < ApplicationController
}
end
def keysend
http_status :not_found unless Setting.lndhub_keysend_enabled?
render json: {
status: "OK",
tag: "keysend",
pubkey: Setting.lndhub_public_key,
customData: [{
customKey: "696969",
customValue: @user.ln_account
}]
}
end
def invoice
amount = params[:amount].to_i / 1000 # msats
address = params[:address]
@@ -72,4 +87,9 @@ class LnurlpayController < ApplicationController
comment.length <= MAX_COMMENT_CHARS
end
private
def check_feature_enabled
http_status :not_found if !Setting.lndhub_enabled?
end
end

View File

@@ -2,10 +2,27 @@
class Setting < RailsSettings::Base
cache_prefix { "v1" }
#
# Registrations
#
field :reserved_usernames, type: :array, default: %w[
account accounts admin donations mail webmaster support
]
field :lndhub_enabled, default: (ENV["LNDHUB_API_URL"].present?.to_s || "false"), type: :boolean
field :lndhub_admin_enabled, default: (ENV["LNDHUB_ADMIN_UI"] || "false"), type: :boolean
#
# Lightning Network
#
field :lndhub_enabled, type: :boolean,
default: (ENV["LNDHUB_API_URL"].present?.to_s || false)
field :lndhub_admin_enabled, type: :boolean,
default: (ENV["LNDHUB_ADMIN_UI"] || false)
field :lndhub_public_key, type: :string,
default: (ENV["LNDHUB_PUBLIC_KEY"] || "")
field :lndhub_keysend_enabled, type: :boolean,
default: -> { self.lndhub_public_key.present?.to_s || false }
end