Slave/btc integration #4
@@ -1,6 +1,6 @@
|
||||
import { ServiceUnavailableException } from '@nestjs/common';
|
||||
import type { ConfigService } from '@nestjs/config';
|
||||
import { BitcoinWalletSyncStatus } from '../types/BitcoinWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus';
|
||||
import type { ElectrumWalletRpcClient } from './ElectrumWalletRpcClient';
|
||||
import { BitcoinWalletAdminService } from './BitcoinWalletAdminService';
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('BitcoinWalletAdminService', () => {
|
||||
rpcVersion: '4.8.1',
|
||||
blockHeight: 900_000,
|
||||
serverHeight: 900_000,
|
||||
syncStatus: BitcoinWalletSyncStatus.Synced,
|
||||
syncStatus: WalletSyncStatus.Synced,
|
||||
balanceBtc: '0.00150000',
|
||||
confirmedBalanceBtc: '0.00150000'
|
||||
})
|
||||
@@ -63,7 +63,7 @@ describe('BitcoinWalletAdminService', () => {
|
||||
|
||||
const status = await service.getStatus();
|
||||
|
||||
expect(status.syncStatus).toBe(BitcoinWalletSyncStatus.Syncing);
|
||||
expect(status.syncStatus).toBe(WalletSyncStatus.Syncing);
|
||||
});
|
||||
|
||||
it('throws when RPC calls fail', async () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable, ServiceUnavailableException } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { convertBtcAtomicToBtc } from '../../../utils/bitcoin/convertBtcAtomicToBtc';
|
||||
import type { Config } from '../../../types/Config';
|
||||
import { BitcoinWalletSyncStatus } from '../types/BitcoinWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus';
|
||||
import type { BitcoinWalletStatusView } from '../types/BitcoinWalletStatusView';
|
||||
import { ElectrumWalletRpcClient } from './ElectrumWalletRpcClient';
|
||||
|
||||
@@ -47,15 +47,15 @@ export class BitcoinWalletAdminService {
|
||||
isSynchronized: boolean,
|
||||
blockHeight: number | null,
|
||||
serverHeight: number | null
|
||||
): BitcoinWalletSyncStatus {
|
||||
): WalletSyncStatus {
|
||||
if (isSynchronized) {
|
||||
return BitcoinWalletSyncStatus.Synced;
|
||||
return WalletSyncStatus.Synced;
|
||||
}
|
||||
|
||||
if (blockHeight === null || serverHeight === null) {
|
||||
return BitcoinWalletSyncStatus.Unknown;
|
||||
return WalletSyncStatus.Unknown;
|
||||
}
|
||||
|
||||
return BitcoinWalletSyncStatus.Syncing;
|
||||
return WalletSyncStatus.Syncing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ElectrumNetwork } from '../../../types/ElectrumNetwork';
|
||||
import { BitcoinWalletSyncStatus } from './BitcoinWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus';
|
||||
|
||||
export interface BitcoinWalletStatusView {
|
||||
network: ElectrumNetwork;
|
||||
rpcVersion: string;
|
||||
blockHeight: number | null;
|
||||
serverHeight: number | null;
|
||||
syncStatus: BitcoinWalletSyncStatus;
|
||||
syncStatus: WalletSyncStatus;
|
||||
balanceBtc: string;
|
||||
confirmedBalanceBtc: string;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export enum BitcoinWalletSyncStatus {
|
||||
Synced = 'synced',
|
||||
Syncing = 'syncing',
|
||||
Unknown = 'unknown'
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { BadRequestException, ServiceUnavailableException } from '@nestjs/common
|
||||
import type { ConfigService } from '@nestjs/config';
|
||||
import axios from 'axios';
|
||||
import type { AuthService } from '../../auth/services/AuthService';
|
||||
import { MoneroWalletSyncStatus } from '../types/MoneroWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus';
|
||||
import type { MoneroWalletRpcClient } from './MoneroWalletRpcClient';
|
||||
import { MoneroWalletAdminService } from './MoneroWalletAdminService';
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('MoneroWalletAdminService', () => {
|
||||
rpcVersion: '0.18.3.1',
|
||||
walletHeight: 3_000_000,
|
||||
daemonHeight: 3_000_000,
|
||||
syncStatus: MoneroWalletSyncStatus.Synced,
|
||||
syncStatus: WalletSyncStatus.Synced,
|
||||
balanceXmr: '2.00000000',
|
||||
unlockedBalanceXmr: '1.00000000'
|
||||
})
|
||||
@@ -137,7 +137,7 @@ describe('MoneroWalletAdminService', () => {
|
||||
|
||||
const status = await service.getStatus();
|
||||
|
||||
expect(status.syncStatus).toBe(MoneroWalletSyncStatus.Unknown);
|
||||
expect(status.syncStatus).toBe(WalletSyncStatus.Unknown);
|
||||
expect(status.daemonHeight).toBeNull();
|
||||
});
|
||||
|
||||
@@ -149,7 +149,7 @@ describe('MoneroWalletAdminService', () => {
|
||||
|
||||
const status = await service.getStatus();
|
||||
|
||||
expect(status.syncStatus).toBe(MoneroWalletSyncStatus.Synced);
|
||||
expect(status.syncStatus).toBe(WalletSyncStatus.Synced);
|
||||
});
|
||||
|
||||
it('throws when reveal seed RPC fails', async () => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { Config } from '../../../types/Config';
|
||||
import type { MoneroDaemonGetInfoResult } from '../types/MoneroDaemonGetInfoResult';
|
||||
import type { MoneroWalletRevealSeedResult } from '../types/MoneroWalletRevealSeedResult';
|
||||
import type { MoneroWalletStatusView } from '../types/MoneroWalletStatusView';
|
||||
import { MoneroWalletSyncStatus } from '../types/MoneroWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus';
|
||||
import type { MoneroWalletWithdrawResult } from '../types/MoneroWalletWithdrawResult';
|
||||
import { MoneroWalletRpcClient } from './MoneroWalletRpcClient';
|
||||
|
||||
@@ -72,7 +72,7 @@ export class MoneroWalletAdminService {
|
||||
throw new BadRequestException('No unlocked balance to withdraw.');
|
||||
}
|
||||
|
||||
if (this.resolveSyncStatus(walletHeight, daemonHeight) !== MoneroWalletSyncStatus.Synced) {
|
||||
if (this.resolveSyncStatus(walletHeight, daemonHeight) !== WalletSyncStatus.Synced) {
|
||||
throw new BadRequestException('Wallet is still syncing. Try again after sync completes.');
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ export class MoneroWalletAdminService {
|
||||
}
|
||||
}
|
||||
|
||||
private resolveSyncStatus(walletHeight: number, daemonHeight: number | null): MoneroWalletSyncStatus {
|
||||
private resolveSyncStatus(walletHeight: number, daemonHeight: number | null): WalletSyncStatus {
|
||||
if (daemonHeight === null) {
|
||||
return MoneroWalletSyncStatus.Unknown;
|
||||
return WalletSyncStatus.Unknown;
|
||||
}
|
||||
|
||||
return walletHeight >= daemonHeight - 1 ? MoneroWalletSyncStatus.Synced : MoneroWalletSyncStatus.Syncing;
|
||||
return walletHeight >= daemonHeight - 1 ? WalletSyncStatus.Synced : WalletSyncStatus.Syncing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { MoneroNetwork } from '../../../types/MoneroNetwork';
|
||||
import { MoneroWalletSyncStatus } from './MoneroWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus';
|
||||
|
||||
export interface MoneroWalletStatusView {
|
||||
network: MoneroNetwork;
|
||||
rpcVersion: string;
|
||||
walletHeight: number;
|
||||
daemonHeight: number | null;
|
||||
syncStatus: MoneroWalletSyncStatus;
|
||||
syncStatus: WalletSyncStatus;
|
||||
balanceXmr: string;
|
||||
unlockedBalanceXmr: string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export enum MoneroWalletSyncStatus {
|
||||
export enum WalletSyncStatus {
|
||||
Synced = 'synced',
|
||||
Syncing = 'syncing',
|
||||
Unknown = 'unknown'
|
||||
Reference in New Issue
Block a user