feat: add network for wallet accounts

This commit is contained in:
Vlad Stan
2022-08-03 13:50:07 +03:00
parent 4671954896
commit 6150b767e4
9 changed files with 57 additions and 23 deletions
@@ -65,7 +65,7 @@
<div>
<a
style="color: unset"
:href="mempoolEndpoint + '/address/' + props.row.address"
:href="'https://'+ mempoolEndpoint + '/address/' + props.row.address"
target="_blank"
>
{{props.row.address}}</a
@@ -8,11 +8,7 @@ async function walletConfig(path) {
data: function () {
return {
networOptions: ['Mainnet', 'Testnet'],
internalConfig: {
mempool_endpoint: 'https://mempool.space',
receive_gap_limit: 20,
change_gap_limit: 5
},
internalConfig: {},
show: false
}
},
@@ -4,7 +4,7 @@ async function walletList(path) {
name: 'wallet-list',
template,
props: ['adminkey', 'inkey', 'sats-denominated', 'addresses'],
props: ['adminkey', 'inkey', 'sats-denominated', 'addresses', 'network'],
data: function () {
return {
walletAccounts: [],
@@ -47,6 +47,15 @@ async function walletList(path) {
}
}
},
watch: {
immediate: true,
async network(newNet, oldNet) {
console.log('### newNet, oldNet', newNet, oldNet)
if (newNet !== oldNet) {
await this.refreshWalletAccounts()
}
}
},
methods: {
satBtc(val, showUnit = true) {
@@ -55,6 +64,7 @@ async function walletList(path) {
addWalletAccount: async function () {
const data = _.omit(this.formDialog.data, 'wallet')
data.network = this.network
await this.createWalletAccount(data)
},
createWalletAccount: async function (data) {
@@ -106,7 +116,7 @@ async function walletList(path) {
try {
const {data} = await LNbits.api.request(
'GET',
'/watchonly/api/v1/wallet',
`/watchonly/api/v1/wallet/?network=${this.network}`,
this.inkey
)
return data
@@ -47,14 +47,15 @@ const watchOnly = async () => {
showAddress: false,
addressNote: '',
showPayment: false,
fetchedUtxos: false
fetchedUtxos: false,
network: null
}
},
computed: {
mempoolHostname() {
mempoolHostname: function () {
if (!this.config.isLoaded) return
const hostname = new URL(this.config.mempool_endpoint).hostname
if (this.config.network === 'testnet') {
let hostname = new URL(this.config.mempool_endpoint).hostname
if (this.config.network === 'Testnet') {
hostname += '/testnet'
}
return hostname