Skip to content

Commit 5938a99

Browse files
committed
Add AttributionData to UpdateFulfillHTLC message
1 parent 5eecba3 commit 5938a99

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,8 +2890,12 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
28902890
as_raa = Some(get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, node_b_id));
28912891
}
28922892

2893-
let fulfill_msg =
2894-
msgs::UpdateFulfillHTLC { channel_id: chan_id_2, htlc_id: 0, payment_preimage };
2893+
let fulfill_msg = msgs::UpdateFulfillHTLC {
2894+
channel_id: chan_id_2,
2895+
htlc_id: 0,
2896+
payment_preimage,
2897+
attribution_data: None,
2898+
};
28952899
if second_fails {
28962900
nodes[2].node.fail_htlc_backwards(&payment_hash);
28972901
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(
@@ -2907,8 +2911,14 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
29072911

29082912
let cs_updates = get_htlc_update_msgs!(nodes[2], node_b_id);
29092913
assert_eq!(cs_updates.update_fulfill_htlcs.len(), 1);
2910-
// Check that the message we're about to deliver matches the one generated:
2911-
assert_eq!(fulfill_msg, cs_updates.update_fulfill_htlcs[0]);
2914+
2915+
// Check that the message we're about to deliver matches the one generated. Ignore attribution data.
2916+
assert_eq!(fulfill_msg.channel_id, cs_updates.update_fulfill_htlcs[0].channel_id);
2917+
assert_eq!(fulfill_msg.htlc_id, cs_updates.update_fulfill_htlcs[0].htlc_id);
2918+
assert_eq!(
2919+
fulfill_msg.payment_preimage,
2920+
cs_updates.update_fulfill_htlcs[0].payment_preimage
2921+
);
29122922
}
29132923
nodes[1].node.handle_update_fulfill_htlc(node_c_id, &fulfill_msg);
29142924
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);

lightning/src/ln/channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8328,6 +8328,7 @@ where
83288328
channel_id: self.context.channel_id(),
83298329
htlc_id: htlc.htlc_id,
83308330
payment_preimage: payment_preimage.clone(),
8331+
attribution_data: None,
83318332
});
83328333
},
83338334
}

lightning/src/ln/htlc_reserve_unit_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,7 @@ pub fn test_update_fulfill_htlc_bolt2_update_fulfill_htlc_before_commitment() {
17851785
channel_id: chan.2,
17861786
htlc_id: 0,
17871787
payment_preimage: our_payment_preimage,
1788+
attribution_data: None,
17881789
};
17891790

17901791
nodes[0].node.handle_update_fulfill_htlc(node_b_id, &update_msg);

lightning/src/ln/msgs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ pub struct UpdateFulfillHTLC {
790790
pub htlc_id: u64,
791791
/// The pre-image of the payment hash, allowing HTLC redemption
792792
pub payment_preimage: PaymentPreimage,
793+
/// Optional field for attribution data that allows the sender to receive per hop HTLC hold times.
794+
pub attribution_data: Option<AttributionData>,
793795
}
794796

795797
/// A [`peer_storage`] message that can be sent to or received from a peer.
@@ -3170,7 +3172,9 @@ impl_writeable_msg!(UpdateFulfillHTLC, {
31703172
channel_id,
31713173
htlc_id,
31723174
payment_preimage
3173-
}, {});
3175+
}, {
3176+
(1, attribution_data, option)
3177+
});
31743178

31753179
impl_writeable_msg!(PeerStorage, { data }, {});
31763180

@@ -5671,6 +5675,7 @@ mod tests {
56715675
channel_id: ChannelId::from_bytes([2; 32]),
56725676
htlc_id: 2316138423780173,
56735677
payment_preimage: PaymentPreimage([1; 32]),
5678+
attribution_data: None,
56745679
};
56755680
let encoded_value = update_fulfill_htlc.encode();
56765681
let target_value = <Vec<u8>>::from_hex("020202020202020202020202020202020202020202020202020202020202020200083a840000034d0101010101010101010101010101010101010101010101010101010101010101").unwrap();

0 commit comments

Comments
 (0)