diff --git a/cw_bitcoin/lib/bitcoin_wallet_service.dart b/cw_bitcoin/lib/bitcoin_wallet_service.dart index ceb785cb2..1bec01036 100644 --- a/cw_bitcoin/lib/bitcoin_wallet_service.dart +++ b/cw_bitcoin/lib/bitcoin_wallet_service.dart @@ -46,10 +46,6 @@ class BitcoinWalletService extends WalletService create(BitcoinNewWalletCredentials credentials) async { - - // set the walletInfo's derivationInfo if not present: - credentials.walletInfo!.derivationInfo ??= credentials.derivationInfo; - final wallet = await BitcoinWalletBase.create( mnemonic: await generateElectrumMnemonic(strength: 132), password: credentials.password!, diff --git a/cw_core/lib/wallet_credentials.dart b/cw_core/lib/wallet_credentials.dart index dd69b7326..0b5fa0ce4 100644 --- a/cw_core/lib/wallet_credentials.dart +++ b/cw_core/lib/wallet_credentials.dart @@ -6,12 +6,15 @@ abstract class WalletCredentials { this.height, this.walletInfo, this.password, - this.derivationInfo, - }); + DerivationInfo? derivationInfo, + }) { + if (this.walletInfo != null && derivationInfo != null) { + this.walletInfo!.derivationInfo = derivationInfo; + } + } final String name; final int? height; String? password; WalletInfo? walletInfo; - DerivationInfo? derivationInfo; } diff --git a/cw_nano/lib/nano_wallet.dart b/cw_nano/lib/nano_wallet.dart index fc8b8ff9e..1f5475208 100644 --- a/cw_nano/lib/nano_wallet.dart +++ b/cw_nano/lib/nano_wallet.dart @@ -355,6 +355,9 @@ abstract class NanoWalletBase } walletInfo.derivationInfo ??= DerivationInfo(derivationType: derivationType); + if (walletInfo.derivationInfo!.derivationType == null) { + walletInfo.derivationInfo!.derivationType = derivationType; + } return NanoWallet( walletInfo: walletInfo, diff --git a/cw_nano/lib/nano_wallet_service.dart b/cw_nano/lib/nano_wallet_service.dart index b04635f62..395db4443 100644 --- a/cw_nano/lib/nano_wallet_service.dart +++ b/cw_nano/lib/nano_wallet_service.dart @@ -31,10 +31,8 @@ class NanoWalletService extends WalletService openWallet(String name, String password) async { final walletInfo = walletInfoSource.values.firstWhere((info) => info.id == WalletBase.idFor(name, getType())); + final wallet = await NanoWalletBase.open( name: name, password: password, diff --git a/lib/view_model/exchange/exchange_trade_view_model.dart b/lib/view_model/exchange/exchange_trade_view_model.dart index bdd0a1a20..cfabd994f 100644 --- a/lib/view_model/exchange/exchange_trade_view_model.dart +++ b/lib/view_model/exchange/exchange_trade_view_model.dart @@ -101,12 +101,12 @@ abstract class ExchangeTradeViewModelBase with Store { return; } - // sendViewModel.clearOutputs(); - // final output = sendViewModel.outputs.first; - // output.address = trade.inputAddress ?? ''; - // output.setCryptoAmount(trade.amount); - // sendViewModel.selectedCryptoCurrency = trade.from; - // await sendViewModel.createTransaction(); + sendViewModel.clearOutputs(); + final output = sendViewModel.outputs.first; + output.address = trade.inputAddress ?? ''; + output.setCryptoAmount(trade.amount); + sendViewModel.selectedCryptoCurrency = trade.from; + await sendViewModel.createTransaction(); } @action diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index 4a653cbf8..ddf8843ef 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -47,13 +47,6 @@ abstract class WalletCreationVMBase with Store { name = await generateName(); } - if (options == null || options["derivationInfo"] == null) { - if (options == null) { - options = {}; - } - options["derivationInfo"] = getDefaultDerivation(); - } - walletCreationService.checkIfExists(name); final dirPath = await pathForWalletDir(name: name, type: type); final path = await pathForWallet(name: name, type: type); @@ -72,8 +65,9 @@ abstract class WalletCreationVMBase with Store { dirPath: dirPath, address: '', showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven, - derivationInfo: credentials.derivationInfo, + derivationInfo: getDefaultDerivation(), ); + credentials.walletInfo = walletInfo; final wallet = restoreWallet != null ? await processFromRestoredWallet(credentials, restoreWallet)