mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
possible putAddresses index violation error during full rescan fix
This commit is contained in:
parent
eaf8fe7094
commit
16d4384525
6 changed files with 110 additions and 41 deletions
|
@ -524,6 +524,7 @@ class BitcoinWallet extends CoinServiceAPI
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
int maxUnusedAddressGap = 20,
|
int maxUnusedAddressGap = 20,
|
||||||
int maxNumberOfIndexesToCheck = 1000,
|
int maxNumberOfIndexesToCheck = 1000,
|
||||||
|
bool isRescan = false,
|
||||||
}) async {
|
}) async {
|
||||||
longMutex = true;
|
longMutex = true;
|
||||||
|
|
||||||
|
@ -697,6 +698,16 @@ class BitcoinWallet extends CoinServiceAPI
|
||||||
p2wpkhChangeAddressArray.add(address);
|
p2wpkhChangeAddressArray.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRescan) {
|
||||||
|
await db.updateOrPutAddresses([
|
||||||
|
...p2wpkhReceiveAddressArray,
|
||||||
|
...p2wpkhChangeAddressArray,
|
||||||
|
...p2pkhReceiveAddressArray,
|
||||||
|
...p2pkhChangeAddressArray,
|
||||||
|
...p2shReceiveAddressArray,
|
||||||
|
...p2shChangeAddressArray,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
await db.putAddresses([
|
await db.putAddresses([
|
||||||
...p2wpkhReceiveAddressArray,
|
...p2wpkhReceiveAddressArray,
|
||||||
...p2wpkhChangeAddressArray,
|
...p2wpkhChangeAddressArray,
|
||||||
|
@ -705,6 +716,7 @@ class BitcoinWallet extends CoinServiceAPI
|
||||||
...p2shReceiveAddressArray,
|
...p2shReceiveAddressArray,
|
||||||
...p2shChangeAddressArray,
|
...p2shChangeAddressArray,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// get own payment code
|
// get own payment code
|
||||||
final myCode = await getPaymentCode(DerivePathType.bip44);
|
final myCode = await getPaymentCode(DerivePathType.bip44);
|
||||||
|
@ -2924,6 +2936,7 @@ class BitcoinWallet extends CoinServiceAPI
|
||||||
mnemonic: mnemonic!,
|
mnemonic: mnemonic!,
|
||||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||||
|
isRescan: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
longMutex = false;
|
longMutex = false;
|
||||||
|
|
|
@ -487,6 +487,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
int maxUnusedAddressGap = 20,
|
int maxUnusedAddressGap = 20,
|
||||||
int maxNumberOfIndexesToCheck = 1000,
|
int maxNumberOfIndexesToCheck = 1000,
|
||||||
|
bool isRescan = false,
|
||||||
}) async {
|
}) async {
|
||||||
longMutex = true;
|
longMutex = true;
|
||||||
|
|
||||||
|
@ -616,12 +617,21 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
p2shChangeAddressArray.add(address);
|
p2shChangeAddressArray.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRescan) {
|
||||||
|
await db.updateOrPutAddresses([
|
||||||
|
...p2pkhReceiveAddressArray,
|
||||||
|
...p2pkhChangeAddressArray,
|
||||||
|
...p2shReceiveAddressArray,
|
||||||
|
...p2shChangeAddressArray,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
await db.putAddresses([
|
await db.putAddresses([
|
||||||
...p2pkhReceiveAddressArray,
|
...p2pkhReceiveAddressArray,
|
||||||
...p2pkhChangeAddressArray,
|
...p2pkhChangeAddressArray,
|
||||||
...p2shReceiveAddressArray,
|
...p2shReceiveAddressArray,
|
||||||
...p2shChangeAddressArray,
|
...p2shChangeAddressArray,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
await _updateUTXOs();
|
await _updateUTXOs();
|
||||||
|
|
||||||
|
@ -2874,6 +2884,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
mnemonic: mnemonic!,
|
mnemonic: mnemonic!,
|
||||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||||
|
isRescan: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
longMutex = false;
|
longMutex = false;
|
||||||
|
|
|
@ -464,6 +464,7 @@ class DogecoinWallet extends CoinServiceAPI
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
int maxUnusedAddressGap = 20,
|
int maxUnusedAddressGap = 20,
|
||||||
int maxNumberOfIndexesToCheck = 1000,
|
int maxNumberOfIndexesToCheck = 1000,
|
||||||
|
bool isRescan = false,
|
||||||
}) async {
|
}) async {
|
||||||
longMutex = true;
|
longMutex = true;
|
||||||
|
|
||||||
|
@ -540,11 +541,17 @@ class DogecoinWallet extends CoinServiceAPI
|
||||||
await _generateAddressForChain(1, 0, DerivePathType.bip44);
|
await _generateAddressForChain(1, 0, DerivePathType.bip44);
|
||||||
p2pkhChangeAddressArray.add(address);
|
p2pkhChangeAddressArray.add(address);
|
||||||
}
|
}
|
||||||
|
if (isRescan) {
|
||||||
|
await db.updateOrPutAddresses([
|
||||||
|
...p2pkhReceiveAddressArray,
|
||||||
|
...p2pkhChangeAddressArray,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
await db.putAddresses([
|
await db.putAddresses([
|
||||||
...p2pkhReceiveAddressArray,
|
...p2pkhReceiveAddressArray,
|
||||||
...p2pkhChangeAddressArray,
|
...p2pkhChangeAddressArray,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// paynym stuff
|
// paynym stuff
|
||||||
// // generate to ensure notification address is in db before refreshing transactions
|
// // generate to ensure notification address is in db before refreshing transactions
|
||||||
|
@ -2573,6 +2580,7 @@ class DogecoinWallet extends CoinServiceAPI
|
||||||
mnemonic: mnemonic!,
|
mnemonic: mnemonic!,
|
||||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||||
|
isRescan: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
longMutex = false;
|
longMutex = false;
|
||||||
|
|
|
@ -517,6 +517,7 @@ class LitecoinWallet extends CoinServiceAPI
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
int maxUnusedAddressGap = 20,
|
int maxUnusedAddressGap = 20,
|
||||||
int maxNumberOfIndexesToCheck = 1000,
|
int maxNumberOfIndexesToCheck = 1000,
|
||||||
|
bool isRescan = false,
|
||||||
}) async {
|
}) async {
|
||||||
longMutex = true;
|
longMutex = true;
|
||||||
|
|
||||||
|
@ -690,6 +691,16 @@ class LitecoinWallet extends CoinServiceAPI
|
||||||
p2wpkhChangeAddressArray.add(address);
|
p2wpkhChangeAddressArray.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRescan) {
|
||||||
|
await db.updateOrPutAddresses([
|
||||||
|
...p2wpkhReceiveAddressArray,
|
||||||
|
...p2wpkhChangeAddressArray,
|
||||||
|
...p2pkhReceiveAddressArray,
|
||||||
|
...p2pkhChangeAddressArray,
|
||||||
|
...p2shReceiveAddressArray,
|
||||||
|
...p2shChangeAddressArray,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
await db.putAddresses([
|
await db.putAddresses([
|
||||||
...p2wpkhReceiveAddressArray,
|
...p2wpkhReceiveAddressArray,
|
||||||
...p2wpkhChangeAddressArray,
|
...p2wpkhChangeAddressArray,
|
||||||
|
@ -698,6 +709,7 @@ class LitecoinWallet extends CoinServiceAPI
|
||||||
...p2shReceiveAddressArray,
|
...p2shReceiveAddressArray,
|
||||||
...p2shChangeAddressArray,
|
...p2shChangeAddressArray,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
await _updateUTXOs();
|
await _updateUTXOs();
|
||||||
|
|
||||||
|
@ -2887,6 +2899,7 @@ class LitecoinWallet extends CoinServiceAPI
|
||||||
mnemonic: mnemonic!,
|
mnemonic: mnemonic!,
|
||||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||||
|
isRescan: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
longMutex = false;
|
longMutex = false;
|
||||||
|
|
|
@ -507,6 +507,7 @@ class NamecoinWallet extends CoinServiceAPI
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
int maxUnusedAddressGap = 20,
|
int maxUnusedAddressGap = 20,
|
||||||
int maxNumberOfIndexesToCheck = 1000,
|
int maxNumberOfIndexesToCheck = 1000,
|
||||||
|
bool isRescan = false,
|
||||||
}) async {
|
}) async {
|
||||||
longMutex = true;
|
longMutex = true;
|
||||||
|
|
||||||
|
@ -680,6 +681,16 @@ class NamecoinWallet extends CoinServiceAPI
|
||||||
p2wpkhChangeAddressArray.add(address);
|
p2wpkhChangeAddressArray.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRescan) {
|
||||||
|
await db.updateOrPutAddresses([
|
||||||
|
...p2wpkhReceiveAddressArray,
|
||||||
|
...p2wpkhChangeAddressArray,
|
||||||
|
...p2pkhReceiveAddressArray,
|
||||||
|
...p2pkhChangeAddressArray,
|
||||||
|
...p2shReceiveAddressArray,
|
||||||
|
...p2shChangeAddressArray,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
await db.putAddresses([
|
await db.putAddresses([
|
||||||
...p2wpkhReceiveAddressArray,
|
...p2wpkhReceiveAddressArray,
|
||||||
...p2wpkhChangeAddressArray,
|
...p2wpkhChangeAddressArray,
|
||||||
|
@ -688,6 +699,7 @@ class NamecoinWallet extends CoinServiceAPI
|
||||||
...p2shReceiveAddressArray,
|
...p2shReceiveAddressArray,
|
||||||
...p2shChangeAddressArray,
|
...p2shChangeAddressArray,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
await _updateUTXOs();
|
await _updateUTXOs();
|
||||||
|
|
||||||
|
@ -2877,6 +2889,7 @@ class NamecoinWallet extends CoinServiceAPI
|
||||||
mnemonic: mnemonic!,
|
mnemonic: mnemonic!,
|
||||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||||
|
isRescan: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
longMutex = false;
|
longMutex = false;
|
||||||
|
|
|
@ -489,6 +489,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
required String mnemonic,
|
required String mnemonic,
|
||||||
int maxUnusedAddressGap = 20,
|
int maxUnusedAddressGap = 20,
|
||||||
int maxNumberOfIndexesToCheck = 1000,
|
int maxNumberOfIndexesToCheck = 1000,
|
||||||
|
bool isRescan = false,
|
||||||
}) async {
|
}) async {
|
||||||
longMutex = true;
|
longMutex = true;
|
||||||
|
|
||||||
|
@ -614,12 +615,21 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
p2wpkhChangeAddressArray.add(address);
|
p2wpkhChangeAddressArray.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRescan) {
|
||||||
|
await db.updateOrPutAddresses([
|
||||||
|
...p2wpkhReceiveAddressArray,
|
||||||
|
...p2wpkhChangeAddressArray,
|
||||||
|
...p2pkhReceiveAddressArray,
|
||||||
|
...p2pkhChangeAddressArray,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
await db.putAddresses([
|
await db.putAddresses([
|
||||||
...p2wpkhReceiveAddressArray,
|
...p2wpkhReceiveAddressArray,
|
||||||
...p2wpkhChangeAddressArray,
|
...p2wpkhChangeAddressArray,
|
||||||
...p2pkhReceiveAddressArray,
|
...p2pkhReceiveAddressArray,
|
||||||
...p2pkhChangeAddressArray,
|
...p2pkhChangeAddressArray,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
await _updateUTXOs();
|
await _updateUTXOs();
|
||||||
|
|
||||||
|
@ -2982,6 +2992,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
mnemonic: mnemonic!,
|
mnemonic: mnemonic!,
|
||||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||||
|
isRescan: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
longMutex = false;
|
longMutex = false;
|
||||||
|
|
Loading…
Reference in a new issue