Skip to content

Commit 447cb60

Browse files
committed
Move [u8; 32] wrapper types to a common module
The `PaymentHash`, `PaymentSecret`, `PaymentPreimage`, and `ChannelId` types are all small wrappers around `[u8; 32]` and are used throughout the codebase but were defined in the top-level `ln/mod.rs` file and the relatively sparsely-populated `ln/channel_id.rs` file. Here we move them to a common `types` module and go ahead and update all our in-crate `use` statements to refer to the new module for bindings. We do, however, leave a `pub use` alias for the old paths to avoid upgrade hassle for users.
1 parent 8084cec commit 447cb60

Some content is hidden

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

51 files changed

+160
-154
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/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};

lightning/src/chain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use bitcoin::network::constants::Network;
1717
use bitcoin::secp256k1::PublicKey;
1818

1919
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent};
20-
use crate::ln::ChannelId;
20+
use crate::ln::types::ChannelId;
2121
use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
2222
use crate::chain::transaction::{OutPoint, TransactionData};
2323
use crate::impl_writeable_tlv_based;

lightning/src/chain/onchaintx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use bitcoin::secp256k1;
2525
use crate::chain::chaininterface::compute_feerate_sat_per_1000_weight;
2626
use crate::sign::{ChannelDerivationParameters, HTLCDescriptor, ChannelSigner, EntropySource, SignerProvider, ecdsa::WriteableEcdsaChannelSigner};
2727
use crate::ln::msgs::DecodeError;
28-
use crate::ln::PaymentPreimage;
28+
use crate::ln::types::PaymentPreimage;
2929
use crate::ln::chan_utils::{self, ChannelTransactionParameters, HTLCOutputInCommitment, HolderCommitmentTransaction};
3030
use crate::chain::ClaimId;
3131
use crate::chain::chaininterface::{ConfirmationTarget, FeeEstimator, BroadcasterInterface, LowerBoundedFeeEstimator};

0 commit comments

Comments
 (0)