From d5cc8d9187c0340655042db142069ae1809396aa Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Wed, 27 Jul 2022 10:10:09 +0300 Subject: [PATCH] refactor: send psbt to device --- .../watchonly/static/components/payment/payment.js | 11 +++++++---- .../components/serial-signer/serial-signer.js | 13 ++----------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/payment/payment.js b/lnbits/extensions/watchonly/static/components/payment/payment.js index b6229096..8fcef05b 100644 --- a/lnbits/extensions/watchonly/static/components/payment/payment.js +++ b/lnbits/extensions/watchonly/static/components/payment/payment.js @@ -79,10 +79,6 @@ async function payment(path) { checkAndSend: async function () { this.showChecking = true try { - console.log( - '### this.checkAndSend', - this.serialSignerRef.isConnected() - ) if (!this.serialSignerRef.isConnected()) { await this.serialSignerRef.openSerialPort() return @@ -93,9 +89,16 @@ async function payment(path) { } await this.createPsbt() + + if (this.psbtBase64) { + await this.serialSignerRef.hwwSendPsbt(this.psbtBase64) + } + + console.log('### hwwSendPsbt') } catch (error) { } finally { this.showChecking = false + this.psbtBase64 = null } }, createPsbt: async function () { diff --git a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js index 22b13510..abd92ffb 100644 --- a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js +++ b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js @@ -271,19 +271,10 @@ async function serialSigner(path) { }) } }, - hwwExecuteDefaultCommand: function () { - if (this.hww.authenticated) { - this.hwwSendPsbt() - } else { - this.hwwShowPasswordDialog() - } - }, - hwwSendPsbt: async function () { + hwwSendPsbt: async function (psbtBase64) { try { this.hww.sendingPsbt = true - await this.writer.write( - COMMAND_SEND_PSBT + ' ' + this.payment.psbtBase64 + '\n' - ) + await this.writer.write(COMMAND_SEND_PSBT + ' ' + psbtBase64 + '\n') this.$q.notify({ type: 'positive', message: 'Data sent to serial port device!',