Files
xo-stack/packages/vue/src/wallet-hd-vue.ts
T
James Zuccon 2ac7af4069 Monorepo stuff
Signed-off-by: James Zuccon <zuccon@gmail.com>
2024-09-02 20:05:35 +10:00

39 lines
971 B
TypeScript

import { Blockchain, WalletHD } from '@xo/wallet';
import { WalletP2PKHVue, useWalletP2PKHVue } from './wallet-p2pkh-vue.js';
import { computed, ref, shallowRef } from 'vue';
import { HdPrivateNodeValid } from '@bitauth/libauth';
export class WalletHDVue extends WalletHD<WalletP2PKHVue> {
// Reactive State.
public rShouldMonitor = ref(false);
public rWallets = shallowRef<Array<WalletP2PKHVue>>([]);
// Computeds.
public rBalance = computed(() => {
return this.rWallets.value.reduce(
(total, node) => total + node.rBalance.value,
0
);
});
constructor(
node: HdPrivateNodeValid,
electrum: Blockchain,
walletFactory = useWalletP2PKHVue
) {
super(node, electrum, walletFactory);
this.events.on(
'walletsUpdated',
(wallets) => (this.rWallets.value = wallets)
);
this.events.on(
'shouldMonitorUpdated',
(shouldMonitor) => (this.rShouldMonitor.value = shouldMonitor)
);
}
}