From 385406a78a846bde5de0347d846eec06f94ff24c Mon Sep 17 00:00:00 2001 From: benarc Date: Mon, 22 Feb 2021 00:45:52 +0000 Subject: [PATCH] Watchonly statspay basic gui working --- lnbits/extensions/satspay/config.json | 2 +- lnbits/extensions/satspay/crud.py | 13 - .../{watchonly => satspay}/_api_docs.html | 0 .../{watchonly => satspay}/display.html | 0 .../{watchonly => satspay}/index.html | 408 ++++-------------- .../watchonly/templates/watchonly/index.html | 119 +---- 6 files changed, 84 insertions(+), 458 deletions(-) rename lnbits/extensions/satspay/templates/{watchonly => satspay}/_api_docs.html (100%) rename lnbits/extensions/satspay/templates/{watchonly => satspay}/display.html (100%) rename lnbits/extensions/satspay/templates/{watchonly => satspay}/index.html (61%) diff --git a/lnbits/extensions/satspay/config.json b/lnbits/extensions/satspay/config.json index 7e9e1a597..beb0071cb 100644 --- a/lnbits/extensions/satspay/config.json +++ b/lnbits/extensions/satspay/config.json @@ -1,7 +1,7 @@ { "name": "SatsPay Server", "short_description": "Create onchain and LN charges", - "icon": "visibility", + "icon": "payment", "contributors": [ "arcbtc" ] diff --git a/lnbits/extensions/satspay/crud.py b/lnbits/extensions/satspay/crud.py index 18934eb6b..bb9b0203a 100644 --- a/lnbits/extensions/satspay/crud.py +++ b/lnbits/extensions/satspay/crud.py @@ -6,20 +6,7 @@ from .models import Charges from lnbits.helpers import urlsafe_short_hash -from embit import bip32 -from embit import ec -from embit.networks import NETWORKS -from embit import base58 -from embit.util import hashlib -import io -from embit.util import secp256k1 -from embit import hashes -from binascii import hexlify from quart import jsonify -from embit import script -from embit import ec -from embit.networks import NETWORKS -from binascii import unhexlify, hexlify, a2b_base64, b2a_base64 import httpx diff --git a/lnbits/extensions/satspay/templates/watchonly/_api_docs.html b/lnbits/extensions/satspay/templates/satspay/_api_docs.html similarity index 100% rename from lnbits/extensions/satspay/templates/watchonly/_api_docs.html rename to lnbits/extensions/satspay/templates/satspay/_api_docs.html diff --git a/lnbits/extensions/satspay/templates/watchonly/display.html b/lnbits/extensions/satspay/templates/satspay/display.html similarity index 100% rename from lnbits/extensions/satspay/templates/watchonly/display.html rename to lnbits/extensions/satspay/templates/satspay/display.html diff --git a/lnbits/extensions/satspay/templates/watchonly/index.html b/lnbits/extensions/satspay/templates/satspay/index.html similarity index 61% rename from lnbits/extensions/satspay/templates/watchonly/index.html rename to lnbits/extensions/satspay/templates/satspay/index.html index b75977f1e..5ea3f1c01 100644 --- a/lnbits/extensions/satspay/templates/watchonly/index.html +++ b/lnbits/extensions/satspay/templates/satspay/index.html @@ -5,36 +5,8 @@ {% raw %} - New wallet - -
- - Point to another Mempool - - {{ this.mempool.endpoint }} - - - -
set - cancel -
- -
-
- -
New charge
@@ -43,113 +15,7 @@
-
Wallets
-
-
- - - - -
-
- - - - -
- - - - - - -
-
-
Paylinks
+
Charges
@@ -276,54 +142,6 @@
- - - - - - - - -
- Update Watch-only Wallet - Create Watch-only Wallet - Cancel -
-
-
-
- - @@ -350,8 +168,48 @@ v-model.trim="formDialogCharge.data.time" type="number" label="Time (secs)" - > - + > + +
+
+
+ +
+
+ + + Watch-Only extension MUST be activated and have a wallet + + + +
+
+
+ +
+ +
+
+
+ + + +
+ + + +
+
+ + +
- - - {% raw %} -
Addresses
-
-

Current: - {{ currentaddress }} - - -

- - - -

- - - - - {{ data.address }} - - - - - - - -

- -
- Get fresh address - Close -
-
-
-{% endraw %} -
{% endblock %} {% block scripts %} {{ window_vars(user) }} @@ -485,10 +281,12 @@ data: function () { return { filter: '', + watchonlyactive: false, balance: null, checker: null, walletLinks: [], ChargeLinks: [], + onchainwallet: '', currentaddress: "", Addresses: { show: false, @@ -497,32 +295,7 @@ mempool:{ endpoint:"" }, - WalletsTable: { - columns: [ - {name: 'id', align: 'left', label: 'ID', field: 'id'}, - { - name: 'title', - align: 'left', - label: 'Title', - field: 'title' - }, - { - name: 'amount', - align: 'left', - label: 'Amount', - field: 'amount' - }, - { - name: 'masterpub', - align: 'left', - label: 'MasterPub', - field: 'masterpub' - }, - ], - pagination: { - rowsPerPage: 10 - } - }, + ChargesTable: { columns: [ {name: 'id', align: 'left', label: 'ID', field: 'id'}, @@ -545,10 +318,16 @@ field: 'amount_paid' }, { - name: 'address', + name: 'onchain address', align: 'left', - label: 'Address', - field: 'address' + label: 'Onchain Address', + field: 'onchainaddress' + }, + { + name: 'LNbits wallet', + align: 'left', + label: 'LNbits wallet', + field: 'lnbits-wallet' }, { name: 'time to pay', @@ -573,7 +352,7 @@ }, formDialogCharge: { show: false, - data: {} + data: {onchain: false,lnbits:false} }, qrCodeDialog: { show: false, @@ -584,59 +363,24 @@ methods: { - - chargeRedirect: function (address){ - window.location.href = this.mempool.endpoint + "/address/" + address; - }, - getMempool: function () { - var self = this - - LNbits.api - .request( - 'GET', - '/satspay/api/v1/mempool', - this.g.user.wallets[0].inkey - ) - .then(function (response) { - console.log(response.data.endpoint) - self.mempool.endpoint = response.data.endpoint - console.log(this.mempool.endpoint) - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - }, - - updateMempool: function () { - var self = this - var wallet = this.g.user.wallets[0] - LNbits.api - .request( - 'PUT', - '/satspay/api/v1/mempool', - wallet.inkey, self.mempool) - .then(function (response) { - self.mempool.endpoint = response.data.endpoint - self.walletLinks.push(mapwalletLink(response.data)) - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - }, getWalletLinks: function () { var self = this LNbits.api .request( 'GET', - '/satspay/api/v1/wallet', + '/watchonly/api/v1/wallet', this.g.user.wallets[0].inkey ) .then(function (response) { - self.walletLinks = response.data.map(function (obj) { - return mapWalletLink(obj) - }) + for (i = 0; i < response.data.length; i++) { + self.walletLinks.push(response.data[i].title + " " + response.data[i].id) + } + console.log(self.walletLinks) + + + return }) .catch(function (error) { LNbits.utils.notifyApiError(error) @@ -831,13 +575,23 @@ }, created: function () { - if (this.g.user.wallets.length) { - var getWalletLinks = this.getWalletLinks - getWalletLinks() + var getWalletLinks = this.getWalletLinks + getWalletLinks() var getCharges = this.getCharges getCharges() - var getMempool = this.getMempool - getMempool() + + if (this.g.user.wallets.length) { + for (i = 0; i < this.g.extensions.length; i++) { + if(this.g.extensions[i].code == "watchonly"){ + console.log(this.walletLinks) + if(this.walletLinks.length > 0 ){ + this.watchonlyactive = true + } + } + } + + + } diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index c60d7e433..ed3a5537b 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -142,124 +142,9 @@
- - - - - -
-
-
Paylinks
-
-
- - - - -
-
- - - - - - {% endraw %} - - - - - -
-
- - - -
- + {% endraw %}
@@ -271,7 +156,7 @@ - {% include "watchonly/_api_docs.html" %} + {% include "watchonly/_api_docs.html" %}