Unregister electronAPI events
Some checks are pending
MacOS Build / build (20) (push) Waiting to run
Ubuntu 22.04 - AppImage Build / build (20) (push) Waiting to run
Ubuntu 22.04 - x64 DEB Build / build (20) (push) Waiting to run
Ubuntu 24.04 - x64 DEB Build / build (20) (push) Waiting to run
Windows Build / build (20) (push) Waiting to run

This commit is contained in:
everoddandeven 2024-10-28 00:42:23 +01:00
parent cd15e0f0f9
commit 3d350409e0
11 changed files with 168 additions and 77 deletions

View file

@ -1,6 +1,5 @@
// preload.js // preload.js
const { contextBridge, ipcRenderer } = require('electron'); const { contextBridge, ipcRenderer } = require('electron');
//const os = require('os');
contextBridge.exposeInMainWorld('electronAPI', { contextBridge.exposeInMainWorld('electronAPI', {
startMonerod: (args) => { startMonerod: (args) => {
@ -18,12 +17,14 @@ contextBridge.exposeInMainWorld('electronAPI', {
onMonitorMonerodError: (callback) => { onMonitorMonerodError: (callback) => {
ipcRenderer.on('on-monitor-monerod-error', callback); ipcRenderer.on('on-monitor-monerod-error', callback);
}, },
unregisterOnMonitorMonerod: () => {
ipcRenderer.removeAllListeners('on-monitor-monerod');
},
unregisterOnMonitorMonerodError: () => {
ipcRenderer.removeAllListeners('on-monitor-monerod-error');
},
unsubscribeOnMonerodStarted: () => { unsubscribeOnMonerodStarted: () => {
const listeners = ipcRenderer.listeners('monerod-started'); ipcRenderer.removeAllListeners('monerod-started');
listeners.forEach((listener) => {
ipcRenderer.removeListener('monerod-started', listener);
});
}, },
onMoneroStdout: (callback) => { onMoneroStdout: (callback) => {
ipcRenderer.on('monero-stdout', callback); ipcRenderer.on('monero-stdout', callback);
@ -31,6 +32,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
onMoneroClose: (callback) => { onMoneroClose: (callback) => {
ipcRenderer.on('monero-close', callback); ipcRenderer.on('monero-close', callback);
}, },
unregisterOnMoneroStdout: () => {
ipcRenderer.removeAllListeners('monero-stdout');
},
getMoneroVersion: (monerodPath) => { getMoneroVersion: (monerodPath) => {
ipcRenderer.invoke('get-monero-version', monerodPath); ipcRenderer.invoke('get-monero-version', monerodPath);
}, },
@ -40,6 +44,13 @@ contextBridge.exposeInMainWorld('electronAPI', {
onMoneroVersionError: (callback) => { onMoneroVersionError: (callback) => {
ipcRenderer.on('monero-version-error', callback); ipcRenderer.on('monero-version-error', callback);
}, },
unregisterOnMoneroVersion: () => {
ipcRenderer.removeAllListeners('on-monero-version');
},
unregisterOnMoneroVersionError: () => {
ipcRenderer.removeAllListeners('unregister-on-monero-version-error');
},
downloadMonerod: (downloadUrl, destination) => { downloadMonerod: (downloadUrl, destination) => {
ipcRenderer.invoke('download-monerod', downloadUrl, destination); ipcRenderer.invoke('download-monerod', downloadUrl, destination);
}, },
@ -70,12 +81,19 @@ contextBridge.exposeInMainWorld('electronAPI', {
onIsWifiConnectedResponse: (callback) => { onIsWifiConnectedResponse: (callback) => {
ipcRenderer.on('is-wifi-connected-result', callback); ipcRenderer.on('is-wifi-connected-result', callback);
}, },
unregisterOnIsWifiConnectedResponse: () => {
ipcRenderer.removeAllListeners('is-wifi-connected-result');
},
getOsType: () => { getOsType: () => {
ipcRenderer.invoke('get-os-type'); ipcRenderer.invoke('get-os-type');
}, },
gotOsType: (callback) => { gotOsType: (callback) => {
ipcRenderer.on('got-os-type', callback); ipcRenderer.on('got-os-type', callback);
}, },
unregisterGotOsType: () => {
ipcRenderer.removeAllListeners('got-os-type');
},
showNotification: (options) => { showNotification: (options) => {
ipcRenderer.invoke('show-notification', options); ipcRenderer.invoke('show-notification', options);
}, },
@ -92,9 +110,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
ipcRenderer.on('on-is-auto-launch-enabled', callback); ipcRenderer.on('on-is-auto-launch-enabled', callback);
}, },
unregisterOnIsAutoLaunchEnabled: () => { unregisterOnIsAutoLaunchEnabled: () => {
const listeners = ipcRenderer.listeners('on-is-auto-launch-enabled'); ipcRenderer.removeAllListeners('on-is-auto-launch-enabled');
listeners.forEach((listener) => ipcRenderer.removeListener('on-is-auto-launch-enabled', listener));
}, },
onEnableAutoLaunchError: (callback) => { onEnableAutoLaunchError: (callback) => {
ipcRenderer.on('on-enable-auto-launch-error', callback); ipcRenderer.on('on-enable-auto-launch-error', callback);
@ -102,6 +118,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
onEnableAutoLaunchSuccess: (callback) => { onEnableAutoLaunchSuccess: (callback) => {
ipcRenderer.on('on-enable-auto-launch-success', callback); ipcRenderer.on('on-enable-auto-launch-success', callback);
}, },
unregisterOnEnableAutoLaunchError: () => {
ipcRenderer.removeAllListeners('on-enable-auto-launch-error');
},
unregisterOnEnableAutoLaunchSuccess: () => {
ipcRenderer.removeAllListeners('on-enable-auto-launch-success')
},
disableAutoLaunch: () => { disableAutoLaunch: () => {
ipcRenderer.invoke('disable-auto-launch'); ipcRenderer.invoke('disable-auto-launch');
}, },
@ -111,12 +133,21 @@ contextBridge.exposeInMainWorld('electronAPI', {
onDisableAutoLaunchSuccess: (callback) => { onDisableAutoLaunchSuccess: (callback) => {
ipcRenderer.on('on-disable-auto-launch-success', callback); ipcRenderer.on('on-disable-auto-launch-success', callback);
}, },
unregisterOnDisableAutoLaunchError: () => {
ipcRenderer.removeAllListeners('on-disable-auto-launch-error');
},
unregisterOnDisableAutoLaunchSuccess: () => {
ipcRenderer.removeAllListeners('on-disable-auto-launch-success')
},
isAppImage: () => { isAppImage: () => {
ipcRenderer.invoke('is-app-image'); ipcRenderer.invoke('is-app-image');
}, },
onIsAppImage: (callback) => { onIsAppImage: (callback) => {
ipcRenderer.on('on-is-app-image', callback); ipcRenderer.on('on-is-app-image', callback);
}, },
unregisterOnIsAppImage: () => {
ipcRenderer.removeAllListeners('on-is-app-image');
},
isAutoLaunched: () => { isAutoLaunched: () => {
ipcRenderer.invoke('is-auto-launched'); ipcRenderer.invoke('is-auto-launched');
}, },

View file

@ -38,32 +38,13 @@ export class AppComponent {
this.load().then().catch((error: any) => console.error(error)); this.load().then().catch((error: any) => console.error(error));
} }
private async isAutoLaunched(): Promise<boolean> {
try {
const promise = new Promise<boolean>((resolve) => {
window.electronAPI.onIsAutoLaunched((event: any, isAutoLaunched: boolean) => {
console.debug(event);
window.electronAPI.unregisterOnIsAutoLaunched();
resolve(isAutoLaunched);
});
});
window.electronAPI.isAutoLaunched();
return await promise;
} catch(error: any) {
console.error(error);
return false;
}
}
private async load(): Promise<void> { private async load(): Promise<void> {
this.loading = true; this.loading = true;
try { try {
this.daemonRunning = await this.daemonService.isRunning(true); this.daemonRunning = await this.daemonService.isRunning(true);
const isAutoLaunched = await this.isAutoLaunched(); const isAutoLaunched = await this.electronService.isAutoLaunched();
if (isAutoLaunched) { if (isAutoLaunched) {
await this.daemonService.startDaemon(); await this.daemonService.startDaemon();

View file

@ -1,6 +1,7 @@
import { EventEmitter, Injectable, NgZone } from '@angular/core'; import { EventEmitter, Injectable, NgZone } from '@angular/core';
import { DaemonService } from './daemon.service'; import { DaemonService } from './daemon.service';
import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetStats, NetStatsHistory, PeerInfo, ProcessStats, PublicNode, SyncInfo, TimeUtils, TxBacklogEntry, TxPool } from '../../../../common'; import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetStats, NetStatsHistory, PeerInfo, ProcessStats, PublicNode, SyncInfo, TimeUtils, TxBacklogEntry, TxPool } from '../../../../common';
import { ElectronService } from '../electron/electron.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -73,7 +74,7 @@ export class DaemonDataService {
public readonly netStatsRefreshStart: EventEmitter<void> = new EventEmitter<void>(); public readonly netStatsRefreshStart: EventEmitter<void> = new EventEmitter<void>();
public readonly netStatsRefreshEnd: EventEmitter<void> = new EventEmitter<void>(); public readonly netStatsRefreshEnd: EventEmitter<void> = new EventEmitter<void>();
constructor(private daemonService: DaemonService, private ngZone: NgZone) { constructor(private daemonService: DaemonService, private electronService: ElectronService, private ngZone: NgZone) {
this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => { this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
this.ngZone.run(() => { this.ngZone.run(() => {
@ -352,7 +353,7 @@ export class DaemonDataService {
const syncAlreadyDisabled = this.daemonService.settings.noSync; const syncAlreadyDisabled = this.daemonService.settings.noSync;
if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) { if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) {
const wifiConnected = await this.daemonService.isWifiConnected(); const wifiConnected = await this.electronService.isWifiConnected();
if (wifiConnected) { if (wifiConnected) {
console.log("Disabling sync ..."); console.log("Disabling sync ...");
@ -361,7 +362,7 @@ export class DaemonDataService {
} }
} }
else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi) { else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi) {
const wifiConnected = await this.daemonService.isWifiConnected(); const wifiConnected = await this.electronService.isWifiConnected();
if (!wifiConnected) { if (!wifiConnected) {
console.log("Enabling sync ..."); console.log("Enabling sync ...");

View file

@ -144,29 +144,6 @@ export class DaemonService {
}); });
} }
public async isWifiConnected(): Promise<boolean> {
try {
return new Promise<boolean>((resolve, reject) => {
try {
window.electronAPI.onIsWifiConnectedResponse((event: any, connected: boolean) => {
console.debug(event);
resolve(connected);
});
window.electronAPI.isWifiConnected();
}
catch(error: any) {
reject(error);
}
});
}
catch(error: any) {
console.error(error);
}
return false;
}
public async disableSync(): Promise<void> { public async disableSync(): Promise<void> {
this.disablingSync = true; this.disablingSync = true;
@ -410,7 +387,7 @@ export class DaemonService {
this.settings = customSettings ? customSettings : await this.getSettings(); this.settings = customSettings ? customSettings : await this.getSettings();
if (!this.settings.noSync && !this.settings.syncOnWifi && await this.isWifiConnected()) { if (!this.settings.noSync && !this.settings.syncOnWifi && await this.electronService.isWifiConnected()) {
console.log("Disabling sync ..."); console.log("Disabling sync ...");
this.settings.noSync = true; this.settings.noSync = true;
@ -780,15 +757,22 @@ export class DaemonService {
throw new Error("Daemon not configured"); throw new Error("Daemon not configured");
} }
return new Promise<DaemonVersion>((resolve, reject) => { const promise = new Promise<DaemonVersion>((resolve, reject) => {
window.electronAPI.onMoneroVersion((event: any, version: string) => { window.electronAPI.onMoneroVersion((event: any, version: string) => {
window.electronAPI.unregisterOnMoneroVersion();
window.electronAPI.unregisterOnMoneroVersionError();
resolve(DaemonVersion.parse(version)); resolve(DaemonVersion.parse(version));
}) })
window.electronAPI.onMoneroVersionError((event: any, error: string) => { window.electronAPI.onMoneroVersionError((event: any, error: string) => {
window.electronAPI.unregisterOnMoneroVersion();
window.electronAPI.unregisterOnMoneroVersionError();
reject(error); reject(error);
}); });
window.electronAPI.getMoneroVersion(monerodPath);
}); });
window.electronAPI.getMoneroVersion(monerodPath);
return await promise;
} }
throw new Error("Daemon not running"); throw new Error("Daemon not running");
@ -1011,7 +995,7 @@ export class DaemonService {
body: 'Successfully stopped monero daemon' body: 'Successfully stopped monero daemon'
}); });
} }
return; return;
} }
await this.delay(5000); await this.delay(5000);
@ -1021,6 +1005,7 @@ export class DaemonService {
title: 'Error', title: 'Error',
body: 'Could not stop daemon' body: 'Could not stop daemon'
}); });
throw new Error('Could not stop daemon'); throw new Error('Could not stop daemon');
} }
@ -1196,10 +1181,14 @@ export class DaemonService {
const getProcessStatsPromise = new Promise<ProcessStats>((resolve, reject) => { const getProcessStatsPromise = new Promise<ProcessStats>((resolve, reject) => {
window.electronAPI.onMonitorMonerodError((event: any, error: string) => { window.electronAPI.onMonitorMonerodError((event: any, error: string) => {
window.electronAPI.unregisterOnMonitorMonerod();
window.electronAPI.unregisterOnMonitorMonerodError();
reject(error); reject(error);
}); });
window.electronAPI.onMonitorMonerod((event: any, stats: ProcessStats) => { window.electronAPI.onMonitorMonerod((event: any, stats: ProcessStats) => {
window.electronAPI.unregisterOnMonitorMonerod();
window.electronAPI.unregisterOnMonitorMonerodError();
resolve(stats); resolve(stats);
}); });
}) })

View file

@ -1,5 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
// If you import a module but never use any of the imported values other than as TypeScript types, // If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all. // the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, webFrame } from 'electron'; import { ipcRenderer, webFrame } from 'electron';
@ -15,6 +14,9 @@ export class ElectronService {
childProcess!: typeof childProcess; childProcess!: typeof childProcess;
fs!: typeof fs; fs!: typeof fs;
private _isAppImage?: boolean;
private _isAutoLaunched?: boolean;
constructor() { constructor() {
// Conditional imports // Conditional imports
if (this.isElectron) { if (this.isElectron) {
@ -54,6 +56,55 @@ export class ElectronService {
return !!(window && window.process && window.process.type); return !!(window && window.process && window.process.type);
} }
public async isWifiConnected(): Promise<boolean> {
try {
const promise = new Promise<boolean>((resolve, reject) => {
try {
window.electronAPI.onIsWifiConnectedResponse((event: any, connected: boolean) => {
console.debug(event);
window.electronAPI.unregisterOnIsWifiConnectedResponse();
resolve(connected);
});
}
catch(error: any) {
reject(error);
}
});
window.electronAPI.isWifiConnected();
return await promise;
}
catch(error: any) {
console.error(error);
}
return false;
}
public async isAutoLaunched(): Promise<boolean> {
if (this._isAutoLaunched === undefined) {
try {
const promise = new Promise<boolean>((resolve) => {
window.electronAPI.onIsAutoLaunched((event: any, isAutoLaunched: boolean) => {
console.debug(event);
window.electronAPI.unregisterOnIsAutoLaunched();
resolve(isAutoLaunched);
});
});
window.electronAPI.isAutoLaunched();
this._isAutoLaunched = await promise;
} catch(error: any) {
console.error(error);
this._isAutoLaunched = false;
}
}
return this._isAutoLaunched;
}
public async isAutoLaunchEnabled(): Promise<boolean> { public async isAutoLaunchEnabled(): Promise<boolean> {
if (await this.isAppImage()) { if (await this.isAppImage()) {
return false; return false;
@ -61,6 +112,7 @@ export class ElectronService {
const promise = new Promise<boolean>((resolve) => { const promise = new Promise<boolean>((resolve) => {
window.electronAPI.onIsAutoLaunchEnabled((event: any, enabled: boolean) => { window.electronAPI.onIsAutoLaunchEnabled((event: any, enabled: boolean) => {
window.electronAPI.unregisterOnIsAutoLaunchEnabled();
resolve(enabled); resolve(enabled);
}); });
}); });
@ -84,11 +136,15 @@ export class ElectronService {
const promise = new Promise<void>((resolve, reject) => { const promise = new Promise<void>((resolve, reject) => {
window.electronAPI.onEnableAutoLaunchError((event: any, error: string) => { window.electronAPI.onEnableAutoLaunchError((event: any, error: string) => {
console.debug(event); console.debug(event);
window.electronAPI.unregisterOnEnableAutoLaunchError();
window.electronAPI.unregisterOnEnableAutoLaunchSuccess();
reject(error); reject(error);
}); });
window.electronAPI.onEnableAutoLaunchSuccess((event: any) => { window.electronAPI.onEnableAutoLaunchSuccess((event: any) => {
console.debug(event); console.debug(event);
window.electronAPI.unregisterOnEnableAutoLaunchError();
window.electronAPI.unregisterOnEnableAutoLaunchSuccess();
resolve(); resolve();
}); });
}); });
@ -113,11 +169,15 @@ export class ElectronService {
const promise = new Promise<void>((resolve, reject) => { const promise = new Promise<void>((resolve, reject) => {
window.electronAPI.onDisableAutoLaunchError((event: any, error: string) => { window.electronAPI.onDisableAutoLaunchError((event: any, error: string) => {
console.debug(event); console.debug(event);
window.electronAPI.unregisterOnDisableAutoLaunchError();
window.electronAPI.unregisterOnDisableAutoLaunchSuccess();
reject(error); reject(error);
}); });
window.electronAPI.onDisableAutoLaunchSuccess((event: any) => { window.electronAPI.onDisableAutoLaunchSuccess((event: any) => {
console.debug(event); console.debug(event);
window.electronAPI.unregisterOnDisableAutoLaunchError();
window.electronAPI.unregisterOnDisableAutoLaunchSuccess();
resolve(); resolve();
}); });
}); });
@ -128,15 +188,20 @@ export class ElectronService {
} }
public async isAppImage(): Promise<boolean> { public async isAppImage(): Promise<boolean> {
const promise = new Promise<boolean>((resolve) => { if (this._isAppImage === undefined) {
window.electronAPI.onIsAppImage((event: any, value: boolean) => { const promise = new Promise<boolean>((resolve) => {
resolve(value); window.electronAPI.onIsAppImage((event: any, value: boolean) => {
window.electronAPI.unregisterOnIsAppImage();
resolve(value);
});
}); });
});
window.electronAPI.isAppImage();
this._isAppImage = await promise;
}
window.electronAPI.isAppImage(); return this._isAppImage;
return await promise;
} }
} }

View file

@ -75,7 +75,7 @@ export class MoneroInstallerService {
} }
private async getMoneroDownloadLink(): Promise<string> { private async getMoneroDownloadLink(): Promise<string> {
return new Promise<string>((resolve, reject) => { const promise = new Promise<string>((resolve, reject) => {
window.electronAPI.gotOsType((event: any, osType: { platform: string, arch: string }) => { window.electronAPI.gotOsType((event: any, osType: { platform: string, arch: string }) => {
const platform = osType.platform; const platform = osType.platform;
const arch = osType.arch; const arch = osType.arch;
@ -104,6 +104,9 @@ export class MoneroInstallerService {
resource = this.resources.linuxriscv64; resource = this.resources.linuxriscv64;
} }
} }
window.electronAPI.unregisterGotOsType();
if (resource != '') if (resource != '')
{ {
resolve(resource); resolve(resource);
@ -111,11 +114,10 @@ export class MoneroInstallerService {
reject('Unsopported platform ' + platform); reject('Unsopported platform ' + platform);
}); });
window.electronAPI.getOsType();
}); });
window.electronAPI.getOsType();
return await promise;
} }
} }

View file

@ -37,7 +37,7 @@
<li class="list-group-item"><strong>Minor Version:</strong> {{ lastBlockHeader.minorVersion }}</li> <li class="list-group-item"><strong>Minor Version:</strong> {{ lastBlockHeader.minorVersion }}</li>
<li class="list-group-item"><strong>Nonce:</strong> {{ lastBlockHeader.nonce }}</li> <li class="list-group-item"><strong>Nonce:</strong> {{ lastBlockHeader.nonce }}</li>
<li class="list-group-item"><strong>Number of Transactions:</strong> {{ lastBlockHeader.numTxes }}</li> <li class="list-group-item"><strong>Number of Transactions:</strong> {{ lastBlockHeader.numTxes }}</li>
<li class="list-group-item"><strong>Reward:</strong> {{ lastBlockHeader.reward }} XMR</li> <li class="list-group-item"><strong>Reward:</strong> {{ lastBlockHeader.rewardXMR }} XMR</li>
<li class="list-group-item"><strong>Timestamp:</strong> {{ lastBlockHeader.timestamp | date:'medium' }}</li> <li class="list-group-item"><strong>Timestamp:</strong> {{ lastBlockHeader.timestamp | date:'medium' }}</li>
</ul> </ul>
</div> </div>
@ -280,7 +280,7 @@
<li class="list-group-item"><strong>Minor Version:</strong> {{ blockHeader.minorVersion }}</li> <li class="list-group-item"><strong>Minor Version:</strong> {{ blockHeader.minorVersion }}</li>
<li class="list-group-item"><strong>Nonce:</strong> {{ blockHeader.nonce }}</li> <li class="list-group-item"><strong>Nonce:</strong> {{ blockHeader.nonce }}</li>
<li class="list-group-item"><strong>Number of Transactions:</strong> {{ blockHeader.numTxes }}</li> <li class="list-group-item"><strong>Number of Transactions:</strong> {{ blockHeader.numTxes }}</li>
<li class="list-group-item"><strong>Reward:</strong> {{ blockHeader.reward }} XMR</li> <li class="list-group-item"><strong>Reward:</strong> {{ blockHeader.rewardXMR }} XMR</li>
<li class="list-group-item"><strong>Timestamp:</strong> {{ blockHeader.timestamp | date:'medium' }}</li> <li class="list-group-item"><strong>Timestamp:</strong> {{ blockHeader.timestamp | date:'medium' }}</li>
</ul> </ul>
</div> </div>

View file

@ -241,7 +241,7 @@ export class MiningComponent extends BasePageComponent implements AfterViewInit
new SimpleBootstrapCard('Seed hash', `${this.seedHash}`), new SimpleBootstrapCard('Seed hash', `${this.seedHash}`),
new SimpleBootstrapCard('Network difficulty', `${this.difficulty}`), new SimpleBootstrapCard('Network difficulty', `${this.difficulty}`),
new SimpleBootstrapCard('Median block weight', `${this.medianWeight}`), new SimpleBootstrapCard('Median block weight', `${this.medianWeight}`),
new SimpleBootstrapCard('Generated Coins', `${this.alreadyGeneratedCoins}`) new SimpleBootstrapCard('Generated Coins', `${this.alreadyGeneratedCoins / 1e12} XMR`)
]; ];
} }

View file

@ -247,9 +247,9 @@ export class TransactionsComponent extends BasePageComponent implements AfterVie
const coinbaseTxSum = await this.daemonService.getCoinbaseTxSum(this.coinbaseTxSumHeight, this.coinbaseTxSumCount); const coinbaseTxSum = await this.daemonService.getCoinbaseTxSum(this.coinbaseTxSumHeight, this.coinbaseTxSumCount);
this.cards = [ this.cards = [
new SimpleBootstrapCard('Emission Amount', `${coinbaseTxSum.emissionAmount}`), new SimpleBootstrapCard('Emission Amount', `${coinbaseTxSum.emissionAmount / 1e12} XMR`),
new SimpleBootstrapCard('Emission Amount Top 64', `${coinbaseTxSum.emissionAmountTop64}`), new SimpleBootstrapCard('Emission Amount Top 64', `${coinbaseTxSum.emissionAmountTop64}`),
new SimpleBootstrapCard('Fee Amount', `${coinbaseTxSum.feeAmount}`), new SimpleBootstrapCard('Fee Amount', `${coinbaseTxSum.feeAmount / 1e12} XMR`),
new SimpleBootstrapCard('Fee Amount Top 64', `${coinbaseTxSum.feeAmountTop64}`), new SimpleBootstrapCard('Fee Amount Top 64', `${coinbaseTxSum.feeAmountTop64}`),
new SimpleBootstrapCard('Wide Emission Amount', coinbaseTxSum.wideEmissionAmount), new SimpleBootstrapCard('Wide Emission Amount', coinbaseTxSum.wideEmissionAmount),
new SimpleBootstrapCard('Wide Fee Amount', coinbaseTxSum.wideFeeAmount) new SimpleBootstrapCard('Wide Fee Amount', coinbaseTxSum.wideFeeAmount)

View file

@ -49,6 +49,10 @@ export class BlockHeader {
public readonly wideCumulativeDifficulty: string; public readonly wideCumulativeDifficulty: string;
public readonly wideDifficulty: string; public readonly wideDifficulty: string;
public get rewardXMR(): number {
return this.reward / 1e12;
}
constructor(blockSize: number, blockWeight: number, cumulativeDifficulty: number, cumulativeDifficultyTop64: number, depth: number, difficulty: number, difficultyTop64: number, hash: string, height: number, longTermWeight: number, majorVersion: number constructor(blockSize: number, blockWeight: number, cumulativeDifficulty: number, cumulativeDifficultyTop64: number, depth: number, difficulty: number, difficultyTop64: number, hash: string, height: number, longTermWeight: number, majorVersion: number
, minerTxHash: string, minorVersion: number, nonce: number, numTxes: number, orphanStatus: boolean, powHash: string, prevHash: string, reward: number, timestamp: number, wideCumulativeDifficulty: string, wideDifficulty: string , minerTxHash: string, minorVersion: number, nonce: number, numTxes: number, orphanStatus: boolean, powHash: string, prevHash: string, reward: number, timestamp: number, wideCumulativeDifficulty: string, wideDifficulty: string
) { ) {

View file

@ -60,6 +60,7 @@ declare global {
interface Window { interface Window {
electronAPI: { electronAPI: {
startMonerod: (options: string[]) => void; startMonerod: (options: string[]) => void;
monitorMonerod: () => void; monitorMonerod: () => void;
onMonitorMonerod: (callback: (event: any, stats: { onMonitorMonerod: (callback: (event: any, stats: {
cpu: number; cpu: number;
@ -72,10 +73,17 @@ declare global {
} }
) => void) => void; ) => void) => void;
onMonitorMonerodError: (callback: (event: any, error: string) => void) => void; onMonitorMonerodError: (callback: (event: any, error: string) => void) => void;
unregisterOnMonitorMonerod: () => void,
unregisterOnMonitorMonerodError: () => void,
onMonerodStarted: (callback: (event: any, started: boolean) => void) => void; onMonerodStarted: (callback: (event: any, started: boolean) => void) => void;
getMoneroVersion: (path: string) => void; getMoneroVersion: (path: string) => void;
onMoneroVersion: (callback: (event: any, version: string) => void) => void; onMoneroVersion: (callback: (event: any, version: string) => void) => void;
onMoneroVersionError: (callback: (event: any, error: string) => void) => void; onMoneroVersionError: (callback: (event: any, error: string) => void) => void;
unregisterOnMoneroVersion: () => void;
unregisterOnMoneroVersionError: () => void;
downloadMonerod: (downloadUrl:string, destination: string) => void; downloadMonerod: (downloadUrl:string, destination: string) => void;
onDownloadProgress: (callback: (event: any, progress: { progress: number, status: string }) => void) => void; onDownloadProgress: (callback: (event: any, progress: { progress: number, status: string }) => void) => void;
checkValidMonerodPath: (path: string) => void; checkValidMonerodPath: (path: string) => void;
@ -83,30 +91,40 @@ declare global {
unsubscribeOnMonerodStarted: () => void; unsubscribeOnMonerodStarted: () => void;
onMoneroClose: (callback: (event: any, code: number) => void) => void; onMoneroClose: (callback: (event: any, code: number) => void) => void;
onMoneroStdout: (callbak: (event: any, out: string) => void) => void; onMoneroStdout: (callbak: (event: any, out: string) => void) => void;
unregisterOnMoneroStdout: () => void;
isWifiConnected: () => void; isWifiConnected: () => void;
onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void; onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void;
unregisterOnIsWifiConnectedResponse: () => void;
selectFolder: () => void; selectFolder: () => void;
selectFile: (extensions?: string[]) => void; selectFile: (extensions?: string[]) => void;
onSelectedFolder: (callback: (event: any, path: string) => void) => void; onSelectedFolder: (callback: (event: any, path: string) => void) => void;
onSelectedFile: (callback: (event: any, path: string) => void) => void; onSelectedFile: (callback: (event: any, path: string) => void) => void;
getOsType: () => void; getOsType: () => void;
gotOsType: (callback: (event: any, osType: { platform: string, arch: string }) => void) => void; gotOsType: (callback: (event: any, osType: { platform: string, arch: string }) => void) => void;
unregisterGotOsType: () => void;
showNotification: (options: NotificationConstructorOptions) => void; showNotification: (options: NotificationConstructorOptions) => void;
quit: () => void; quit: () => void;
isAppImage: () => void; isAppImage: () => void;
onIsAppImage: (callback: (event: any, value: boolean) => void) => void; onIsAppImage: (callback: (event: any, value: boolean) => void) => void;
unregisterOnIsAppImage: () => void;
isAutoLaunchEnabled: () => void; isAutoLaunchEnabled: () => void;
onIsAutoLaunchEnabled: (callback: (event: any, enabled: boolean) => void) => void; onIsAutoLaunchEnabled: (callback: (event: any, enabled: boolean) => void) => void;
unregisterOnIsAutoLaunchEnabled: () => void;
enableAutoLaunch: (minimized: boolean) => void; enableAutoLaunch: (minimized: boolean) => void;
onEnableAutoLaunchError: (callback: (event: any, error: string) => void) => void; onEnableAutoLaunchError: (callback: (event: any, error: string) => void) => void;
onEnableAutoLaunchSuccess: (callback: (event: any) => void) => void; onEnableAutoLaunchSuccess: (callback: (event: any) => void) => void;
unregisterOnEnableAutoLaunchError: () => void,
unregisterOnEnableAutoLaunchSuccess: () => void,
disableAutoLaunch: () => void; disableAutoLaunch: () => void;
onDisableAutoLaunchError: (callback: (event: any, error: string) => void) => void; onDisableAutoLaunchError: (callback: (event: any, error: string) => void) => void;
onDisableAutoLaunchSuccess: (callback: (event: any) => void) => void; onDisableAutoLaunchSuccess: (callback: (event: any) => void) => void;
unregisterOnDisableAutoLaunchError: () => void,
unregisterOnDisableAutoLaunchSuccess: () => void,
isAutoLaunched: () => void; isAutoLaunched: () => void;
onIsAutoLaunched: (callback: (event: any, isAutoLaunched: boolean) => void) => void; onIsAutoLaunched: (callback: (event: any, isAutoLaunched: boolean) => void) => void;