Skip to content

Commit 15da2b8

Browse files
committed
ln/refactor: add constructor for ClaimableHTLC
Will be used in the commit that follows to create ClaimableHTLC in tests tests, so that we don't have to bump every field to pub(crate).
1 parent c742f8a commit 15da2b8

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,22 @@ struct ClaimableHTLC {
557557
}
558558

559559
impl ClaimableHTLC {
560+
pub(crate) fn new(
561+
prev_hop: HTLCPreviousHopData, value: u64, sender_intended_value: u64, cltv_expiry: u32,
562+
onion_payload: OnionPayload, counterparty_skimmed_fee_msat: Option<u64>,
563+
) -> Self {
564+
ClaimableHTLC {
565+
prev_hop,
566+
cltv_expiry,
567+
value,
568+
sender_intended_value,
569+
onion_payload,
570+
timer_ticks: 0,
571+
total_value_received: None,
572+
counterparty_skimmed_fee_msat,
573+
}
574+
}
575+
560576
// Increments timer ticks and returns a boolean indicating whether HTLC is timed out.
561577
fn mpp_timer_tick(&mut self) -> bool {
562578
self.timer_ticks += 1;
@@ -8686,19 +8702,17 @@ impl<
86868702
..
86878703
} = prev_hop;
86888704

8689-
let claimable_htlc = ClaimableHTLC {
8705+
let claimable_htlc = ClaimableHTLC::new(
86908706
prev_hop,
86918707
// We differentiate the received value from the sender intended value
86928708
// if possible so that we don't prematurely mark MPP payments complete
86938709
// if routing nodes overpay
8694-
value: htlc_value,
8695-
sender_intended_value: outgoing_amt_msat,
8696-
timer_ticks: 0,
8697-
total_value_received: None,
8710+
htlc_value,
8711+
outgoing_amt_msat,
86988712
cltv_expiry,
86998713
onion_payload,
8700-
counterparty_skimmed_fee_msat: skimmed_fee_msat,
8701-
};
8714+
skimmed_fee_msat,
8715+
);
87028716

87038717
macro_rules! fail_receive_htlc {
87048718
($committed_to_claimable: expr) => {

0 commit comments

Comments
 (0)