Cw 1438 adapt batch fetching for balance and unspents#3199
Open
serhii-bor wants to merge 6 commits into
Open
Conversation
…Balance-and-unspents
OmarHatem28
reviewed
May 23, 2026
| return historyMap; | ||
| } | ||
|
|
||
| Future<Map<String, List<Map<String, dynamic>>>> getBatchUnspent( |
Contributor
There was a problem hiding this comment.
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; | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
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>; |
Contributor
There was a problem hiding this comment.
why specific casting? handleResponse function already handles that
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Number (if Applicable): Fixes #
Description
Please include a summary of the changes and which issue is fixed / feature is added.
Pull Request - Checklist