Expose JWT-protected withdraw-all and reveal-seed endpoints with address validation and password verification, matching Monero wallet admin behavior.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|
import { Throttle } from '@nestjs/throttler';
|
|
import { JwtGuard } from '../../../guards/JwtGuard';
|
|
import { throttleProfiles } from '../../../config/throttleProfiles';
|
|
import { BitcoinWalletRevealSeedDto } from '../dto/BitcoinWalletRevealSeedDto';
|
|
import { BitcoinWalletWithdrawDto } from '../dto/BitcoinWalletWithdrawDto';
|
|
import { BitcoinWalletAdminService } from '../services/BitcoinWalletAdminService';
|
|
|
|
@Controller('bitcoin-wallet')
|
|
@UseGuards(JwtGuard)
|
|
export class BitcoinWalletController {
|
|
constructor(private readonly walletAdminService: BitcoinWalletAdminService) {}
|
|
|
|
@Get('/')
|
|
getStatus() {
|
|
return this.walletAdminService.getStatus();
|
|
}
|
|
|
|
@Post('/withdraw')
|
|
@Throttle(throttleProfiles.walletWithdraw)
|
|
withdraw(@Body() { destinationAddress, feeRateSatVbyte, password }: BitcoinWalletWithdrawDto) {
|
|
return this.walletAdminService.withdrawAll(destinationAddress, feeRateSatVbyte, password);
|
|
}
|
|
|
|
@Post('/reveal-seed')
|
|
@Throttle(throttleProfiles.walletRevealSeed)
|
|
revealSeed(@Body() { password }: BitcoinWalletRevealSeedDto) {
|
|
return this.walletAdminService.revealSeed(password);
|
|
}
|
|
}
|