Skip to content

Commit 1913746

Browse files
committed
ln/refactor: add constructor for ClaimableHTLC
Added so that we can create ClaimableHTLC for trampoline tests in a separate file, rather than needing to make several fields pub(crate) just for the sake of tests.
1 parent 8d24995 commit 1913746

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
@@ -549,6 +549,22 @@ struct ClaimableHTLC {
549549
}
550550

551551
impl ClaimableHTLC {
552+
pub(crate) fn new(
553+
prev_hop: HTLCPreviousHopData, value: u64, sender_intended_value: u64, cltv_expiry: u32,
554+
onion_payload: OnionPayload, counterparty_skimmed_fee_msat: Option<u64>,
555+
) -> Self {
556+
ClaimableHTLC {
557+
prev_hop,
558+
cltv_expiry,
559+
value,
560+
sender_intended_value,
561+
onion_payload,
562+
timer_ticks: 0,
563+
total_value_received: None,
564+
counterparty_skimmed_fee_msat,
565+
}
566+
}
567+
552568
// Increments timer ticks and returns a boolean indicating whether HTLC is timed out.
553569
fn mpp_timer_tick(&mut self) -> bool {
554570
self.timer_ticks += 1;
@@ -8480,19 +8496,17 @@ impl<
84808496
..
84818497
} = prev_hop;
84828498

8483-
let claimable_htlc = ClaimableHTLC {
8499+
let claimable_htlc = ClaimableHTLC::new(
84848500
prev_hop,
84858501
// We differentiate the received value from the sender intended value
84868502
// if possible so that we don't prematurely mark MPP payments complete
84878503
// if routing nodes overpay
8488-
value: htlc_value,
8489-
sender_intended_value: outgoing_amt_msat,
8490-
timer_ticks: 0,
8491-
total_value_received: None,
8504+
htlc_value,
8505+
outgoing_amt_msat,
84928506
cltv_expiry,
84938507
onion_payload,
8494-
counterparty_skimmed_fee_msat: skimmed_fee_msat,
8495-
};
8508+
skimmed_fee_msat,
8509+
);
84968510

84978511
macro_rules! fail_receive_htlc {
84988512
($committed_to_claimable: expr) => {

0 commit comments

Comments
 (0)