From c0283a37ee300c8aee45e7cb4fa318cf4fdcd1f5 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Fri, 11 Apr 2025 14:13:40 +0200 Subject: [PATCH] minor fix [skip ci] --- cw_decred/lib/wallet.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cw_decred/lib/wallet.dart b/cw_decred/lib/wallet.dart index c41643067..2c7af61f0 100644 --- a/cw_decred/lib/wallet.dart +++ b/cw_decred/lib/wallet.dart @@ -710,14 +710,18 @@ abstract class DecredWalletBase // walletBirthdayBlockHeight checks if the wallet birthday is set and returns // it. Returns -1 if not. Future walletBirthdayBlockHeight() async { - final res = await _libwallet.birthState(walletInfo.name); - final decoded = json.decode(res); - // Having these values set indicates that sync has not reached the birthday - // yet, so no birthday is set. - if (decoded["setfromheight"] == true || decoded["setfromtime"] == true) { - return -1; + try { + final res = await _libwallet.birthState(walletInfo.name); + final decoded = json.decode(res); + // Having these values set indicates that sync has not reached the birthday + // yet, so no birthday is set. + if (decoded["setfromheight"] == true || decoded["setfromtime"] == true) { + return -1; + } + return decoded["height"] ?? 0; + } on FormatException catch (_) { + return 0; } - return decoded["height"] ?? 0; } Future verifyMessage(String message, String signature, {String? address = null}) async {