Skip to content

Commit 1350daa

Browse files
committed
Make FinalOnionHopData public
In 4b5db8c, `channelmanager::PendingHTLCRouting` was made public, exposing a `FinalOnionHopData` field to the world. However, `FinalOnionHopData` was left crate-private, making the enum impossible to construct. There isn't a strong reason for this (even though the `FinalOnionHopData` API is somewhat confusing, being separated from the rest of the onion structs), so we expose it here.
1 parent 7d3b14d commit 1350daa

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lightning/src/ln/msgs.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -1668,23 +1668,31 @@ pub trait OnionMessageHandler: EventsProvider {
16681668
fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures;
16691669
}
16701670

1671+
#[derive(Clone)]
1672+
#[cfg_attr(test, derive(Debug, PartialEq))]
1673+
/// Information communicated in the onion to the recipient for multi-part tracking and proof that
1674+
/// the payment is associated with an invoice.
1675+
pub struct FinalOnionHopData {
1676+
/// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
1677+
/// Because it is generated by the recipient and included in the invoice, it also provides
1678+
/// proof to the recipient that the payment was sent by someone with the generated invoice.
1679+
pub payment_secret: PaymentSecret,
1680+
/// The intended total amount that this payment is for.
1681+
///
1682+
/// Message serialization may panic if this value is more than 21 million Bitcoin.
1683+
pub total_msat: u64,
1684+
}
1685+
16711686
mod fuzzy_internal_msgs {
16721687
use bitcoin::secp256k1::PublicKey;
16731688
use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay};
16741689
use crate::prelude::*;
16751690
use crate::ln::{PaymentPreimage, PaymentSecret};
16761691
use crate::ln::features::BlindedHopFeatures;
1692+
use super::FinalOnionHopData;
16771693

16781694
// These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
16791695
// them from untrusted input):
1680-
#[derive(Clone)]
1681-
#[cfg_attr(test, derive(Debug, PartialEq))]
1682-
pub struct FinalOnionHopData {
1683-
pub payment_secret: PaymentSecret,
1684-
/// The total value, in msat, of the payment as received by the ultimate recipient.
1685-
/// Message serialization may panic if this value is more than 21 million Bitcoin.
1686-
pub total_msat: u64,
1687-
}
16881696

16891697
pub enum InboundOnionPayload {
16901698
Forward {

0 commit comments

Comments
 (0)