mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
refactor: simplify hashed wallet identifier creation by optimizing seed and address handling logic (#2675)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user