Skip to content

Commit 4d39494

Browse files
f rename
1 parent 2a80f6d commit 4d39494

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

fuzz/src/onion_hop_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use crate::utils::test_logger;
1616
pub fn onion_hop_data_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
1717
use lightning::util::ser::Readable;
1818
let mut r = ::std::io::Cursor::new(data);
19-
let _ = <lightning::ln::msgs::InboundPayload as Readable>::read(&mut r);
19+
let _ = <lightning::ln::msgs::InboundOnionPayload as Readable>::read(&mut r);
2020
}
2121

2222
#[no_mangle]
2323
pub extern "C" fn onion_hop_data_run(data: *const u8, datalen: usize) {
2424
use lightning::util::ser::Readable;
2525
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
2626
let mut r = ::std::io::Cursor::new(data);
27-
let _ = <lightning::ln::msgs::InboundPayload as Readable>::read(&mut r);
27+
let _ = <lightning::ln::msgs::InboundOnionPayload as Readable>::read(&mut r);
2828
}

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ where
26172617
}
26182618

26192619
fn construct_fwd_pending_htlc_info(
2620-
&self, msg: &msgs::UpdateAddHTLC, hop_data: msgs::InboundPayload, hop_hmac: [u8; 32],
2620+
&self, msg: &msgs::UpdateAddHTLC, hop_data: msgs::InboundOnionPayload, hop_hmac: [u8; 32],
26212621
new_packet_bytes: [u8; onion_utils::ONION_DATA_LEN], shared_secret: [u8; 32],
26222622
next_packet_pubkey_opt: Option<Result<PublicKey, secp256k1::Error>>
26232623
) -> Result<PendingHTLCInfo, InboundOnionErr> {
@@ -2630,9 +2630,9 @@ where
26302630
};
26312631

