Track block hash, return via `get_relevant_txids`
authorElias Rohrer <ero@tnull.de>
Tue, 8 Nov 2022 20:45:28 +0000 (21:45 +0100)
committerElias Rohrer <ero@tnull.de>
Wed, 9 Nov 2022 10:12:35 +0000 (11:12 +0100)
commit9685d6c2727d0eb1e194e87d31a27c003dae78e2
treea7c4a687079e8f523df8e42fcac3489ef6809aa0
parente55e0d53c74ba8c810ad36ea39e0ea1621873c34
Track block hash, return via `get_relevant_txids`

Previously, `Confirm::get_relevant_txids()` only returned a list of
transactions that have to be monitored for reorganization out of the
chain. This interface however required double bookkeeping: while we
internally keep track of the best block, height, etc, it would also
require the user to keep track which transaction was previously
confirmed in which block and to take actions based on any change, e.g,
to reconfirm them when the block would be reorged-out and the
transactions had been reconfirmed in another block.

Here, we track the confirmation block hash internally and return it via
`Confirm::get_relevant_txids()` to the user, which alleviates the
requirement for double bookkeeping: the user can now simply check
whether the given transaction is still confirmed and in the given block,
and take action if not.

We also split `update_claims_view`: Previously it was one, now it's two
methods: `update_claims_view_from_matched_txn` and
`update_claims_view_from_requests`.
lightning/src/chain/chainmonitor.rs
lightning/src/chain/channelmonitor.rs
lightning/src/chain/mod.rs
lightning/src/chain/onchaintx.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/reorg_tests.rs