possible putAddresses index violation error during full rescan fix

This commit is contained in:
julian 2023-02-02 09:03:57 -06:00
parent eaf8fe7094
commit 16d4384525
6 changed files with 110 additions and 41 deletions

View file

@ -524,6 +524,7 @@ class BitcoinWallet extends CoinServiceAPI
required String mnemonic,
int maxUnusedAddressGap = 20,
int maxNumberOfIndexesToCheck = 1000,
bool isRescan = false,
}) async {
longMutex = true;
@ -697,6 +698,16 @@ class BitcoinWallet extends CoinServiceAPI
p2wpkhChangeAddressArray.add(address);
}
if (isRescan) {
await db.updateOrPutAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
} else {
await db.putAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
@ -705,6 +716,7 @@ class BitcoinWallet extends CoinServiceAPI
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
}
// get own payment code
final myCode = await getPaymentCode(DerivePathType.bip44);
@ -2924,6 +2936,7 @@ class BitcoinWallet extends CoinServiceAPI
mnemonic: mnemonic!,
maxUnusedAddressGap: maxUnusedAddressGap,
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
isRescan: true,
);
longMutex = false;

View file

@ -487,6 +487,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
required String mnemonic,
int maxUnusedAddressGap = 20,
int maxNumberOfIndexesToCheck = 1000,
bool isRescan = false,
}) async {
longMutex = true;
@ -616,12 +617,21 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
p2shChangeAddressArray.add(address);
}
if (isRescan) {
await db.updateOrPutAddresses([
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
} else {
await db.putAddresses([
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
}
await _updateUTXOs();
@ -2874,6 +2884,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
mnemonic: mnemonic!,
maxUnusedAddressGap: maxUnusedAddressGap,
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
isRescan: true,
);
longMutex = false;

View file

@ -464,6 +464,7 @@ class DogecoinWallet extends CoinServiceAPI
required String mnemonic,
int maxUnusedAddressGap = 20,
int maxNumberOfIndexesToCheck = 1000,
bool isRescan = false,
}) async {
longMutex = true;
@ -540,11 +541,17 @@ class DogecoinWallet extends CoinServiceAPI
await _generateAddressForChain(1, 0, DerivePathType.bip44);
p2pkhChangeAddressArray.add(address);
}
if (isRescan) {
await db.updateOrPutAddresses([
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
]);
} else {
await db.putAddresses([
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
]);
}
// paynym stuff
// // generate to ensure notification address is in db before refreshing transactions
@ -2573,6 +2580,7 @@ class DogecoinWallet extends CoinServiceAPI
mnemonic: mnemonic!,
maxUnusedAddressGap: maxUnusedAddressGap,
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
isRescan: true,
);
longMutex = false;

View file

@ -517,6 +517,7 @@ class LitecoinWallet extends CoinServiceAPI
required String mnemonic,
int maxUnusedAddressGap = 20,
int maxNumberOfIndexesToCheck = 1000,
bool isRescan = false,
}) async {
longMutex = true;
@ -690,6 +691,16 @@ class LitecoinWallet extends CoinServiceAPI
p2wpkhChangeAddressArray.add(address);
}
if (isRescan) {
await db.updateOrPutAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
} else {
await db.putAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
@ -698,6 +709,7 @@ class LitecoinWallet extends CoinServiceAPI
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
}
await _updateUTXOs();
@ -2887,6 +2899,7 @@ class LitecoinWallet extends CoinServiceAPI
mnemonic: mnemonic!,
maxUnusedAddressGap: maxUnusedAddressGap,
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
isRescan: true,
);
longMutex = false;

View file

@ -507,6 +507,7 @@ class NamecoinWallet extends CoinServiceAPI
required String mnemonic,
int maxUnusedAddressGap = 20,
int maxNumberOfIndexesToCheck = 1000,
bool isRescan = false,
}) async {
longMutex = true;
@ -680,6 +681,16 @@ class NamecoinWallet extends CoinServiceAPI
p2wpkhChangeAddressArray.add(address);
}
if (isRescan) {
await db.updateOrPutAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
} else {
await db.putAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
@ -688,6 +699,7 @@ class NamecoinWallet extends CoinServiceAPI
...p2shReceiveAddressArray,
...p2shChangeAddressArray,
]);
}
await _updateUTXOs();
@ -2877,6 +2889,7 @@ class NamecoinWallet extends CoinServiceAPI
mnemonic: mnemonic!,
maxUnusedAddressGap: maxUnusedAddressGap,
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
isRescan: true,
);
longMutex = false;

View file

@ -489,6 +489,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
required String mnemonic,
int maxUnusedAddressGap = 20,
int maxNumberOfIndexesToCheck = 1000,
bool isRescan = false,
}) async {
longMutex = true;
@ -614,12 +615,21 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
p2wpkhChangeAddressArray.add(address);
}
if (isRescan) {
await db.updateOrPutAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
]);
} else {
await db.putAddresses([
...p2wpkhReceiveAddressArray,
...p2wpkhChangeAddressArray,
...p2pkhReceiveAddressArray,
...p2pkhChangeAddressArray,
]);
}
await _updateUTXOs();
@ -2982,6 +2992,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
mnemonic: mnemonic!,
maxUnusedAddressGap: maxUnusedAddressGap,
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
isRescan: true,
);
longMutex = false;