ci: docker_tag=dev-test
**Motivations :** - Ajouter des logs de débogage pour comprendre pourquoi le wallet n'a pas de clés (has_spend_key: false, has_scan_key: false) - Diagnostiquer le problème de génération des clés dans createNewDevice et updateDeviceBlockHeight **Modifications :** - src/services/service.ts: Ajout de logs détaillés dans createNewDevice() et updateDeviceBlockHeight() pour tracer la génération des clés **Pages affectées :** - Service de création de wallet avec diagnostic des clés - Logs de débogage pour identifier le problème de génération des clés
This commit is contained in:
parent
683743d629
commit
31f57b86a0
@ -1187,7 +1187,7 @@ export default class Services {
|
|||||||
|
|
||||||
// Notify user that a transaction was received
|
// Notify user that a transaction was received
|
||||||
this.updateUserStatus('📨 New transaction received from blockchain...');
|
this.updateUserStatus('📨 New transaction received from blockchain...');
|
||||||
|
|
||||||
// Mark that we've received a transaction for waitForAmount
|
// Mark that we've received a transaction for waitForAmount
|
||||||
this.hasReceivedTransaction = true;
|
this.hasReceivedTransaction = true;
|
||||||
|
|
||||||
@ -1880,9 +1880,20 @@ export default class Services {
|
|||||||
throw new Error('WebAssembly SDK not initialized - cannot create device');
|
throw new Error('WebAssembly SDK not initialized - cannot create device');
|
||||||
}
|
}
|
||||||
// We set birthday later when we have the chain tip from relay
|
// We set birthday later when we have the chain tip from relay
|
||||||
|
console.log('🔧 Creating new device with birthday 0...');
|
||||||
spAddress = await this.sdkClient.create_new_device(0, 'signet');
|
spAddress = await this.sdkClient.create_new_device(0, 'signet');
|
||||||
|
console.log('✅ Device created with address:', spAddress);
|
||||||
|
|
||||||
const device = this.dumpDeviceFromMemory();
|
const device = this.dumpDeviceFromMemory();
|
||||||
|
console.log('🔍 Device details after creation:', {
|
||||||
|
has_spend_key: !!device.sp_wallet?.spend_key,
|
||||||
|
has_scan_key: !!device.sp_wallet?.scan_key,
|
||||||
|
birthday: device.sp_wallet?.birthday,
|
||||||
|
sp_address: device.sp_address
|
||||||
|
});
|
||||||
|
|
||||||
await this.saveDeviceInDatabase(device);
|
await this.saveDeviceInDatabase(device);
|
||||||
|
console.log('✅ Device saved to database');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Services ~ Error:', e);
|
console.error('Services ~ Error:', e);
|
||||||
}
|
}
|
||||||
@ -1924,7 +1935,7 @@ export default class Services {
|
|||||||
*/
|
*/
|
||||||
public async ensureCompleteInitialScan(): Promise<void> {
|
public async ensureCompleteInitialScan(): Promise<void> {
|
||||||
console.log('🔄 Ensuring complete initial scan...');
|
console.log('🔄 Ensuring complete initial scan...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const device = await this.getDeviceFromDatabase();
|
const device = await this.getDeviceFromDatabase();
|
||||||
if (!device || !device.sp_wallet) {
|
if (!device || !device.sp_wallet) {
|
||||||
@ -1934,15 +1945,15 @@ export default class Services {
|
|||||||
// Force a complete scan from birthday to current block height
|
// Force a complete scan from birthday to current block height
|
||||||
const scanFromHeight = Math.max(0, this.currentBlockHeight - 100);
|
const scanFromHeight = Math.max(0, this.currentBlockHeight - 100);
|
||||||
console.log(`🔄 Performing complete scan from block ${scanFromHeight} to ${this.currentBlockHeight}...`);
|
console.log(`🔄 Performing complete scan from block ${scanFromHeight} to ${this.currentBlockHeight}...`);
|
||||||
|
|
||||||
await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL);
|
await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL);
|
||||||
console.log('✅ Complete initial scan completed');
|
console.log('✅ Complete initial scan completed');
|
||||||
|
|
||||||
// Update last_scan to current block height
|
// Update last_scan to current block height
|
||||||
device.sp_wallet.last_scan = this.currentBlockHeight;
|
device.sp_wallet.last_scan = this.currentBlockHeight;
|
||||||
await this.saveDeviceInDatabase(device);
|
await this.saveDeviceInDatabase(device);
|
||||||
console.log('✅ Wallet scan state updated');
|
console.log('✅ Wallet scan state updated');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Error during complete initial scan:', error);
|
console.error('❌ Error during complete initial scan:', error);
|
||||||
throw error;
|
throw error;
|
||||||
@ -1976,14 +1987,23 @@ export default class Services {
|
|||||||
if (birthday === 0) {
|
if (birthday === 0) {
|
||||||
// This is a new device, set birthday to scan from much earlier to catch faucet transactions
|
// 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
|
// Scan from 100 blocks earlier to ensure we catch all faucet transactions
|
||||||
|
console.log('🔧 Updating birthday for new device:', {
|
||||||
|
old_birthday: device.sp_wallet.birthday,
|
||||||
|
new_birthday: Math.max(0, this.currentBlockHeight - 100),
|
||||||
|
current_block: this.currentBlockHeight
|
||||||
|
});
|
||||||
|
|
||||||
device.sp_wallet.birthday = Math.max(0, this.currentBlockHeight - 100);
|
device.sp_wallet.birthday = Math.max(0, this.currentBlockHeight - 100);
|
||||||
// We also set last_scan to the same value initially
|
// We also set last_scan to the same value initially
|
||||||
device.sp_wallet.last_scan = device.sp_wallet.birthday;
|
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);
|
||||||
|
console.log('✅ Device restored in memory with updated birthday');
|
||||||
|
|
||||||
// Then save it to database
|
// Then save it to database
|
||||||
await this.saveDeviceInDatabase(device);
|
await this.saveDeviceInDatabase(device);
|
||||||
|
console.log('✅ Device saved to database with updated birthday');
|
||||||
|
|
||||||
// For new wallets, perform initial scan to catch any existing transactions
|
// For new wallets, perform initial scan to catch any existing transactions
|
||||||
console.log(`🔄 Performing initial scan for new wallet from block ${device.sp_wallet.birthday} to ${this.currentBlockHeight}...`);
|
console.log(`🔄 Performing initial scan for new wallet from block ${device.sp_wallet.birthday} to ${this.currentBlockHeight}...`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user