@@ -41,7 +41,7 @@ import { ElectrsService, ELECTRS_URLS_BY_NETWORK } from "./electrs";
4141import { fetchNbtcAddresses , fetchPackageConfigs , type Storage } from "./storage" ;
4242import { CFStorage } from "./cf-storage" ;
4343import type { PutNbtcTxResponse } from "./rpc-interface" ;
44- import { extractSenderAddress } from "./btc-address-utils" ;
44+ import { extractAllSenderAddress } from "./btc-address-utils" ;
4545import type { ComplianceRpc } from "@gonative-cc/lib/rpc-types" ;
4646
4747interface ConfirmingTxCandidate < T > {
@@ -709,16 +709,37 @@ export class Indexer {
709709 const client = this . getSuiClient ( config . sui_network ) ;
710710 const pkgKey = config . nbtc_pkg ;
711711
712- // Filter out sanctioned addresses before minting
712+ // Extract all sender addresses at once
713+ const senderAddressMap : Map < number , string | null > = await extractAllSenderAddress (
714+ mintArgs ,
715+ config . btc_network ,
716+ ) ;
717+
718+ // Check all addresses for blocking at once
719+ const uniqueAddresses = [
720+ ...new Set (
721+ Array . from ( senderAddressMap . values ( ) ) . filter ( ( a ) : a is string => a !== null ) ,
722+ ) ,
723+ ] ;
724+ const blockedAddressSet = new Set < string > ( ) ;
725+ await Promise . all (
726+ uniqueAddresses . map ( async ( addr ) => {
727+ if ( await this . compliance . isBtcBlocked ( addr ) ) {
728+ blockedAddressSet . add ( addr ) ;
729+ }
730+ } ) ,
731+ ) ;
732+
733+ // Filter out sanctioned addresses
713734 const filteredMintArgs : MintBatchArg [ ] = [ ] ;
714735 const filteredProcessedKeys : ProcessedKey [ ] = [ ] ;
715736
716737 for ( let i = 0 ; i < mintArgs . length ; i ++ ) {
717738 const args = mintArgs [ i ] ;
718739 if ( ! args ) continue ;
719740
720- const senderAddress = await extractSenderAddress ( args . tx , config . btc_network ) ;
721- if ( senderAddress && ( await this . compliance . isBtcBlocked ( senderAddress ) ) ) {
741+ const senderAddress = senderAddressMap . get ( i ) ;
742+ if ( senderAddress && blockedAddressSet . has ( senderAddress ) ) {
722743 logger . error ( {
723744 msg : "Sanctioned address detected, skipping mint" ,
724745 txId : args . tx . getId ( ) ,
0 commit comments