get10101 / itchysats

CFDs on Bitcoin.
https://itchysats.network
MIT License
61 stars 17 forks source link

Investigate coins not found in development mode #965

Closed thomaseizinger closed 2 years ago

thomaseizinger commented 2 years ago

We sometimes run into the problem that we start with 0 balance when using our development seeds. Perhaps #838 is related to this issue.

We should investigate, how bdk scans for coins (enable some logs?) and see how to resolve the issue. The original thinking was, because we use electrum as a backend, we should be able to re-scan from scratch on every startup and find ALL coins.

thomaseizinger commented 2 years ago

Adding this to the milestone because it is seriously annoying.

Ideas on how to debug this:

da-kami commented 2 years ago

+1 on seriously annoying. I keep running into this problem upon almost every local test run. @thomaseizinger do you think that bringing back the SQlite database to cache wallet state would help? At the moment we still only use the in-memory wallet, but I remember we discussed bringing back the wallet db. We should probably #838 into the milestone if we want to tackle this.

thomaseizinger commented 2 years ago

So the bug reliably goes away if we scan more than 100 transactions which leads me to conclude that:

thomaseizinger commented 2 years ago

Try and use the esplora backend instead of the electrum backend in BDK for our wallet (we need to keep the electrum_client dependency for monitor, so don't get too confused by

We can't do that unfortuntely because the esplora backend doesn't work with the async-interface: https://github.com/bitcoindevkit/bdk/issues/165.

I tried using ureq which is horribly slow because it is a blocking client but it doesn't fix the issue anyway.