ci: docker_tag=dev-test

**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
This commit is contained in:
NicolasCantu 2025-10-24 01:27:00 +02:00
parent d34848c54e
commit d013676f9f

View File

@ -832,13 +832,13 @@ export default class Services {
current_block: this.currentBlockHeight current_block: this.currentBlockHeight
}); });
// For faucet tokens, we need to scan from birthday to current block // For faucet tokens, we need to scan from birthday to current block
// even if birthday equals current block (new wallet case) // even if birthday equals current block (new wallet case)
if (device.sp_wallet.birthday <= this.currentBlockHeight) { if (device.sp_wallet.birthday <= this.currentBlockHeight) {
// For new wallets, scan from a few blocks earlier to catch faucet transactions // For new wallets, scan from much earlier to catch faucet transactions
const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight
? Math.max(0, this.currentBlockHeight - 10) // Scan from 10 blocks earlier for new wallets ? Math.max(0, this.currentBlockHeight - 100) // Scan from 100 blocks earlier for new wallets
: device.sp_wallet.birthday; : device.sp_wallet.birthday;
console.log(`🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...`); console.log(`🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...`);
await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL);
@ -1258,12 +1258,12 @@ export default class Services {
}); });
// Force scan from birthday to current block height // Force scan from birthday to current block height
// For faucet tokens, we need to scan even if birthday equals current block // For faucet tokens, we need to scan even if birthday equals current block
if (device.sp_wallet.birthday <= this.currentBlockHeight) { if (device.sp_wallet.birthday <= this.currentBlockHeight) {
// For new wallets, scan from a few blocks earlier to catch faucet transactions // For new wallets, scan from much earlier to catch faucet transactions
const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight const scanFromHeight = device.sp_wallet.birthday === this.currentBlockHeight
? Math.max(0, this.currentBlockHeight - 10) // Scan from 10 blocks earlier for new wallets ? Math.max(0, this.currentBlockHeight - 100) // Scan from 100 blocks earlier for new wallets
: device.sp_wallet.birthday; : device.sp_wallet.birthday;
console.log(`🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...`); console.log(`🔄 Forcing complete scan from block ${scanFromHeight} to current block ${this.currentBlockHeight}...`);
await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL);
@ -1699,6 +1699,23 @@ export default class Services {
try { try {
const amount = this.sdkClient.get_available_amount(); const amount = this.sdkClient.get_available_amount();
console.log(`💰 SDK get_available_amount() returned: ${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; return amount;
} catch (error) { } catch (error) {
console.error('❌ Error calling get_available_amount():', error); console.error('❌ Error calling get_available_amount():', error);
@ -1940,11 +1957,12 @@ export default class Services {
throw new Error('Birthday not found'); throw new Error('Birthday not found');
} }
if (birthday === 0) { if (birthday === 0) {
// This is a new device, set birthday to a few blocks earlier to allow scanning for faucet transactions // This is a new device, set birthday to scan from much earlier to catch faucet transactions
device.sp_wallet.birthday = Math.max(0, this.currentBlockHeight - 10); // Scan from 100 blocks earlier to ensure we catch all faucet transactions
// We also set last_scan to the same value initially device.sp_wallet.birthday = Math.max(0, this.currentBlockHeight - 100);
device.sp_wallet.last_scan = device.sp_wallet.birthday; // We also set last_scan to the same value initially
device.sp_wallet.last_scan = device.sp_wallet.birthday;
try { try {
// First set the updated device in memory // First set the updated device in memory
this.sdkClient.restore_device(device); this.sdkClient.restore_device(device);