Skip to content

Commit a617462

Browse files
authored
Merge pull request #2434 from TheBlueMatt/2023-07-116-bindings-part-2
0.0.116 Bindings Changes
2 parents e4c44f3 + 27bf1d0 commit a617462

File tree

10 files changed

+22
-8
lines changed

10 files changed

+22
-8
lines changed

ci/check-compiles.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ cargo doc
77
cargo doc --document-private-items
88
cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo check --features=stdin_fuzz
99
cd ../lightning && cargo check --no-default-features --features=no-std
10+
cd .. && RUSTC_BOOTSTRAP=1 RUSTFLAGS="--cfg=c_bindings" cargo check -Z avoid-dev-deps

lightning/src/chain/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,5 +391,7 @@ where
391391
}
392392

393393
/// A unique identifier to track each pending output claim within a [`ChannelMonitor`].
394+
///
395+
/// This is not exported to bindings users as we just use [u8; 32] directly.
394396
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
395397
pub struct ClaimId(pub [u8; 32]);

lightning/src/events/bump_transaction.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ pub enum BumpTransactionEvent {
341341
/// An input that must be included in a transaction when performing coin selection through
342342
/// [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it
343343
/// must have an empty [`TxIn::script_sig`] when spent.
344+
#[derive(Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
344345
pub struct Input {
345346
/// The unique identifier of the input.
346347
pub outpoint: OutPoint,
@@ -354,7 +355,7 @@ pub struct Input {
354355

355356
/// An unspent transaction output that is available to spend resulting from a successful
356357
/// [`CoinSelection`] attempt.
357-
#[derive(Clone, Debug)]
358+
#[derive(Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
358359
pub struct Utxo {
359360
/// The unique identifier of the output.
360361
pub outpoint: OutPoint,
@@ -421,6 +422,7 @@ impl Utxo {
421422

422423
/// The result of a successful coin selection attempt for a transaction requiring additional UTXOs
423424
/// to cover its fees.
425+
#[derive(Clone, Debug)]
424426
pub struct CoinSelection {
425427
/// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
426428
/// requiring additional fees.

lightning/src/ln/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<T: sealed::Context> Features<T> {
728728
}
729729

730730
/// Returns true if this `Features` object contains required features unknown by `other`.
731-
pub fn requires_unknown_bits_from(&self, other: &Features<T>) -> bool {
731+
pub fn requires_unknown_bits_from(&self, other: &Self) -> bool {
732732
// Bitwise AND-ing with all even bits set except for known features will select required
733733
// unknown features.
734734
self.flags.iter().enumerate().any(|(i, &byte)| {

lightning/src/ln/peer_handler.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ pub type SimpleRefPeerManager<
641641
/// A generic trait which is implemented for all [`PeerManager`]s. This makes bounding functions or
642642
/// structs on any [`PeerManager`] much simpler as only this trait is needed as a bound, rather
643643
/// than the full set of bounds on [`PeerManager`] itself.
644+
///
645+
/// This is not exported to bindings users as general cover traits aren't useful in other
646+
/// languages.
644647
#[allow(missing_docs)]
645648
pub trait APeerManager {
646649
type Descriptor: SocketDescriptor;

lightning/src/offers/invoice.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ impl Bolt12Invoice {
475475
///
476476
/// Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this
477477
/// privacy is lost if a public node id is used for [`Bolt12Invoice::signing_pubkey`].
478+
///
479+
/// This is not exported to bindings users as slices with non-reference types cannot be ABI
480+
/// matched in another language.
478481
pub fn payment_paths(&self) -> &[(BlindedPayInfo, BlindedPath)] {
479482
&self.contents.fields().payment_paths[..]
480483
}

lightning/src/offers/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<T: SeekReadable> TryFrom<Vec<u8>> for ParsedMessage<T> {
116116
}
117117

118118
/// Error when parsing a bech32 encoded message using [`str::parse`].
119-
#[derive(Debug, PartialEq)]
119+
#[derive(Clone, Debug, PartialEq)]
120120
pub enum Bolt12ParseError {
121121
/// The bech32 encoding does not conform to the BOLT 12 requirements for continuing messages
122122
/// across multiple parts (i.e., '+' followed by whitespace).
@@ -135,7 +135,7 @@ pub enum Bolt12ParseError {
135135
}
136136

137137
/// Error when interpreting a TLV stream as a specific type.
138-
#[derive(Debug, PartialEq)]
138+
#[derive(Clone, Debug, PartialEq)]
139139
pub enum Bolt12SemanticError {
140140
/// The current [`std::time::SystemTime`] is past the offer or invoice's expiration.
141141
AlreadyExpired,

lightning/src/onion_message/offers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub trait OffersMessageHandler {
3838
/// Possible BOLT 12 Offers messages sent and received via an [`OnionMessage`].
3939
///
4040
/// [`OnionMessage`]: crate::ln::msgs::OnionMessage
41-
#[derive(Debug)]
41+
#[derive(Clone, Debug)]
4242
pub enum OffersMessage {
4343
/// A request for a [`Bolt12Invoice`] for a particular [`Offer`].
4444
///

lightning/src/sign/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ impl KeysManager {
13121312
///
13131313
/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used
13141314
/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
1315-
pub fn sign_spendable_outputs_psbt<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], psbt: &mut PartiallySignedTransaction, secp_ctx: &Secp256k1<C>) -> Result<(), ()> {
1315+
pub fn sign_spendable_outputs_psbt<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], mut psbt: PartiallySignedTransaction, secp_ctx: &Secp256k1<C>) -> Result<PartiallySignedTransaction, ()> {
13161316
let mut keys_cache: Option<(InMemorySigner, [u8; 32])> = None;
13171317
for outp in descriptors {
13181318
match outp {
@@ -1374,7 +1374,7 @@ impl KeysManager {
13741374
}
13751375
}
13761376

1377-
Ok(())
1377+
Ok(psbt)
13781378
}
13791379

13801380
/// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an
@@ -1396,7 +1396,7 @@ impl KeysManager {
13961396
/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
13971397
pub fn spend_spendable_outputs<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], outputs: Vec<TxOut>, change_destination_script: Script, feerate_sat_per_1000_weight: u32, locktime: Option<PackedLockTime>, secp_ctx: &Secp256k1<C>) -> Result<Transaction, ()> {
13981398
let (mut psbt, expected_max_weight) = SpendableOutputDescriptor::create_spendable_outputs_psbt(descriptors, outputs, change_destination_script, feerate_sat_per_1000_weight, locktime)?;
1399-
self.sign_spendable_outputs_psbt(descriptors, &mut psbt, secp_ctx)?;
1399+
psbt = self.sign_spendable_outputs_psbt(descriptors, psbt, secp_ctx)?;
14001400

14011401
let spend_tx = psbt.extract_tx();
14021402

lightning/src/util/ser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ impl Readable for U48 {
358358
/// encoded in several different ways, which we must check for at deserialization-time. Thus, if
359359
/// you're looking for an example of a variable-length integer to use for your own project, move
360360
/// along, this is a rather poor design.
361+
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
361362
pub struct BigSize(pub u64);
362363
impl Writeable for BigSize {
363364
#[inline]
@@ -1351,13 +1352,15 @@ impl Readable for Hostname {
13511352
}
13521353
}
13531354

1355+
/// This is not exported to bindings users as `Duration`s are simply mapped as ints.
13541356
impl Writeable for Duration {
13551357
#[inline]
13561358
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
13571359
self.as_secs().write(w)?;
13581360
self.subsec_nanos().write(w)
13591361
}
13601362
}
1363+
/// This is not exported to bindings users as `Duration`s are simply mapped as ints.
13611364
impl Readable for Duration {
13621365
#[inline]
13631366
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {

0 commit comments

Comments
 (0)