Skip to content

Commit 57644f6

Browse files
committed
Provide more color in filter registration methods
A few years ago we had repeated user confusion dealing with the `Filter` methods and exactly how they differ. Here we try to add a bit more color in several ways as suggested by users in a few places - listing examples of why the methods are used as well as ensuring its clearly communicated that not all parameters need be used. Fixes #1069
1 parent 37c431a commit 57644f6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lightning/src/chain/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ pub trait Watch<ChannelSigner: WriteableEcdsaChannelSigner> {
327327
pub trait Filter {
328328
/// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
329329
/// a spending condition.
330+
///
331+
/// This may be used, for example, to monitor for when a funding transaction confirms.
332+
///
333+
/// The `script_pubkey` is provided for informational purposes and may be useful for block
334+
/// sources which only support filtering on scripts.
330335
fn register_tx(&self, txid: &Txid, script_pubkey: &Script);
331336

332337
/// Registers interest in spends of a transaction output.
@@ -335,6 +340,9 @@ pub trait Filter {
335340
/// to ensure that also dependent output spents within an already connected block are correctly
336341
/// handled, e.g., by re-scanning the block in question whenever new outputs have been
337342
/// registered mid-processing.
343+
///
344+
/// This may be used, for example, to monitor for when a funding output is spent (by any
345+
/// transaction).
338346
fn register_output(&self, output: WatchedOutput);
339347
}
340348

@@ -347,6 +355,9 @@ pub trait Filter {
347355
/// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
348356
/// may have been spent there. See [`Filter::register_output`] for details.
349357
///
358+
/// Depending on your block source, you may need one or both of either [`Self::outpoint`] or
359+
/// [`Self::script_pubkey`].
360+
///
350361
/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
351362
/// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
352363
#[derive(Clone, PartialEq, Eq, Hash)]

0 commit comments

Comments
 (0)