mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
fixes
This commit is contained in:
parent
5ed0b794c7
commit
7ec117dd07
1 changed files with 13 additions and 25 deletions
|
@ -1,7 +1,6 @@
|
||||||
part of 'bitcoin.dart';
|
part of 'bitcoin.dart';
|
||||||
|
|
||||||
class CWBitcoin extends Bitcoin {
|
class CWBitcoin extends Bitcoin {
|
||||||
|
|
||||||
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials({
|
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials({
|
||||||
required String name,
|
required String name,
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
|
@ -29,29 +28,10 @@ class CWBitcoin extends Bitcoin {
|
||||||
WalletCredentials createBitcoinNewWalletCredentials(
|
WalletCredentials createBitcoinNewWalletCredentials(
|
||||||
{required String name, WalletInfo? walletInfo}) =>
|
{required String name, WalletInfo? walletInfo}) =>
|
||||||
BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority getMediumTransactionPriority() => BitcoinTransactionPriority.medium;
|
TransactionPriority getMediumTransactionPriority() => BitcoinTransactionPriority.medium;
|
||||||
|
|
||||||
@override
|
|
||||||
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials(
|
|
||||||
{required String name, required String mnemonic, required String password}) =>
|
|
||||||
BitcoinRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password);
|
|
||||||
|
|
||||||
@override
|
|
||||||
WalletCredentials createBitcoinRestoreWalletFromWIFCredentials(
|
|
||||||
{required String name,
|
|
||||||
required String password,
|
|
||||||
required String wif,
|
|
||||||
WalletInfo? walletInfo}) =>
|
|
||||||
BitcoinRestoreWalletFromWIFCredentials(
|
|
||||||
name: name, password: password, wif: wif, walletInfo: walletInfo);
|
|
||||||
|
|
||||||
@override
|
|
||||||
WalletCredentials createBitcoinNewWalletCredentials(
|
|
||||||
{required String name, WalletInfo? walletInfo}) =>
|
|
||||||
BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<String> getWordList() => wordlist;
|
List<String> getWordList() => wordlist;
|
||||||
|
|
||||||
|
@ -235,7 +215,6 @@ class CWBitcoin extends Bitcoin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<DerivationType>> compareDerivationMethods(
|
Future<List<DerivationType>> compareDerivationMethods(
|
||||||
{required String mnemonic, required Node node}) async {
|
{required String mnemonic, required Node node}) async {
|
||||||
|
@ -246,6 +225,16 @@ class CWBitcoin extends Bitcoin {
|
||||||
return [DerivationType.bip39, DerivationType.electrum2];
|
return [DerivationType.bip39, DerivationType.electrum2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _countOccurrences(String str, String charToCount) {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < str.length; i++) {
|
||||||
|
if (str[i] == charToCount) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<DerivationInfo>> getDerivationsFromMnemonic(
|
Future<List<DerivationInfo>> getDerivationsFromMnemonic(
|
||||||
{required String mnemonic, required Node node}) async {
|
{required String mnemonic, required Node node}) async {
|
||||||
|
@ -273,7 +262,7 @@ class CWBitcoin extends Bitcoin {
|
||||||
var node = bip32.BIP32.fromSeed(seedBytes);
|
var node = bip32.BIP32.fromSeed(seedBytes);
|
||||||
|
|
||||||
String derivationPath = dInfoCopy.derivationPath!;
|
String derivationPath = dInfoCopy.derivationPath!;
|
||||||
int derivationDepth = countOccurrences(derivationPath, "/");
|
int derivationDepth = _countOccurrences(derivationPath, "/");
|
||||||
if (derivationDepth == 3) {
|
if (derivationDepth == 3) {
|
||||||
derivationPath += "/0/0";
|
derivationPath += "/0/0";
|
||||||
dInfoCopy.derivationPath = dInfoCopy.derivationPath! + "/0";
|
dInfoCopy.derivationPath = dInfoCopy.derivationPath! + "/0";
|
||||||
|
@ -292,7 +281,6 @@ class CWBitcoin extends Bitcoin {
|
||||||
.address;
|
.address;
|
||||||
break;
|
break;
|
||||||
case "p2pkh":
|
case "p2pkh":
|
||||||
// case "p2wpkh-p2sh":// TODO
|
|
||||||
default:
|
default:
|
||||||
address = btc
|
address = btc
|
||||||
.P2PKH(
|
.P2PKH(
|
||||||
|
@ -304,7 +292,7 @@ class CWBitcoin extends Bitcoin {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
final sh = scriptHash(address!, networkType: btc.bitcoin);
|
final sh = scriptHash(address!, network: BitcoinNetwork.mainnet);
|
||||||
final history = await electrumClient.getHistory(sh);
|
final history = await electrumClient.getHistory(sh);
|
||||||
|
|
||||||
final balance = await electrumClient.getBalance(sh);
|
final balance = await electrumClient.getBalance(sh);
|
||||||
|
|
Loading…
Reference in a new issue