@@ -107,31 +107,35 @@ pub trait Listen {
107
107
fn block_disconnected ( & self , header : & BlockHeader , height : u32 ) ;
108
108
}
109
109
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.
112
112
///
113
113
/// 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.
117
118
///
118
119
/// # Use
119
- ///
120
120
/// 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.
125
126
///
126
127
/// # Order
127
128
///
128
129
/// 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.
131
132
/// - Dependent transactions within the same block must be given in topological order, possibly in
132
133
/// 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.
135
139
///
136
140
/// See individual method documentation for further details.
137
141
///
@@ -140,9 +144,9 @@ pub trait Listen {
140
144
/// [`best_block_updated`]: Self::best_block_updated
141
145
/// [`get_relevant_txids`]: Self::get_relevant_txids
142
146
pub 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.
144
148
///
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
146
150
/// transactions spending an output registered by [`Filter::register_output`]. Such transactions
147
151
/// appearing in the same block do not need to be included in the same call; instead, multiple
148
152
/// calls with additional transactions may be made so long as they are made in [chain order].
@@ -154,36 +158,36 @@ pub trait Confirm {
154
158
/// [chain order]: Confirm#order
155
159
/// [`best_block_updated`]: Self::best_block_updated
156
160
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.
159
162
///
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
162
166
/// by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`].
163
167
///
164
168
/// [`get_relevant_txids`]: Self::get_relevant_txids
165
169
/// [`transactions_confirmed`]: Self::transactions_confirmed
166
170
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.
169
172
///
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 .
172
175
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.
176
178
///
177
179
/// Will include any transactions passed to [`transactions_confirmed`] that have insufficient
178
180
/// confirmations to be safe from a chain reorganization. Will not include any transactions
179
181
/// passed to [`transaction_unconfirmed`], unless later reconfirmed.
180
182
///
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
182
184
/// 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.
187
191
///
188
192
/// [`transactions_confirmed`]: Self::transactions_confirmed
189
193
/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
0 commit comments