Skip to content

Commit 36bb2ea

Browse files
f rename
1 parent 42655ce commit 36bb2ea

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

lightning/src/ln/functional_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8039,7 +8039,7 @@ fn test_onion_value_mpp_set_calculation() {
80398039
RecipientOnionFields::secret_only(our_payment_secret), height + 1, &None).unwrap();
80408040
// Edit amt_to_forward to simulate the sender having set
80418041
// the final amount and the routing node taking less fee
8042-
if let msgs::OutboundPayload::Receive { ref mut amt_msat, .. } = onion_payloads[1] {
8042+
if let msgs::OutboundOnionPayload::Receive { ref mut amt_msat, .. } = onion_payloads[1] {
80438043
*amt_msat = 99_000;
80448044
} else { panic!() }
80458045
let new_onion_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys, [0; 32], &our_payment_hash).unwrap();

lightning/src/ln/msgs.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ mod fuzzy_internal_msgs {
14421442
},
14431443
}
14441444

1445-
pub(crate) enum OutboundPayload {
1445+
pub(crate) enum OutboundOnionPayload {
14461446
Forward {
14471447
short_channel_id: u64,
14481448
amt_to_forward: u64,
@@ -1963,7 +1963,7 @@ impl Readable for FinalOnionHopData {
19631963
}
19641964
}
19651965

1966-
impl Writeable for OutboundPayload {
1966+
impl Writeable for OutboundOnionPayload {
19671967
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
19681968
match self {
19691969
Self::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } => {
@@ -3536,7 +3536,7 @@ mod tests {
35363536

35373537
#[test]
35383538
fn encoding_nonfinal_onion_hop_data() {
3539-
let outbound_msg = msgs::OutboundPayload::Forward {
3539+
let outbound_msg = msgs::OutboundOnionPayload::Forward {
35403540
short_channel_id: 0xdeadbeef1bad1dea,
35413541
amt_to_forward: 0x0badf00d01020304,
35423542
outgoing_cltv_value: 0xffffffff,
@@ -3555,7 +3555,7 @@ mod tests {
35553555

35563556
#[test]
35573557
fn encoding_final_onion_hop_data() {
3558-
let outbound_msg = msgs::OutboundPayload::Receive {
3558+
let outbound_msg = msgs::OutboundOnionPayload::Receive {
35593559
payment_data: None,
35603560
payment_metadata: None,
35613561
keysend_preimage: None,
@@ -3576,7 +3576,7 @@ mod tests {
35763576
#[test]
35773577
fn encoding_final_onion_hop_data_with_secret() {
35783578
let expected_payment_secret = PaymentSecret([0x42u8; 32]);
3579-
let outbound_msg = msgs::OutboundPayload::Receive {
3579+
let outbound_msg = msgs::OutboundOnionPayload::Receive {
35803580
payment_data: Some(FinalOnionHopData {
35813581
payment_secret: expected_payment_secret,
35823582
total_msat: 0x1badca1f
@@ -3758,14 +3758,14 @@ mod tests {
37583758
// see above test, needs to be a separate method for use of the serialization macros.
37593759
fn encode_big_payload() -> Result<Vec<u8>, io::Error> {
37603760
use crate::util::ser::HighZeroBytesDroppedBigSize;
3761-
let payload = msgs::OutboundPayload::Forward {
3761+
let payload = msgs::OutboundOnionPayload::Forward {
37623762
short_channel_id: 0xdeadbeef1bad1dea,
37633763
amt_to_forward: 1000,
37643764
outgoing_cltv_value: 0xffffffff,
37653765
};
37663766
let mut encoded_payload = Vec::new();
37673767
let test_bytes = vec![42u8; 1000];
3768-
if let msgs::OutboundPayload::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } = payload {
3768+
if let msgs::OutboundOnionPayload::Forward { short_channel_id, amt_to_forward, outgoing_cltv_value } = payload {
37693769
_encode_varint_length_prefixed_tlv!(&mut encoded_payload, {
37703770
(1, test_bytes, required_vec),
37713771
(2, HighZeroBytesDroppedBigSize(amt_to_forward), required),

lightning/src/ln/onion_route_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ struct BogusOnionHopData {
252252
data: Vec<u8>
253253
}
254254
impl BogusOnionHopData {
255-
fn new(orig: msgs::OutboundPayload) -> Self {
255+
fn new(orig: msgs::OutboundOnionPayload) -> Self {
256256
Self { data: orig.encode() }
257257
}
258258
}
@@ -876,14 +876,14 @@ fn test_always_create_tlv_format_onion_payloads() {
876876
&route.paths[0], 40000, RecipientOnionFields::spontaneous_empty(), cur_height, &None).unwrap();
877877

878878
match onion_payloads[0] {
879-
msgs::OutboundPayload::Forward {..} => {},
879+
msgs::OutboundOnionPayload::Forward {..} => {},
880880
_ => { panic!(
881881
"Should have generated a `msgs::OnionHopDataFormat::NonFinalNode` payload for `hops[0]`,
882882
despite that the features signals no support for variable length onions"
883883
)}
884884
}
885885
match onion_payloads[1] {
886-
msgs::OutboundPayload::Receive {..} => {},
886+
msgs::OutboundOnionPayload::Receive {..} => {},
887887
_ => {panic!(
888888
"Should have generated a `msgs::OnionHopDataFormat::FinalNode` payload for `hops[1]`,
889889
despite that the features signals no support for variable length onions"

lightning/src/ln/onion_utils.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ pub(super) fn construct_onion_keys<T: secp256k1::Signing>(secp_ctx: &Secp256k1<T
149149
}
150150

151151
/// returns the hop data, as well as the first-hop value_msat and CLTV value we should send.
152-
pub(super) fn build_onion_payloads(path: &Path, total_msat: u64, mut recipient_onion: RecipientOnionFields, starting_htlc_offset: u32, keysend_preimage: &Option<PaymentPreimage>) -> Result<(Vec<msgs::OutboundPayload>, u64, u32), APIError> {
152+
pub(super) fn build_onion_payloads(path: &Path, total_msat: u64, mut recipient_onion: RecipientOnionFields, starting_htlc_offset: u32, keysend_preimage: &Option<PaymentPreimage>) -> Result<(Vec<msgs::OutboundOnionPayload>, u64, u32), APIError> {
153153
let mut cur_value_msat = 0u64;
154154
let mut cur_cltv = starting_htlc_offset;
155155
let mut last_short_channel_id = 0;
156-
let mut res: Vec<msgs::OutboundPayload> = Vec::with_capacity(path.hops.len());
156+
let mut res: Vec<msgs::OutboundOnionPayload> = Vec::with_capacity(path.hops.len());
157157

158158
for (idx, hop) in path.hops.iter().rev().enumerate() {
159159
// First hop gets special values so that it can check, on receipt, that everything is
@@ -162,7 +162,7 @@ pub(super) fn build_onion_payloads(path: &Path, total_msat: u64, mut recipient_o
162162
let value_msat = if cur_value_msat == 0 { hop.fee_msat } else { cur_value_msat };
163163
let cltv = if cur_cltv == starting_htlc_offset { hop.cltv_expiry_delta + starting_htlc_offset } else { cur_cltv };
164164
res.insert(0, if idx == 0 {
165-
msgs::OutboundPayload::Receive {
165+
msgs::OutboundOnionPayload::Receive {
166166
payment_data: if let Some(secret) = recipient_onion.payment_secret.take() {
167167
Some(msgs::FinalOnionHopData {
168168
payment_secret: secret,
@@ -175,7 +175,7 @@ pub(super) fn build_onion_payloads(path: &Path, total_msat: u64, mut recipient_o
175175
outgoing_cltv_value: cltv,
176176
}
177177
} else {
178-
msgs::OutboundPayload::Forward {
178+
msgs::OutboundOnionPayload::Forward {
179179
short_channel_id: last_short_channel_id,
180180
amt_to_forward: value_msat,
181181
outgoing_cltv_value: cltv,
@@ -209,7 +209,7 @@ fn shift_slice_right(arr: &mut [u8], amt: usize) {
209209
}
210210

211211
pub(super) fn construct_onion_packet(
212-
payloads: Vec<msgs::OutboundPayload>, onion_keys: Vec<OnionKeys>, prng_seed: [u8; 32],
212+
payloads: Vec<msgs::OutboundOnionPayload>, onion_keys: Vec<OnionKeys>, prng_seed: [u8; 32],
213213
associated_data: &PaymentHash
214214
) -> Result<msgs::OnionPacket, ()> {
215215
let mut packet_data = [0; ONION_DATA_LEN];
@@ -991,7 +991,7 @@ mod tests {
991991
// with raw hex instead of our in-memory enums, as the payloads contains custom types, and
992992
// we have no way of representing that with our enums.
993993
let payloads = vec!(
994-
RawOnionHopData::new(msgs::OutboundPayload::Forward {
994+
RawOnionHopData::new(msgs::OutboundOnionPayload::Forward {
995995
short_channel_id: 1,
996996
amt_to_forward: 15000,
997997
outgoing_cltv_value: 1500,
@@ -1014,12 +1014,12 @@ mod tests {
10141014
RawOnionHopData {
10151015
data: hex::decode("52020236b00402057806080000000000000002fd02013c0102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f").unwrap(),
10161016
},
1017-
RawOnionHopData::new(msgs::OutboundPayload::Forward {
1017+
RawOnionHopData::new(msgs::OutboundOnionPayload::Forward {
10181018
short_channel_id: 3,
10191019
amt_to_forward: 12500,
10201020
outgoing_cltv_value: 1250,
10211021
}),
1022-
RawOnionHopData::new(msgs::OutboundPayload::Forward {
1022+
RawOnionHopData::new(msgs::OutboundOnionPayload::Forward {
10231023
short_channel_id: 4,
10241024
amt_to_forward: 10000,
10251025
outgoing_cltv_value: 1000,
@@ -1098,7 +1098,7 @@ mod tests {
10981098
data: Vec<u8>
10991099
}
11001100
impl RawOnionHopData {
1101-
fn new(orig: msgs::OutboundPayload) -> Self {
1101+
fn new(orig: msgs::OutboundOnionPayload) -> Self {
11021102
Self { data: orig.encode() }
11031103
}
11041104
}

0 commit comments

Comments
 (0)