feat: use 1.4.0 dynamic extension loading (#116)
* feat: use 1.4.0 dynamic extension loading and go through extension todo: https://github.com/lnbits/lnbits/issues/3652
This commit is contained in:
parent
a1a55cb974
commit
33b06bcd9b
18 changed files with 1622 additions and 1599 deletions
|
|
@ -12,7 +12,6 @@ LNURL is a range of lightning-network standards that allow us to use lightning-n
|
||||||
|
|
||||||
1. Create an LNURLp (New Pay link)\
|
1. Create an LNURLp (New Pay link)\
|
||||||

|

|
||||||
|
|
||||||
- select your wallets
|
- select your wallets
|
||||||
- make a small description
|
- make a small description
|
||||||
- enter amount
|
- enter amount
|
||||||
|
|
@ -25,7 +24,6 @@ LNURL is a range of lightning-network standards that allow us to use lightning-n
|
||||||
|
|
||||||
2. Use the shareable link or view the LNURLp you just created\
|
2. Use the shareable link or view the LNURLp you just created\
|
||||||

|

|
||||||
|
|
||||||
- you can now open your LNURLp and copy the LNURL, get the shareable link or print it\
|
- you can now open your LNURLp and copy the LNURL, get the shareable link or print it\
|
||||||

|

|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Pay Links",
|
"name": "Pay Links",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"short_description": "Make reusable LNURL pay links",
|
"short_description": "Make reusable LNURL pay links",
|
||||||
"tile": "/lnurlp/static/image/lnurl-pay.png",
|
"tile": "/lnurlp/static/image/lnurl-pay.png",
|
||||||
"min_lnbits_version": "1.4.0",
|
"min_lnbits_version": "1.4.0",
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ async def m001_initial(db):
|
||||||
"""
|
"""
|
||||||
Initial pay table.
|
Initial pay table.
|
||||||
"""
|
"""
|
||||||
await db.execute(
|
await db.execute(f"""
|
||||||
f"""
|
|
||||||
CREATE TABLE lnurlp.pay_links (
|
CREATE TABLE lnurlp.pay_links (
|
||||||
id {db.serial_primary_key},
|
id {db.serial_primary_key},
|
||||||
wallet TEXT NOT NULL,
|
wallet TEXT NOT NULL,
|
||||||
|
|
@ -17,8 +16,7 @@ async def m001_initial(db):
|
||||||
served_meta INTEGER NOT NULL,
|
served_meta INTEGER NOT NULL,
|
||||||
served_pr INTEGER NOT NULL
|
served_pr INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def m002_webhooks_and_success_actions(db):
|
async def m002_webhooks_and_success_actions(db):
|
||||||
|
|
@ -28,16 +26,14 @@ async def m002_webhooks_and_success_actions(db):
|
||||||
await db.execute("ALTER TABLE lnurlp.pay_links ADD COLUMN webhook_url TEXT;")
|
await db.execute("ALTER TABLE lnurlp.pay_links ADD COLUMN webhook_url TEXT;")
|
||||||
await db.execute("ALTER TABLE lnurlp.pay_links ADD COLUMN success_text TEXT;")
|
await db.execute("ALTER TABLE lnurlp.pay_links ADD COLUMN success_text TEXT;")
|
||||||
await db.execute("ALTER TABLE lnurlp.pay_links ADD COLUMN success_url TEXT;")
|
await db.execute("ALTER TABLE lnurlp.pay_links ADD COLUMN success_url TEXT;")
|
||||||
await db.execute(
|
await db.execute(f"""
|
||||||
f"""
|
|
||||||
CREATE TABLE lnurlp.invoices (
|
CREATE TABLE lnurlp.invoices (
|
||||||
pay_link INTEGER NOT NULL REFERENCES {db.references_schema}pay_links (id),
|
pay_link INTEGER NOT NULL REFERENCES {db.references_schema}pay_links (id),
|
||||||
payment_hash TEXT NOT NULL,
|
payment_hash TEXT NOT NULL,
|
||||||
webhook_sent INT, -- null means not sent, otherwise store status
|
webhook_sent INT, -- null means not sent, otherwise store status
|
||||||
expiry INT
|
expiry INT
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def m003_min_max_comment_fiat(db):
|
async def m003_min_max_comment_fiat(db):
|
||||||
|
|
@ -86,8 +82,7 @@ async def m006_redux(db):
|
||||||
else:
|
else:
|
||||||
# but we have to do this for sqlite
|
# but we have to do this for sqlite
|
||||||
await db.execute("ALTER TABLE lnurlp.pay_links RENAME TO pay_links_old")
|
await db.execute("ALTER TABLE lnurlp.pay_links RENAME TO pay_links_old")
|
||||||
await db.execute(
|
await db.execute(f"""
|
||||||
f"""
|
|
||||||
CREATE TABLE lnurlp.pay_links (
|
CREATE TABLE lnurlp.pay_links (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
wallet TEXT NOT NULL,
|
wallet TEXT NOT NULL,
|
||||||
|
|
@ -105,8 +100,7 @@ async def m006_redux(db):
|
||||||
webhook_headers TEXT,
|
webhook_headers TEXT,
|
||||||
webhook_body TEXT
|
webhook_body TEXT
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
for row in [
|
for row in [
|
||||||
list(row) for row in await db.fetchall("SELECT * FROM lnurlp.pay_links_old")
|
list(row) for row in await db.fetchall("SELECT * FROM lnurlp.pay_links_old")
|
||||||
|
|
@ -172,13 +166,11 @@ async def m009_add_settings(db):
|
||||||
"""
|
"""
|
||||||
Add extension settings table
|
Add extension settings table
|
||||||
"""
|
"""
|
||||||
await db.execute(
|
await db.execute("""
|
||||||
"""
|
|
||||||
CREATE TABLE lnurlp.settings (
|
CREATE TABLE lnurlp.settings (
|
||||||
nostr_private_key TEXT NOT NULL
|
nostr_private_key TEXT NOT NULL
|
||||||
);
|
);
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def m010_add_pay_link_domain(db):
|
async def m010_add_pay_link_domain(db):
|
||||||
|
|
@ -193,14 +185,10 @@ async def m011_add_created_at(db: Connection):
|
||||||
Add created_at to pay links
|
Add created_at to pay links
|
||||||
"""
|
"""
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(f"""ALTER TABLE lnurlp.pay_links ADD COLUMN
|
||||||
f"""ALTER TABLE lnurlp.pay_links ADD COLUMN
|
created_at TIMESTAMP DEFAULT {db.timestamp_column_default}""")
|
||||||
created_at TIMESTAMP DEFAULT {db.timestamp_column_default}"""
|
await db.execute(f"""ALTER TABLE lnurlp.pay_links ADD COLUMN
|
||||||
)
|
updated_at TIMESTAMP DEFAULT {db.timestamp_column_default}""")
|
||||||
await db.execute(
|
|
||||||
f"""ALTER TABLE lnurlp.pay_links ADD COLUMN
|
|
||||||
updated_at TIMESTAMP DEFAULT {db.timestamp_column_default}"""
|
|
||||||
)
|
|
||||||
|
|
||||||
now = int(time())
|
now = int(time())
|
||||||
await db.execute(
|
await db.execute(
|
||||||
|
|
|
||||||
19
package-lock.json
generated
19
package-lock.json
generated
|
|
@ -9,8 +9,8 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.7.4",
|
||||||
"pyright": "^1.1.358"
|
"pyright": "^1.1.407"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fsevents": {
|
"node_modules/fsevents": {
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
"darwin"
|
"darwin"
|
||||||
|
|
@ -27,9 +28,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.3.3",
|
"version": "3.7.4",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz",
|
||||||
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
|
"integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==",
|
||||||
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin/prettier.cjs"
|
"prettier": "bin/prettier.cjs"
|
||||||
},
|
},
|
||||||
|
|
@ -41,9 +43,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pyright": {
|
"node_modules/pyright": {
|
||||||
"version": "1.1.372",
|
"version": "1.1.407",
|
||||||
"resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.372.tgz",
|
"resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.407.tgz",
|
||||||
"integrity": "sha512-S0XYmTQWK+ha9FTIWviNk91UnbD569wPUCNEltSqtHeTJhbHj5z3LkOKiqXAOvn72BBfylcgpQqyQHsocmQtiQ==",
|
"integrity": "sha512-zU+peTFEVUdokNQyUBhGQYt+NWI/3aiNlvBbDBSsn5Ti334XElFUs+GDjQzCbchYfkT+DvMAT3OkMcV4CuEfDg==",
|
||||||
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"pyright": "index.js",
|
"pyright": "index.js",
|
||||||
"pyright-langserver": "langserver.index.js"
|
"pyright-langserver": "langserver.index.js"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.7.4",
|
||||||
"pyright": "^1.1.358"
|
"pyright": "^1.1.407"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@ dependencies = ["lnbits>1"]
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
package-mode = false
|
package-mode = false
|
||||||
|
|
||||||
[tool.uv]
|
[dependency-groups]
|
||||||
dev-dependencies = [
|
dev = [
|
||||||
"black>=24.3.0",
|
"black>=24.3.0",
|
||||||
"pytest-asyncio>=0.21.0",
|
"pytest-asyncio>=0.21.0",
|
||||||
"pytest>=7.3.2",
|
"pytest>=7.3.2",
|
||||||
"mypy>=1.5.1",
|
"mypy==1.17.1",
|
||||||
"pre-commit>=3.2.2",
|
"pre-commit>=3.2.2",
|
||||||
"ruff>=0.3.2",
|
"ruff>=0.3.2",
|
||||||
"types-cffi>=1.16.0.20240331",
|
"types-cffi>=1.16.0.20240331",
|
||||||
|
|
@ -34,14 +34,6 @@ warn_untyped_fields = true
|
||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
module = [
|
module = [
|
||||||
"lnbits.*",
|
"lnbits.*",
|
||||||
"lnurl.*",
|
|
||||||
"loguru.*",
|
|
||||||
"fastapi.*",
|
|
||||||
"pydantic.*",
|
|
||||||
"pyqrcode.*",
|
|
||||||
"shortuuid.*",
|
|
||||||
"httpx.*",
|
|
||||||
"websocket.*",
|
|
||||||
"pynostr.*",
|
"pynostr.*",
|
||||||
]
|
]
|
||||||
ignore_missing_imports = "True"
|
ignore_missing_imports = "True"
|
||||||
|
|
|
||||||
11
static/display.js
Normal file
11
static/display.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
window.PageLnurlpPublic = {
|
||||||
|
template: '#page-lnurlp-public',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
url: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.url = window.location.origin + '/lnurlp/' + this.$route.params.id
|
||||||
|
}
|
||||||
|
}
|
||||||
67
static/display.vue
Normal file
67
static/display.vue
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<template id="page-lnurlp-public">
|
||||||
|
<div class="row q-col-gutter-md justify-center">
|
||||||
|
<div class="col-12 col-sm-6 col-md-5 col-lg-4">
|
||||||
|
<q-card class="q-pa-lg">
|
||||||
|
<q-card-section class="q-pa-none">
|
||||||
|
<div class="text-center">
|
||||||
|
<lnbits-qrcode-lnurl :url="url" :nfc="true"></lnbits-qrcode-lnurl>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-6 col-md-5 col-lg-4 q-gutter-y-md">
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<h6 class="text-subtitle1 q-mb-sm q-mt-none">
|
||||||
|
LNbits LNURL-pay link
|
||||||
|
</h6>
|
||||||
|
<p class="q-my-none">
|
||||||
|
Use an LNURL compatible bitcoin wallet to pay.
|
||||||
|
</p>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section class="q-pa-none">
|
||||||
|
<q-separator></q-separator>
|
||||||
|
<q-list>
|
||||||
|
<q-expansion-item
|
||||||
|
group="extras"
|
||||||
|
icon="info"
|
||||||
|
label="Powered by LNURL"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<p>
|
||||||
|
LNURL is a range of lightning-network standards that allow
|
||||||
|
us to use lightning-network differently. An LNURL-pay is a
|
||||||
|
link that wallets use to fetch an invoice from a server
|
||||||
|
on-demand. The link or QR code is fixed, but each time it is
|
||||||
|
read by a compatible wallet a new QR code is issued by the
|
||||||
|
service. It can be used to activate machines without them
|
||||||
|
having to maintain an electronic screen to generate and show
|
||||||
|
invoices locally, or to sell any predefined good or service
|
||||||
|
automatically.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Exploring LNURL and finding use cases, is really helping
|
||||||
|
inform lightning protocol development, rather than the
|
||||||
|
protocol dictating how lightning-network should be engaged
|
||||||
|
with.
|
||||||
|
</p>
|
||||||
|
<small
|
||||||
|
>Check
|
||||||
|
<a
|
||||||
|
class="text-secondary"
|
||||||
|
href="https://github.com/fiatjaf/awesome-lnurl"
|
||||||
|
target="_blank"
|
||||||
|
>Awesome LNURL</a
|
||||||
|
>
|
||||||
|
for further information.</small
|
||||||
|
>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
</q-list>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -1,31 +1,10 @@
|
||||||
/* globals Quasar, Vue, _, VueQrcode, windowMixin, LNbits, LOCALE */
|
window.PageLnurlp = {
|
||||||
|
template: '#page-lnurlp',
|
||||||
const locationPath = [
|
|
||||||
window.location.protocol,
|
|
||||||
'//',
|
|
||||||
window.location.host,
|
|
||||||
window.location.pathname
|
|
||||||
].join('')
|
|
||||||
|
|
||||||
const mapPayLink = obj => {
|
|
||||||
obj._data = _.clone(obj)
|
|
||||||
obj.created_at = LNbits.utils.formatDateString(obj.created_at)
|
|
||||||
obj.updated_at = LNbits.utils.formatDateString(obj.updated_at)
|
|
||||||
if (obj.currency) {
|
|
||||||
obj.min = obj.min / obj.fiat_base_multiplier
|
|
||||||
obj.max = obj.max / obj.fiat_base_multiplier
|
|
||||||
}
|
|
||||||
|
|
||||||
obj.print_url = [locationPath, 'print/', obj.id].join('')
|
|
||||||
obj.pay_url = [locationPath, 'link/', obj.id].join('')
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
|
|
||||||
window.app = Vue.createApp({
|
|
||||||
el: '#vue',
|
|
||||||
mixins: [window.windowMixin],
|
|
||||||
computed: {
|
computed: {
|
||||||
endpoint: function () {
|
baseUrl() {
|
||||||
|
return window.location.origin + '/lnurlp/api/v1/links'
|
||||||
|
},
|
||||||
|
endpoint() {
|
||||||
return `/lnurlp/api/v1/settings?usr=${this.g.user.id}`
|
return `/lnurlp/api/v1/settings?usr=${this.g.user.id}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -40,7 +19,6 @@ window.app = Vue.createApp({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
domain: window.location.host,
|
domain: window.location.host,
|
||||||
currencies: [],
|
|
||||||
fiatRates: {},
|
fiatRates: {},
|
||||||
payLinks: [],
|
payLinks: [],
|
||||||
payLinksTable: {
|
payLinksTable: {
|
||||||
|
|
@ -106,6 +84,24 @@ window.app = Vue.createApp({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
mapPayLink(obj) {
|
||||||
|
const locationPath = [
|
||||||
|
window.location.protocol,
|
||||||
|
'//',
|
||||||
|
window.location.host,
|
||||||
|
window.location.pathname
|
||||||
|
].join('')
|
||||||
|
obj._data = _.clone(obj)
|
||||||
|
obj.created_at = LNbits.utils.formatDate(obj.created_at)
|
||||||
|
obj.updated_at = LNbits.utils.formatDate(obj.updated_at)
|
||||||
|
if (obj.currency) {
|
||||||
|
obj.min = obj.min / obj.fiat_base_multiplier
|
||||||
|
obj.max = obj.max / obj.fiat_base_multiplier
|
||||||
|
}
|
||||||
|
obj.print_url = [locationPath, 'print/', obj.id].join('')
|
||||||
|
obj.pay_url = [locationPath, 'link/', obj.id].join('')
|
||||||
|
return obj
|
||||||
|
},
|
||||||
getPayLinks() {
|
getPayLinks() {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
|
|
@ -114,7 +110,7 @@ window.app = Vue.createApp({
|
||||||
this.g.user.wallets[0].inkey
|
this.g.user.wallets[0].inkey
|
||||||
)
|
)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.payLinks = response.data.map(mapPayLink)
|
this.payLinks = response.data.map(this.mapPayLink)
|
||||||
})
|
})
|
||||||
.catch(LNbits.utils.notifyApiError)
|
.catch(LNbits.utils.notifyApiError)
|
||||||
},
|
},
|
||||||
|
|
@ -191,7 +187,7 @@ window.app = Vue.createApp({
|
||||||
)
|
)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.payLinks = _.reject(this.payLinks, obj => obj.id === data.id)
|
this.payLinks = _.reject(this.payLinks, obj => obj.id === data.id)
|
||||||
this.payLinks.push(mapPayLink(response.data))
|
this.payLinks.push(this.mapPayLink(response.data))
|
||||||
this.formDialog.show = false
|
this.formDialog.show = false
|
||||||
this.resetFormData()
|
this.resetFormData()
|
||||||
})
|
})
|
||||||
|
|
@ -246,13 +242,5 @@ window.app = Vue.createApp({
|
||||||
if (this.g.user.wallets?.length) {
|
if (this.g.user.wallets?.length) {
|
||||||
this.getPayLinks()
|
this.getPayLinks()
|
||||||
}
|
}
|
||||||
LNbits.api
|
|
||||||
.request('GET', '/api/v1/currencies')
|
|
||||||
.then(response => {
|
|
||||||
this.currencies = ['satoshis', ...response.data]
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
LNbits.utils.notifyApiError(err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
667
static/index.vue
Normal file
667
static/index.vue
Normal file
|
|
@ -0,0 +1,667 @@
|
||||||
|
<template id="page-lnurlp">
|
||||||
|
<div class="row q-col-gutter-md">
|
||||||
|
<div class="col-12 col-md-7 q-gutter-y-md">
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<q-btn unelevated color="primary" @click="formDialog.show = true"
|
||||||
|
>New pay link</q-btn
|
||||||
|
>
|
||||||
|
<lnbits-extension-settings-btn-dialog
|
||||||
|
v-if="g.user.admin"
|
||||||
|
:endpoint="endpoint"
|
||||||
|
:options="settings"
|
||||||
|
/>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<div class="row items-center no-wrap q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<h5 class="text-subtitle1 q-my-none">Pay links</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<q-table
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
:rows="payLinks"
|
||||||
|
:columns="payLinksTable.columns"
|
||||||
|
row-key="id"
|
||||||
|
v-model:pagination="payLinksTable.pagination"
|
||||||
|
>
|
||||||
|
<template v-slot:header="props">
|
||||||
|
<q-tr class="text-left" :props="props">
|
||||||
|
<q-th auto-width></q-th>
|
||||||
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
|
<span v-text="col.label"></span>
|
||||||
|
</q-th>
|
||||||
|
<q-th auto-width></q-th>
|
||||||
|
<q-th auto-width></q-th>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-td auto-width>
|
||||||
|
<q-btn
|
||||||
|
unelevated
|
||||||
|
dense
|
||||||
|
size="xs"
|
||||||
|
icon="launch"
|
||||||
|
:color="$q.dark.isActive ? 'grey-7' : 'grey-5'"
|
||||||
|
type="a"
|
||||||
|
:href="props.row.pay_url"
|
||||||
|
target="_blank"
|
||||||
|
class="q-ml-sm"
|
||||||
|
><q-tooltip>Shareable Page</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
unelevated
|
||||||
|
dense
|
||||||
|
size="xs"
|
||||||
|
icon="visibility"
|
||||||
|
:color="$q.dark.isActive ? 'grey-7' : 'grey-5'"
|
||||||
|
class="q-ml-sm"
|
||||||
|
@click="openQrCodeDialog(props.row.id)"
|
||||||
|
><q-tooltip>View Link</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
</q-td>
|
||||||
|
<q-td
|
||||||
|
v-for="col in props.cols"
|
||||||
|
:key="col.name"
|
||||||
|
:props="props"
|
||||||
|
v-text="col.value"
|
||||||
|
></q-td>
|
||||||
|
<q-td>
|
||||||
|
<q-icon v-if="props.row.webhook_url" size="14px" name="http">
|
||||||
|
<q-tooltip
|
||||||
|
>Webhook to <span v-text="props.row.webhook_url"></span
|
||||||
|
></q-tooltip>
|
||||||
|
</q-icon>
|
||||||
|
<q-icon
|
||||||
|
v-if="props.row.success_text || props.row.success_url"
|
||||||
|
size="14px"
|
||||||
|
name="call_to_action"
|
||||||
|
>
|
||||||
|
<q-tooltip>
|
||||||
|
On success, show message '<span
|
||||||
|
v-text="props.row.success_text"
|
||||||
|
></span
|
||||||
|
>'
|
||||||
|
<span v-if="props.row.success_url"
|
||||||
|
>and URL '<span v-text="props.row.success_url"></span
|
||||||
|
>'</span
|
||||||
|
>
|
||||||
|
</q-tooltip>
|
||||||
|
</q-icon>
|
||||||
|
<q-icon
|
||||||
|
v-if="props.row.comment_chars > 0"
|
||||||
|
size="14px"
|
||||||
|
name="insert_comment"
|
||||||
|
>
|
||||||
|
<q-tooltip>
|
||||||
|
<span v-text="props.row.comment_chars"></span>-char
|
||||||
|
comment allowed
|
||||||
|
</q-tooltip>
|
||||||
|
</q-icon>
|
||||||
|
</q-td>
|
||||||
|
<q-td auto-width>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
size="xs"
|
||||||
|
@click="openUpdateDialog(props.row.id)"
|
||||||
|
icon="edit"
|
||||||
|
color="light-blue"
|
||||||
|
>
|
||||||
|
<q-tooltip>Edit</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
size="xs"
|
||||||
|
@click="deletePayLink(props.row.id)"
|
||||||
|
icon="cancel"
|
||||||
|
color="pink"
|
||||||
|
><q-tooltip>Delete</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 col-md-5 q-gutter-y-md">
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<h6 class="text-subtitle1 q-my-none">LNURL-pay extension</h6>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section class="q-pa-none">
|
||||||
|
<q-separator></q-separator>
|
||||||
|
<q-list>
|
||||||
|
<q-expansion-item
|
||||||
|
group="extras"
|
||||||
|
icon="swap_vertical_circle"
|
||||||
|
label="API info"
|
||||||
|
:content-inset-level="0.5"
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
label="Swagger API"
|
||||||
|
type="a"
|
||||||
|
href="../docs#/lnurlp"
|
||||||
|
></q-btn>
|
||||||
|
<q-expansion-item
|
||||||
|
group="api"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
label="List pay links"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<code
|
||||||
|
><span class="text-blue">GET</span>
|
||||||
|
/lnurlp/api/v1/links</code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
|
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Body (application/json)
|
||||||
|
</h5>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Returns 200 OK (application/json)
|
||||||
|
</h5>
|
||||||
|
<code>[<pay_link_object>, ...]</code>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
|
<code
|
||||||
|
>curl -X GET <span v-text="baseUrl"></span> -H "X-Api-Key:
|
||||||
|
<span v-text="g.user.wallets[0].inkey"></span>"
|
||||||
|
</code>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
<q-expansion-item
|
||||||
|
group="api"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
label="Get a pay link"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<code
|
||||||
|
><span class="text-blue">GET</span>
|
||||||
|
/lnurlp/api/v1/links/<pay_id></code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
|
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Body (application/json)
|
||||||
|
</h5>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Returns 201 CREATED (application/json)
|
||||||
|
</h5>
|
||||||
|
<code>{"lnurl": <string>}</code>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
|
<code
|
||||||
|
>curl -X GET
|
||||||
|
<span v-text="baseUrl + '/<pay_id>'"></span>
|
||||||
|
-H "X-Api-Key:
|
||||||
|
<span v-text="g.user.wallets[0].inkey"></span>"
|
||||||
|
</code>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
<q-expansion-item
|
||||||
|
group="api"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
label="Create a pay link"
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
label="Swagger API"
|
||||||
|
type="a"
|
||||||
|
href="../docs#/lnurlp"
|
||||||
|
></q-btn>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<code
|
||||||
|
><span class="text-green">POST</span>
|
||||||
|
/lnurlp/api/v1/links</code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
|
<code>{"X-Api-Key": <admin_key>}</code><br />
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Body (application/json)
|
||||||
|
</h5>
|
||||||
|
<code
|
||||||
|
>{"description": <string> "amount": <integer>
|
||||||
|
"max": <integer> "min": <integer>
|
||||||
|
"comment_chars": <integer> "username":
|
||||||
|
<string> }</code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Returns 201 CREATED (application/json)
|
||||||
|
</h5>
|
||||||
|
<code>{"lnurl": <string>}</code>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
|
<code
|
||||||
|
>curl -X POST <span v-text="baseUrl"></span> -d
|
||||||
|
'{"description": <string>, "amount":
|
||||||
|
<integer>, "max": <integer>, "min":
|
||||||
|
<integer>, "comment_chars": <integer>}' -H
|
||||||
|
"Content-type: application/json" -H "X-Api-Key:
|
||||||
|
<span v-text="g.user.wallets[0].adminkey"></span>"
|
||||||
|
</code>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
<q-expansion-item
|
||||||
|
group="api"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
label="Update a pay link"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<code
|
||||||
|
><span class="text-green">PUT</span>
|
||||||
|
/lnurlp/api/v1/links/<pay_id></code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
|
<code>{"X-Api-Key": <admin_key>}</code><br />
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Body (application/json)
|
||||||
|
</h5>
|
||||||
|
<code
|
||||||
|
>{"description": <string>, "amount":
|
||||||
|
<integer>}</code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Returns 200 OK (application/json)
|
||||||
|
</h5>
|
||||||
|
<code>{"lnurl": <string>}</code>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
|
<code
|
||||||
|
>curl -X PUT
|
||||||
|
<span v-text="baseUrl + '/<pay_id>'"></span>
|
||||||
|
-d '{"description": <string>, "amount":
|
||||||
|
<integer>}' -H "Content-type: application/json" -H
|
||||||
|
"X-Api-Key:
|
||||||
|
<span v-text="g.user.wallets[0].adminkey"></span>"
|
||||||
|
</code>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
<q-expansion-item
|
||||||
|
group="api"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
label="Delete a pay link"
|
||||||
|
class="q-pb-md"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<code
|
||||||
|
><span class="text-pink">DELETE</span>
|
||||||
|
/lnurlp/api/v1/links/<pay_id></code
|
||||||
|
>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
|
<code>{"X-Api-Key": <admin_key>}</code><br />
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
Returns 204 NO CONTENT
|
||||||
|
</h5>
|
||||||
|
<code></code>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
|
<code
|
||||||
|
>curl -X DELETE
|
||||||
|
<span v-text="baseUrl + '/<pay_id>'"></span>
|
||||||
|
-H "X-Api-Key:
|
||||||
|
<span v-text="g.user.wallets[0].adminkey"></span>"
|
||||||
|
</code>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
</q-expansion-item>
|
||||||
|
<q-separator></q-separator>
|
||||||
|
<q-expansion-item
|
||||||
|
group="extras"
|
||||||
|
icon="info"
|
||||||
|
label="Powered by LNURL"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<p>
|
||||||
|
<b>WARNING: LNURL must be used over https or TOR</b><br />
|
||||||
|
LNURL is a range of lightning-network standards that allow
|
||||||
|
us to use lightning-network differently. An LNURL-pay is a
|
||||||
|
link that wallets use to fetch an invoice from a server
|
||||||
|
on-demand. The link or QR code is fixed, but each time it is
|
||||||
|
read by a compatible wallet a new QR code is issued by the
|
||||||
|
service. It can be used to activate machines without them
|
||||||
|
having to maintain an electronic screen to generate and show
|
||||||
|
invoices locally, or to sell any predefined good or service
|
||||||
|
automatically.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Exploring LNURL and finding use cases, is really helping
|
||||||
|
inform lightning protocol development, rather than the
|
||||||
|
protocol dictating how lightning-network should be engaged
|
||||||
|
with.
|
||||||
|
</p>
|
||||||
|
<small
|
||||||
|
>Check
|
||||||
|
<a
|
||||||
|
class="text-secondary"
|
||||||
|
href="https://github.com/fiatjaf/awesome-lnurl"
|
||||||
|
target="_blank"
|
||||||
|
>Awesome LNURL</a
|
||||||
|
>
|
||||||
|
for further information.</small
|
||||||
|
>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
</q-list>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<q-dialog v-model="formDialog.show" @hide="closeFormDialog">
|
||||||
|
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||||
|
<q-form @submit="sendFormData" class="q-gutter-md">
|
||||||
|
<q-select
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
emit-value
|
||||||
|
v-model="formDialog.data.wallet"
|
||||||
|
:options="g.user.walletOptions"
|
||||||
|
label="Wallet *"
|
||||||
|
>
|
||||||
|
</q-select>
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.trim="formDialog.data.description"
|
||||||
|
type="text"
|
||||||
|
label="Item description *"
|
||||||
|
>
|
||||||
|
</q-input>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.trim="formDialog.data.username"
|
||||||
|
type="text"
|
||||||
|
label="Lightning Address"
|
||||||
|
@input="
|
||||||
|
formDialog.data.username =
|
||||||
|
formDialog.data.username.toLowerCase()
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin-top: 10px">
|
||||||
|
<span class="label">
|
||||||
|
@ <span v-text="domain"></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row q-col-gutter-sm q-mx-sm">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.number="formDialog.data.min"
|
||||||
|
type="number"
|
||||||
|
:step="
|
||||||
|
formDialog.data.currency &&
|
||||||
|
formDialog.data.currency !== 'satoshis'
|
||||||
|
? '0.01'
|
||||||
|
: '1'
|
||||||
|
"
|
||||||
|
:label="formDialog.fixedAmount ? 'Amount *' : 'Min *'"
|
||||||
|
:hint="
|
||||||
|
formDialog.data.currency &&
|
||||||
|
fiatRates[formDialog.data.currency] &&
|
||||||
|
formDialog.data.min
|
||||||
|
? `approx. ${parseInt(Math.round(formDialog.data.min * fiatRates[formDialog.data.currency]))} sat`
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
></q-input>
|
||||||
|
<q-input
|
||||||
|
v-if="!formDialog.fixedAmount"
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.number="formDialog.data.max"
|
||||||
|
type="number"
|
||||||
|
:step="
|
||||||
|
formDialog.data.currency &&
|
||||||
|
formDialog.data.currency !== 'satoshis'
|
||||||
|
? '0.01'
|
||||||
|
: '1'
|
||||||
|
"
|
||||||
|
label="Max *"
|
||||||
|
:hint="
|
||||||
|
formDialog.data.currency &&
|
||||||
|
fiatRates[formDialog.data.currency] &&
|
||||||
|
formDialog.data.max
|
||||||
|
? `approx. ${parseInt(Math.round(formDialog.data.max * fiatRates[formDialog.data.currency]))} sat`
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
<div class="row q-col-gutter-sm">
|
||||||
|
<div class="col">
|
||||||
|
<q-checkbox
|
||||||
|
dense
|
||||||
|
v-model="formDialog.fixedAmount"
|
||||||
|
label="Fixed amount"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
:options="g.allowedCurrencies || g.currencies"
|
||||||
|
v-model="formDialog.data.currency"
|
||||||
|
:display-value="formDialog.data.currency || 'satoshis'"
|
||||||
|
label="Currency"
|
||||||
|
:hint="
|
||||||
|
'Converted to satoshis at each payment. ' +
|
||||||
|
(formDialog.data.currency &&
|
||||||
|
fiatRates[formDialog.data.currency]
|
||||||
|
? `Currently 1 ${formDialog.data.currency} = ${fiatRates[formDialog.data.currency]} sat`
|
||||||
|
: '')
|
||||||
|
"
|
||||||
|
@input="updateFiatRate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<q-expansion-item
|
||||||
|
group="advanced"
|
||||||
|
icon="settings"
|
||||||
|
label="Advanced options"
|
||||||
|
>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||||
|
LUD-11: Disposable and storeable payRequests.
|
||||||
|
</h5>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-checkbox
|
||||||
|
dense
|
||||||
|
:toggle-indeterminate="false"
|
||||||
|
v-model="formDialog.data.disposable"
|
||||||
|
label="If enabled, the LNURL will not be stored (default)."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">LNURL</h5>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.number="formDialog.data.comment_chars"
|
||||||
|
type="number"
|
||||||
|
label="Comment maximum characters"
|
||||||
|
hint="Allow the payer to attach a comment."
|
||||||
|
>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model="formDialog.data.webhook_url"
|
||||||
|
type="text"
|
||||||
|
label="Webhook URL (optional)"
|
||||||
|
hint="A URL to be called whenever this link receives a payment."
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" v-if="formDialog.data.webhook_url">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model="formDialog.data.webhook_headers"
|
||||||
|
type="text"
|
||||||
|
label="Webhook headers (optional)"
|
||||||
|
hint="Custom data as JSON string, send headers along with the webhook."
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model="formDialog.data.webhook_body"
|
||||||
|
type="text"
|
||||||
|
label="Webhook custom data (optional)"
|
||||||
|
hint="Custom data as JSON string, will get posted along with webhook 'body' field."
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model="formDialog.data.success_text"
|
||||||
|
type="text"
|
||||||
|
label="Success message (optional)"
|
||||||
|
hint="Will be shown to the user in his wallet after a successful payment."
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model="formDialog.data.success_url"
|
||||||
|
type="text"
|
||||||
|
label="Success URL (optional)"
|
||||||
|
hint="Link will be shown to the sender after a successful payment."
|
||||||
|
>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section>
|
||||||
|
<h5 class="text-caption q-mt-sm q-mb-none">Nostr</h5>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-checkbox
|
||||||
|
:toggle-indeterminate="false"
|
||||||
|
dense
|
||||||
|
v-model="formDialog.data.zaps"
|
||||||
|
label="Enable nostr zaps"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-expansion-item>
|
||||||
|
<div class="row q-mt-lg">
|
||||||
|
<q-btn
|
||||||
|
v-if="formDialog.data.id"
|
||||||
|
unelevated
|
||||||
|
color="primary"
|
||||||
|
type="submit"
|
||||||
|
>Update pay link</q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
v-else
|
||||||
|
unelevated
|
||||||
|
color="primary"
|
||||||
|
:disable="
|
||||||
|
formDialog.data.wallet == null ||
|
||||||
|
formDialog.data.description == null ||
|
||||||
|
formDialog.data.min == null ||
|
||||||
|
formDialog.data.min <= 0
|
||||||
|
"
|
||||||
|
type="submit"
|
||||||
|
>Create pay link</q-btn
|
||||||
|
>
|
||||||
|
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||||
|
>Cancel</q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</q-form>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="qrCodeDialog.show" position="top">
|
||||||
|
<q-card v-if="qrCodeDialog.data" class="q-pa-lg lnbits__dialog-card">
|
||||||
|
<lnbits-qrcode-lnurl :url="activeUrl" :nfc="true"></lnbits-qrcode-lnurl>
|
||||||
|
<p style="word-break: break-all">
|
||||||
|
<strong>ID:</strong> <span v-text="qrCodeDialog.data.id"></span><br />
|
||||||
|
<strong>Amount:</strong>
|
||||||
|
<span v-text="qrCodeDialog.data.amount"></span><br />
|
||||||
|
|
||||||
|
<span v-if="qrCodeDialog.data.currency"
|
||||||
|
><strong
|
||||||
|
><span v-text="qrCodeDialog.data.currency"></span> price:</strong
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="fiatRates[qrCodeDialog.data.currency]"
|
||||||
|
v-text="fiatRates[qrCodeDialog.data.currency] + 'sat'"
|
||||||
|
></span>
|
||||||
|
<span v-else>Loading...</span>
|
||||||
|
<br
|
||||||
|
/></span>
|
||||||
|
<strong>Accepts comments:</strong>
|
||||||
|
<span v-text="qrCodeDialog.data.comments"></span><br />
|
||||||
|
<strong>Dispatches webhook to:</strong>
|
||||||
|
<span v-text="qrCodeDialog.data.webhook"></span><br />
|
||||||
|
<strong>On success:</strong>
|
||||||
|
<span v-text="qrCodeDialog.data.success"></span><br />
|
||||||
|
<span v-if="qrCodeDialog.data.username">
|
||||||
|
<strong>Lightning Address: </strong>
|
||||||
|
<span v-text="qrCodeDialog.data.username + '@' + domain"></span>
|
||||||
|
<br />
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<div class="row q-mt-lg q-gutter-sm">
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
color="grey"
|
||||||
|
icon="link"
|
||||||
|
@click="
|
||||||
|
utils.copyText(
|
||||||
|
qrCodeDialog.data.pay_url,
|
||||||
|
'Link copied to clipboard!'
|
||||||
|
)
|
||||||
|
"
|
||||||
|
><q-tooltip>Copy sharable link</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
14
static/routes.json
Normal file
14
static/routes.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path": "/lnurlp/",
|
||||||
|
"name": "PageLnurlp",
|
||||||
|
"template": "/lnurlp/static/index.vue",
|
||||||
|
"component": "/lnurlp/static/index.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/lnurlp/link/:id",
|
||||||
|
"name": "PageLnurlpPublic",
|
||||||
|
"template": "/lnurlp/static/display.vue",
|
||||||
|
"component": "/lnurlp/static/display.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -1,138 +0,0 @@
|
||||||
<q-expansion-item
|
|
||||||
group="extras"
|
|
||||||
icon="swap_vertical_circle"
|
|
||||||
label="API info"
|
|
||||||
:content-inset-level="0.5"
|
|
||||||
>
|
|
||||||
<q-btn flat label="Swagger API" type="a" href="../docs#/lnurlp"></q-btn>
|
|
||||||
<q-expansion-item group="api" dense expand-separator label="List pay links">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<code><span class="text-blue">GET</span> /lnurlp/api/v1/links</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
|
||||||
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
|
||||||
Returns 200 OK (application/json)
|
|
||||||
</h5>
|
|
||||||
<code>[<pay_link_object>, ...]</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
|
||||||
<code
|
|
||||||
>curl -X GET {{ request.base_url }}lnurlp/api/v1/links -H "X-Api-Key:
|
|
||||||
<span v-text="g.user.wallets[0].inkey"></span> "
|
|
||||||
</code>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
<q-expansion-item group="api" dense expand-separator label="Get a pay link">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<code
|
|
||||||
><span class="text-blue">GET</span>
|
|
||||||
/lnurlp/api/v1/links/<pay_id></code
|
|
||||||
>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
|
||||||
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
|
||||||
Returns 201 CREATED (application/json)
|
|
||||||
</h5>
|
|
||||||
<code>{"lnurl": <string>}</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
|
||||||
<code
|
|
||||||
>curl -X GET {{ request.base_url }}lnurlp/api/v1/links/<pay_id>
|
|
||||||
-H "X-Api-Key: <span v-text="g.user.wallets[0].inkey"></span>"
|
|
||||||
</code>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
<q-expansion-item
|
|
||||||
group="api"
|
|
||||||
dense
|
|
||||||
expand-separator
|
|
||||||
label="Create a pay link"
|
|
||||||
>
|
|
||||||
<q-btn flat label="Swagger API" type="a" href="../docs#/lnurlp"></q-btn>
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<code><span class="text-green">POST</span> /lnurlp/api/v1/links</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
|
||||||
<code>{"X-Api-Key": <admin_key>}</code><br />
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
|
||||||
<code
|
|
||||||
>{"description": <string> "amount": <integer> "max":
|
|
||||||
<integer> "min": <integer> "comment_chars":
|
|
||||||
<integer> "username": <string> }</code
|
|
||||||
>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
|
||||||
Returns 201 CREATED (application/json)
|
|
||||||
</h5>
|
|
||||||
<code>{"lnurl": <string>}</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
|
||||||
<code
|
|
||||||
>curl -X POST {{ request.base_url }}lnurlp/api/v1/links -d
|
|
||||||
'{"description": <string>, "amount": <integer>, "max":
|
|
||||||
<integer>, "min": <integer>, "comment_chars":
|
|
||||||
<integer>}' -H "Content-type: application/json" -H "X-Api-Key:
|
|
||||||
<span v-text="g.user.wallets[0].adminkey"></span>"
|
|
||||||
</code>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
<q-expansion-item
|
|
||||||
group="api"
|
|
||||||
dense
|
|
||||||
expand-separator
|
|
||||||
label="Update a pay link"
|
|
||||||
>
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<code
|
|
||||||
><span class="text-green">PUT</span>
|
|
||||||
/lnurlp/api/v1/links/<pay_id></code
|
|
||||||
>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
|
||||||
<code>{"X-Api-Key": <admin_key>}</code><br />
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
|
||||||
<code>{"description": <string>, "amount": <integer>}</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
|
||||||
Returns 200 OK (application/json)
|
|
||||||
</h5>
|
|
||||||
<code>{"lnurl": <string>}</code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
|
||||||
<code
|
|
||||||
>curl -X PUT {{ request.base_url }}lnurlp/api/v1/links/<pay_id>
|
|
||||||
-d '{"description": <string>, "amount": <integer>}' -H
|
|
||||||
"Content-type: application/json" -H "X-Api-Key:
|
|
||||||
<span v-text="g.user.wallets[0].adminkey"></span>"
|
|
||||||
</code>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
<q-expansion-item
|
|
||||||
group="api"
|
|
||||||
dense
|
|
||||||
expand-separator
|
|
||||||
label="Delete a pay link"
|
|
||||||
class="q-pb-md"
|
|
||||||
>
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<code
|
|
||||||
><span class="text-pink">DELETE</span>
|
|
||||||
/lnurlp/api/v1/links/<pay_id></code
|
|
||||||
>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
|
||||||
<code>{"X-Api-Key": <admin_key>}</code><br />
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Returns 204 NO CONTENT</h5>
|
|
||||||
<code></code>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
|
||||||
<code
|
|
||||||
>curl -X DELETE {{ request.base_url
|
|
||||||
}}lnurlp/api/v1/links/<pay_id> -H "X-Api-Key:
|
|
||||||
<span v-text="g.user.wallets[0].adminkey"></span>"
|
|
||||||
</code>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
</q-expansion-item>
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
<q-expansion-item group="extras" icon="info" label="Powered by LNURL">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<p>
|
|
||||||
<b>WARNING: LNURL must be used over https or TOR</b><br />
|
|
||||||
LNURL is a range of lightning-network standards that allow us to use
|
|
||||||
lightning-network differently. An LNURL-pay is a link that wallets use
|
|
||||||
to fetch an invoice from a server on-demand. The link or QR code is
|
|
||||||
fixed, but each time it is read by a compatible wallet a new QR code is
|
|
||||||
issued by the service. It can be used to activate machines without them
|
|
||||||
having to maintain an electronic screen to generate and show invoices
|
|
||||||
locally, or to sell any predefined good or service automatically.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Exploring LNURL and finding use cases, is really helping inform
|
|
||||||
lightning protocol development, rather than the protocol dictating how
|
|
||||||
lightning-network should be engaged with.
|
|
||||||
</p>
|
|
||||||
<small
|
|
||||||
>Check
|
|
||||||
<a
|
|
||||||
class="text-secondary"
|
|
||||||
href="https://github.com/fiatjaf/awesome-lnurl"
|
|
||||||
target="_blank"
|
|
||||||
>Awesome LNURL</a
|
|
||||||
>
|
|
||||||
for further information.</small
|
|
||||||
>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
{% extends "public.html" %} {% block page %}
|
|
||||||
<div class="row q-col-gutter-md justify-center">
|
|
||||||
<div class="col-12 col-sm-6 col-md-5 col-lg-4">
|
|
||||||
<q-card class="q-pa-lg">
|
|
||||||
<q-card-section class="q-pa-none">
|
|
||||||
<div class="text-center">
|
|
||||||
<lnbits-qrcode-lnurl :url="url" :nfc="true"></lnbits-qrcode-lnurl>
|
|
||||||
</div>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-sm-6 col-md-5 col-lg-4 q-gutter-y-md">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<h6 class="text-subtitle1 q-mb-sm q-mt-none">LNbits LNURL-pay link</h6>
|
|
||||||
<p class="q-my-none">Use an LNURL compatible bitcoin wallet to pay.</p>
|
|
||||||
</q-card-section>
|
|
||||||
<q-card-section class="q-pa-none">
|
|
||||||
<q-separator></q-separator>
|
|
||||||
<q-list> {% include "lnurlp/_lnurl.html" %} </q-list>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %} {% block scripts %}
|
|
||||||
<script>
|
|
||||||
window.app = Vue.createApp({
|
|
||||||
el: '#vue',
|
|
||||||
mixins: [window.windowMixin],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
url: window.location.origin + '/lnurlp/{{ link_id }}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
@ -1,427 +0,0 @@
|
||||||
{% extends "base.html" %} {% from "macros.jinja" import window_vars with context
|
|
||||||
%} {% block page %}
|
|
||||||
<div class="row q-col-gutter-md">
|
|
||||||
<div class="col-12 col-md-7 q-gutter-y-md">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<q-btn unelevated color="primary" @click="formDialog.show = true"
|
|
||||||
>New pay link</q-btn
|
|
||||||
>
|
|
||||||
<lnbits-extension-settings-btn-dialog
|
|
||||||
v-if="this.g.user.admin"
|
|
||||||
:endpoint="endpoint"
|
|
||||||
:options="settings"
|
|
||||||
/>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
|
||||||
<div class="col">
|
|
||||||
<h5 class="text-subtitle1 q-my-none">Pay links</h5>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<q-table
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
:rows="payLinks"
|
|
||||||
:columns="payLinksTable.columns"
|
|
||||||
row-key="id"
|
|
||||||
v-model:pagination="payLinksTable.pagination"
|
|
||||||
>
|
|
||||||
<template v-slot:header="props">
|
|
||||||
<q-tr class="text-left" :props="props">
|
|
||||||
<q-th auto-width></q-th>
|
|
||||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
||||||
<span v-text="col.label"></span>
|
|
||||||
</q-th>
|
|
||||||
<q-th auto-width></q-th>
|
|
||||||
<q-th auto-width></q-th>
|
|
||||||
</q-tr>
|
|
||||||
</template>
|
|
||||||
<template v-slot:body="props">
|
|
||||||
<q-tr :props="props">
|
|
||||||
<q-td auto-width>
|
|
||||||
<q-btn
|
|
||||||
unelevated
|
|
||||||
dense
|
|
||||||
size="xs"
|
|
||||||
icon="launch"
|
|
||||||
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
|
||||||
type="a"
|
|
||||||
:href="props.row.pay_url"
|
|
||||||
target="_blank"
|
|
||||||
class="q-ml-sm"
|
|
||||||
><q-tooltip>Shareable Page</q-tooltip></q-btn
|
|
||||||
>
|
|
||||||
<q-btn
|
|
||||||
unelevated
|
|
||||||
dense
|
|
||||||
size="xs"
|
|
||||||
icon="visibility"
|
|
||||||
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
|
||||||
class="q-ml-sm"
|
|
||||||
@click="openQrCodeDialog(props.row.id)"
|
|
||||||
><q-tooltip>View Link</q-tooltip></q-btn
|
|
||||||
>
|
|
||||||
</q-td>
|
|
||||||
<q-td
|
|
||||||
v-for="col in props.cols"
|
|
||||||
:key="col.name"
|
|
||||||
:props="props"
|
|
||||||
v-text="col.value"
|
|
||||||
></q-td>
|
|
||||||
<q-td>
|
|
||||||
<q-icon v-if="props.row.webhook_url" size="14px" name="http">
|
|
||||||
<q-tooltip
|
|
||||||
>Webhook to <span v-text="props.row.webhook_url"></span
|
|
||||||
></q-tooltip>
|
|
||||||
</q-icon>
|
|
||||||
<q-icon
|
|
||||||
v-if="props.row.success_text || props.row.success_url"
|
|
||||||
size="14px"
|
|
||||||
name="call_to_action"
|
|
||||||
>
|
|
||||||
<q-tooltip>
|
|
||||||
On success, show message '<span
|
|
||||||
v-text="props.row.success_text"
|
|
||||||
></span
|
|
||||||
>'
|
|
||||||
<span v-if="props.row.success_url"
|
|
||||||
>and URL '<span v-text="props.row.success_url"></span
|
|
||||||
>'</span
|
|
||||||
>
|
|
||||||
</q-tooltip>
|
|
||||||
</q-icon>
|
|
||||||
<q-icon
|
|
||||||
v-if="props.row.comment_chars > 0"
|
|
||||||
size="14px"
|
|
||||||
name="insert_comment"
|
|
||||||
>
|
|
||||||
<q-tooltip>
|
|
||||||
<span v-text="props.row.comment_chars"></span>-char comment
|
|
||||||
allowed
|
|
||||||
</q-tooltip>
|
|
||||||
</q-icon>
|
|
||||||
</q-td>
|
|
||||||
<q-td auto-width>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="xs"
|
|
||||||
@click="openUpdateDialog(props.row.id)"
|
|
||||||
icon="edit"
|
|
||||||
color="light-blue"
|
|
||||||
>
|
|
||||||
<q-tooltip>Edit</q-tooltip>
|
|
||||||
</q-btn>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
size="xs"
|
|
||||||
@click="deletePayLink(props.row.id)"
|
|
||||||
icon="cancel"
|
|
||||||
color="pink"
|
|
||||||
><q-tooltip>Delete</q-tooltip></q-btn
|
|
||||||
>
|
|
||||||
</q-td>
|
|
||||||
</q-tr>
|
|
||||||
</template>
|
|
||||||
</q-table>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12 col-md-5 q-gutter-y-md">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<h6 class="text-subtitle1 q-my-none">
|
|
||||||
{{ SITE_TITLE }} LNURL-pay extension
|
|
||||||
</h6>
|
|
||||||
</q-card-section>
|
|
||||||
<q-card-section class="q-pa-none">
|
|
||||||
<q-separator></q-separator>
|
|
||||||
<q-list>
|
|
||||||
{% include "lnurlp/_api_docs.html" %}
|
|
||||||
<q-separator></q-separator>
|
|
||||||
{% include "lnurlp/_lnurl.html" %}
|
|
||||||
</q-list>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<q-dialog v-model="formDialog.show" @hide="closeFormDialog">
|
|
||||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
|
||||||
<q-form @submit="sendFormData" class="q-gutter-md">
|
|
||||||
<q-select
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
emit-value
|
|
||||||
v-model="formDialog.data.wallet"
|
|
||||||
:options="g.user.walletOptions"
|
|
||||||
label="Wallet *"
|
|
||||||
>
|
|
||||||
</q-select>
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model.trim="formDialog.data.description"
|
|
||||||
type="text"
|
|
||||||
label="Item description *"
|
|
||||||
>
|
|
||||||
</q-input>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model.trim="formDialog.data.username"
|
|
||||||
type="text"
|
|
||||||
label="Lightning Address"
|
|
||||||
@input="formDialog.data.username = formDialog.data.username.toLowerCase()"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="col" style="margin-top: 10px">
|
|
||||||
<span class="label">
|
|
||||||
@ <span v-text="domain"></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row q-col-gutter-sm q-mx-sm">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model.number="formDialog.data.min"
|
|
||||||
type="number"
|
|
||||||
:step="formDialog.data.currency && formDialog.data.currency !== 'satoshis' ? '0.01' : '1'"
|
|
||||||
:label="formDialog.fixedAmount ? 'Amount *' : 'Min *'"
|
|
||||||
:hint="formDialog.data.currency && fiatRates[formDialog.data.currency] && formDialog.data.min ? `approx. ${parseInt(Math.round(formDialog.data.min * fiatRates[formDialog.data.currency]))} sat` : ''"
|
|
||||||
></q-input>
|
|
||||||
<q-input
|
|
||||||
v-if="!formDialog.fixedAmount"
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model.number="formDialog.data.max"
|
|
||||||
type="number"
|
|
||||||
:step="formDialog.data.currency && formDialog.data.currency !== 'satoshis' ? '0.01' : '1'"
|
|
||||||
label="Max *"
|
|
||||||
:hint="formDialog.data.currency && fiatRates[formDialog.data.currency] && formDialog.data.max ? `approx. ${parseInt(Math.round(formDialog.data.max * fiatRates[formDialog.data.currency]))} sat` : ''"
|
|
||||||
></q-input>
|
|
||||||
</div>
|
|
||||||
<div class="row q-col-gutter-sm">
|
|
||||||
<div class="col">
|
|
||||||
<q-checkbox
|
|
||||||
dense
|
|
||||||
v-model="formDialog.fixedAmount"
|
|
||||||
label="Fixed amount"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<q-select
|
|
||||||
dense
|
|
||||||
:options="currencies"
|
|
||||||
v-model="formDialog.data.currency"
|
|
||||||
:display-value="formDialog.data.currency || 'satoshis'"
|
|
||||||
label="Currency"
|
|
||||||
:hint="'Converted to satoshis at each payment. ' + (formDialog.data.currency && fiatRates[formDialog.data.currency] ? `Currently 1 ${formDialog.data.currency} = ${fiatRates[formDialog.data.currency]} sat` : '')"
|
|
||||||
@input="updateFiatRate"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<q-expansion-item
|
|
||||||
group="advanced"
|
|
||||||
icon="settings"
|
|
||||||
label="Advanced options"
|
|
||||||
>
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
|
||||||
LUD-11: Disposable and storeable payRequests.
|
|
||||||
</h5>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-checkbox
|
|
||||||
dense
|
|
||||||
:toggle-indeterminate="false"
|
|
||||||
v-model="formDialog.data.disposable"
|
|
||||||
label="If enabled, the LNURL will not be stored (default)."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">LNURL</h5>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model.number="formDialog.data.comment_chars"
|
|
||||||
type="number"
|
|
||||||
label="Comment maximum characters"
|
|
||||||
hint="Allow the payer to attach a comment."
|
|
||||||
>
|
|
||||||
</q-input>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model="formDialog.data.webhook_url"
|
|
||||||
type="text"
|
|
||||||
label="Webhook URL (optional)"
|
|
||||||
hint="A URL to be called whenever this link receives a payment."
|
|
||||||
></q-input>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row" v-if="formDialog.data.webhook_url">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model="formDialog.data.webhook_headers"
|
|
||||||
type="text"
|
|
||||||
label="Webhook headers (optional)"
|
|
||||||
hint="Custom data as JSON string, send headers along with the webhook."
|
|
||||||
></q-input>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model="formDialog.data.webhook_body"
|
|
||||||
type="text"
|
|
||||||
label="Webhook custom data (optional)"
|
|
||||||
hint="Custom data as JSON string, will get posted along with webhook 'body' field."
|
|
||||||
></q-input>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model="formDialog.data.success_text"
|
|
||||||
type="text"
|
|
||||||
label="Success message (optional)"
|
|
||||||
hint="Will be shown to the user in his wallet after a successful payment."
|
|
||||||
></q-input>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-input
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
v-model="formDialog.data.success_url"
|
|
||||||
type="text"
|
|
||||||
label="Success URL (optional)"
|
|
||||||
hint="Link will be shown to the sender after a successful payment."
|
|
||||||
>
|
|
||||||
</q-input>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</q-card-section>
|
|
||||||
<q-card-section>
|
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Nostr</h5>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<q-checkbox
|
|
||||||
:toggle-indeterminate="false"
|
|
||||||
dense
|
|
||||||
v-model="formDialog.data.zaps"
|
|
||||||
label="Enable nostr zaps"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</q-expansion-item>
|
|
||||||
<div class="row q-mt-lg">
|
|
||||||
<q-btn
|
|
||||||
v-if="formDialog.data.id"
|
|
||||||
unelevated
|
|
||||||
color="primary"
|
|
||||||
type="submit"
|
|
||||||
>Update pay link</q-btn
|
|
||||||
>
|
|
||||||
<q-btn
|
|
||||||
v-else
|
|
||||||
unelevated
|
|
||||||
color="primary"
|
|
||||||
:disable="
|
|
||||||
formDialog.data.wallet == null ||
|
|
||||||
formDialog.data.description == null ||
|
|
||||||
(
|
|
||||||
formDialog.data.min == null ||
|
|
||||||
formDialog.data.min <= 0
|
|
||||||
)
|
|
||||||
"
|
|
||||||
type="submit"
|
|
||||||
>Create pay link</q-btn
|
|
||||||
>
|
|
||||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
|
||||||
>Cancel</q-btn
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</q-form>
|
|
||||||
</q-card>
|
|
||||||
</q-dialog>
|
|
||||||
|
|
||||||
<q-dialog v-model="qrCodeDialog.show" position="top">
|
|
||||||
<q-card v-if="qrCodeDialog.data" class="q-pa-lg lnbits__dialog-card">
|
|
||||||
<lnbits-qrcode-lnurl :url="activeUrl" :nfc="true"></lnbits-qrcode-lnurl>
|
|
||||||
<p style="word-break: break-all">
|
|
||||||
<strong>ID:</strong> <span v-text="qrCodeDialog.data.id"></span><br />
|
|
||||||
<strong>Amount:</strong> <span v-text="qrCodeDialog.data.amount"></span
|
|
||||||
><br />
|
|
||||||
|
|
||||||
<span v-if="qrCodeDialog.data.currency"
|
|
||||||
><strong
|
|
||||||
><span v-text="qrCodeDialog.data.currency"></span> price:</strong
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
v-if="fiatRates[qrCodeDialog.data.currency]"
|
|
||||||
v-text="fiatRates[qrCodeDialog.data.currency] + 'sat'"
|
|
||||||
></span>
|
|
||||||
<span v-else>Loading...</span>
|
|
||||||
<br
|
|
||||||
/></span>
|
|
||||||
<strong>Accepts comments:</strong>
|
|
||||||
<span v-text="qrCodeDialog.data.comments"></span><br />
|
|
||||||
<strong>Dispatches webhook to:</strong>
|
|
||||||
<span v-text="qrCodeDialog.data.webhook"></span><br />
|
|
||||||
<strong>On success:</strong>
|
|
||||||
<span v-text="qrCodeDialog.data.success"></span><br />
|
|
||||||
<span v-if="qrCodeDialog.data.username">
|
|
||||||
<strong>Lightning Address: </strong>
|
|
||||||
<span v-text="qrCodeDialog.data.username+'@'+domain"></span>
|
|
||||||
<br />
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<div class="row q-mt-lg q-gutter-sm">
|
|
||||||
<q-btn
|
|
||||||
outline
|
|
||||||
color="grey"
|
|
||||||
icon="link"
|
|
||||||
@click="copyText(qrCodeDialog.data.pay_url, 'Link copied to clipboard!')"
|
|
||||||
><q-tooltip>Copy sharable link</q-tooltip>
|
|
||||||
</q-btn>
|
|
||||||
<q-btn
|
|
||||||
outline
|
|
||||||
color="grey"
|
|
||||||
icon="print"
|
|
||||||
type="a"
|
|
||||||
:href="qrCodeDialog.data.print_url"
|
|
||||||
target="_blank"
|
|
||||||
><q-tooltip>Print</q-tooltip></q-btn
|
|
||||||
>
|
|
||||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
|
||||||
</div>
|
|
||||||
</q-card>
|
|
||||||
</q-dialog>
|
|
||||||
</div>
|
|
||||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
|
||||||
<script src="/lnurlp/static/js/index.js"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
{% extends "print.html" %} {% block page %}
|
|
||||||
<div class="row justify-center">
|
|
||||||
<div class="qr">
|
|
||||||
<lnbits-qrcode :value="lnurl" :show-buttons="false"></lnbits-qrcode>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %} {% block styles %}
|
|
||||||
<style>
|
|
||||||
.qr {
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %} {% block scripts %}
|
|
||||||
<script>
|
|
||||||
window.app = Vue.createApp({
|
|
||||||
el: '#vue',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
lnurl: '',
|
|
||||||
width: window.innerWidth * 0.5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
const url = window.location.origin + '/lnurlp/{{ link_id }}'
|
|
||||||
const bytes = new TextEncoder().encode(url)
|
|
||||||
const bech32 = NostrTools.nip19.encodeBytes('lnurl', bytes)
|
|
||||||
this.lnurl = `lightning:${bech32.toUpperCase()}`
|
|
||||||
window.print()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
50
views.py
50
views.py
|
|
@ -1,45 +1,17 @@
|
||||||
from http import HTTPStatus
|
from fastapi import APIRouter, Depends
|
||||||
|
from lnbits.core.views.generic import index, index_public
|
||||||
from fastapi import APIRouter, Depends, Request
|
|
||||||
from lnbits.core.models import User
|
|
||||||
from lnbits.decorators import check_user_exists
|
from lnbits.decorators import check_user_exists
|
||||||
from lnbits.helpers import template_renderer
|
|
||||||
from starlette.exceptions import HTTPException
|
|
||||||
from starlette.responses import HTMLResponse
|
|
||||||
|
|
||||||
from .crud import get_pay_link
|
|
||||||
|
|
||||||
lnurlp_generic_router = APIRouter()
|
lnurlp_generic_router = APIRouter()
|
||||||
|
|
||||||
|
lnurlp_generic_router.add_api_route(
|
||||||
|
"/", methods=["GET"], endpoint=index, dependencies=[Depends(check_user_exists)]
|
||||||
|
)
|
||||||
|
|
||||||
def lnurlp_renderer():
|
lnurlp_generic_router.add_api_route(
|
||||||
return template_renderer(["lnurlp/templates"])
|
"/link/{link_id}", methods=["GET"], endpoint=index_public
|
||||||
|
)
|
||||||
|
|
||||||
|
lnurlp_generic_router.add_api_route(
|
||||||
@lnurlp_generic_router.get("/", response_class=HTMLResponse)
|
"/print/{link_id}", methods=["GET"], endpoint=index_public
|
||||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
)
|
||||||
return lnurlp_renderer().TemplateResponse(
|
|
||||||
"lnurlp/index.html", {"request": request, "user": user.json()}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@lnurlp_generic_router.get("/link/{link_id}", response_class=HTMLResponse)
|
|
||||||
async def display(request: Request, link_id):
|
|
||||||
link = await get_pay_link(link_id)
|
|
||||||
if not link:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Pay link does not exist."
|
|
||||||
)
|
|
||||||
ctx = {"request": request, "link_id": link.id}
|
|
||||||
return lnurlp_renderer().TemplateResponse("lnurlp/display.html", ctx)
|
|
||||||
|
|
||||||
|
|
||||||
@lnurlp_generic_router.get("/print/{link_id}", response_class=HTMLResponse)
|
|
||||||
async def print_qr(request: Request, link_id):
|
|
||||||
link = await get_pay_link(link_id)
|
|
||||||
if not link:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Pay link does not exist."
|
|
||||||
)
|
|
||||||
ctx = {"request": request, "link_id": link.id}
|
|
||||||
return lnurlp_renderer().TemplateResponse("lnurlp/print_qr.html", ctx)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue