From 7b75cbf59c41b269d0c59a27383a632481d8ab92 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 12 Jul 2022 15:46:30 +0300 Subject: [PATCH] feat: add `Share PSBT` button with options --- .../extensions/watchonly/static/js/index.js | 51 +++++++------ .../watchonly/templates/watchonly/index.html | 73 ++++++++++++++++--- 2 files changed, 93 insertions(+), 31 deletions(-) diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js index f44d30cd..70c3ae16 100644 --- a/lnbits/extensions/watchonly/static/js/index.js +++ b/lnbits/extensions/watchonly/static/js/index.js @@ -426,28 +426,6 @@ new Vue({ this.payment.txSize = Math.round(txSize(tx)) return this.payment.feeRate * this.payment.txSize }, - createPsbt: async function () { - const wallet = this.g.user.wallets[0] - try { - this.computeFee() - const tx = this.createTx() - txSize(tx) - for (const input of tx.inputs) { - input.tx_hex = await this.fetchTxHex(input.tx_id) - } - - const {data} = await LNbits.api.request( - 'POST', - '/watchonly/api/v1/psbt', - wallet.adminkey, - tx - ) - - this.payment.psbtBase64 = data - } catch (err) { - LNbits.utils.notifyApiError(err) - } - }, deletePaymentAddress: function (v) { const index = this.payment.data.indexOf(v) if (index !== -1) { @@ -499,6 +477,35 @@ new Vue({ const payedAmount = this.getTotalPaymentAmount() paymentAddress.amount = Math.max(0, inputAmount - payedAmount - fee) }, + //################### PSBT ################### + createPsbt: async function () { + const wallet = this.g.user.wallets[0] + try { + this.computeFee() + const tx = this.createTx() + txSize(tx) + for (const input of tx.inputs) { + input.tx_hex = await this.fetchTxHex(input.tx_id) + } + + const {data} = await LNbits.api.request( + 'POST', + '/watchonly/api/v1/psbt', + wallet.adminkey, + tx + ) + + this.payment.psbtBase64 = data + } catch (err) { + LNbits.utils.notifyApiError(err) + } + }, + sharePsbtOnSerialPort: async function () { + console.log('### sharePsbtOnSerialPort') + }, + sharePsbtWithAnimatedQRCode: async function () { + console.log('### sharePsbtWithAnimatedQRCode') + }, //################### UTXOs ################### scanAllAddresses: async function () { diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index ff596699..16ebdabb 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -674,8 +674,22 @@ - + +
+
+ + The payed amount is higher than the selected amount! + +
+
+ @@ -993,6 +1007,7 @@ +
- - The payed amount is higher than the selected amount! - + + + + + + + Serial Port + Send the PSBT using an USB port + + + + + + + + + + Animated QR Code + Comming Soon + + + +