don't create a decred wallet with empty seed
What changed, and why it matters
This change stops Cake Wallet from creating or continuing with a Decred wallet when the wallet's recovery seed is missing or empty. Previously, if the seed could not be retrieved, the code silently fell back to an empty string, which could lead to a wallet being initialized without a usable backup seed. Now it throws an explicit error instead.
Treat this as a defensive hardening fix. Review whether any existing Decred wallets were created with an empty seed and consider warning or re-deriving affected users. No immediate emergency response is indicated by the diff alone.
Security signals we found
Missing/null seed now raises an exception instead of silently continuing
Empty seed fallback removed
BadMnemonicException introduced for Decred wallet initialization failure
Evidence from the diff
In cw_decred/lib/wallet.dart, the init() method previously assigned _seed from _libwallet.walletSeed(…) with a ?? ‘’ fallback. The patch removes the empty fallback and throws BadMnemonicException when walletSeed returns null. This prevents a Decred wallet from being used with an empty/missing seed, which could cause backup or key-derivation issues.
Changed components
cw_decred/lib/wallet.dartDecredWalletBase.init()Decred wallet creation/initialization flowInspect captured patch +8 / −3
### cw_decred/lib/wallet.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:cw_core/amount/money.dart';
+import "package:cw_core/exceptions/cake_exception.dart" show BadMnemonicException;
import 'package:path/path.dart' as p;
import 'package:cw_core/exceptions.dart';
import 'package:cw_core/transaction_direction.dart';
@@ -137,12 +138,16 @@ abstract class DecredWalletBase
String get pubkey => _pubkey;
Future<void> init() async {
- final getSeed = () async {
+ Future<void> getSeed() async {
if (!watchingOnly) {
- _seed = await _libwallet.walletSeed(walletInfo.name, _password) ?? "";
+ final seed = await _libwallet.walletSeed(walletInfo.name, _password);
+ if (seed == null) {
+ throw const BadMnemonicException("Seed can't be null");
+ }
+ _seed = seed;
}
_pubkey = await _libwallet.defaultPubkey(walletInfo.name);
- };
+ }
await Future.wait([
updateBalance(),
updateTransactionHistory(),Why this scored 42/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.