use {"tag": ext} for extension-related payments.

This commit is contained in:
fiatjaf
2020-09-02 12:44:54 -03:00
parent 4447a48724
commit 197af922d0
14 changed files with 100 additions and 39 deletions
+13 -1
View File
@@ -1,3 +1,4 @@
import json
import datetime
from uuid import uuid4
from typing import List, Optional, Dict
@@ -245,7 +246,18 @@ def create_payment(
amount, pending, memo, fee, extra)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(wallet_id, checking_id, payment_request, payment_hash, preimage, amount, int(pending), memo, fee, extra),
(
wallet_id,
checking_id,
payment_request,
payment_hash,
preimage,
amount,
int(pending),
memo,
fee,
json.dumps(extra) if extra and extra != {} and type(extra) is dict else None,
),
)
new_payment = get_wallet_payment(wallet_id, payment_hash)
+20
View File
@@ -83,6 +83,26 @@ def m002_add_fields_to_apipayments(db):
db.execute("ALTER TABLE apipayments ADD COLUMN bolt11 TEXT")
db.execute("ALTER TABLE apipayments ADD COLUMN extra TEXT")
import json
rows = db.fetchall("SELECT * FROM apipayments")
for row in rows:
if not row["memo"] or not row["memo"].startswith("#"):
continue
for ext in ["withdraw", "events", "lnticket", "paywall", "tpos"]:
prefix = "#" + ext + " "
if row["memo"].startswith(prefix):
new = row["memo"][len(prefix) :]
db.execute(
"""
UPDATE apipayments SET extra = ?, memo = ?
WHERE checking_id = ? AND memo = ?
""",
(json.dumps({"tag": ext}), new, row["checking_id"], row["memo"]),
)
break
def migrate():
with open_db() as db:
+12 -6
View File
@@ -1,4 +1,4 @@
/* globals Vue, VueQrcodeReader, VueQrcode, Quasar, LNbits, _ */
/* globals decode, Vue, VueQrcodeReader, VueQrcode, Quasar, LNbits, _, EventHub, Chart */
Vue.component(VueQrcode.name, VueQrcode)
Vue.use(VueQrcodeReader)
@@ -123,6 +123,7 @@ new Vue({
mixins: [windowMixin],
data: function() {
return {
user: LNbits.map.user(window.user),
receive: {
show: false,
status: 'pending',
@@ -146,7 +147,12 @@ new Vue({
payments: [],
paymentsTable: {
columns: [
{name: 'memo', align: 'left', label: 'Memo', field: 'memo'},
{
name: 'memo',
align: 'left',
label: 'Memo',
field: 'memo'
},
{
name: 'date',
align: 'left',
@@ -179,7 +185,7 @@ new Vue({
computed: {
filteredPayments: function() {
var q = this.paymentsTable.filter
if (!q || q == '') return this.payments
if (!q || q === '') return this.payments
return LNbits.utils.search(this.payments, q)
},
@@ -316,11 +322,11 @@ new Vue({
_.each(invoice.data.tags, function(tag) {
if (_.isObject(tag) && _.has(tag, 'description')) {
if (tag.description == 'payment_hash') {
if (tag.description === 'payment_hash') {
cleanInvoice.hash = tag.value
} else if (tag.description == 'description') {
} else if (tag.description === 'description') {
cleanInvoice.description = tag.value
} else if (tag.description == 'expiry') {
} else if (tag.description === 'expiry') {
var expireDate = new Date(
(invoice.data.time_stamp + tag.value) * 1000
)
+8 -3
View File
@@ -8,7 +8,7 @@
{% endblock %} {% block scripts %} {{ window_vars(user, wallet) }}
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
{% assets filters='rjsmin', output='__bundle__/core/chart.js',
'vendor/moment@2.25.1/moment.min.js', 'vendor/chart.js@2.9.3/chart.min.js' %}
'vendor/moment@2.27.0/moment.min.js', 'vendor/chart.js@2.9.3/chart.min.js' %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %} {% assets filters='rjsmin', output='__bundle__/core/wallet.js',
'vendor/bolt11/utils.js', 'vendor/bolt11/decoder.js',
@@ -76,7 +76,7 @@
clearable
v-model="paymentsTable.filter"
debounce="300"
placeholder="Search by memo, amount"
placeholder="Search by tag, memo, amount"
class="q-mb-md"
>
</q-input>
@@ -84,7 +84,7 @@
dense
flat
:data="filteredPayments"
row-key="checking_id"
row-key="payment_hash"
:columns="paymentsTable.columns"
:pagination.sync="paymentsTable.pagination"
>
@@ -111,6 +111,11 @@
</q-icon>
</q-td>
<q-td key="memo" :props="props">
<q-badge v-if="props.row.tag" color="yellow" text-color="black">
<a class="inherit" :href="['/', props.row.tag, '?usr=', user.id].join('')">
#{{ props.row.tag }}
</a>
</q-badge>
{{ props.row.memo }}
</q-td>
<q-td auto-width key="date" :props="props">