pub trait Filter {
fn register_tx(&self, txid: &Txid, script_pubkey: &Script);
fn register_output(
&self,
output: WatchedOutput
) -> Option<(usize, Transaction)>;
}
Expand description
The Filter
trait defines behavior for indicating chain activity of interest pertaining to
channels.
This is useful in order to have a Watch
implementation convey to a chain source which
transactions to be notified of. Notification may take the form of pre-filtering blocks or, in
the case of BIP 157/BIP 158, only fetching a block if the compact filter matches. If
receiving full blocks from a chain source, any further filtering is unnecessary.
After an output has been registered, subsequent block retrievals from the chain source must not exclude any transactions matching the new criteria nor any in-block descendants of such transactions.
Note that use as part of a Watch
implementation involves reentrancy. Therefore, the Filter
should not block on I/O. Implementations should instead queue the newly monitored data to be
processed later. Then, in order to block until the data has been processed, any Watch
invocation that has called the Filter
must return TemporaryFailure
.
Required Methods
fn register_tx(&self, txid: &Txid, script_pubkey: &Script)
fn register_tx(&self, txid: &Txid, script_pubkey: &Script)
Registers interest in a transaction with txid
and having an output with script_pubkey
as
a spending condition.
fn register_output(&self, output: WatchedOutput) -> Option<(usize, Transaction)>
fn register_output(&self, output: WatchedOutput) -> Option<(usize, Transaction)>
Registers interest in spends of a transaction output.
Optionally, when output.block_hash
is set, should return any transaction spending the
output that is found in the corresponding block along with its index.
This return value is useful for Electrum clients in order to supply in-block descendant transactions which otherwise were not included. This is not necessary for other clients if such descendant transactions were already included (e.g., when a BIP 157 client provides the full block).