We add a new channel constraint rule that enforces limits on channel
opening for the OpenChannelSync and BatchOpenChannel end points.
The channel constraint rule takes care about:
* min channel size
* max channel size
* max push amount
* no closing address was used
This adds an on-chain budget that handles requests and responses for the
following endpoints:
* OpenChannelSync
* BatchOpenChannel
The budget rule checks that the onchain fee rate is not violated and
that pending and confirmed amounts are handled correctly.
An edge case can occur when lit crashes or shuts down after the budget
rule has forwarded a request but didn't receive a response yet. The
pending budget is not removed in case the request didn't go through and
is not accounted towards the spent budget in case the request did go
through. To be able to handle these cases in the future we add a unique
identifier to the request, that can be checked by calling LND's channel
bookkeeping APIs. Not all of them expose the identifier yet, which is
why pending actions cannot be deleted yet. This leads to underspending
of the budget and can be fixed by user intervention by creating a new
session. The memo prefix is removed when reading forwarding the
bookkeeping requests for privacy reasons.
We pass a random lnd connection identifier to the rule enforcer that is
unique per lnd connection lifetime. It is used to generate unique
request identifiers that amend the non-unique request identifiers that
are passed from lnd.
This is to tolerate unknown rules sent from the autopilot for the
`autopilot features` command.
Otherwise, when trying to register a feature that requires an upgrade, a
more user friendly error is returned.
This commit expands the RealToPseudo methods to take in a privacy map db
reader. This allows the methods to check if the privacy map db already
contains an entry for a "real" string before generating a new one.
For now, only an empty PrivacyMapReader is ever provided to the
RealToPseudo call. This will be changed in the following commit.