@@ -173,9 +173,6 @@ enum InboundHTLCState {
173
173
/// This can be used to inspect what next message an HTLC is waiting for to advance its state.
174
174
#[derive(Clone, Debug, PartialEq)]
175
175
pub enum InboundHTLCStateDetails {
176
- /// The remote node announced the HTLC with update_add_htlc but the HTLC is not added to any
177
- /// commitment transactions yet.
178
- RemoteAnnounced,
179
176
/// We have added this HTLC in our commitment transaction by receiving commitment_signed and
180
177
/// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote
181
178
/// before this HTLC is included on the remote commitment transaction.
@@ -200,33 +197,31 @@ pub enum InboundHTLCStateDetails {
200
197
AwaitingRemoteRevokeToRemoveFail,
201
198
}
202
199
203
- impl From<&InboundHTLCState> for InboundHTLCStateDetails {
204
- fn from(state: &InboundHTLCState) -> InboundHTLCStateDetails {
200
+ impl From<&InboundHTLCState> for Option< InboundHTLCStateDetails> {
201
+ fn from(state: &InboundHTLCState) -> Option< InboundHTLCStateDetails> {
205
202
match state {
206
- InboundHTLCState::RemoteAnnounced(_) =>
207
- InboundHTLCStateDetails::RemoteAnnounced,
203
+ InboundHTLCState::RemoteAnnounced(_) => None,
208
204
InboundHTLCState::AwaitingRemoteRevokeToAnnounce(_) =>
209
- InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
205
+ Some( InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd) ,
210
206
InboundHTLCState::AwaitingAnnouncedRemoteRevoke(_) =>
211
- InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
207
+ Some( InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd) ,
212
208
InboundHTLCState::Committed =>
213
- InboundHTLCStateDetails::Committed,
209
+ Some( InboundHTLCStateDetails::Committed) ,
214
210
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(_)) =>
215
- InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
211
+ Some( InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail) ,
216
212
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(_)) =>
217
- InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
213
+ Some( InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail) ,
218
214
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(_)) =>
219
- InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
215
+ Some( InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill) ,
220
216
}
221
217
}
222
218
}
223
219
224
220
impl_writeable_tlv_based_enum!(InboundHTLCStateDetails,
225
- (0, RemoteAnnounced) => {},
226
- (2, AwaitingRemoteRevokeToAdd) => {},
227
- (4, Committed) => {},
228
- (6, AwaitingRemoteRevokeToRemoveFulfill) => {},
229
- (8, AwaitingRemoteRevokeToRemoveFail) => {};
221
+ (0, AwaitingRemoteRevokeToAdd) => {},
222
+ (2, Committed) => {},
223
+ (4, AwaitingRemoteRevokeToRemoveFulfill) => {},
224
+ (6, AwaitingRemoteRevokeToRemoveFail) => {};
230
225
);
231
226
232
227
struct InboundHTLCOutput {
@@ -2219,14 +2214,16 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2219
2214
};
2220
2215
let holder_dust_limit_success_sat = htlc_success_dust_limit + self.holder_dust_limit_satoshis;
2221
2216
for htlc in self.pending_inbound_htlcs.iter() {
2222
- inbound_details.push(InboundHTLCDetails{
2223
- htlc_id: htlc.htlc_id,
2224
- amount_msat: htlc.amount_msat,
2225
- cltv_expiry: htlc.cltv_expiry,
2226
- payment_hash: htlc.payment_hash,
2227
- state: holding_cell_states.remove(&htlc.htlc_id).unwrap_or((&htlc.state).into()),
2228
- is_dust: htlc.amount_msat / 1000 < holder_dust_limit_success_sat,
2229
- });
2217
+ if let Some(state_details) = (&htlc.state).into() {
2218
+ inbound_details.push(InboundHTLCDetails{
2219
+ htlc_id: htlc.htlc_id,
2220
+ amount_msat: htlc.amount_msat,
2221
+ cltv_expiry: htlc.cltv_expiry,
2222
+ payment_hash: htlc.payment_hash,
2223
+ state: holding_cell_states.remove(&htlc.htlc_id).unwrap_or(state_details),
2224
+ is_dust: htlc.amount_msat / 1000 < holder_dust_limit_success_sat,
2225
+ });
2226
+ }
2230
2227
}
2231
2228
inbound_details
2232
2229
}
0 commit comments