From b9f76bd24195e43d7bf746031f190d896d5fa531 Mon Sep 17 00:00:00 2001 From: Rafael Saes Date: Sun, 17 Nov 2024 15:23:13 -0300 Subject: [PATCH] fix: btc create --- cw_bitcoin/lib/bitcoin_wallet.dart | 43 +++--------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/cw_bitcoin/lib/bitcoin_wallet.dart b/cw_bitcoin/lib/bitcoin_wallet.dart index dd4a1f400..ecd4a48b6 100644 --- a/cw_bitcoin/lib/bitcoin_wallet.dart +++ b/cw_bitcoin/lib/bitcoin_wallet.dart @@ -108,44 +108,6 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store { int initialSilentAddressIndex = 0, required bool mempoolAPIEnabled, }) async { - late List seedBytes; - final Map hdWallets = {}; - - for (final derivation in walletInfo.derivations ?? []) { - if (derivation.description?.contains("SP") ?? false) { - continue; - } - - if (derivation.derivationType == DerivationType.bip39) { - seedBytes = Bip39SeedGenerator.generateFromString(mnemonic, passphrase); - hdWallets[CWBitcoinDerivationType.bip39] = Bip32Slip10Secp256k1.fromSeed(seedBytes); - break; - } else { - try { - seedBytes = ElectrumV2SeedGenerator.generateFromString(mnemonic, passphrase); - hdWallets[CWBitcoinDerivationType.electrum] = Bip32Slip10Secp256k1.fromSeed(seedBytes); - } catch (e) { - print("electrum_v2 seed error: $e"); - - try { - seedBytes = ElectrumV1SeedGenerator(mnemonic).generate(); - hdWallets[CWBitcoinDerivationType.electrum] = Bip32Slip10Secp256k1.fromSeed(seedBytes); - } catch (e) { - print("electrum_v1 seed error: $e"); - } - } - - break; - } - } - - if (hdWallets[CWBitcoinDerivationType.bip39] != null) { - hdWallets[CWBitcoinDerivationType.old_bip39] = hdWallets[CWBitcoinDerivationType.bip39]!; - } - if (hdWallets[CWBitcoinDerivationType.electrum] != null) { - hdWallets[CWBitcoinDerivationType.old_electrum] = hdWallets[CWBitcoinDerivationType.bip39]!; - } - return BitcoinWallet( mnemonic: mnemonic, passphrase: passphrase ?? "", @@ -157,13 +119,14 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store { initialSilentAddressIndex: initialSilentAddressIndex, initialBalance: initialBalance, encryptionFileUtils: encryptionFileUtils, - seedBytes: seedBytes, + seedBytes: walletInfo.derivationInfo?.derivationType == DerivationType.electrum + ? ElectrumV2SeedGenerator.generateFromString(mnemonic, passphrase) + : Bip39SeedGenerator.generateFromString(mnemonic, passphrase), initialRegularAddressIndex: initialRegularAddressIndex, initialChangeAddressIndex: initialChangeAddressIndex, addressPageType: addressPageType, networkParam: network, mempoolAPIEnabled: mempoolAPIEnabled, - hdWallets: hdWallets, initialUnspentCoins: [], ); }