Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with seed restore and open offers #4507

Conversation

chimp1984
Copy link
Contributor

Fixes #4499

When restoring from same seeds and the user had open offers the reserved balance was not updated as the addressEntry list got created newly. It is not the normal use case that a user applies the same seed to a data directory containing open offers but we should handle such cases correctly as well.

We also check now for open offers and enforce that those get removed at restore from seeds.

There have been potential bugs as well in the addressEntryList class which are hopefully eliminated by that PR. Some might have been responsible for out-of-sync addressList with wallet data issues. Those cases are hard to reproduce and mostly happen at rather un-usual situations.

Lots of refactoring as well...

I tested quite a bit but it will require good testing before deployment.

In dev testing I got the case of duplicated address entries and thus
incorrect balance. I could not reproduce it later but looking in the
AddressEntry code it was unsafe using the add operation on list without
a contains check. Better instead to use a HashSet and avoid possibility
of duplicated entries by the chosen data structure.
Note that the protobuf representation is still a list and get converted
to a HashSet.
…tModificationExceptions

- Make entrySet final
- Avoind unneeded wrapping
- Remove visibility of entrySet
- Add getAddressEntriesAsListImmutable method. This is the only access for the hashSet
so we ensure it cannot be changed from outside.
- Remove stream() method
- Remove unused return types
- Improve some stream structures
- Renaming, improve comments
- Add SharedPresentation class for methods in GUIUtil which are no
utility methods.
- Move restoreSeedWords to SharedPresentation
at restore from seed and create a backup copy.
I don't know what was the motivation of removing the original file
(probably the use case that the seeds are different and thus there
is no match of existing entries with the new addresses) as
that breaks the internal association of addresses with trades/offers and
the reserved balances display.

This should be tested well though with the related use cases
(diff. offer and trade states, wallet restore with same seed of with
foreign seed -> in that case we need to recreated the AddressEntryList
but that should be handled in the related domain)

- Add copyFile method
an open offer.

Improve handling of restore and add more checks to avoid invalid
entries.
@ghubstan
Copy link
Member

ACK

My dev/regtest/dao mode test scenarios:

  1. 1 Open Offer (not taken), reserved + available = total -> 0.1150 + 209.88462285 = 209.99962285

    Shutdown, forget password, and restore from seed at startup.

    Did I see warning msg about removing offers when restoring? Yes (open offers will be removed)

    Is available balance now 209.99962285 ? reserve = 0 ? Yes and Yes

    Has offer been removed? Yes

  2. 6 Open Offers (none taken), 3 sell, 3 buy

    reserved + available = total -> 0.2730 + 209.72422459 = 209.99722459

    Shutdown, forget password, and restore from seed at startup.

    Did I see warning msg about removing offers when restoring? Yes (open offers will be removed)

    Is available balance now 209.99722459 ? reserve = 0 ? Yes and Yes

    Offers been removed? Yes

  3. 1 Open Trade (payment not started) reserved + locked + available = total -> 0 + 0.1150 + 209.88185154 = 209.99685154

    Shutdown, forget password, and restore from seed at startup.

    Did I see warning msg about removing offers when restoring? No

    Is available balance now 209.99685154 ? reserve = 0 locked = 0.1150 ? Yes and Yes and Yes

    Does Open Trade still exist? Yes

  4. 1 Open Trade (payment started) reserved + locked + available = total -> 0 + 0.1150 + 209.88185154 = 209.99685154

    Shutdown, forget password, and restore from seed at startup.

    Did I see warning msg about removing offers when restoring? No

    Is available balance now 209.99685154 ? reserve = 0 locked = 0.1150 ? Yes and Yes and Yes

    Does Open Trade still exist? Yes

Copy link
Contributor

@ripcurlx ripcurlx left a comment

Choose a reason for hiding this comment

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

utACK based on #4507 (comment)

@ripcurlx ripcurlx merged commit 2b9445d into bisq-network:master Sep 11, 2020
@ripcurlx ripcurlx added this to the v1.3.9 milestone Sep 11, 2020
@chimp1984 chimp1984 deleted the fix-bug-with-seed-restore-and-open-offers branch October 8, 2020 23:27
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.

Reserve bal moved to available bal after restore from seed
3 participants