diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js index 98f19971f..5aeae3ccb 100644 --- a/lnbits/extensions/watchonly/static/js/index.js +++ b/lnbits/extensions/watchonly/static/js/index.js @@ -48,7 +48,8 @@ new Vue({ password: null, authenticated: false, showPasswordDialog: false, - showConsole: false + showConsole: false, + psbtSent: false }, formDialog: { @@ -564,6 +565,7 @@ new Vue({ wallet.adminkey, {tx_hex: this.payment.signedTxHex} ) + this.payment.sentTxId = data this.$q.notify({ type: 'positive', message: 'Transaction broadcasted!', @@ -571,6 +573,7 @@ new Vue({ timeout: 10000 }) } catch (error) { + this.payment.sentTxId = null this.$q.notify({ type: 'warning', message: 'Failed to broadcast!', @@ -695,6 +698,7 @@ new Vue({ else if (msg[0] == COMMAND_PASSWORD) this.handleLoginResponse(msg[1]) else if (msg[0] == COMMAND_PASSWORD_CLEAR) this.handleLogoutResponse(msg[1]) + else if (msg[0] == COMMAND_SEND_PSBT) this.handleSendPsbtResponse(msg[1]) else console.log('### handleSerialPortResponse', value) }, updateSerialPortConsole: function (value) { @@ -708,6 +712,19 @@ new Vue({ console.log('### sharePsbtWithAnimatedQRCode') }, //################### HARDWARE WALLET ################### + hwwShowPasswordDialog: async function () { + try { + this.hww.showPasswordDialog = true + await this.serial.writer.write(COMMAND_PASSWORD + '\n') + } catch (error) { + this.$q.notify({ + type: 'warning', + message: 'Failed to connect to Hardware Wallet!', + caption: `${error}`, + timeout: 10000 + }) + } + }, hwwLogin: async function () { try { await this.serial.writer.write( @@ -716,7 +733,7 @@ new Vue({ } catch (error) { this.$q.notify({ type: 'warning', - message: 'Failed to send password to hardware wallet!', + message: 'Failed to send password to Hardware Wallet!', caption: `${error}`, timeout: 10000 }) @@ -767,7 +784,7 @@ new Vue({ if (this.hww.authenticated) { this.hwwLogout() } else { - this.hww.showPasswordDialog = true + this.hwwShowPasswordDialog() } }, hwwSendPsbt: async function () { @@ -789,6 +806,9 @@ new Vue({ }) } }, + handleSendPsbtResponse: function (res = '') { + this.hww.psbtSent = true + }, hwwSignPsbt: async function () { try { await this.serial.writer.write(COMMAND_SIGN_PSBT + '\n') diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index b19ee7dce..c3e8d2957 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -1128,12 +1128,13 @@ v-if="!hww.authenticated" clickable v-close-popup - @click="hww.showPasswordDialog = true" + @click="hwwShowPasswordDialog()" > Login Enter password for HWW.Enter password for Hardware + Wallet. @@ -1155,14 +1156,8 @@ :disabled="!hww.authenticated" clickable v-close-popup - @click="hww.showPasswordDialog = true" + @click="hwwShowPasswordDialog()" > - - Sign - Sign PSBT on Hardware Wallet. - @@ -1234,25 +1229,62 @@ - Please check transaction data on the Hardware Wallet - Display Confirm + + + + + + + + + + Send Payment + + + Transaction Details + + + + Outputs + - - - - - Send Payment - - - + class="q-mb-lg" + > + + + + + diff --git a/lnbits/extensions/watchonly/views_api.py b/lnbits/extensions/watchonly/views_api.py index 298a3251f..8adbd22e1 100644 --- a/lnbits/extensions/watchonly/views_api.py +++ b/lnbits/extensions/watchonly/views_api.py @@ -311,10 +311,9 @@ async def api_psbt_extract_tx( @watchonly_ext.post("/api/v1/tx") -async def api_psbt_extract_tx( +async def api_tx_broadcast( data: BroadcastTransaction, w: WalletTypeInfo = Depends(require_admin_key) ): - print("### data", data) try: config = await get_config(w.wallet.user) if not config: @@ -322,11 +321,12 @@ async def api_psbt_extract_tx( "Cannot broadcast transaction. Mempool endpoint not defined!" ) x = bytes.fromhex(data.tx_hex) - print("### x", x) - async with httpx.AsyncClient() as client: - r = await client.post(config.mempool_endpoint + "/api/tx", data=data.tx_hex) - tx_id = r.text - return tx_id + + # async with httpx.AsyncClient() as client: + # r = await client.post(config.mempool_endpoint + "/api/tx", data=data.tx_hex) + # tx_id = r.text + # return tx_id + return "0f0f0f0f0f0f0f0f0f0f0f00f0f0f0f0f0f0f0f0f0f00f0f0f0f0f0f0.mock.transaction.id" except Exception as e: raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail=str(e))