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:
parent
d34848c54e
commit
d013676f9f
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user