@@ -107,31 +107,35 @@ pub trait Listen {
107107 fn block_disconnected ( & self , header : & BlockHeader , height : u32 ) ;
108108}
109109
110- /// The `Confirm` trait is used to notify when transactions have been confirmed on chain or
111- /// unconfirmed during a chain reorganization.
110+ /// The `Confirm` trait is used to notify LDK when relevant transactions have been confirmed on
111+ /// chain or unconfirmed during a chain reorganization.
112112///
113113/// Clients sourcing chain data using a transaction-oriented API should prefer this interface over
114- /// [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity
115- /// related to registered transactions and outputs. Upon notification, it would pass along the
116- /// matching transactions using this interface.
114+ /// [`Listen`]. For instance, an Electrum-based transaction sync implementation may implement
115+ /// [`Filter`] to subscribe to relevant transactions and unspent outputs it should monitor for
116+ /// on-chain activity. Then, it needs to notify LDK via this interface upon observing any changes
117+ /// with reference to the confirmation status of the monitored objects.
117118///
118119/// # Use
119- ///
120120/// The intended use is as follows:
121- /// - Call [`transactions_confirmed`] to process any on-chain activity of interest.
122- /// - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`]
123- /// that has been reorganized out of the chain.
124- /// - Call [`best_block_updated`] whenever a new chain tip becomes available.
121+ /// - Call [`transactions_confirmed`] to notify LDK whenever any of the registered transactions or
122+ /// outputs are, respectively, confirmed or spent on chain.
123+ /// - Call [`transaction_unconfirmed`] to notify LDK whenever any transaction returned by
124+ /// [`get_relevant_txids`] is no longer confirmed in the block with the given block hash.
125+ /// - Call [`best_block_updated`] to notify LDK whenever a new chain tip becomes available.
125126///
126127/// # Order
127128///
128129/// Clients must call these methods in chain order. Specifically:
129- /// - Transactions confirmed in a block must be given before transactions confirmed in a later
130- /// block.
130+ /// - Transactions which are confirmed in a particular block must be given before transactions
131+ /// confirmed in a later block.
131132/// - Dependent transactions within the same block must be given in topological order, possibly in
132133/// separate calls.
133- /// - Unconfirmed transactions must be given after the original confirmations and before any
134- /// reconfirmation.
134+ /// - All unconfirmed transactions must be given after the original confirmations and before *any*
135+ /// reconfirmations, i.e., [`transactions_confirmed`] and [`transaction_unconfirmed`] calls should
136+ /// never be interleaved, but always conduced *en bloc*.
137+ /// - Any reconfirmed transactions need to be explicitly unconfirmed before they are reconfirmed
138+ /// in regard to the new block.
135139///
136140/// See individual method documentation for further details.
137141///
@@ -140,9 +144,9 @@ pub trait Listen {
140144/// [`best_block_updated`]: Self::best_block_updated
141145/// [`get_relevant_txids`]: Self::get_relevant_txids
142146pub trait Confirm {
143- /// Processes transactions confirmed in a block with a given header and height.
147+ /// Notifies LDK of transactions confirmed in a block with a given header and height.
144148 ///
145- /// Should be called for any transactions registered by [`Filter::register_tx`] or any
149+ /// Must be called for any transactions registered by [`Filter::register_tx`] or any
146150 /// transactions spending an output registered by [`Filter::register_output`]. Such transactions
147151 /// appearing in the same block do not need to be included in the same call; instead, multiple
148152 /// calls with additional transactions may be made so long as they are made in [chain order].
@@ -154,36 +158,36 @@ pub trait Confirm {
154158 /// [chain order]: Confirm#order
155159 /// [`best_block_updated`]: Self::best_block_updated
156160 fn transactions_confirmed ( & self , header : & BlockHeader , txdata : & TransactionData , height : u32 ) ;
157-
158- /// Processes a transaction that is no longer confirmed as result of a chain reorganization.
161+ /// Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization.
159162 ///
160- /// Should be called for any transaction returned by [`get_relevant_txids`] if it has been
161- /// reorganized out of the best chain. Once called, the given transaction will not be returned
163+ /// Must be called for any transaction returned by [`get_relevant_txids`] if it has been
164+ /// reorganized out of the best chain or if it is no longer confirmed in the block with the
165+ /// given block hash. Once called, the given transaction will not be returned
162166 /// by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`].
163167 ///
164168 /// [`get_relevant_txids`]: Self::get_relevant_txids
165169 /// [`transactions_confirmed`]: Self::transactions_confirmed
166170 fn transaction_unconfirmed ( & self , txid : & Txid ) ;
167-
168- /// Processes an update to the best header connected at the given height.
171+ /// Notifies LDK of an update to the best header connected at the given height.
169172 ///
170- /// Should be called when a new header is available but may be skipped for intermediary blocks
171- /// if they become available at the same time .
173+ /// Must be called whenever a new chain tip becomes available. May be skipped for intermediary
174+ /// blocks .
172175 fn best_block_updated ( & self , header : & BlockHeader , height : u32 ) ;
173-
174- /// Returns transactions that should be monitored for reorganization out of the chain along
175- /// with the hash of the block as part of which had been previously confirmed.
176+ /// Returns transactions that must be monitored for reorganization out of the chain along
177+ /// with the hash of the block as part of which it had been previously confirmed.
176178 ///
177179 /// Will include any transactions passed to [`transactions_confirmed`] that have insufficient
178180 /// confirmations to be safe from a chain reorganization. Will not include any transactions
179181 /// passed to [`transaction_unconfirmed`], unless later reconfirmed.
180182 ///
181- /// May be called to determine the subset of transactions that must still be monitored for
183+ /// Must be called to determine the subset of transactions that must be monitored for
182184 /// reorganization. Will be idempotent between calls but may change as a result of calls to the
183- /// other interface methods. Thus, this is useful to determine which transactions may need to be
184- /// given to [`transaction_unconfirmed`]. If any of the returned transactions are confirmed in
185- /// a block other than the one with the given hash, they need to be unconfirmed and reconfirmed
186- /// via [`transaction_unconfirmed`] and [`transactions_confirmed`], respectively.
185+ /// other interface methods. Thus, this is useful to determine which transactions must be
186+ /// given to [`transaction_unconfirmed`].
187+ ///
188+ /// If any of the returned transactions are confirmed in a block other than the one with the
189+ /// given hash, they need to be unconfirmed and reconfirmed via [`transaction_unconfirmed`] and
190+ /// [`transactions_confirmed`], respectively.
187191 ///
188192 /// [`transactions_confirmed`]: Self::transactions_confirmed
189193 /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
0 commit comments