Compare commits
5 Commits
6790e8383d
...
v0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
f7d0a0ba85
|
|||
| 83e4dfa18f | |||
|
4c70600d1f
|
|||
|
9903683536
|
|||
|
4c51b9c966
|
@@ -3,6 +3,7 @@ class LnurlpayController < ApplicationController
|
||||
|
||||
MIN_SATS = 100
|
||||
MAX_SATS = 1_000_000
|
||||
MAX_COMMENT_CHARS = 100
|
||||
|
||||
def index
|
||||
render json: {
|
||||
@@ -12,22 +13,32 @@ class LnurlpayController < ApplicationController
|
||||
maxSendable: MAX_SATS * 1000, # msat
|
||||
minSendable: MIN_SATS * 1000, # msat
|
||||
metadata: metadata(@user.address),
|
||||
commentAllowed: 0
|
||||
commentAllowed: MAX_COMMENT_CHARS
|
||||
}
|
||||
end
|
||||
|
||||
def invoice
|
||||
amount = params[:amount].to_i / 1000 # msats
|
||||
address = params[:address]
|
||||
comment = params[:comment] || ""
|
||||
|
||||
if !valid_amount?(amount)
|
||||
render json: { status: "ERROR", reason: "Invalid amount" }
|
||||
return
|
||||
end
|
||||
|
||||
if !valid_comment?(comment)
|
||||
render json: { status: "ERROR", reason: "Comment too long" }
|
||||
return
|
||||
end
|
||||
|
||||
memo = "Sats for #{address}"
|
||||
memo = "#{memo}: \"#{comment}\"" if comment.present?
|
||||
|
||||
payment_request = @user.ln_create_invoice({
|
||||
amount: amount, # we create invoices in sats
|
||||
description_hash: Digest::SHA2.hexdigest(metadata(address))
|
||||
memo: memo,
|
||||
description_hash: Digest::SHA2.hexdigest(metadata(address)),
|
||||
})
|
||||
|
||||
render json: {
|
||||
@@ -57,4 +68,8 @@ class LnurlpayController < ApplicationController
|
||||
amount_in_sats <= MAX_SATS && amount_in_sats >= MIN_SATS
|
||||
end
|
||||
|
||||
def valid_comment?(comment)
|
||||
comment.length <= MAX_COMMENT_CHARS
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -49,6 +49,7 @@ class Lndhub
|
||||
def addinvoice(payload)
|
||||
invoice = post "addinvoice", {
|
||||
amt: payload[:amount],
|
||||
memo: payload[:memo],
|
||||
description_hash: payload[:description_hash]
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"sass": "^1.49.7",
|
||||
"tailwindcss": "^3.0.22"
|
||||
},
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"scripts": {
|
||||
"build:css:sass": "sass ./app/assets/stylesheets/legacy.sass.scss ./app/assets/builds/legacy.css --no-source-map --load-path=node_modules",
|
||||
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
||||
|
||||
Reference in New Issue
Block a user