mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
Merge branch 'cypherstack:staging' into staging
This commit is contained in:
commit
6c25ce7d67
3 changed files with 44 additions and 15 deletions
|
@ -154,6 +154,8 @@ class _XPubViewState extends ConsumerState<XPubView> {
|
||||||
rootNavigator: true,
|
rootNavigator: true,
|
||||||
).pop,
|
).pop,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
AnimatedSize(
|
AnimatedSize(
|
||||||
duration: const Duration(
|
duration: const Duration(
|
||||||
milliseconds: 150,
|
milliseconds: 150,
|
||||||
|
@ -165,8 +167,6 @@ class _XPubViewState extends ConsumerState<XPubView> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:bech32/bech32.dart';
|
import 'package:bech32/bech32.dart';
|
||||||
import 'package:bip32/bip32.dart' as bip32;
|
import 'package:bip32/bip32.dart' as bip32;
|
||||||
|
@ -377,7 +378,7 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
level: LogLevel.Info);
|
level: LogLevel.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Tuple2<List<isar_models.Address>, DerivePathType>> _checkGaps(
|
Future<Tuple3<List<isar_models.Address>, DerivePathType, int>> _checkGaps(
|
||||||
int maxNumberOfIndexesToCheck,
|
int maxNumberOfIndexesToCheck,
|
||||||
int maxUnusedAddressGap,
|
int maxUnusedAddressGap,
|
||||||
int txCountBatchSize,
|
int txCountBatchSize,
|
||||||
|
@ -387,6 +388,8 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
) async {
|
) async {
|
||||||
List<isar_models.Address> addressArray = [];
|
List<isar_models.Address> addressArray = [];
|
||||||
int gapCounter = 0;
|
int gapCounter = 0;
|
||||||
|
int highestIndexWithHistory = 0;
|
||||||
|
|
||||||
for (int index = 0;
|
for (int index = 0;
|
||||||
index < maxNumberOfIndexesToCheck && gapCounter < maxUnusedAddressGap;
|
index < maxNumberOfIndexesToCheck && gapCounter < maxUnusedAddressGap;
|
||||||
index += txCountBatchSize) {
|
index += txCountBatchSize) {
|
||||||
|
@ -460,6 +463,10 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
iterationsAddressArray.add(txCountCallArgs["${_id}_$k"]!);
|
iterationsAddressArray.add(txCountCallArgs["${_id}_$k"]!);
|
||||||
|
|
||||||
|
// update highest
|
||||||
|
highestIndexWithHistory = index + k;
|
||||||
|
|
||||||
|
// reset counter
|
||||||
gapCounter = 0;
|
gapCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +478,7 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
// cache all the transactions while waiting for the current function to finish.
|
// cache all the transactions while waiting for the current function to finish.
|
||||||
unawaited(getTransactionCacheEarly(iterationsAddressArray));
|
unawaited(getTransactionCacheEarly(iterationsAddressArray));
|
||||||
}
|
}
|
||||||
return Tuple2(addressArray, type);
|
return Tuple3(addressArray, type, highestIndexWithHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getTransactionCacheEarly(List<String> allAddresses) async {
|
Future<void> getTransactionCacheEarly(List<String> allAddresses) async {
|
||||||
|
@ -519,9 +526,9 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
deriveTypes.add(DerivePathType.bch44);
|
deriveTypes.add(DerivePathType.bch44);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Future<Tuple2<List<isar_models.Address>, DerivePathType>>>
|
final List<Future<Tuple3<List<isar_models.Address>, DerivePathType, int>>>
|
||||||
receiveFutures = [];
|
receiveFutures = [];
|
||||||
final List<Future<Tuple2<List<isar_models.Address>, DerivePathType>>>
|
final List<Future<Tuple3<List<isar_models.Address>, DerivePathType, int>>>
|
||||||
changeFutures = [];
|
changeFutures = [];
|
||||||
|
|
||||||
const receiveChain = 0;
|
const receiveChain = 0;
|
||||||
|
@ -579,6 +586,8 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
final changeResults = futuresResult[1];
|
final changeResults = futuresResult[1];
|
||||||
|
|
||||||
final List<isar_models.Address> addressesToStore = [];
|
final List<isar_models.Address> addressesToStore = [];
|
||||||
|
|
||||||
|
int highestReceivingIndexWithHistory = 0;
|
||||||
// If restoring a wallet that never received any funds, then set receivingArray manually
|
// If restoring a wallet that never received any funds, then set receivingArray manually
|
||||||
// If we didn't do this, it'd store an empty array
|
// If we didn't do this, it'd store an empty array
|
||||||
for (final tuple in receiveResults) {
|
for (final tuple in receiveResults) {
|
||||||
|
@ -590,10 +599,15 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
);
|
);
|
||||||
addressesToStore.add(address);
|
addressesToStore.add(address);
|
||||||
} else {
|
} else {
|
||||||
|
highestReceivingIndexWithHistory = max(
|
||||||
|
tuple.item3,
|
||||||
|
highestReceivingIndexWithHistory,
|
||||||
|
);
|
||||||
addressesToStore.addAll(tuple.item1);
|
addressesToStore.addAll(tuple.item1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int highestChangeIndexWithHistory = 0;
|
||||||
// If restoring a wallet that never sent any funds with change, then set changeArray
|
// If restoring a wallet that never sent any funds with change, then set changeArray
|
||||||
// manually. If we didn't do this, it'd store an empty array.
|
// manually. If we didn't do this, it'd store an empty array.
|
||||||
for (final tuple in changeResults) {
|
for (final tuple in changeResults) {
|
||||||
|
@ -605,17 +619,32 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
);
|
);
|
||||||
addressesToStore.add(address);
|
addressesToStore.add(address);
|
||||||
} else {
|
} else {
|
||||||
|
highestChangeIndexWithHistory = max(
|
||||||
|
tuple.item3,
|
||||||
|
highestChangeIndexWithHistory,
|
||||||
|
);
|
||||||
addressesToStore.addAll(tuple.item1);
|
addressesToStore.addAll(tuple.item1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove extra addresses to help minimize risk of creating a large gap
|
||||||
|
addressesToStore.removeWhere((e) =>
|
||||||
|
e.subType == isar_models.AddressSubType.change &&
|
||||||
|
e.derivationIndex > highestChangeIndexWithHistory);
|
||||||
|
addressesToStore.removeWhere((e) =>
|
||||||
|
e.subType == isar_models.AddressSubType.receiving &&
|
||||||
|
e.derivationIndex > highestReceivingIndexWithHistory);
|
||||||
|
|
||||||
if (isRescan) {
|
if (isRescan) {
|
||||||
await db.updateOrPutAddresses(addressesToStore);
|
await db.updateOrPutAddresses(addressesToStore);
|
||||||
} else {
|
} else {
|
||||||
await db.putAddresses(addressesToStore);
|
await db.putAddresses(addressesToStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _updateUTXOs();
|
await Future.wait([
|
||||||
|
_refreshTransactions(),
|
||||||
|
_updateUTXOs(),
|
||||||
|
]);
|
||||||
|
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
updateCachedId(walletId),
|
updateCachedId(walletId),
|
||||||
|
|
|
@ -11,7 +11,7 @@ description: Stack Wallet
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.7.4+164
|
version: 1.7.4+165
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in a new issue