Loading the CFD by oracle event id, based on the "initial oracle event id" that we store in the CFD is wrong.
We should actually no store this even id at all, as it only becomes relevant once the setup is completed and we have a DLC.
If we load based on the event id that was stored in the CFD we might still load based on an outdated id once we roll over!
Thus, the event id of the cfd was removed. We always use the one stored in the DLC.
Since it is very hard to load a CFD based on the event id in the DLC (because that only exists in some states) this was removed.
Instead, upon attestation, we load all CFDs and then decide if we care about the attestation.
This should be optimized to loading all **open** CFDs at some point.
The rollover actor is spawned the the maker receives a rollover proposal message from the taker. After the rollover is complete, it sends itself
a completion message triggering a "cleanup" handler. Cleanup involves sending messages to maker_cfd actor and the maker_inc_connections to
trigger removal of stored references to the rollover actor.
Add a macro to simplify assertions on Cfd state in both maker and taker, which
significantly reduces boilerplate in tests.
Macro was used for brevity (we can hide `.await.unwrap()`), when a function was
used it would take 4 lines after formatting.
Putting each import statement on a dedicated line makes it a lot less
likely to create merge conflicts when items are removed / added because
Git resolves conflicts on a line-by-line basis.
We need this on the maker side to be able to get stats on what takers do.
For the taker it will also become relevant in the future so it is not wrong to add it.
If we don't receive a message from BitMex within 5 seconds, we ping
them to let them know that we are still using this connection. This
avoids the constant dis/reconnects that we have been seeing.
To make boot-up of the system easier, we want allow for a state where
we do not yet have a quote available.
Allow the quote in the projection to be optional and fallback to `None`
for profit calculation.
In case we fail to calculate the profit or this data is otherwise not
available, we still want to display as much as possible and only
blank out the data we cannot compute.
BDK's database only acts as a cache and can always be fully restored
by deleting it. With an Electrum backend, syncing is very quick meaning
the local cache basically does not serve any purpose. We've been having
troubles with BDK's database being broken due to internal inconsistency
problems. Switching to an in-memory database should fix these because
a restart of the application essentially wipes the database.
Resolves#465.
Implying `Sync` as part of withdraw allows us to remove the `Sync`
from the startup of the application which avoids an error case in
case we cannot find a particular transaction.
In case the wallet sync fails, we replace the value with `None` to
indicate to the UI that we don't have an up-to-date wallet information.
In case the sync works again at some point, we will replace it with
`Some` again.
Making this optional also allows us to start up the system without
syncing the wallet, a step towards https://github.com/itchysats/itchysats/discussions/753.
This should prevent accidential double-spends of our own inputs
when doing concurrent contract setups or other interactions of the
wallet.
We only store these in-memory, thus a simple restart of the application
will "unlock" a UTXO in case it was previously marked used but the
transaction never made it to the blockchain for whatever reason.
Resolves#790.