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', label: 'Date',
field: 'date', field: 'date',
sortable: true sortable: true
},
{
name: 'txId',
field: 'txId'
} }
], ],
exportColums: [ exportColums: [

View file

@ -33,7 +33,6 @@ async function payment(path) {
signedTxHex: null, signedTxHex: null,
sentTxId: null, sentTxId: null,
signedTxId: null, signedTxId: null,
paymentTab: 'destination',
sendToList: [{address: '', amount: undefined}], sendToList: [{address: '', amount: undefined}],
changeWallet: null, changeWallet: null,
changeAddress: {}, changeAddress: {},
@ -83,6 +82,17 @@ async function payment(path) {
satBtc(val, showUnit = true) { satBtc(val, showUnit = true) {
return satOrBtc(val, showUnit, this.satsDenominated) 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 () { checkAndSend: async function () {
this.showChecking = true this.showChecking = true
try { try {
@ -143,7 +153,6 @@ async function payment(path) {
}, },
createPsbt: async function () { createPsbt: async function () {
try { try {
console.log('### this.createPsbt')
this.tx = this.createTx() this.tx = this.createTx()
for (const input of this.tx.inputs) { for (const input of this.tx.inputs) {
input.tx_hex = await this.fetchTxHex(input.tx_id) input.tx_hex = await this.fetchTxHex(input.tx_id)
@ -237,8 +246,6 @@ async function payment(path) {
this.showChecking = true this.showChecking = true
this.psbtBase64Signed = psbtBase64 this.psbtBase64Signed = psbtBase64
console.log('### payment updateSignedPsbt psbtBase64', psbtBase64)
const data = await this.extractTxFromPsbt(psbtBase64) const data = await this.extractTxFromPsbt(psbtBase64)
this.showFinalTx = true this.showFinalTx = true
if (data) { if (data) {
@ -253,7 +260,6 @@ async function payment(path) {
} }
}, },
extractTxFromPsbt: async function (psbtBase64) { extractTxFromPsbt: async function (psbtBase64) {
console.log('### extractTxFromPsbt psbtBase64', psbtBase64)
try { try {
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
'PUT', 'PUT',
@ -264,13 +270,12 @@ async function payment(path) {
inputs: this.tx.inputs inputs: this.tx.inputs
} }
) )
console.log('### extractTxFromPsbt data', data)
return data return data
} catch (error) { } catch (error) {
console.log('### error', error)
this.$q.notify({ this.$q.notify({
type: 'warning', type: 'warning',
message: 'Cannot finalize PSBT!', message: 'Cannot finalize PSBT!',
caption: `${error}`,
timeout: 10000 timeout: 10000
}) })
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
@ -293,8 +298,8 @@ async function payment(path) {
timeout: 10000 timeout: 10000
}) })
// todo: event rescan with amount this.clearState()
// todo: display tx id this.$emit('broadcast-done', this.sentTxId)
} catch (error) { } catch (error) {
this.sentTxId = null this.sentTxId = null
this.$q.notify({ this.$q.notify({

View file

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

View file

@ -386,6 +386,13 @@ const watchOnly = async () => {
this.addresses = addresses this.addresses = addresses
this.scanAddressWithAmount() 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 () { created: async function () {

View file

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