Before this patch Bob is not sending message 3. This is because we are not
polling Bob's swarm correctly. To fix it we can just mimic the other NB's and
bubble up an event when Bob receives message 3 response from Alice, this way we
can `await` upon this event which triggers polling, making Bob's swarm send the
message.
Unfortunately, I had to put the wrap the swarm in Alice's `Network`
struct in an `Arc<Mutex<T>>` in order to be able to use `backoff` to
control the retry mechanism. This is because the stream of events
cannot be turned into a `SharedFuture` (unlike Bob's).
It would be good to find an alternative solution.
In order for Alice to complete the handshake she needs to transition to state 3,
for this she needs message 2 from Bob.
Send `bob::Message2` to Alice and transition to `State3` - completing the
handshake.
Anything that needs to be re-exported by this crate from
`curve25519_dalek` can be re-exported from the `monero` module. In
fact, the `Scalar` type was already being re-exported.
Not doing so means that receiving an invalid encrypted signature from
Bob would make the generator produce a `RedeemBtc` action that should
not be accepted by the node (since Bob's signature would be invalid
after decrypting his encrypted signature).
It's better to fail early and let the user know what went wrong,
rather than let them hit an incomprehensible error when using their
wallet.
Also:
- Move generator functions to `alice` and `bob` modules. This makes
using `tracing` a lot easier, since the context of the file name let's
us differentiate between Alice's and Bob's generator logs more
clearly.
- Accept 0 confirmations when watching for the Monero lock
transaction. This should eventually be configured by the application,
but in the tests it's making things unexpectedly slower.
The database is now bound to a type eg. alice::State or bob::State.
The caller cannot expect to retrieve a type that is different to
the type that was stored.
ECDSAfun's serialisation implementation was already imported
making the custom implementation redundant
Remove remnants of stale comment
Remove redundant conversion
Rename params to be consistent