Repository navigation
get_asset_balance: count a colored witness receive once - #27
Closed
darkhorse-core wants to merge 1 commit into
Closed
darkhorse-core wants to merge 1 commit into
darkhorse-core wants to merge 1 commit into
Conversation
A witness receive waiting for confirmations was counted twice in `future`: once through the allocation already recorded on its output, and once more through the transfer's requested assignment. With a settled balance of 1000 and an incoming 500, `future` reported 2000. The pending amount exists to cover transfers whose allocations are not on a TXO yet. Once a receive has been colored its allocation is already part of `txos_allocations`, so adding the requested assignment on top counts the same amount a second time. Asset transfers that already have a `Receive` coloring are now skipped there. The added test covers both sides, with the allocation colored and without.
Author
|
Friendly ping — is there anything we can add to make this easier to review (more tests, a reproducer against the published package, a different shape for the fix)? Happy to adjust. For context: we hit this while running a browser wallet on the published WASM bindings, where a colored witness receive was counted twice and the displayed balance inflated. |
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.
get_asset_balancecounts a witness receive waiting for confirmations twice infuture.What happens. A wallet with a settled balance of 1000 receives 500 through a witness
invoice. While the transfer waits for confirmations,
futurereads 2000 instead of 1500.Why. The pending amount exists to cover transfers whose allocations are not on a TXO yet.
Once a receive has been colored its allocation is already part of
txos_allocations, so addingthe transfer's
requested_assignmenton top counts the same amount a second time.Fix. Asset transfers that already carry a
Receivecoloring are skipped when the pendingamounts are summed.
The added test covers both sides, with the allocation colored and without.
cargo test --lib database::memory_dbpasses: 48 tests, 0 failures.Branched from
devat 2610d4a.