mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +00:00
fix: btc create
This commit is contained in:
parent
aa6f932d8a
commit
b9f76bd241
1 changed files with 3 additions and 40 deletions
|
@ -108,44 +108,6 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
int initialSilentAddressIndex = 0,
|
int initialSilentAddressIndex = 0,
|
||||||
required bool mempoolAPIEnabled,
|
required bool mempoolAPIEnabled,
|
||||||
}) async {
|
}) async {
|
||||||
late List<int> seedBytes;
|
|
||||||
final Map<CWBitcoinDerivationType, Bip32Slip10Secp256k1> hdWallets = {};
|
|
||||||
|
|
||||||
for (final derivation in walletInfo.derivations ?? <DerivationInfo>[]) {
|
|
||||||
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(
|
return BitcoinWallet(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
passphrase: passphrase ?? "",
|
passphrase: passphrase ?? "",
|
||||||
|
@ -157,13 +119,14 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialSilentAddressIndex: initialSilentAddressIndex,
|
initialSilentAddressIndex: initialSilentAddressIndex,
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
encryptionFileUtils: encryptionFileUtils,
|
encryptionFileUtils: encryptionFileUtils,
|
||||||
seedBytes: seedBytes,
|
seedBytes: walletInfo.derivationInfo?.derivationType == DerivationType.electrum
|
||||||
|
? ElectrumV2SeedGenerator.generateFromString(mnemonic, passphrase)
|
||||||
|
: Bip39SeedGenerator.generateFromString(mnemonic, passphrase),
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
addressPageType: addressPageType,
|
addressPageType: addressPageType,
|
||||||
networkParam: network,
|
networkParam: network,
|
||||||
mempoolAPIEnabled: mempoolAPIEnabled,
|
mempoolAPIEnabled: mempoolAPIEnabled,
|
||||||
hdWallets: hdWallets,
|
|
||||||
initialUnspentCoins: [],
|
initialUnspentCoins: [],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue