Regrading the `Watcher`, fields (appointments, locator_uuid_map) has
been replaced by DB calls when needed.
For `Responder`, the field `trackers` has been replaced by DB calls when
needed, and `tx_tracker_map` wasn't actually needed for the tower to
operate, so was just dropped.
For `GateKeeper`, `registered_users::appointments` which used to hold
the uuids of every appointment the user submitted was removed so that
`registered_users` only holds meta information about users.
Also now the gatekeeper is the entity responsible for deleting appointments from the database. Instead of the watcher/responder asking the gatekeeper for the users to update and carry out the deletion and update itself, now the watcher/responder will hand the gatekeeper the uuids to delete and the gatekeeper will figure out which users it needs to update (refund the freed slots to).
Also now, like in `Watcher::store_triggered_appointment`, if the appointment is invalid or was rejected by the network in block connections, the freed slots will not be refunded to the user.
Also the block connection order starts with the gatekeeper first, this
allows the gatekeeper to delete the outdated users so that the watcher
and the responder doesn't take them into account.
Implements ping/pong logic for the tower and CLN plugin
Modification in test as suggested and some more
Some fixed
Signed-off-by: Anmol Agrawal <anmol2002.aa1@gmail.com>
The `watchtower-plugin` was specifying a custom tor flag to signal whether Tor may be used by the client. This was due to `cln-plugin (v0.1.1-)` not allowing plugins to access the CoreLN configuration options and, therefore, our plugin was unable to fetch the `proxy` / `always-use-proxy` options.
This fetches the aforementioned options and revamps the logic to comply with the `always-use-proxy` requirements, that is, if the flag is set all communications must be performed using Tor. Also, it replaces some of the currently used `String`s for more meaningful types to store network data (such as `AddressType`, `NetAddress`, or `ProxyInfo`).
This drops our custom `watchtower-proxy` config option
Needed to bump the lightning version used and had to bump bitcoin, bitcoincore-rpc aswell to match dep verions in lightining
merkle root computation changed in `bitcoin`, thus some methods in the test_utils needed to adapt (basically by adding a tx if there is none in a block). See: b454cf8e15
Also SecretKey had it's `to_string` method removed, so TEOS now encodes its tower key using `display_secret().to_string()`. See: https://github.com/rust-bitcoin/rust-secp256k1/pull/312
This new constructor useful for passing the information along in the clients,
avoiding moving around a struct with an empty field and the signature separately.
On the other hand, the verify functions makes it easier cleaner a valid receipt.
Local types were using a mix between serialize / deserialize / to_vec / from_slice
methods to serialize / deserialize structures without using the serde crate.
Normalizes the method naming to it/s to_vec / from_slice. May reformat to serialize / deserialize
if we end up using serde for that.
Also adds some utility serde methods and derives serde from some structs that required so for client building.
The codebase had different ways of performing bitcoin serde:
- Using bitcoin::consensus::{encode, decode}
- Using bitcoin::util::psbt::serialize::{Deserialize, Serialize};
The former feels like a cleaner way of doing so, normalizing all the appearances.
checked_txs cache the transactions that have already been queried to bitcoind so we do not need to spam it
in case multiple trackers share the same penalty.
The ChainMonitor will set the flag as false if the connection with bitcoind is lost. As a result,
the InternalAPI can block the PublicAPI so no requests are accepted until bitcoind is back up.
- Old TODOs/FIXMes are removed
- Cargo.toml files are reformatted
- base64 is replaces by bitcoin::base64
- prost_types is removed (it was unused)
- Unnecessary crate features are removed
- simple_logger is bumped
Appointment used to require a raw locator in the constructor (`[u8;16]`)
but that has turned out to be highly unuseful specially when having to
deserialize appointments and/or build them from user provided data.
Updates the constructor so a Locator is passed instead.
Refactors severals parts of the code so:
- Copy values are not passed as reference
- Copy values are derefered when needed instead of cloned
- Clones are avoided as much as possible
- Strings are replaced by &str when possible
More passes to the code may be necessary in the future, but this is a good start
The JSON serialization logic was added to deal with data storage. Given won't be using LevelDB for this implementation, but a SQL database, all that serialization logic in unnecessary.
Moves temporary parsing between `bitcoin` and `bitcoincore-rpc` data types to the `Carrier` so it is transparent to the rest of the system.
Adds `httpmock` to Watcher test so RPC conversation between the `Responder` and `bitcoind` can be mocked.