mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-23 07:38:49 +00:00
clean up tx count function
This commit is contained in:
parent
43b4ffb614
commit
d270ea38a2
1 changed files with 10 additions and 11 deletions
|
@ -3215,17 +3215,18 @@ class FiroWallet extends CoinServiceAPI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO call get transaction and check each tx to see if it is a "received" tx?
|
Future<int> _getTxCount({required String address}) async {
|
||||||
Future<int> _getReceivedTxCount({required String address}) async {
|
|
||||||
try {
|
try {
|
||||||
final scripthash = AddressUtils.convertToScriptHash(address, _network);
|
final scriptHash = AddressUtils.convertToScriptHash(address, _network);
|
||||||
final transactions =
|
final transactions = await electrumXClient.getHistory(
|
||||||
await electrumXClient.getHistory(scripthash: scripthash);
|
scripthash: scriptHash,
|
||||||
|
);
|
||||||
return transactions.length;
|
return transactions.length;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"Exception rethrown in _getReceivedTxCount(address: $address): $e",
|
"Exception rethrown in _getReceivedTxCount(address: $address): $e",
|
||||||
level: LogLevel.Error);
|
level: LogLevel.Error,
|
||||||
|
);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3234,8 +3235,7 @@ class FiroWallet extends CoinServiceAPI
|
||||||
try {
|
try {
|
||||||
final currentReceiving = await _currentReceivingAddress;
|
final currentReceiving = await _currentReceivingAddress;
|
||||||
|
|
||||||
final int txCount =
|
final int txCount = await _getTxCount(address: currentReceiving.value);
|
||||||
await _getReceivedTxCount(address: currentReceiving.value);
|
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
'Number of txs for current receiving address $currentReceiving: $txCount',
|
'Number of txs for current receiving address $currentReceiving: $txCount',
|
||||||
level: LogLevel.Info);
|
level: LogLevel.Info);
|
||||||
|
@ -3281,8 +3281,7 @@ class FiroWallet extends CoinServiceAPI
|
||||||
Future<void> checkChangeAddressForTransactions() async {
|
Future<void> checkChangeAddressForTransactions() async {
|
||||||
try {
|
try {
|
||||||
final currentChange = await _currentChangeAddress;
|
final currentChange = await _currentChangeAddress;
|
||||||
final int txCount =
|
final int txCount = await _getTxCount(address: currentChange.value);
|
||||||
await _getReceivedTxCount(address: currentChange.value);
|
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
'Number of txs for current change address: $currentChange: $txCount',
|
'Number of txs for current change address: $currentChange: $txCount',
|
||||||
level: LogLevel.Info);
|
level: LogLevel.Info);
|
||||||
|
|
Loading…
Reference in a new issue