refactor: simplify hashed wallet identifier creation by optimizing seed and address handling logic (#2675)

This commit is contained in:
Konstantin Ullrich
2025-11-25 00:15:13 +01:00
committed by GitHub
parent a4a6e2e3e9
commit efc99c14f6
+2 -7
View File
@@ -5,17 +5,12 @@ import 'package:cw_core/wallet_base.dart';
import 'package:hashlib/hashlib.dart';
String createHashedWalletIdentifier(WalletBase wallet) {
if (wallet.seed == null) return '';
final hashContent = wallet.seed ?? wallet.walletAddresses.primaryAddress;
final salt = secrets.walletGroupSalt;
final combined = '$salt.${wallet.seed}';
final combined = '$salt.$hashContent';
// Convert to UTF-8 bytes.
final bytes = utf8.encode(combined);
// Perform SHA-256 hash.
final digest = sha256.convert(bytes);
// Return the hex string representation of the hash.
return digest.toString();
}