Skip to content

Commit 37c431a

Browse files
authored
Merge pull request #3035 from TheBlueMatt/2024-04-upstream-123-bindings
2 parents a27088d + 376df87 commit 37c431a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+199
-183
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ mod tests {
932932
use lightning::chain::transaction::OutPoint;
933933
use lightning::events::{Event, PathFailure, MessageSendEventsProvider, MessageSendEvent};
934934
use lightning::{get_event_msg, get_event};
935-
use lightning::ln::{PaymentHash, ChannelId};
935+
use lightning::ln::types::{PaymentHash, ChannelId};
936936
use lightning::ln::channelmanager;
937937
use lightning::ln::channelmanager::{BREAKDOWN_TIMEOUT, ChainParameters, MIN_CLTV_EXPIRY_DELTA, PaymentId};
938938
use lightning::ln::features::{ChannelFeatures, NodeFeatures};

lightning-invoice/src/de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use bitcoin::address::WitnessVersion;
1515
use bitcoin::hashes::Hash;
1616
use bitcoin::hashes::sha256;
1717
use crate::prelude::*;
18-
use lightning::ln::PaymentSecret;
18+
use lightning::ln::types::PaymentSecret;
1919
use lightning::routing::gossip::RoutingFees;
2020
use lightning::routing::router::{RouteHint, RouteHintHop};
2121

lightning-invoice/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use core::str;
6565
use serde::{Deserialize, Deserializer,Serialize, Serializer, de::Error};
6666

6767
#[doc(no_inline)]
68-
pub use lightning::ln::PaymentSecret;
68+
pub use lightning::ln::types::PaymentSecret;
6969
#[doc(no_inline)]
7070
pub use lightning::routing::router::{RouteHint, RouteHintHop};
7171
#[doc(no_inline)]
@@ -162,7 +162,7 @@ pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = 18;
162162
/// use secp256k1::Secp256k1;
163163
/// use secp256k1::SecretKey;
164164
///
165-
/// use lightning::ln::PaymentSecret;
165+
/// use lightning::ln::types::PaymentSecret;
166166
///
167167
/// use lightning_invoice::{Currency, InvoiceBuilder};
168168
///
@@ -1877,7 +1877,7 @@ mod test {
18771877
Bolt11SemanticError};
18781878

18791879
let private_key = SecretKey::from_slice(&[42; 32]).unwrap();
1880-
let payment_secret = lightning::ln::PaymentSecret([21; 32]);
1880+
let payment_secret = lightning::ln::types::PaymentSecret([21; 32]);
18811881
let invoice_template = RawBolt11Invoice {
18821882
hrp: RawHrp {
18831883
currency: Currency::Bitcoin,

lightning-invoice/src/payment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use crate::Bolt11Invoice;
1313
use bitcoin::hashes::Hash;
1414

15-
use lightning::ln::PaymentHash;
15+
use lightning::ln::types::PaymentHash;
1616
use lightning::ln::channelmanager::RecipientOnionFields;
1717
use lightning::routing::router::{PaymentParameters, RouteParameters};
1818

@@ -85,7 +85,7 @@ mod tests {
8585
use super::*;
8686
use crate::{InvoiceBuilder, Currency};
8787
use bitcoin::hashes::sha256::Hash as Sha256;
88-
use lightning::ln::PaymentSecret;
88+
use lightning::ln::types::PaymentSecret;
8989
use lightning::routing::router::Payee;
9090
use secp256k1::{SecretKey, PublicKey, Secp256k1};
9191
use core::time::Duration;

lightning-invoice/src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bitcoin::hashes::Hash;
88
use lightning::chain;
99
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
1010
use lightning::sign::{Recipient, NodeSigner, SignerProvider, EntropySource};
11-
use lightning::ln::{PaymentHash, PaymentSecret};
11+
use lightning::ln::types::{PaymentHash, PaymentSecret};
1212
use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, MIN_FINAL_CLTV_EXPIRY_DELTA};
1313
use lightning::ln::channelmanager::{PhantomRouteHints, MIN_CLTV_EXPIRY_DELTA};
1414
use lightning::ln::inbound_payment::{create, create_from_hash, ExpandedKey};
@@ -824,9 +824,9 @@ mod test {
824824
use bitcoin::hashes::sha256::Hash as Sha256;
825825
use lightning::sign::PhantomKeysManager;
826826
use lightning::events::{MessageSendEvent, MessageSendEventsProvider};
827-
use lightning::ln::PaymentHash;
827+
use lightning::ln::types::PaymentHash;
828828
#[cfg(feature = "std")]
829-
use lightning::ln::PaymentPreimage;
829+
use lightning::ln::types::PaymentPreimage;
830830
use lightning::ln::channelmanager::{PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY_DELTA, PaymentId, RecipientOnionFields, Retry};
831831
use lightning::ln::functional_test_utils::*;
832832
use lightning::ln::msgs::ChannelMessageHandler;

lightning/src/blinded_path/message.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
33
#[allow(unused_imports)]
44
use crate::prelude::*;
55

6-
use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode, NodeIdLookUp};
6+
use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode, NextMessageHop, NodeIdLookUp};
77
use crate::blinded_path::utils;
88
use crate::io;
99
use crate::io::Cursor;
@@ -20,7 +20,7 @@ use core::ops::Deref;
2020
/// route, they are encoded into [`BlindedHop::encrypted_payload`].
2121
pub(crate) struct ForwardTlvs {
2222
/// The next hop in the onion message's path.
23-
pub(crate) next_hop: NextHop,
23+
pub(crate) next_hop: NextMessageHop,
2424
/// Senders to a blinded path use this value to concatenate the route they find to the
2525
/// introduction node with the blinded path.
2626
pub(crate) next_blinding_override: Option<PublicKey>,
@@ -34,20 +34,11 @@ pub(crate) struct ReceiveTlvs {
3434
pub(crate) path_id: Option<[u8; 32]>,
3535
}
3636

37-
/// The next hop to forward the onion message along its path.
38-
#[derive(Debug)]
39-
pub enum NextHop {
40-
/// The node id of the next hop.
41-
NodeId(PublicKey),
42-
/// The short channel id leading to the next hop.
43-
ShortChannelId(u64),
44-
}
45-
4637
impl Writeable for ForwardTlvs {
4738
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
4839
let (next_node_id, short_channel_id) = match self.next_hop {
49-
NextHop::NodeId(pubkey) => (Some(pubkey), None),
50-
NextHop::ShortChannelId(scid) => (None, Some(scid)),
40+
NextMessageHop::NodeId(pubkey) => (Some(pubkey), None),
41+
NextMessageHop::ShortChannelId(scid) => (None, Some(scid)),
5142
};
5243
// TODO: write padding
5344
encode_tlv_stream!(writer, {
@@ -75,7 +66,7 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
7566
) -> Result<Vec<BlindedHop>, secp256k1::Error> {
7667
let blinded_tlvs = unblinded_path.iter()
7768
.skip(1) // The first node's TLVs contains the next node's pubkey
78-
.map(|pk| ForwardTlvs { next_hop: NextHop::NodeId(*pk), next_blinding_override: None })
69+
.map(|pk| ForwardTlvs { next_hop: NextMessageHop::NodeId(*pk), next_blinding_override: None })
7970
.map(|tlvs| ControlTlvs::Forward(tlvs))
8071
.chain(core::iter::once(ControlTlvs::Receive(ReceiveTlvs { path_id: None })));
8172

@@ -102,8 +93,8 @@ where
10293
readable: ControlTlvs::Forward(ForwardTlvs { next_hop, next_blinding_override })
10394
}) => {
10495
let next_node_id = match next_hop {
105-
NextHop::NodeId(pubkey) => pubkey,
106-
NextHop::ShortChannelId(scid) => match node_id_lookup.next_node_id(scid) {
96+
NextMessageHop::NodeId(pubkey) => pubkey,
97+
NextMessageHop::ShortChannelId(scid) => match node_id_lookup.next_node_id(scid) {
10798
Some(pubkey) => pubkey,
10899
None => return Err(()),
109100
},

lightning/src/blinded_path/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ use crate::util::ser::{Readable, Writeable, Writer};
2424
use crate::io;
2525
use crate::prelude::*;
2626

27+
/// The next hop to forward an onion message along its path.
28+
///
29+
/// Note that payment blinded paths always specify their next hop using an explicit node id.
30+
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
31+
pub enum NextMessageHop {
32+
/// The node id of the next hop.
33+
NodeId(PublicKey),
34+
/// The short channel id leading to the next hop.
35+
ShortChannelId(u64),
36+
}
37+
2738
/// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
2839
/// identity of the recipient.
2940
#[derive(Clone, Debug, Hash, PartialEq, Eq)]

lightning/src/blinded_path/payment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
77
use crate::blinded_path::BlindedHop;
88
use crate::blinded_path::utils;
99
use crate::io;
10-
use crate::ln::PaymentSecret;
10+
use crate::ln::types::PaymentSecret;
1111
use crate::ln::channelmanager::CounterpartyForwardingInfo;
1212
use crate::ln::features::BlindedHopFeatures;
1313
use crate::ln::msgs::DecodeError;
@@ -425,7 +425,7 @@ impl_writeable_tlv_based!(Bolt12RefundContext, {});
425425
mod tests {
426426
use bitcoin::secp256k1::PublicKey;
427427
use crate::blinded_path::payment::{ForwardNode, ForwardTlvs, ReceiveTlvs, PaymentConstraints, PaymentContext, PaymentRelay};
428-
use crate::ln::PaymentSecret;
428+
use crate::ln::types::PaymentSecret;
429429
use crate::ln::features::BlindedHopFeatures;
430430
use crate::ln::functional_test_utils::TEST_FINAL_CLTV;
431431

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::chain::{ChannelMonitorUpdateStatus, Filter, WatchedOutput};
3131
use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
3232
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, Balance, MonitorEvent, TransactionOutputs, WithChannelMonitor, LATENCY_GRACE_PERIOD_BLOCKS};
3333
use crate::chain::transaction::{OutPoint, TransactionData};
34-
use crate::ln::ChannelId;
34+
use crate::ln::types::ChannelId;
3535
use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
3636
use crate::events;
3737
use crate::events::{Event, EventHandler};

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use bitcoin::secp256k1;
3434
use bitcoin::sighash::EcdsaSighashType;
3535

3636
use crate::ln::channel::INITIAL_COMMITMENT_NUMBER;
37-
use crate::ln::{PaymentHash, PaymentPreimage, ChannelId};
37+
use crate::ln::types::{PaymentHash, PaymentPreimage, ChannelId};
3838
use crate::ln::msgs::DecodeError;
3939
use crate::ln::channel_keys::{DelayedPaymentKey, DelayedPaymentBasepoint, HtlcBasepoint, HtlcKey, RevocationKey, RevocationBasepoint};
4040
use crate::ln::chan_utils::{self,CommitmentTransaction, CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HTLCClaim, ChannelTransactionParameters, HolderCommitmentTransaction, TxCreationKeys};
@@ -4811,7 +4811,7 @@ mod tests {
48114811
use crate::chain::package::{weight_offered_htlc, weight_received_htlc, weight_revoked_offered_htlc, weight_revoked_received_htlc, WEIGHT_REVOKED_OUTPUT};
48124812
use crate::chain::transaction::OutPoint;
48134813
use crate::sign::InMemorySigner;
4814-
use crate::ln::{PaymentPreimage, PaymentHash, ChannelId};
4814+
use crate::ln::types::{PaymentPreimage, PaymentHash, ChannelId};
48154815
use crate::ln::channel_keys::{DelayedPaymentBasepoint, DelayedPaymentKey, HtlcBasepoint, RevocationBasepoint, RevocationKey};
48164816
use crate::ln::chan_utils::{self,HTLCOutputInCommitment, ChannelPublicKeys, ChannelTransactionParameters, HolderCommitmentTransaction, CounterpartyChannelTransactionParameters};
48174817
use crate::ln::channelmanager::{PaymentSendFailure, PaymentId, RecipientOnionFields};

0 commit comments

Comments
 (0)