mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
commit
0d9066b517
8 changed files with 147 additions and 62 deletions
|
@ -103,9 +103,11 @@ class AddressCard extends StatelessWidget {
|
|||
return RoundedWhiteContainer(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
address.value,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
Expanded(
|
||||
child: Text(
|
||||
address.value,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
|
@ -524,6 +524,7 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
required String mnemonic,
|
||||
int maxUnusedAddressGap = 20,
|
||||
int maxNumberOfIndexesToCheck = 1000,
|
||||
bool isRescan = false,
|
||||
}) async {
|
||||
longMutex = true;
|
||||
|
||||
|
@ -697,14 +698,25 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
if (isRescan) {
|
||||
await db.updateOrPutAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
} else {
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
}
|
||||
|
||||
// get own payment code
|
||||
final myCode = await getPaymentCode(DerivePathType.bip44);
|
||||
|
@ -2932,6 +2944,7 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
mnemonic: mnemonic!,
|
||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||
isRescan: true,
|
||||
);
|
||||
|
||||
longMutex = false;
|
||||
|
|
|
@ -491,11 +491,13 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _recoverWalletFromBIP32SeedPhrase(
|
||||
{required String mnemonic,
|
||||
int maxUnusedAddressGap = 20,
|
||||
int maxNumberOfIndexesToCheck = 1000,
|
||||
Coin? coin}) async {
|
||||
Future<void> _recoverWalletFromBIP32SeedPhrase({
|
||||
required String mnemonic,
|
||||
int maxUnusedAddressGap = 20,
|
||||
int maxNumberOfIndexesToCheck = 1000,
|
||||
bool isRescan = false,
|
||||
Coin? coin,
|
||||
}) async {
|
||||
longMutex = true;
|
||||
|
||||
Map<String, Map<String, String>> bip44P2pkhReceiveDerivations = {};
|
||||
|
@ -631,6 +633,13 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
p2shChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
final addressesToStore = [
|
||||
...bip44P2pkhReceiveAddressArray,
|
||||
...bip44P2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
];
|
||||
|
||||
if (!testnet) {
|
||||
final resultReceiveBch44 = _checkGaps(
|
||||
maxNumberOfIndexesToCheck,
|
||||
|
@ -689,21 +698,16 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
bch44P2pkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await db.putAddresses([
|
||||
...bip44P2pkhReceiveAddressArray,
|
||||
...bip44P2pkhChangeAddressArray,
|
||||
...bch44P2pkhReceiveAddressArray,
|
||||
...bch44P2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
addressesToStore.addAll([
|
||||
...bch44P2pkhReceiveAddressArray,
|
||||
...bch44P2pkhChangeAddressArray,
|
||||
]);
|
||||
}
|
||||
|
||||
if (isRescan) {
|
||||
await db.updateOrPutAddresses(addressesToStore);
|
||||
} else {
|
||||
await db.putAddresses([
|
||||
...bip44P2pkhReceiveAddressArray,
|
||||
...bip44P2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
await db.putAddresses(addressesToStore);
|
||||
}
|
||||
|
||||
await _updateUTXOs();
|
||||
|
@ -2732,19 +2736,28 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// p2pkh / bip44
|
||||
final p2pkhLength = addressesP2PKH.length;
|
||||
if (p2pkhLength > 0) {
|
||||
final receiveDerivations = await _fetchDerivations(
|
||||
final receiveDerivationsBip44 = await _fetchDerivations(
|
||||
chain: 0,
|
||||
derivePathType: DerivePathType.bip44,
|
||||
);
|
||||
final changeDerivations = await _fetchDerivations(
|
||||
final changeDerivationsBip44 = await _fetchDerivations(
|
||||
chain: 1,
|
||||
derivePathType: DerivePathType.bip44,
|
||||
);
|
||||
final receiveDerivationsBch44 = await _fetchDerivations(
|
||||
chain: 0,
|
||||
derivePathType: DerivePathType.bch44,
|
||||
);
|
||||
final changeDerivationsBch44 = await _fetchDerivations(
|
||||
chain: 1,
|
||||
derivePathType: DerivePathType.bch44,
|
||||
);
|
||||
for (int i = 0; i < p2pkhLength; i++) {
|
||||
String address = addressesP2PKH[i];
|
||||
|
||||
// receives
|
||||
final receiveDerivation = receiveDerivations[address];
|
||||
final receiveDerivation = receiveDerivationsBip44[address] ??
|
||||
receiveDerivationsBch44[address];
|
||||
// if a match exists it will not be null
|
||||
if (receiveDerivation != null) {
|
||||
final data = P2PKH(
|
||||
|
@ -2765,7 +2778,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
}
|
||||
} else {
|
||||
// if its not a receive, check change
|
||||
final changeDerivation = changeDerivations[address];
|
||||
final changeDerivation = changeDerivationsBip44[address] ??
|
||||
changeDerivationsBch44[address];
|
||||
// if a match exists it will not be null
|
||||
if (changeDerivation != null) {
|
||||
final data = P2PKH(
|
||||
|
@ -2976,6 +2990,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
mnemonic: mnemonic!,
|
||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||
isRescan: true,
|
||||
);
|
||||
|
||||
longMutex = false;
|
||||
|
|
|
@ -465,6 +465,7 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
required String mnemonic,
|
||||
int maxUnusedAddressGap = 20,
|
||||
int maxNumberOfIndexesToCheck = 1000,
|
||||
bool isRescan = false,
|
||||
}) async {
|
||||
longMutex = true;
|
||||
|
||||
|
@ -541,11 +542,17 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
await _generateAddressForChain(1, 0, DerivePathType.bip44);
|
||||
p2pkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await db.putAddresses([
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
]);
|
||||
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
|
||||
|
@ -2574,6 +2581,7 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
mnemonic: mnemonic!,
|
||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||
isRescan: true,
|
||||
);
|
||||
|
||||
longMutex = false;
|
||||
|
|
|
@ -839,6 +839,10 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
isar_models.Address? address = await db
|
||||
.getAddresses(walletId)
|
||||
.filter()
|
||||
.subTypeEqualTo(isar_models.AddressSubType.receiving)
|
||||
.and()
|
||||
.typeEqualTo(isar_models.AddressType.mimbleWimble)
|
||||
.and()
|
||||
.derivationIndexEqualTo(index)
|
||||
.findFirst();
|
||||
|
||||
|
@ -877,8 +881,14 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
(await _currentReceivingAddress)?.value ??
|
||||
(await _getReceivingAddressForIndex(0)).value;
|
||||
|
||||
Future<isar_models.Address?> get _currentReceivingAddress =>
|
||||
db.getAddresses(walletId).sortByDerivationIndexDesc().findFirst();
|
||||
Future<isar_models.Address?> get _currentReceivingAddress => db
|
||||
.getAddresses(walletId)
|
||||
.filter()
|
||||
.subTypeEqualTo(isar_models.AddressSubType.receiving)
|
||||
.and()
|
||||
.typeEqualTo(isar_models.AddressType.mimbleWimble)
|
||||
.sortByDerivationIndexDesc()
|
||||
.findFirst();
|
||||
|
||||
@override
|
||||
Future<void> exit() async {
|
||||
|
|
|
@ -517,6 +517,7 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
required String mnemonic,
|
||||
int maxUnusedAddressGap = 20,
|
||||
int maxNumberOfIndexesToCheck = 1000,
|
||||
bool isRescan = false,
|
||||
}) async {
|
||||
longMutex = true;
|
||||
|
||||
|
@ -690,14 +691,25 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
if (isRescan) {
|
||||
await db.updateOrPutAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
} else {
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
}
|
||||
|
||||
await _updateUTXOs();
|
||||
|
||||
|
@ -2895,6 +2907,7 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
mnemonic: mnemonic!,
|
||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||
isRescan: true,
|
||||
);
|
||||
|
||||
longMutex = false;
|
||||
|
|
|
@ -507,6 +507,7 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
required String mnemonic,
|
||||
int maxUnusedAddressGap = 20,
|
||||
int maxNumberOfIndexesToCheck = 1000,
|
||||
bool isRescan = false,
|
||||
}) async {
|
||||
longMutex = true;
|
||||
|
||||
|
@ -680,14 +681,25 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
p2wpkhChangeAddressArray.add(address);
|
||||
}
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
if (isRescan) {
|
||||
await db.updateOrPutAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
} else {
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
...p2shReceiveAddressArray,
|
||||
...p2shChangeAddressArray,
|
||||
]);
|
||||
}
|
||||
|
||||
await _updateUTXOs();
|
||||
|
||||
|
@ -2884,6 +2896,7 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
mnemonic: mnemonic!,
|
||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck,
|
||||
isRescan: true,
|
||||
);
|
||||
|
||||
longMutex = false;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
await db.putAddresses([
|
||||
...p2wpkhReceiveAddressArray,
|
||||
...p2wpkhChangeAddressArray,
|
||||
...p2pkhReceiveAddressArray,
|
||||
...p2pkhChangeAddressArray,
|
||||
]);
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue