diff --git a/lnbits/extensions/watchonly/static/components/history/history.js b/lnbits/extensions/watchonly/static/components/history/history.js index 574a1ef6..81cf44cc 100644 --- a/lnbits/extensions/watchonly/static/components/history/history.js +++ b/lnbits/extensions/watchonly/static/components/history/history.js @@ -39,6 +39,10 @@ async function history(path) { label: 'Date', field: 'date', sortable: true + }, + { + name: 'txId', + field: 'txId' } ], exportColums: [ diff --git a/lnbits/extensions/watchonly/static/components/payment/payment.js b/lnbits/extensions/watchonly/static/components/payment/payment.js index 2056fcfe..a74e5489 100644 --- a/lnbits/extensions/watchonly/static/components/payment/payment.js +++ b/lnbits/extensions/watchonly/static/components/payment/payment.js @@ -33,7 +33,6 @@ async function payment(path) { signedTxHex: null, sentTxId: null, signedTxId: null, - paymentTab: 'destination', sendToList: [{address: '', amount: undefined}], changeWallet: null, changeAddress: {}, @@ -83,6 +82,17 @@ async function payment(path) { satBtc(val, showUnit = true) { return satOrBtc(val, showUnit, this.satsDenominated) }, + clearState: function () { + this.psbtBase64 = null + this.psbtBase64Signed = null + this.signedTx = null + this.signedTxHex = null + this.signedTxId = null + this.sendToList = [{address: '', amount: undefined}] + this.showChecking = false + this.showPsbt = false + this.showFinalTx = false + }, checkAndSend: async function () { this.showChecking = true try { @@ -143,7 +153,6 @@ async function payment(path) { }, createPsbt: async function () { try { - console.log('### this.createPsbt') this.tx = this.createTx() for (const input of this.tx.inputs) { input.tx_hex = await this.fetchTxHex(input.tx_id) @@ -237,8 +246,6 @@ async function payment(path) { this.showChecking = true this.psbtBase64Signed = psbtBase64 - console.log('### payment updateSignedPsbt psbtBase64', psbtBase64) - const data = await this.extractTxFromPsbt(psbtBase64) this.showFinalTx = true if (data) { @@ -253,7 +260,6 @@ async function payment(path) { } }, extractTxFromPsbt: async function (psbtBase64) { - console.log('### extractTxFromPsbt psbtBase64', psbtBase64) try { const {data} = await LNbits.api.request( 'PUT', @@ -264,13 +270,12 @@ async function payment(path) { inputs: this.tx.inputs } ) - console.log('### extractTxFromPsbt data', data) return data } catch (error) { - console.log('### error', error) this.$q.notify({ type: 'warning', message: 'Cannot finalize PSBT!', + caption: `${error}`, timeout: 10000 }) LNbits.utils.notifyApiError(error) @@ -293,8 +298,8 @@ async function payment(path) { timeout: 10000 }) - // todo: event rescan with amount - // todo: display tx id + this.clearState() + this.$emit('broadcast-done', this.sentTxId) } catch (error) { this.sentTxId = null this.$q.notify({ diff --git a/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js b/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js index c545ed2e..f36e0d59 100644 --- a/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js +++ b/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js @@ -99,6 +99,7 @@ async function walletList(path) { async network(newNet, oldNet) { if (newNet !== oldNet) { await this.refreshWalletAccounts() + this.handleAddressTypeChanged(this.addressTypeOptions[1]) } } }, diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js index 68204aca..ad1cdc14 100644 --- a/lnbits/extensions/watchonly/static/js/index.js +++ b/lnbits/extensions/watchonly/static/js/index.js @@ -386,6 +386,13 @@ const watchOnly = async () => { this.addresses = addresses this.scanAddressWithAmount() } + }, + handleBroadcastSuccess: async function (txId) { + this.tab = 'history' + this.searchInTab({tab: 'history', value: txId}) + this.showPayment = false + await this.refreshAddresses() + await this.scanAddressWithAmount() } }, created: async function () { diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index 5108da91..b9ce361c 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -136,6 +136,7 @@ :adminkey="g.user.wallets[0].adminkey" :serial-signer-ref="$refs.serialSigner" :sats-denominated="config.sats_denominated" + @broadcast-done="handleBroadcastSuccess" > @@ -176,7 +177,7 @@ dense size="ms" icon="content_copy" - @click="copyText(props.row.address)" + @click="copyText(currentAddress.address)" class="q-ml-sm" >