From d013676f9f1d4c2fd567c6b3872fcebec19dbc31 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Fri, 24 Oct 2025 01:27:00 +0200 Subject: [PATCH] ci: docker_tag=dev-test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations :** - Étendre la plage de scan pour capturer les transactions faucet (100 blocs au lieu de 10) - Ajouter des logs de débogage détaillés pour comprendre pourquoi le SDK ne détecte pas les tokens **Modifications :** - src/services/service.ts: Augmentation de la plage de scan de 10 à 100 blocs pour les nouveaux wallets, ajout de logs de débogage dans getAmount() **Pages affectées :** - Service de gestion des tokens faucet avec scan étendu - Logs de débogage pour diagnostic des problèmes de détection --- src/services/service.ts | 54 +++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/src/services/service.ts b/src/services/service.ts index 5737827..ea1d907 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -832,13 +832,13 @@ export default class Services { current_block: this.currentBlockHeight }); - // For faucet tokens, we need to scan from birthday to current block - // even if birthday equals current block (new wallet case) - if (device.sp_wallet.birthday <= this.currentBlockHeight) { - // For new wallets, scan from a few blocks earlier to catch faucet transactions - const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight - ? Math.max(0, this.currentBlockHeight - 10) // Scan from 10 blocks earlier for new wallets - : device.sp_wallet.birthday; + // For faucet tokens, we need to scan from birthday to current block + // even if birthday equals current block (new wallet case) + if (device.sp_wallet.birthday <= this.currentBlockHeight) { + // For new wallets, scan from much earlier to catch faucet transactions + const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight + ? Math.max(0, this.currentBlockHeight - 100) // Scan from 100 blocks earlier for new wallets + : device.sp_wallet.birthday; console.log(`🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...`); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); @@ -1258,12 +1258,12 @@ export default class Services { }); // Force scan from birthday to current block height - // For faucet tokens, we need to scan even if birthday equals current block - if (device.sp_wallet.birthday <= this.currentBlockHeight) { - // For new wallets, scan from a few blocks earlier to catch faucet transactions - const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight - ? Math.max(0, this.currentBlockHeight - 10) // Scan from 10 blocks earlier for new wallets - : device.sp_wallet.birthday; + // For faucet tokens, we need to scan even if birthday equals current block + if (device.sp_wallet.birthday <= this.currentBlockHeight) { + // For new wallets, scan from much earlier to catch faucet transactions + const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight + ? Math.max(0, this.currentBlockHeight - 100) // Scan from 100 blocks earlier for new wallets + : device.sp_wallet.birthday; console.log(`🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...`); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); @@ -1699,6 +1699,23 @@ export default class Services { try { const amount = this.sdkClient.get_available_amount(); console.log(`💰 SDK get_available_amount() returned: ${amount}`); + + // Additional debugging: check wallet state + try { + const device = this.dumpDeviceFromMemory(); + if (device && device.sp_wallet) { + console.log(`🔍 Wallet debugging info:`, { + birthday: device.sp_wallet.birthday, + last_scan: device.sp_wallet.last_scan, + current_block: this.currentBlockHeight, + has_spend_key: !!device.sp_wallet.spend_key, + has_scan_key: !!device.sp_wallet.scan_key + }); + } + } catch (error) { + console.warn('⚠️ Error getting wallet debugging info:', error); + } + return amount; } catch (error) { console.error('❌ Error calling get_available_amount():', error); @@ -1940,11 +1957,12 @@ export default class Services { throw new Error('Birthday not found'); } - if (birthday === 0) { - // This is a new device, set birthday to a few blocks earlier to allow scanning for faucet transactions - device.sp_wallet.birthday = Math.max(0, this.currentBlockHeight - 10); - // We also set last_scan to the same value initially - device.sp_wallet.last_scan = device.sp_wallet.birthday; + if (birthday === 0) { + // This is a new device, set birthday to scan from much earlier to catch faucet transactions + // Scan from 100 blocks earlier to ensure we catch all faucet transactions + device.sp_wallet.birthday = Math.max(0, this.currentBlockHeight - 100); + // We also set last_scan to the same value initially + device.sp_wallet.last_scan = device.sp_wallet.birthday; try { // First set the updated device in memory this.sdkClient.restore_device(device);