Skip to content

Commit

Permalink
Fix daemon url
Browse files Browse the repository at this point in the history
  • Loading branch information
everoddandeven committed Oct 15, 2024
1 parent 5e46d68 commit 42739d9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
59 changes: 33 additions & 26 deletions src/app/core/services/daemon/daemon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,25 @@ export class DaemonService {
private openDbPromise: Promise<IDBPDatabase>;

private daemonRunning?: boolean;
private url: string = "http://127.0.0.1:28081";
private get url(): string {
return `http://127.0.0.1:${this.port}`;
}
public settings: DaemonSettings;

private get port(): number {
if (this.settings.rpcBindPort > 0) {
return this.settings.rpcBindPort;
}
else if (this.settings.mainnet) {
return 18081;
}
else if (this.settings.testnet) {
return 28081;
}

return 38081;
}

//private url: string = "http://node2.monerodevs.org:28089";
//private url: string = "https://testnet.xmr.ditatompel.com";
//private url: string = "https://xmr.yemekyedim.com:18081";
Expand All @@ -119,22 +135,11 @@ export class DaemonService {
this.openDbPromise = this.openDatabase();
this.settings = new DaemonSettings();

const wdw = (window as any);

if (this.electronService.isElectron) {
this.electronService.ipcRenderer.on('monero-close', (event, code: number | null) => {
console.log(event);
console.log(code);
this.onClose();
});
}
else if (wdw.electronAPI && wdw.electronAPI.onMoneroClose) {
wdw.electronAPI.onMoneroClose((event: any, code: number) => {
console.log(event);
console.log(code);
this.onClose();
});
}
window.electronAPI.onMoneroClose((event: any, code: number) => {
console.log(event);
console.log(code);
this.onClose();
});
}

public async isWifiConnected(): Promise<boolean> {
Expand Down Expand Up @@ -365,18 +370,20 @@ export class DaemonService {

if (started) {
console.log("Daemon started");
this.isRunning(true).then((running: boolean) => {
this.onDaemonStatusChanged.emit(running);
this.starting = false;
resolve();
this.delay(3000).then(() => {
this.isRunning(true).then((running: boolean) => {
this.onDaemonStatusChanged.emit(running);
this.starting = false;
resolve();
}).catch((error: any) => {
console.error(error);
this.onDaemonStatusChanged.emit(false);
this.starting = false;
reject(error);
});
}).catch((error: any) => {
console.error(error);
this.onDaemonStatusChanged.emit(false);
this.starting = false;
reject(error);
});


}
else {
console.log("Daemon not started");
Expand Down
1 change: 1 addition & 0 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ declare global {
electronAPI: {
startMonerod: (options: string[]) => void;
onMonerodStarted: (callback: (event: any, started: boolean) => void) => void;
onMoneroClose: (callback: (event: any, code: number) => void) => void;
isWifiConnected: () => void;
onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void;
getOsType: () => void;
Expand Down

0 comments on commit 42739d9

Please sign in to comment.