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 { // Reactive State. public rShouldMonitor = ref(false); public rWallets = shallowRef>([]); // 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) ); } }