@@ -29,11 +29,8 @@ export function getAccountFromSeed(
2929 return new Account ( accountData . secretKey ) ;
3030 } catch ( error ) {
3131 logError ( 'getAccountFromSeed failed:' , error ) ;
32- // Return a fallback account with a deterministic key based on wallet index
33- const fallbackSeed = new Uint8Array ( 32 ) ;
34- fallbackSeed [ 0 ] = ( walletIndex || 0 ) % 256 ;
35- const fallbackKeyPair = nacl . sign . keyPair . fromSeed ( fallbackSeed ) ;
36- return new Account ( fallbackKeyPair . secretKey ) ;
32+ // Fail securely instead of using weak fallback keys
33+ throw new Error ( 'Unable to generate secure account keys. Please unlock wallet again.' ) ;
3734 }
3835}
3936
@@ -61,9 +58,8 @@ export class LocalStorageWalletProvider {
6158 if ( seed ) {
6259 seedBuffer = Buffer . from ( seed , 'hex' ) ;
6360 } else {
64- // Fallback seed if none available
65- seedBuffer = Buffer . alloc ( 32 ) ;
66- logWarn ( 'Using fallback seed for address listing' ) ;
61+ // Fail securely if no seed available instead of using weak fallback
62+ throw new Error ( 'No seed available for secure key generation' ) ;
6763 }
6864
6965 return [ ...Array ( walletCount ) . keys ( ) ] . map ( ( walletIndex ) => {
@@ -79,17 +75,13 @@ export class LocalStorageWalletProvider {
7975 `Failed to generate address for wallet ${ walletIndex } :` ,
8076 error ,
8177 ) ;
82- // Return a fallback address structure
83- return {
84- index : walletIndex ,
85- address : null ,
86- name : `Wallet ${ walletIndex } (Error)` ,
87- } ;
78+ // Return error structure instead of weak fallback
79+ throw new Error ( `Unable to generate secure address for wallet ${ walletIndex } ` ) ;
8880 }
8981 } ) ;
9082 } catch ( error ) {
9183 logError ( 'Failed to list addresses:' , error ) ;
92- return [ ] ;
84+ throw new Error ( 'Unable to list addresses securely. Please unlock wallet again.' ) ;
9385 }
9486 } ;
9587
0 commit comments