fix(blockchain-service): 过滤热钱包发出的转账避免内部转账重复入账

内部转账时,wallet-service 已经处理了接收方入账,
需要过滤掉 blockchain-service 扫描到的热钱包转出交易,
避免将其当作充值重复处理导致双倍入账

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-22 23:56:53 -08:00
parent f91aeb7d92
commit 2ce0177b59
1 changed files with 9 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import { EventPublisherService } from '@/infrastructure/kafka/event-publisher.se
import { AddressCacheService } from '@/infrastructure/redis/address-cache.service';
import { ConfirmationPolicyService } from '@/domain/services/confirmation-policy.service';
import { ChainConfigService } from '@/domain/services/chain-config.service';
import { Erc20TransferService } from '@/domain/services/erc20-transfer.service';
import {
DEPOSIT_TRANSACTION_REPOSITORY,
IDepositTransactionRepository,
@ -44,6 +45,7 @@ export class DepositDetectionService implements OnModuleInit {
private readonly addressCache: AddressCacheService,
private readonly confirmationPolicy: ConfirmationPolicyService,
private readonly chainConfig: ChainConfigService,
private readonly transferService: Erc20TransferService,
@Inject(DEPOSIT_TRANSACTION_REPOSITORY)
private readonly depositRepo: IDepositTransactionRepository,
@Inject(MONITORED_ADDRESS_REPOSITORY)
@ -141,6 +143,13 @@ export class DepositDetectionService implements OnModuleInit {
const chainType = ChainType.fromEnum(event.chainType);
// 过滤从热钱包发出的转账(内部转账/提现),避免重复入账
const hotWalletAddress = this.transferService.getHotWalletAddress(event.chainType);
if (hotWalletAddress && event.from.toLowerCase() === hotWalletAddress.toLowerCase()) {
this.logger.debug(`Skipping hot wallet outgoing transfer: ${event.txHash} from ${event.from}`);
return;
}
// 查找监控地址以获取用户ID或系统账户信息
const monitoredAddress = await this.monitoredAddressRepo.findByChainAndAddress(
chainType,