26322632
let (short_channel_id, amt_to_forward, outgoing_cltv_value) = match hop_data {
2633-
msgs::InboundPayload::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } =>
2633+
msgs::InboundOnionPayload::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } =>
26342634
(short_channel_id, amt_to_forward, outgoing_cltv_value),
2635-
msgs::InboundPayload::Receive { .. } =>
2635+
msgs::InboundOnionPayload::Receive { .. } =>
26362636
return Err(InboundOnionErr {
26372637
msg: "Final Node OnionHopData provided for us as an intermediary node",
26382638
err_code: 0x4000 | 22,
@@ -2655,12 +2655,12 @@ where
26552655
}
26562656

26572657
fn construct_recv_pending_htlc_info(
2658-
&self, hop_data: msgs::InboundPayload, shared_secret: [u8; 32], payment_hash: PaymentHash,
2658+
&self, hop_data: msgs::InboundOnionPayload, shared_secret: [u8; 32], payment_hash: PaymentHash,
26592659
amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>, allow_underpay: bool,
26602660
counterparty_skimmed_fee_msat: Option<u64>,
26612661
) -> Result<PendingHTLCInfo, InboundOnionErr> {
26622662
let (payment_data, keysend_preimage, onion_amt_msat, outgoing_cltv_value, payment_metadata) = match hop_data {
2663-
msgs::InboundPayload::Receive {
2663+
msgs::InboundOnionPayload::Receive {
26642664
payment_data, keysend_preimage, amt_msat, outgoing_cltv_value, payment_metadata, ..
26652665
} =>
26662666
(payment_data, keysend_preimage, amt_msat, outgoing_cltv_value, payment_metadata),
@@ -2819,7 +2819,7 @@ where
28192819
};
28202820
let (outgoing_scid, outgoing_amt_msat, outgoing_cltv_value, next_packet_pk_opt) = match next_hop {
28212821
onion_utils::Hop::Forward {
2822-
next_hop_data: msgs::InboundPayload::Forward {
2822+
next_hop_data: msgs::InboundOnionPayload::Forward {
28232823
short_channel_id, amt_to_forward, outgoing_cltv_value
28242824
}, ..
28252825
} => {
@@ -2830,7 +2830,7 @@ where
28302830
// We'll do receive checks in [`Self::construct_pending_htlc_info`] so we have access to the
28312831
// inbound channel's state.
28322832
onion_utils::Hop::Receive { .. } => return Ok((next_hop, shared_secret, None)),
2833-
onion_utils::Hop::Forward { next_hop_data: msgs::InboundPayload::Receive { .. }, .. } => {
2833+
onion_utils::Hop::Forward { next_hop_data: msgs::InboundOnionPayload::Receive { .. }, .. } => {
28342834
return_err!("Final Node OnionHopData provided for us as an intermediary node", 0x4000 | 22, &[0; 0]);
28352835
}
28362836
};
@@ -10020,7 +10020,7 @@ mod tests {
1002010020
let node = create_network(1, &node_cfg, &node_chanmgr);
1002110021
let sender_intended_amt_msat = 100;
1002210022
let extra_fee_msat = 10;
10023-
let hop_data = msgs::InboundPayload::Receive {
10023+
let hop_data = msgs::InboundOnionPayload::Receive {
1002410024
amt_msat: 100,
1002510025
outgoing_cltv_value: 42,
1002610026
payment_metadata: None,
@@ -10039,7 +10039,7 @@ mod tests {
1003910039
} else { panic!(); }
1004010040

1004110041
// If amt_received + extra_fee is equal to the sender intended amount, we're fine.
10042-
let hop_data = msgs::InboundPayload::Receive { // This is the same payload as above, InboundPayload doesn't implement Clone
10042+
let hop_data = msgs::InboundOnionPayload::Receive { // This is the same payload as above, InboundOnionPayload doesn't implement Clone
1004310043
amt_msat: 100,
1004410044
outgoing_cltv_value: 42,
1004510045
payment_metadata: None,

lightning/src/ln/msgs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ mod fuzzy_internal_msgs {
14261426
pub total_msat: u64,
14271427
}
14281428

1429-
pub enum InboundPayload {
1429+
pub enum InboundOnionPayload {
14301430
Forward {
14311431
short_channel_id: u64,
14321432
amt_to_forward: u64,
@@ -1989,7 +1989,7 @@ impl Writeable for OnionHopData {
19891989
}
19901990
}
19911991

1992-
impl Readable for InboundPayload {
1992+
impl Readable for InboundOnionPayload {
19931993
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
19941994
let mut amt = HighZeroBytesDroppedBigSize(0u64);
19951995
let mut cltv_value = HighZeroBytesDroppedBigSize(0u32);
@@ -2035,7 +2035,7 @@ impl Readable for InboundPayload {
20352035

20362036
// ReadableArgs because we need onion_utils::decode_next_hop to accommodate payment packets and
20372037
// onion message packets.
2038-
impl ReadableArgs<()> for InboundPayload {
2038+
impl ReadableArgs<()> for InboundOnionPayload {
20392039
fn read<R: Read>(r: &mut R, _arg: ()) -> Result<Self, DecodeError> {
20402040
<Self as Readable>::read(r)
20412041
}
@@ -3548,7 +3548,7 @@ mod tests {
35483548
assert_eq!(encoded_value, target_value);
35493549

35503550
let inbound_msg = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
3551-
if let msgs::InboundPayload::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } = inbound_msg {
3551+
if let msgs::InboundOnionPayload::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } = inbound_msg {
35523552
assert_eq!(short_channel_id, 0xdeadbeef1bad1dea);
35533553
assert_eq!(amt_to_forward, 0x0badf00d01020304);
35543554
assert_eq!(outgoing_cltv_value, 0xffffffff);
@@ -3571,7 +3571,7 @@ mod tests {
35713571
assert_eq!(encoded_value, target_value);
35723572

35733573
let inbound_msg = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
3574-
if let msgs::InboundPayload::Receive { payment_data: None, amt_msat, outgoing_cltv_value, .. } = inbound_msg {
3574+
if let msgs::InboundOnionPayload::Receive { payment_data: None, amt_msat, outgoing_cltv_value, .. } = inbound_msg {
35753575
assert_eq!(amt_msat, 0x0badf00d01020304);
35763576
assert_eq!(outgoing_cltv_value, 0xffffffff);
35773577
} else { panic!(); }
@@ -3597,7 +3597,7 @@ mod tests {
35973597
assert_eq!(encoded_value, target_value);
35983598

35993599
let inbound_msg = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
3600-
if let msgs::InboundPayload::Receive {
3600+
if let msgs::InboundOnionPayload::Receive {
36013601
payment_data: Some(FinalOnionHopData {
36023602
payment_secret,
36033603
total_msat: 0x1badca1f
@@ -3759,7 +3759,7 @@ mod tests {
37593759
// payload length to be encoded over multiple bytes rather than a single u8.
37603760
let big_payload = encode_big_payload().unwrap();
37613761
let mut rd = Cursor::new(&big_payload[..]);
3762-
<msgs::InboundPayload as Readable>::read(&mut rd).unwrap();
3762+
<msgs::InboundOnionPayload as Readable>::read(&mut rd).unwrap();
37633763
}
37643764
// see above test, needs to be a separate method for use of the serialization macros.
37653765
fn encode_big_payload() -> Result<Vec<u8>, io::Error> {

lightning/src/ln/onion_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,11 @@ impl NextPacketBytes for Vec<u8> {
763763
pub(crate) enum Hop {
764764
/// This onion payload was for us, not for forwarding to a next-hop. Contains information for
765765
/// verifying the incoming payment.
766-
Receive(msgs::InboundPayload),
766+
Receive(msgs::InboundOnionPayload),
767767
/// This onion payload needs to be forwarded to a next-hop.
768768
Forward {
769769
/// Onion payload data used in forwarding the payment.
770-
next_hop_data: msgs::InboundPayload,
770+
next_hop_data: msgs::InboundOnionPayload,
771771
/// HMAC of the next hop's onion packet.
772772
next_hop_hmac: [u8; 32],
773773
/// Bytes of the onion packet we're forwarding.

0 commit comments

Comments
 (0)