Skip to content

Cw 1438 adapt batch fetching for balance and unspents#3199

Open
serhii-bor wants to merge 6 commits into
amount-refactorfrom
CW-1438-Adapt-batch-fetching-for-Balance-and-unspents
Open

Cw 1438 adapt batch fetching for balance and unspents#3199
serhii-bor wants to merge 6 commits into
amount-refactorfrom
CW-1438-Adapt-batch-fetching-for-Balance-and-unspents

Conversation

@serhii-bor
Copy link
Copy Markdown
Contributor

Issue Number (if Applicable): Fixes #

Description

Please include a summary of the changes and which issue is fixed / feature is added.

Pull Request - Checklist

  • Initial Manual Tests Passed
  • Double check modified code and verify it with the feature/task requirements
  • Format code
  • Look for code duplication
  • Clear naming for variables and methods
  • Manual tests in accessibility mode (TalkBack on Android) passed

@OmarHatem28 OmarHatem28 changed the base branch from dev to amount-refactor May 7, 2026 02:48
return historyMap;
}

Future<Map<String, List<Map<String, dynamic>>>> getBatchUnspent(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would rather simplify it

Comment on lines +3521 to +3529
for (final tx in transactionHistory.transactions.values) {
final heightDiff = ((tx.height ?? 0) - (tx.height ?? 0)).abs();
// this isn't a perfect matching algorithm since we don't have the right input/output information from these transaction models (the addresses are in different formats), but this should be more than good enough for now as it's extremely unlikely a user receives the EXACT same amount from 2 different sources and one of them is a peg out and the other isn't WITHIN 5 blocks of each other
if (tx.additionalInfo["isPegOut"] == true &&
tx.amount == tx.amount &&
heightDiff <= 5) {
tx.additionalInfo["fromPegOut"] = true;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will shadow the parameter passed to the function

Suggested change
for (final tx in transactionHistory.transactions.values) {
final heightDiff = ((tx.height ?? 0) - (tx.height ?? 0)).abs();
// this isn't a perfect matching algorithm since we don't have the right input/output information from these transaction models (the addresses are in different formats), but this should be more than good enough for now as it's extremely unlikely a user receives the EXACT same amount from 2 different sources and one of them is a peg out and the other isn't WITHIN 5 blocks of each other
if (tx.additionalInfo["isPegOut"] == true &&
tx.amount == tx.amount &&
heightDiff <= 5) {
tx.additionalInfo["fromPegOut"] = true;
}
}
for (final tx2 in transactionHistory.transactions.values) {
final heightDiff = ((tx2.height ?? 0) - (tx.height ?? 0)).abs();
// this isn't a perfect matching algorithm since we don't have the right input/output information from these transaction models (the addresses are in different formats), but this should be more than good enough for now as it's extremely unlikely a user receives the EXACT same amount from 2 different sources and one of them is a peg out and the other isn't WITHIN 5 blocks of each other
if (tx2.additionalInfo["isPegOut"] == true &&
tx2.amount == tx.amount &&
heightDiff <= 5) {
tx.additionalInfo["fromPegOut"] = true;
}
}

);

if (newAddresses.isNotEmpty) {
currentBranch.addAll(newAddresses);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are adding the new addresses here but you're not calling fetch transactions for address type on the new addresses


if (isJSONStringCorrect(unterminatedString)) {
final response = json.decode(unterminatedString);
final response = json.decode(unterminatedString) as Map<String, dynamic>;
Copy link
Copy Markdown
Contributor

@OmarHatem28 OmarHatem28 May 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why specific casting? handleResponse function already handles that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants