mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
- resetToDefault omitted Wownero: the reset button null-crashed and left WOW wallets with an empty node list - accountLabel was missing a return and rendered blank for WOW wallets - sec_random now throws instead of returning empty bytes when the native entropy channel fails or under-delivers - iOS builds no longer register the leftover cakewallet:// URL scheme - WOW fee estimate now fetched from the connected daemon's get_fee_estimate RPC and cached; the inherited XMR constant table remains only as a pre-fetch fallback - pin cake_backup, flutter_local_authentication, and bech32 git deps to their locked SHAs for reproducible builds
28 lines
1012 B
Dart
28 lines
1012 B
Dart
import 'dart:io';
|
|
import 'dart:math';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
const utils = const MethodChannel('com.cake_wallet/native_utils');
|
|
|
|
Future<Uint8List> secRandom(int count) async {
|
|
try {
|
|
if (Platform.isWindows || Platform.isLinux) {
|
|
// Used method to get securely generated random bytes from cake backups
|
|
const byteSize = 256;
|
|
final rng = Random.secure();
|
|
return Uint8List.fromList(List<int>.generate(count, (_) => rng.nextInt(byteSize)));
|
|
}
|
|
final bytes = await utils.invokeMethod<Uint8List>('sec_random', {'count': count});
|
|
if (bytes == null || bytes.length != count) {
|
|
throw StateError('sec_random returned ${bytes?.length ?? 0} bytes, expected $count');
|
|
}
|
|
return bytes;
|
|
} on PlatformException catch (e) {
|
|
// Never fail open: an entropy source that cannot deliver must throw,
|
|
// not hand back an empty buffer for key material.
|
|
throw StateError('sec_random platform call failed: ${e.message}');
|
|
}
|
|
}
|