|
7 | 7 | // You may not use this file except in accordance with one or both of these |
8 | 8 | // licenses. |
9 | 9 |
|
| 10 | +//! Utilities for handling and manipulating onions |
| 11 | +
|
10 | 12 | use super::msgs::OnionErrorPacket; |
11 | 13 | use crate::blinded_path::BlindedHop; |
12 | 14 | use crate::crypto::chacha20::ChaCha20; |
@@ -985,7 +987,7 @@ pub use self::fuzzy_onion_utils::*; |
985 | 987 | #[cfg(not(fuzzing))] |
986 | 988 | pub(crate) use self::fuzzy_onion_utils::*; |
987 | 989 |
|
988 | | -pub fn process_onion_failure<T: secp256k1::Signing, L: Deref>( |
| 990 | +pub(crate) fn process_onion_failure<T: secp256k1::Signing, L: Deref>( |
989 | 991 | secp_ctx: &Secp256k1<T>, logger: &L, htlc_source: &HTLCSource, |
990 | 992 | encrypted_packet: OnionErrorPacket, |
991 | 993 | ) -> DecodedOnionFailure |
@@ -1467,7 +1469,7 @@ where |
1467 | 1469 | } |
1468 | 1470 |
|
1469 | 1471 | /// Decodes the attribution data that we got back from upstream on a payment we sent. |
1470 | | -pub fn decode_fulfill_attribution_data<T: secp256k1::Signing, L: Deref>( |
| 1472 | +pub(crate) fn decode_fulfill_attribution_data<T: secp256k1::Signing, L: Deref>( |
1471 | 1473 | secp_ctx: &Secp256k1<T>, logger: &L, path: &Path, outer_session_priv: &SecretKey, |
1472 | 1474 | mut attribution_data: AttributionData, |
1473 | 1475 | ) -> Vec<u32> |
@@ -2708,16 +2710,16 @@ fn decode_next_hop<T, R: ReadableArgs<T>, N: NextPacketBytes>( |
2708 | 2710 | } |
2709 | 2711 | } |
2710 | 2712 |
|
2711 | | -pub const HOLD_TIME_LEN: usize = 4; |
2712 | | -pub const MAX_HOPS: usize = 20; |
2713 | | -pub const HMAC_LEN: usize = 4; |
| 2713 | +pub(crate) const HOLD_TIME_LEN: usize = 4; |
| 2714 | +pub(crate) const MAX_HOPS: usize = 20; |
| 2715 | +pub(crate) const HMAC_LEN: usize = 4; |
2714 | 2716 |
|
2715 | 2717 | // Define the number of HMACs in the attributable data block. For the first node, there are 20 HMACs, and then for every |
2716 | 2718 | // subsequent node, the number of HMACs decreases by 1. 20 + 19 + 18 + ... + 1 = 20 * 21 / 2 = 210. |
2717 | | -pub const HMAC_COUNT: usize = MAX_HOPS * (MAX_HOPS + 1) / 2; |
| 2719 | +pub(crate) const HMAC_COUNT: usize = MAX_HOPS * (MAX_HOPS + 1) / 2; |
2718 | 2720 |
|
2719 | 2721 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] |
2720 | | -pub struct AttributionData { |
| 2722 | +pub(crate) struct AttributionData { |
2721 | 2723 | pub hold_times: [u8; MAX_HOPS * HOLD_TIME_LEN], |
2722 | 2724 | pub hmacs: [u8; HMAC_LEN * HMAC_COUNT], |
2723 | 2725 | } |
|
0 commit comments