feat: frontend component for LNURLs (#3321)
This commit is contained in:
parent
609c949394
commit
1488f580ff
7 changed files with 94 additions and 29 deletions
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -187,34 +187,6 @@ window.app.component('lnbits-lnurlpay-success-action', {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
window.app.component('lnbits-qrcode', {
|
|
||||||
mixins: [window.windowMixin],
|
|
||||||
template: '#lnbits-qrcode',
|
|
||||||
components: {
|
|
||||||
QrcodeVue
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
options: Object
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
custom: {
|
|
||||||
margin: 3,
|
|
||||||
width: 350,
|
|
||||||
size: 350,
|
|
||||||
logo: LNBITS_QR_LOGO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.custom = {...this.custom, ...this.options}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
window.app.component('lnbits-notifications-btn', {
|
window.app.component('lnbits-notifications-btn', {
|
||||||
template: '#lnbits-notifications-btn',
|
template: '#lnbits-notifications-btn',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
|
|
|
||||||
43
lnbits/static/js/components/lnbits-qrcode-lnurl.js
Normal file
43
lnbits/static/js/components/lnbits-qrcode-lnurl.js
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
window.app.component('lnbits-qrcode-lnurl', {
|
||||||
|
template: '#lnbits-qrcode-lnurl',
|
||||||
|
mixins: [window.windowMixin],
|
||||||
|
props: {
|
||||||
|
url: {
|
||||||
|
required: true,
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
prefix: {
|
||||||
|
type: String,
|
||||||
|
default: 'lnurlp'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tab: 'bech32',
|
||||||
|
lnurl: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setLnurl() {
|
||||||
|
if (this.tab == 'bech32') {
|
||||||
|
const bytes = new TextEncoder().encode(this.url)
|
||||||
|
const bech32 = NostrTools.nip19.encodeBytes('lnurl', bytes)
|
||||||
|
this.lnurl = `lightning:${bech32.toUpperCase()}`
|
||||||
|
} else if (this.tab == 'lud17') {
|
||||||
|
this.lnurl = this.url.replace('https://', this.prefix + '://')
|
||||||
|
}
|
||||||
|
this.$emit('update:lnurl', this.lnurl)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
url() {
|
||||||
|
this.setLnurl()
|
||||||
|
},
|
||||||
|
tab() {
|
||||||
|
this.setLnurl()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.setLnurl()
|
||||||
|
}
|
||||||
|
})
|
||||||
27
lnbits/static/js/components/lnbits-qrcode.js
Normal file
27
lnbits/static/js/components/lnbits-qrcode.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
window.app.component('lnbits-qrcode', {
|
||||||
|
mixins: [window.windowMixin],
|
||||||
|
template: '#lnbits-qrcode',
|
||||||
|
components: {
|
||||||
|
QrcodeVue
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
options: Object
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
custom: {
|
||||||
|
margin: 3,
|
||||||
|
width: 350,
|
||||||
|
size: 350,
|
||||||
|
logo: LNBITS_QR_LOGO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.custom = {...this.custom, ...this.options}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -38,6 +38,8 @@
|
||||||
"js/bolt11-decoder.js"
|
"js/bolt11-decoder.js"
|
||||||
],
|
],
|
||||||
"components": [
|
"components": [
|
||||||
|
"js/components/lnbits-qrcode.js",
|
||||||
|
"js/components/lnbits-qrcode-lnurl.js",
|
||||||
"js/components/lnbits-funding-sources.js",
|
"js/components/lnbits-funding-sources.js",
|
||||||
"js/components/extension-settings.js",
|
"js/components/extension-settings.js",
|
||||||
"js/components/payment-list.js",
|
"js/components/payment-list.js",
|
||||||
|
|
|
||||||
|
|
@ -635,6 +635,25 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template id="lnbits-qrcode-lnurl">
|
||||||
|
<div class="qrcode_lnurl__wrapper">
|
||||||
|
<q-tabs
|
||||||
|
v-model="tab"
|
||||||
|
dense
|
||||||
|
class="text-grey q-mb-md"
|
||||||
|
active-color="primary"
|
||||||
|
indicator-color="primary"
|
||||||
|
align="justify"
|
||||||
|
narrow-indicator
|
||||||
|
inline-label
|
||||||
|
>
|
||||||
|
<q-tab name="bech32" icon="qr_code" label="bech32"></q-tab>
|
||||||
|
<q-tab name="lud17" icon="link" label="url (lud17)"></q-tab>
|
||||||
|
</q-tabs>
|
||||||
|
<lnbits-qrcode :value="lnurl" class="rounded-borders"></lnbits-qrcode>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template id="lnbits-lnurlpay-success-action">
|
<template id="lnbits-lnurlpay-success-action">
|
||||||
<div>
|
<div>
|
||||||
<p
|
<p
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@
|
||||||
"js/bolt11-decoder.js"
|
"js/bolt11-decoder.js"
|
||||||
],
|
],
|
||||||
"components": [
|
"components": [
|
||||||
|
"js/components/lnbits-qrcode.js",
|
||||||
|
"js/components/lnbits-qrcode-lnurl.js",
|
||||||
"js/components/lnbits-funding-sources.js",
|
"js/components/lnbits-funding-sources.js",
|
||||||
"js/components/extension-settings.js",
|
"js/components/extension-settings.js",
|
||||||
"js/components/payment-list.js",
|
"js/components/payment-list.js",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue