mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 04:19:50 +00:00
fix(cw_monero): keys nullcheck handling (#2338)
add default values to monero wallet keys functions in order to prevent null check crashes
This commit is contained in:
parent
73588071ba
commit
900304d405
1 changed files with 10 additions and 5 deletions
|
@ -116,12 +116,17 @@ String getSeedLegacy(String? language) {
|
|||
}
|
||||
|
||||
String getPassphrase() {
|
||||
return currentWallet!.getCacheAttribute(key: "cakewallet.passphrase");
|
||||
return currentWallet?.getCacheAttribute(key: "cakewallet.passphrase") ?? "";
|
||||
}
|
||||
|
||||
Map<int, Map<int, Map<int, String>>> addressCache = {};
|
||||
|
||||
String getAddress({int accountIndex = 0, int addressIndex = 0}) {
|
||||
// this is a workaround for when we switch the wallet pointer,
|
||||
// it should never reach UI but should be good enough to prevent gray screen
|
||||
// or other errors because of forced null check.
|
||||
if (currentWallet == null) return "<wallet not ready ($accountIndex:$addressIndex)>";
|
||||
|
||||
// printV("getaddress: ${accountIndex}/${addressIndex}: ${monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)}: ${monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex)}");
|
||||
// this could be a while loop, but I'm in favor of making it if to not cause freezes
|
||||
if (currentWallet!.numSubaddresses(accountIndex: accountIndex)-1 < addressIndex) {
|
||||
|
@ -272,13 +277,13 @@ void closeCurrentWallet() {
|
|||
currentWallet!.stop();
|
||||
}
|
||||
|
||||
String getSecretViewKey() => currentWallet!.secretViewKey();
|
||||
String getSecretViewKey() => currentWallet?.secretViewKey() ?? "";
|
||||
|
||||
String getPublicViewKey() => currentWallet!.publicViewKey();
|
||||
String getPublicViewKey() => currentWallet?.publicViewKey() ?? "";
|
||||
|
||||
String getSecretSpendKey() => currentWallet!.secretSpendKey();
|
||||
String getSecretSpendKey() => currentWallet?.secretSpendKey() ?? "";
|
||||
|
||||
String getPublicSpendKey() => currentWallet!.publicSpendKey();
|
||||
String getPublicSpendKey() => currentWallet?.publicSpendKey() ?? "";
|
||||
|
||||
class SyncListener {
|
||||
SyncListener(this.onNewBlock, this.onNewTransaction)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue