2022-07-22 18:01:47 +03:00
|
|
|
async function walletConfig(path) {
|
|
|
|
const t = await loadTemplateAsync(path)
|
|
|
|
Vue.component('wallet-config', {
|
|
|
|
name: 'wallet-config',
|
|
|
|
template: t,
|
|
|
|
|
|
|
|
props: ['total', 'config', 'adminkey'],
|
|
|
|
data: function () {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
satBtc(val, showUnit = true) {
|
|
|
|
return satOrBtc(val, showUnit, this.config.data.sats_denominated)
|
|
|
|
},
|
|
|
|
updateConfig: async function () {
|
|
|
|
try {
|
|
|
|
await LNbits.api.request(
|
|
|
|
'PUT',
|
|
|
|
'/watchonly/api/v1/config',
|
|
|
|
this.adminkey,
|
|
|
|
this.config.data
|
|
|
|
)
|
|
|
|
this.config.show = false
|
|
|
|
} catch (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getConfig: async function () {
|
|
|
|
try {
|
|
|
|
const {data} = await LNbits.api.request(
|
|
|
|
'GET',
|
|
|
|
'/watchonly/api/v1/config',
|
|
|
|
this.adminkey
|
|
|
|
)
|
|
|
|
this.config.data = data
|
|
|
|
} catch (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created: async function () {
|
2022-07-25 10:50:12 +03:00
|
|
|
await this.getConfig()
|
2022-07-22 18:01:47 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|