diff --git a/ci/check-compiles.sh b/ci/check-compiles.sh index 193c2b4ef1f..af88bceee01 100755 --- a/ci/check-compiles.sh +++ b/ci/check-compiles.sh @@ -7,3 +7,4 @@ cargo doc cargo doc --document-private-items cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo check --features=stdin_fuzz cd ../lightning && cargo check --no-default-features --features=no-std +cd .. && RUSTC_BOOTSTRAP=1 RUSTFLAGS="--cfg=c_bindings" cargo check -Z avoid-dev-deps diff --git a/lightning/src/chain/mod.rs b/lightning/src/chain/mod.rs index a32bcb29901..236b10a7b19 100644 --- a/lightning/src/chain/mod.rs +++ b/lightning/src/chain/mod.rs @@ -391,5 +391,7 @@ where } /// A unique identifier to track each pending output claim within a [`ChannelMonitor`]. +/// +/// This is not exported to bindings users as we just use [u8; 32] directly. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct ClaimId(pub [u8; 32]); diff --git a/lightning/src/events/bump_transaction.rs b/lightning/src/events/bump_transaction.rs index 751a43e0233..5963da8e9f2 100644 --- a/lightning/src/events/bump_transaction.rs +++ b/lightning/src/events/bump_transaction.rs @@ -341,6 +341,7 @@ pub enum BumpTransactionEvent { /// An input that must be included in a transaction when performing coin selection through /// [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it /// must have an empty [`TxIn::script_sig`] when spent. +#[derive(Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct Input { /// The unique identifier of the input. pub outpoint: OutPoint, @@ -354,7 +355,7 @@ pub struct Input { /// An unspent transaction output that is available to spend resulting from a successful /// [`CoinSelection`] attempt. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct Utxo { /// The unique identifier of the output. pub outpoint: OutPoint, @@ -421,6 +422,7 @@ impl Utxo { /// The result of a successful coin selection attempt for a transaction requiring additional UTXOs /// to cover its fees. +#[derive(Clone, Debug)] pub struct CoinSelection { /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction /// requiring additional fees. diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 6309eea413a..5de383b1f44 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -728,7 +728,7 @@ impl Features { } /// Returns true if this `Features` object contains required features unknown by `other`. - pub fn requires_unknown_bits_from(&self, other: &Features) -> bool { + pub fn requires_unknown_bits_from(&self, other: &Self) -> bool { // Bitwise AND-ing with all even bits set except for known features will select required // unknown features. self.flags.iter().enumerate().any(|(i, &byte)| { diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 60230af78ef..1a39bbb3ae4 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -641,6 +641,9 @@ pub type SimpleRefPeerManager< /// A generic trait which is implemented for all [`PeerManager`]s. This makes bounding functions or /// structs on any [`PeerManager`] much simpler as only this trait is needed as a bound, rather /// than the full set of bounds on [`PeerManager`] itself. +/// +/// This is not exported to bindings users as general cover traits aren't useful in other +/// languages. #[allow(missing_docs)] pub trait APeerManager { type Descriptor: SocketDescriptor; diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 279e31dd66a..c3d4500aaeb 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -475,6 +475,9 @@ impl Bolt12Invoice { /// /// Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this /// privacy is lost if a public node id is used for [`Bolt12Invoice::signing_pubkey`]. + /// + /// This is not exported to bindings users as slices with non-reference types cannot be ABI + /// matched in another language. pub fn payment_paths(&self) -> &[(BlindedPayInfo, BlindedPath)] { &self.contents.fields().payment_paths[..] } diff --git a/lightning/src/offers/parse.rs b/lightning/src/offers/parse.rs index b722499f251..e9477086ee9 100644 --- a/lightning/src/offers/parse.rs +++ b/lightning/src/offers/parse.rs @@ -116,7 +116,7 @@ impl TryFrom> for ParsedMessage { } /// Error when parsing a bech32 encoded message using [`str::parse`]. -#[derive(Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub enum Bolt12ParseError { /// The bech32 encoding does not conform to the BOLT 12 requirements for continuing messages /// across multiple parts (i.e., '+' followed by whitespace). @@ -135,7 +135,7 @@ pub enum Bolt12ParseError { } /// Error when interpreting a TLV stream as a specific type. -#[derive(Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub enum Bolt12SemanticError { /// The current [`std::time::SystemTime`] is past the offer or invoice's expiration. AlreadyExpired, diff --git a/lightning/src/onion_message/offers.rs b/lightning/src/onion_message/offers.rs index 9a1f59b8459..de373bda1bc 100644 --- a/lightning/src/onion_message/offers.rs +++ b/lightning/src/onion_message/offers.rs @@ -38,7 +38,7 @@ pub trait OffersMessageHandler { /// Possible BOLT 12 Offers messages sent and received via an [`OnionMessage`]. /// /// [`OnionMessage`]: crate::ln::msgs::OnionMessage -#[derive(Debug)] +#[derive(Clone, Debug)] pub enum OffersMessage { /// A request for a [`Bolt12Invoice`] for a particular [`Offer`]. /// diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index c11d47e9ff9..a71bdae8876 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -1312,7 +1312,7 @@ impl KeysManager { /// /// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used /// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. - pub fn sign_spendable_outputs_psbt(&self, descriptors: &[&SpendableOutputDescriptor], psbt: &mut PartiallySignedTransaction, secp_ctx: &Secp256k1) -> Result<(), ()> { + pub fn sign_spendable_outputs_psbt(&self, descriptors: &[&SpendableOutputDescriptor], mut psbt: PartiallySignedTransaction, secp_ctx: &Secp256k1) -> Result { let mut keys_cache: Option<(InMemorySigner, [u8; 32])> = None; for outp in descriptors { match outp { @@ -1374,7 +1374,7 @@ impl KeysManager { } } - Ok(()) + Ok(psbt) } /// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an @@ -1396,7 +1396,7 @@ impl KeysManager { /// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. pub fn spend_spendable_outputs(&self, descriptors: &[&SpendableOutputDescriptor], outputs: Vec, change_destination_script: Script, feerate_sat_per_1000_weight: u32, locktime: Option, secp_ctx: &Secp256k1) -> Result { let (mut psbt, expected_max_weight) = SpendableOutputDescriptor::create_spendable_outputs_psbt(descriptors, outputs, change_destination_script, feerate_sat_per_1000_weight, locktime)?; - self.sign_spendable_outputs_psbt(descriptors, &mut psbt, secp_ctx)?; + psbt = self.sign_spendable_outputs_psbt(descriptors, psbt, secp_ctx)?; let spend_tx = psbt.extract_tx(); diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 0e510760e62..1eb5e7424c8 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -358,6 +358,7 @@ impl Readable for U48 { /// encoded in several different ways, which we must check for at deserialization-time. Thus, if /// you're looking for an example of a variable-length integer to use for your own project, move /// along, this is a rather poor design. +#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct BigSize(pub u64); impl Writeable for BigSize { #[inline] @@ -1351,6 +1352,7 @@ impl Readable for Hostname { } } +/// This is not exported to bindings users as `Duration`s are simply mapped as ints. impl Writeable for Duration { #[inline] fn write(&self, w: &mut W) -> Result<(), io::Error> { @@ -1358,6 +1360,7 @@ impl Writeable for Duration { self.subsec_nanos().write(w) } } +/// This is not exported to bindings users as `Duration`s are simply mapped as ints. impl Readable for Duration { #[inline] fn read(r: &mut R) -> Result {