refactor: code clean-up

This commit is contained in:
Vlad Stan 2022-07-27 11:35:42 +03:00
parent 32486d62bf
commit b664500061
2 changed files with 10 additions and 15 deletions

View file

@ -28,6 +28,9 @@ async function payment(path) {
DUST_LIMIT: 546, DUST_LIMIT: 546,
tx: null, tx: null,
psbtBase64: null, psbtBase64: null,
signedTx: null,
sentTxId: null,
signedTxId: null,
paymentTab: 'destination', paymentTab: 'destination',
sendToList: [{address: '', amount: undefined}], sendToList: [{address: '', amount: undefined}],
changeWallet: null, changeWallet: null,
@ -228,14 +231,13 @@ async function payment(path) {
}, },
broadcastTransaction: async function () { broadcastTransaction: async function () {
try { try {
const wallet = this.g.user.wallets[0]
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
'POST', 'POST',
'/watchonly/api/v1/tx', '/watchonly/api/v1/tx',
wallet.adminkey, this.adminkey,
{tx_hex: this.payment.signedTxHex} {tx_hex: this.signedTxHex}
) )
this.payment.sentTxId = data this.sentTxId = data
this.$q.notify({ this.$q.notify({
type: 'positive', type: 'positive',
@ -244,15 +246,10 @@ async function payment(path) {
timeout: 10000 timeout: 10000
}) })
this.hww.psbtSent = false // await this.scanAddressWithAmount()
this.payment.psbtBase64Signed = null // todo: event
this.payment.signedTxHex = null
this.payment.signedTx = null
this.payment.psbtBase64 = null
await this.scanAddressWithAmount()
} catch (error) { } catch (error) {
this.payment.sentTxId = null this.sentTxId = null
this.$q.notify({ this.$q.notify({
type: 'warning', type: 'warning',
message: 'Failed to broadcast!', message: 'Failed to broadcast!',

View file

@ -84,9 +84,7 @@ const watchOnly = async () => {
showAddress: false, showAddress: false,
addressNote: '', addressNote: '',
showPayment: false, showPayment: false,
fetchedUtxos: false, fetchedUtxos: false
signedTx: null,
signedTxHex: null
} }
}, },