Skip to content

Commit 186cc67

Browse files
committed
Add annotations for things which we cannot (yet) expose
1 parent 0cce026 commit 186cc67

File tree

11 files changed

+70
-0
lines changed

11 files changed

+70
-0
lines changed

lightning/src/chain/chaininterface.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub enum ChainError {
3838
/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
3939
/// called from inside the library in response to ChainListener events, P2P events, or timer
4040
/// events).
41+
/// (C-not exported) due to tuples and Result<>s
4142
pub trait ChainWatchInterface: Sync + Send {
4243
/// Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
4344
fn install_watch_tx(&self, txid: &Txid, script_pub_key: &Script);
@@ -72,6 +73,7 @@ pub trait BroadcasterInterface: Sync + Send {
7273
}
7374

7475
/// A trait indicating a desire to listen for events from the chain
76+
/// (C-not exported)
7577
pub trait ChainListener: Sync + Send {
7678
/// Notifies a listener that a block was connected.
7779
///
@@ -128,6 +130,7 @@ pub trait FeeEstimator: Sync + Send {
128130
pub const MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = 4000;
129131

130132
/// Utility for tracking registered txn/outpoints and checking for matches
133+
/// (C-not exported)
131134
#[cfg_attr(test, derive(PartialEq))]
132135
pub struct ChainWatchedUtil {
133136
watch_all: bool,
@@ -169,6 +172,7 @@ impl ChainWatchedUtil {
169172

170173
/// Registers an outpoint for monitoring, returning true if it was a new outpoint and false if
171174
/// we'd already been watching for it
175+
/// (C-not exported) due to tuples
172176
pub fn register_outpoint(&mut self, outpoint: (Txid, u32), _script_pub_key: &Script) -> bool {
173177
if self.watch_all { return false; }
174178
self.watched_outpoints.insert(outpoint)
@@ -220,6 +224,7 @@ impl ChainWatchedUtil {
220224
/// parameters with static lifetimes). Other times you can afford a reference, which is more
221225
/// efficient, in which case BlockNotifierRef is a more appropriate type. Defining these type
222226
/// aliases prevents issues such as overly long function definitions.
227+
/// (C-not exported)
223228
pub type BlockNotifierArc = Arc<BlockNotifier<'static, Arc<ChainListener>>>;
224229

225230
/// BlockNotifierRef is useful when you want a BlockNotifier that points to ChainListeners
@@ -238,6 +243,7 @@ pub type BlockNotifierRef<'a> = BlockNotifier<'a, &'a ChainListener>;
238243
/// or a BlockNotifierRef for conciseness. See their documentation for more details, but essentially
239244
/// you should default to using a BlockNotifierRef, and use a BlockNotifierArc instead when you
240245
/// require ChainListeners with static lifetimes, such as when you're using lightning-net-tokio.
246+
/// (C-not exported) due to ChainListener not being exported
241247
pub struct BlockNotifier<'a, CL: Deref<Target = ChainListener + 'a> + 'a> {
242248
listeners: Mutex<Vec<CL>>,
243249
chain_monitor: Arc<ChainWatchInterface>,
@@ -312,6 +318,7 @@ impl<'a, CL: Deref<Target = ChainListener + 'a> + 'a> BlockNotifier<'a, CL> {
312318
/// Utility to capture some common parts of ChainWatchInterface implementors.
313319
///
314320
/// Keeping a local copy of this in a ChainWatchInterface implementor is likely useful.
321+
/// (C-not exported)
315322
pub struct ChainWatchInterfaceUtil {
316323
network: Network,
317324
watched: Mutex<ChainWatchedUtil>,

lightning/src/chain/keysinterface.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,26 +170,34 @@ impl Readable for SpendableOutputDescriptor {
170170
// TODO: We should remove Clone by instead requesting a new ChannelKeys copy when we create
171171
// ChannelMonitors instead of expecting to clone the one out of the Channel into the monitors.
172172
pub trait ChannelKeys : Send+Clone {
173+
/// (C-not exported) due to references
173174
/// Gets the private key for the anchor tx
174175
fn funding_key<'a>(&'a self) -> &'a SecretKey;
175176
/// Gets the local secret key for blinded revocation pubkey
177+
/// (C-not exported) due to references
176178
fn revocation_base_key<'a>(&'a self) -> &'a SecretKey;
177179
/// Gets the local secret key used in the to_remote output of remote commitment tx (ie the
178180
/// output to us in transactions our counterparty broadcasts).
179181
/// Also as part of obscured commitment number.
182+
/// (C-not exported) due to references
180183
fn payment_key<'a>(&'a self) -> &'a SecretKey;
181184
/// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
185+
/// (C-not exported) due to references
182186
fn delayed_payment_base_key<'a>(&'a self) -> &'a SecretKey;
183187
/// Gets the local htlc secret key used in commitment tx htlc outputs
188+
/// (C-not exported) due to references
184189
fn htlc_base_key<'a>(&'a self) -> &'a SecretKey;
185190
/// Gets the commitment seed
191+
/// (C-not exported) due to references
186192
fn commitment_seed<'a>(&'a self) -> &'a [u8; 32];
187193
/// Gets the local channel public keys and basepoints
194+
/// (C-not exported) due to references
188195
fn pubkeys<'a>(&'a self) -> &'a ChannelPublicKeys;
189196

190197
/// Create a signature for a remote commitment transaction and associated HTLC transactions.
191198
///
192199
/// Note that if signing fails or is rejected, the channel will be force-closed.
200+
/// (C-not exported) due to references
193201
//
194202
// TODO: Document the things someone using this interface should enforce before signing.
195203
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
@@ -199,6 +207,7 @@ pub trait ChannelKeys : Send+Clone {
199207
/// Create a signature for a local commitment transaction. This will only ever be called with
200208
/// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
201209
/// that it will not be called multiple times.
210+
/// (C-not exported) due to references
202211
//
203212
// TODO: Document the things someone using this interface should enforce before signing.
204213
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
@@ -224,12 +233,14 @@ pub trait ChannelKeys : Send+Clone {
224233
/// (implying they were considered dust at the time the commitment transaction was negotiated),
225234
/// a corresponding None should be included in the return value. All other positions in the
226235
/// return value must contain a signature.
236+
/// (C-not exported) due to references
227237
fn sign_local_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, local_csv: u16, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()>;
228238

229239
/// Create a signature for a (proposed) closing transaction.
230240
///
231241
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
232242
/// chosen to forgo their output as dust.
243+
/// (C-not exported) due to references
233244
fn sign_closing_transaction<T: secp256k1::Signing>(&self, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
234245

235246
/// Signs a channel announcement message with our funding key, proving it comes from one
@@ -238,12 +249,14 @@ pub trait ChannelKeys : Send+Clone {
238249
/// Note that if this fails or is rejected, the channel will not be publicly announced and
239250
/// our counterparty may (though likely will not) close the channel on us for violating the
240251
/// protocol.
252+
/// (C-not exported) due to references
241253
fn sign_channel_announcement<T: secp256k1::Signing>(&self, msg: &msgs::UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
242254

243255
/// Set the remote channel basepoints. This is done immediately on incoming channels
244256
/// and as soon as the channel is accepted on outgoing channels.
245257
///
246258
/// Will be called before any signatures are applied.
259+
/// (C-not exported) due to references
247260
fn set_remote_channel_pubkeys(&mut self, channel_points: &ChannelPublicKeys);
248261
}
249262

@@ -261,8 +274,10 @@ pub trait KeysInterface: Send + Sync {
261274
fn get_shutdown_pubkey(&self) -> PublicKey;
262275
/// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
263276
/// restarted with some stale data!
277+
/// (C-not exported) due to Self (though it *should* work...)
264278
fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> Self::ChanKeySigner;
265279
/// Get a secret and PRNG seed for construting an onion packet
280+
/// (C-not exported) due to tuple
266281
fn get_onion_rand(&self) -> (SecretKey, [u8; 32]);
267282
/// Get a unique temporary channel id. Channels will be referred to by this until the funding
268283
/// transaction is created, at which point they will use the outpoint in the funding
@@ -295,6 +310,7 @@ pub struct InMemoryChannelKeys {
295310

296311
impl InMemoryChannelKeys {
297312
/// Create a new InMemoryChannelKeys
313+
/// (C-not exported) due to secp context
298314
pub fn new<C: Signing>(
299315
secp_ctx: &Secp256k1<C>,
300316
funding_key: SecretKey,

lightning/src/chain/transaction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl OutPoint {
2626
}
2727

2828
/// Converts this OutPoint into the OutPoint field as used by rust-bitcoin
29+
/// (C-not exported)
2930
pub fn into_bitcoin_outpoint(self) -> BitcoinOutPoint {
3031
BitcoinOutPoint {
3132
txid: self.txid,

lightning/src/ln/chan_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ pub fn build_htlc_transaction(prev_hash: &Txid, feerate_per_kw: u64, to_self_del
481481
/// We use this to track local commitment transactions and put off signing them until we are ready
482482
/// to broadcast. Eventually this will require a signer which is possibly external, but for now we
483483
/// just pass in the SecretKeys required.
484+
/// (C-not exported)
484485
pub struct LocalCommitmentTransaction {
485486
// TODO: We should migrate away from providing the transaction, instead providing enough to
486487
// allow the ChannelKeys to construct it from scratch. Luckily we already have HTLC data here,

lightning/src/ln/channelmanager.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,15 @@ pub(super) enum HTLCFailReason {
169169
}
170170

171171
/// payment_hash type, use to cross-lock hop
172+
/// (C-not exported) as we just use [u8; 32] directly
172173
#[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
173174
pub struct PaymentHash(pub [u8;32]);
174175
/// payment_preimage type, use to route payment between hop
176+
/// (C-not exported) as we just use [u8; 32] directly
175177
#[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
176178
pub struct PaymentPreimage(pub [u8;32]);
177179
/// payment_secret type, use to authenticate sender to the receiver and tie MPP HTLCs together
180+
/// (C-not exported) as we just use [u8; 32] directly
178181
#[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
179182
pub struct PaymentSecret(pub [u8;32]);
180183

@@ -753,6 +756,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
753756
///
754757
/// Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
755758
/// greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
759+
/// (C-not exported) due to Result
756760
pub fn create_channel(&self, their_network_key: PublicKey, channel_value_satoshis: u64, push_msat: u64, user_id: u64, override_config: Option<UserConfig>) -> Result<(), APIError> {
757761
if channel_value_satoshis < 1000 {
758762
return Err(APIError::APIMisuseError { err: "channel_value must be at least 1000 satoshis" });
@@ -812,6 +816,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
812816

813817
/// Gets the list of open channels, in random order. See ChannelDetail field documentation for
814818
/// more information.
819+
/// (C-not exported) due to Vec
815820
pub fn list_channels(&self) -> Vec<ChannelDetails> {
816821
self.list_channels_with_filter(|_| true)
817822
}
@@ -821,6 +826,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
821826
///
822827
/// These are guaranteed to have their is_live value set to true, see the documentation for
823828
/// ChannelDetails::is_live for more info on exactly what the criteria are.
829+
/// (C-not exported) due to Vec
824830
pub fn list_usable_channels(&self) -> Vec<ChannelDetails> {
825831
// Note we use is_live here instead of usable which leads to somewhat confused
826832
// internal/external nomenclature, but that's ok cause that's probably what the user
@@ -833,6 +839,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
833839
/// pending HTLCs, the channel will be closed on chain.
834840
///
835841
/// May generate a SendShutdown message event on success, which should be relayed.
842+
/// (C-not exported) due to Result
836843
pub fn close_channel(&self, channel_id: &[u8; 32]) -> Result<(), APIError> {
837844
let _ = self.total_consistency_lock.read().unwrap();
838845

@@ -1339,6 +1346,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
13391346
/// If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
13401347
/// bit set (either as required or as available). If multiple paths are present in the Route,
13411348
/// we assume the invoice had the basic_mpp feature set.
1349+
/// (C-not exported) due to Option + Result
13421350
pub fn send_payment(&self, route: &Route, payment_hash: PaymentHash, payment_secret: &Option<PaymentSecret>) -> Result<(), PaymentSendFailure> {
13431351
if route.paths.len() < 1 {
13441352
return Err(PaymentSendFailure::ParameterError(APIError::RouteError{err: "There must be at least one path to send over"}));
@@ -1406,6 +1414,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
14061414
///
14071415
/// May panic if the funding_txo is duplicative with some other channel (note that this should
14081416
/// be trivially prevented by using unique funding transaction keys per-channel).
1417+
/// (C-not exported) due to OutPoint
14091418
pub fn funding_transaction_generated(&self, temporary_channel_id: &[u8; 32], funding_txo: OutPoint) {
14101419
let _ = self.total_consistency_lock.read().unwrap();
14111420

@@ -1489,6 +1498,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
14891498
/// only Tor Onion addresses.
14901499
///
14911500
/// Panics if addresses is absurdly large (more than 500).
1501+
/// (C-not exported) due to Vec
14921502
pub fn broadcast_node_announcement(&self, rgb: [u8; 3], alias: [u8; 32], addresses: Vec<msgs::NetAddress>) {
14931503
let _ = self.total_consistency_lock.read().unwrap();
14941504

@@ -1797,6 +1807,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
17971807
/// along the path (including in our own channel on which we received it).
17981808
/// Returns false if no payment was found to fail backwards, true if the process of failing the
17991809
/// HTLC backwards has been started.
1810+
/// (C-not exported) due to Option
18001811
pub fn fail_htlc_backwards(&self, payment_hash: &PaymentHash, payment_secret: &Option<PaymentSecret>) -> bool {
18011812
let _ = self.total_consistency_lock.read().unwrap();
18021813

@@ -1936,6 +1947,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
19361947
/// set. Thus, for such payments we will claim any payments which do not under-pay.
19371948
///
19381949
/// May panic if called except in response to a PaymentReceived event.
1950+
/// (C-not exported) due to Option
19391951
pub fn claim_funds(&self, payment_preimage: PaymentPreimage, payment_secret: &Option<PaymentSecret>, expected_amount: u64) -> bool {
19401952
let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0).into_inner());
19411953

@@ -2123,6 +2135,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
21232135
/// 3) update(s) are applied to each remote copy of a ChannelMonitor,
21242136
/// 4) once all remote copies are updated, you call this function with the update_id that
21252137
/// completed, and once it is the latest the Channel will be re-enabled.
2138+
/// (C-not exported) due to OutPoint
21262139
pub fn channel_monitor_updated(&self, funding_txo: &OutPoint, highest_applied_update_id: u64) {
21272140
let _ = self.total_consistency_lock.read().unwrap();
21282141

@@ -2833,6 +2846,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
28332846
/// If successful, will generate a UpdateHTLCs event, so you should probably poll
28342847
/// PeerManager::process_events afterwards.
28352848
/// Note: This API is likely to change!
2849+
/// (C-not exported) Cause its doc(hidden) anyway
28362850
#[doc(hidden)]
28372851
pub fn update_fee(&self, channel_id: [u8;32], feerate_per_kw: u64) -> Result<(), APIError> {
28382852
let _ = self.total_consistency_lock.read().unwrap();
@@ -3627,6 +3641,7 @@ impl<ChanSigner: ChannelKeys + Writeable, M: Deref, T: Deref, K: Deref, F: Deref
36273641
/// 5) Move the ChannelMonitors into your local ManyChannelMonitor.
36283642
/// 6) Disconnect/connect blocks on the ChannelManager.
36293643
/// 7) Register the new ChannelManager with your ChainWatchInterface.
3644+
/// (C-not exported) due to references
36303645
pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref>
36313646
where M::Target: ManyChannelMonitor<Keys=ChanSigner>,
36323647
T::Target: BroadcasterInterface,

0 commit comments

Comments
 (0)