diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 9b2b6fd7a..c06435d8e 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -105,11 +105,17 @@ abstract class ElectrumWalletBase } if (seedBytes != null) { - return currency == CryptoCurrency.bch - ? bitcoinCashHDWallet(seedBytes) - : Bip32Slip10Secp256k1.fromSeed(seedBytes).derivePath( + switch (currency) { + case CryptoCurrency.btc: + case CryptoCurrency.ltc: + return Bip32Slip10Secp256k1.fromSeed(seedBytes).derivePath( _hardenedDerivationPath(derivationInfo?.derivationPath ?? electrum_path)) as Bip32Slip10Secp256k1; + case CryptoCurrency.bch: + return bitcoinCashHDWallet(seedBytes); + default: + throw Exception("Unsupported currency"); + } } return Bip32Slip10Secp256k1.fromExtendedKey(xpub!); @@ -461,7 +467,6 @@ abstract class ElectrumWalletBase } } - node!.isElectrs = false; node!.save(); return node!.isElectrs!; @@ -2281,4 +2286,3 @@ class UtxoDetails { required this.spendsUnconfirmedTX, }); } - diff --git a/cw_bitcoin/lib/litecoin_wallet.dart b/cw_bitcoin/lib/litecoin_wallet.dart index dea91b345..6d7554bab 100644 --- a/cw_bitcoin/lib/litecoin_wallet.dart +++ b/cw_bitcoin/lib/litecoin_wallet.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:math'; -import 'package:blockchain_utils/bip/bip/bip32/base/bip32_base.dart'; import 'package:collection/collection.dart'; import 'package:convert/convert.dart' as convert; import 'package:crypto/crypto.dart'; @@ -65,7 +64,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { seedBytes: seedBytes, currency: CryptoCurrency.ltc, ) { - mwebHd = Bip32Slip10Secp256k1.fromSeed(seedBytes).derivePath("m/1000") as Bip32Slip10Secp256k1; + mwebHd = Bip32Slip10Secp256k1.fromSeed(seedBytes).derivePath("m/1000'") as Bip32Slip10Secp256k1; mwebEnabled = alwaysScan ?? false; walletAddresses = LitecoinWalletAddresses( walletInfo, @@ -84,7 +83,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { _stub = value; }); } - late final Bip32Slip10Secp256k1 mwebHd; late final Box mwebUtxosBox; Timer? _syncTimer; diff --git a/cw_bitcoin/lib/litecoin_wallet_addresses.dart b/cw_bitcoin/lib/litecoin_wallet_addresses.dart index 7fc013211..46ab1d12a 100644 --- a/cw_bitcoin/lib/litecoin_wallet_addresses.dart +++ b/cw_bitcoin/lib/litecoin_wallet_addresses.dart @@ -27,9 +27,10 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with } final Bip32Slip10Secp256k1 mwebHd; + List get scanSecret => mwebHd.childKey(Bip32KeyIndex(0x80000000)).privateKey.privKey.raw; - // TODO: I'm not 100% sure if it's supposed to be the compressed or uncompressed public key! - List get spendPubkey => mwebHd.childKey(Bip32KeyIndex(0x80000001)).publicKey.pubKey.compressed; + List get spendPubkey => + mwebHd.childKey(Bip32KeyIndex(0x80000001)).publicKey.pubKey.compressed; List mwebAddrs = []; diff --git a/cw_bitcoin/pubspec.yaml b/cw_bitcoin/pubspec.yaml index fc20cf2f9..23ce23e18 100644 --- a/cw_bitcoin/pubspec.yaml +++ b/cw_bitcoin/pubspec.yaml @@ -45,7 +45,6 @@ dependencies: url: https://github.com/rafael-xmr/sp_scanner ref: sp_v4.0.0 - dev_dependencies: flutter_test: sdk: flutter @@ -66,6 +65,10 @@ dependency_overrides: url: https://github.com/cake-tech/bitcoin_base ref: cake-update-v5 + + + pointycastle: 3.7.4 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec