feat: UI improvements and fixes

This commit is contained in:
Vlad Stan 2022-08-22 10:09:26 +03:00
parent d08b7455e7
commit 9bbcd28452
5 changed files with 28 additions and 10 deletions

View file

@ -39,6 +39,10 @@ async function history(path) {
label: 'Date',
field: 'date',
sortable: true
},
{
name: 'txId',
field: 'txId'
}
],
exportColums: [

View file

@ -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({

View file

@ -99,6 +99,7 @@ async function walletList(path) {
async network(newNet, oldNet) {
if (newNet !== oldNet) {
await this.refreshWalletAccounts()
this.handleAddressTypeChanged(this.addressTypeOptions[1])
}
}
},

View file

@ -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 () {

View file

@ -136,6 +136,7 @@
:adminkey="g.user.wallets[0].adminkey"
:serial-signer-ref="$refs.serialSigner"
:sats-denominated="config.sats_denominated"
@broadcast-done="handleBroadcastSuccess"
></payment>
<!-- todo: no more utxos.data -->
</div>
@ -176,7 +177,7 @@
dense
size="ms"
icon="content_copy"
@click="copyText(props.row.address)"
@click="copyText(currentAddress.address)"
class="q-ml-sm"
></q-btn>