Expose counterparty-revoked-outputs in `get_claimable_balance`
authorMatt Corallo <git@bluematt.me>
Tue, 24 May 2022 23:57:56 +0000 (23:57 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 16 Aug 2022 01:06:00 +0000 (01:06 +0000)
commit5a8ede09fb3c8bbcd8694d94c12dac9ea7485537
tree99c581343244c02d9e5d997432031f63408b4953
parentf712eb41572d98af2e234bb05013728138f3f4f5
Expose counterparty-revoked-outputs in `get_claimable_balance`

This uses the various new tracking added in the prior commits to
expose a new `Balance` type - `CounterpartyRevokedOutputClaimable`.

Some nontrivial work is required, however, as we now have to track
HTLC outputs as spendable in a transaction that comes *after* an
HTLC-Success/HTLC-Timeout transaction, which we previously didn't
need to do. Thus, we have to check if an
`onchain_events_awaiting_threshold_conf` event spends a commitment
transaction's HTLC output while walking events. Further, because
we now need to track HTLC outputs after the
HTLC-Success/HTLC-Timeout confirms, and because we have to track
the counterparty's `to_self` output as a contentious output which
could be claimed by either party, we have to examine the
`OnchainTxHandler`'s set of outputs to spend when determining if
certain outputs are still spendable.

Two new tests are added which test various different transaction
formats, and hopefully provide good test coverage of the various
revoked output paths.
lightning/src/chain/channelmonitor.rs
lightning/src/chain/onchaintx.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/monitor_tests.rs