mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
notification messages, dev fee
This commit is contained in:
@@ -58,11 +58,12 @@ export class BitcoinRpcService {
|
||||
}
|
||||
|
||||
public async SUBMIT_BLOCK(hexdata: string): Promise<string> {
|
||||
let response: string = '';
|
||||
let response: string = 'unknown';
|
||||
try {
|
||||
response = await this.client.submitblock({
|
||||
await this.client.submitblock({
|
||||
hexdata
|
||||
});
|
||||
response = 'SUCCESS!';
|
||||
console.log(`BLOCK SUBMISSION RESPONSE: ${response}`);
|
||||
console.log(hexdata);
|
||||
console.log(JSON.stringify(response));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Block } from 'bitcoinjs-lib';
|
||||
import { Client, Collection, Events, GatewayIntentBits, REST, Routes, SlashCommandBuilder, TextChannel } from 'discord.js';
|
||||
|
||||
interface IDiscordCommand {
|
||||
@@ -102,13 +103,13 @@ export class DiscordService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
|
||||
public async notifySUbscribersBlockFound(message: string) {
|
||||
public async notifySubscribersBlockFound(height: number, block: Block, message: string) {
|
||||
if (this.bot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const guild = await this.bot.guilds.fetch(this.guildId);
|
||||
const channel = await guild.channels.fetch(this.channelId) as TextChannel;
|
||||
channel.send(`Block Found! result ${message}`)
|
||||
channel.send(`Block Found! Result: ${message}, Height: ${height}`)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { Block } from 'bitcoinjs-lib';
|
||||
|
||||
import { DiscordService } from './discord.service';
|
||||
import { TelegramService } from './telegram.service';
|
||||
@@ -16,8 +17,8 @@ export class NotificationService implements OnModuleInit {
|
||||
|
||||
}
|
||||
|
||||
public async notifySubscribersBlockFound(address: string, message: string) {
|
||||
await this.discordService.notifySUbscribersBlockFound(message);
|
||||
await this.telegramService.notifySubscribersBlockFound(address, message);
|
||||
public async notifySubscribersBlockFound(address: string, height: number, block: Block, message: string) {
|
||||
await this.discordService.notifySubscribersBlockFound(height, block, message);
|
||||
await this.telegramService.notifySubscribersBlockFound(address, height, block, message);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { validate } from 'bitcoin-address-validation';
|
||||
import { Block } from 'bitcoinjs-lib';
|
||||
import * as TelegramBot from 'node-telegram-bot-api';
|
||||
import { TelegramSubscriptionsService } from 'src/ORM/telegram-subscriptions/telegram-subscriptions.service';
|
||||
|
||||
@@ -48,14 +49,14 @@ export class TelegramService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
public async notifySubscribersBlockFound(address: string, message: string) {
|
||||
public async notifySubscribersBlockFound(address: string, height: number, block: Block, message: string) {
|
||||
if (this.bot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const subscribers = await this.telegramSubscriptionsService.getSubscriptions(address);
|
||||
subscribers.forEach(subscriber => {
|
||||
this.bot.sendMessage(subscriber.telegramChatId, `You found a block! ${message}`);
|
||||
this.bot.sendMessage(subscriber.telegramChatId, `Block Found! Result: ${message}, Height: ${height}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user