Skip to content

Commit 246abc9

Browse files
committed
Update auto-generated bindings to latest upstream
1 parent 73528d7 commit 246abc9

File tree

8 files changed

+282
-167
lines changed

8 files changed

+282
-167
lines changed

lightning-c-bindings/include/ldk_rust_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymen
5555
struct nativeStaticPaymentOutputDescriptorOpaque;
5656
typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor;
5757
struct LDKBaseSign;
58-
typedef struct LDKBaseSign LDKBaseSign;
5958
struct nativeInMemorySignerOpaque;
6059
typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner;
6160
struct nativeKeysManagerOpaque;
@@ -120,7 +119,6 @@ struct nativeErroringMessageHandlerOpaque;
120119
typedef struct nativeErroringMessageHandlerOpaque LDKnativeErroringMessageHandler;
121120
struct nativeMessageHandlerOpaque;
122121
typedef struct nativeMessageHandlerOpaque LDKnativeMessageHandler;
123-
typedef struct LDKSocketDescriptor LDKSocketDescriptor;
124122
struct nativePeerHandleErrorOpaque;
125123
typedef struct nativePeerHandleErrorOpaque LDKnativePeerHandleError;
126124
struct nativePeerManagerOpaque;

lightning-c-bindings/include/lightning.h

Lines changed: 116 additions & 71 deletions
Large diffs are not rendered by default.

lightning-c-bindings/src/lightning/ln/channelmanager.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ pub extern "C" fn ChannelDetails_set_is_funding_locked(this_ptr: &mut ChannelDet
536536
unsafe { &mut *this_ptr.inner }.is_funding_locked = val;
537537
}
538538
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
539-
/// the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
540-
/// channel is not currently negotiating a shutdown.
539+
/// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
541540
///
542541
/// This is a strict superset of `is_funding_locked`.
543542
#[no_mangle]
@@ -546,8 +545,7 @@ pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> boo
546545
*inner_val
547546
}
548547
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
549-
/// the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
550-
/// channel is not currently negotiating a shutdown.
548+
/// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
551549
///
552550
/// This is a strict superset of `is_funding_locked`.
553551
#[no_mangle]

lightning-c-bindings/src/lightning/ln/msgs.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,6 +4014,9 @@ pub enum ErrorAction {
40144014
},
40154015
/// The peer did something harmless that we weren't able to process, just log and ignore
40164016
IgnoreError,
4017+
/// The peer did something harmless that we weren't able to meaningfully process.
4018+
/// If the error is logged, log it at the given level.
4019+
IgnoreAndLog(crate::lightning::util::logger::Level),
40174020
/// The peer did something incorrect. Tell them.
40184021
SendErrorMessage {
40194022
/// The message to send.
@@ -4033,6 +4036,12 @@ impl ErrorAction {
40334036
}
40344037
},
40354038
ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4039+
ErrorAction::IgnoreAndLog (ref a, ) => {
4040+
let mut a_nonref = (*a).clone();
4041+
nativeErrorAction::IgnoreAndLog (
4042+
a_nonref.into_native(),
4043+
)
4044+
},
40364045
ErrorAction::SendErrorMessage {ref msg, } => {
40374046
let mut msg_nonref = (*msg).clone();
40384047
nativeErrorAction::SendErrorMessage {
@@ -4051,6 +4060,11 @@ impl ErrorAction {
40514060
}
40524061
},
40534062
ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4063+
ErrorAction::IgnoreAndLog (mut a, ) => {
4064+
nativeErrorAction::IgnoreAndLog (
4065+
a.into_native(),
4066+
)
4067+
},
40544068
ErrorAction::SendErrorMessage {mut msg, } => {
40554069
nativeErrorAction::SendErrorMessage {
40564070
msg: *unsafe { Box::from_raw(msg.take_inner()) },
@@ -4069,6 +4083,12 @@ impl ErrorAction {
40694083
}
40704084
},
40714085
nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4086+
nativeErrorAction::IgnoreAndLog (ref a, ) => {
4087+
let mut a_nonref = (*a).clone();
4088+
ErrorAction::IgnoreAndLog (
4089+
crate::lightning::util::logger::Level::native_into(a_nonref),
4090+
)
4091+
},
40724092
nativeErrorAction::SendErrorMessage {ref msg, } => {
40734093
let mut msg_nonref = (*msg).clone();
40744094
ErrorAction::SendErrorMessage {
@@ -4087,6 +4107,11 @@ impl ErrorAction {
40874107
}
40884108
},
40894109
nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4110+
nativeErrorAction::IgnoreAndLog (mut a, ) => {
4111+
ErrorAction::IgnoreAndLog (
4112+
crate::lightning::util::logger::Level::native_into(a),
4113+
)
4114+
},
40904115
nativeErrorAction::SendErrorMessage {mut msg, } => {
40914116
ErrorAction::SendErrorMessage {
40924117
msg: crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },

lightning-c-bindings/src/lightning/ln/peer_handler.rs

Lines changed: 93 additions & 54 deletions
Large diffs are not rendered by default.

lightning-c-bindings/src/lightning/util/logger.rs

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,57 @@ use crate::c_types::*;
2323
#[derive(Clone)]
2424
#[repr(C)]
2525
pub enum Level {
26-
///Designates logger being silent
27-
Off,
28-
/// Designates very serious errors
29-
Error,
30-
/// Designates hazardous situations
31-
Warn,
32-
/// Designates useful information
33-
Info,
34-
/// Designates lower priority information
35-
Debug,
3626
/// Designates very low priority, often extremely verbose, information
3727
Trace,
28+
/// Designates lower priority information
29+
Debug,
30+
/// Designates useful information
31+
Info,
32+
/// Designates hazardous situations
33+
Warn,
34+
/// Designates very serious errors
35+
Error,
3836
}
3937
use lightning::util::logger::Level as nativeLevel;
4038
impl Level {
4139
#[allow(unused)]
4240
pub(crate) fn to_native(&self) -> nativeLevel {
4341
match self {
44-
Level::Off => nativeLevel::Off,
45-
Level::Error => nativeLevel::Error,
46-
Level::Warn => nativeLevel::Warn,
47-
Level::Info => nativeLevel::Info,
48-
Level::Debug => nativeLevel::Debug,
4942
Level::Trace => nativeLevel::Trace,
43+
Level::Debug => nativeLevel::Debug,
44+
Level::Info => nativeLevel::Info,
45+
Level::Warn => nativeLevel::Warn,
46+
Level::Error => nativeLevel::Error,
5047
}
5148
}
5249
#[allow(unused)]
5350
pub(crate) fn into_native(self) -> nativeLevel {
5451
match self {
55-
Level::Off => nativeLevel::Off,
56-
Level::Error => nativeLevel::Error,
57-
Level::Warn => nativeLevel::Warn,
58-
Level::Info => nativeLevel::Info,
59-
Level::Debug => nativeLevel::Debug,
6052
Level::Trace => nativeLevel::Trace,
53+
Level::Debug => nativeLevel::Debug,
54+
Level::Info => nativeLevel::Info,
55+
Level::Warn => nativeLevel::Warn,
56+
Level::Error => nativeLevel::Error,
6157
}
6258
}
6359
#[allow(unused)]
6460
pub(crate) fn from_native(native: &nativeLevel) -> Self {
6561
match native {
66-
nativeLevel::Off => Level::Off,
67-
nativeLevel::Error => Level::Error,
68-
nativeLevel::Warn => Level::Warn,
69-
nativeLevel::Info => Level::Info,
70-
nativeLevel::Debug => Level::Debug,
7162
nativeLevel::Trace => Level::Trace,
63+
nativeLevel::Debug => Level::Debug,
64+
nativeLevel::Info => Level::Info,
65+
nativeLevel::Warn => Level::Warn,
66+
nativeLevel::Error => Level::Error,
7267
}
7368
}
7469
#[allow(unused)]
7570
pub(crate) fn native_into(native: nativeLevel) -> Self {
7671
match native {
77-
nativeLevel::Off => Level::Off,
78-
nativeLevel::Error => Level::Error,
79-
nativeLevel::Warn => Level::Warn,
80-
nativeLevel::Info => Level::Info,
81-
nativeLevel::Debug => Level::Debug,
8272
nativeLevel::Trace => Level::Trace,
73+
nativeLevel::Debug => Level::Debug,
74+
nativeLevel::Info => Level::Info,
75+
nativeLevel::Warn => Level::Warn,
76+
nativeLevel::Error => Level::Error,
8377
}
8478
}
8579
}

lightning-c-bindings/src/lightning/util/message_signing.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
//! Note this is not part of the specs, but follows lnd's signing and verifying protocol, which can is defined as follows:
1515
//!
1616
//! signature = zbase32(SigRec(sha256d((\"Lightning Signed Message:\" + msg)))
17-
//! zbase32 from https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt
17+
//! zbase32 from <https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt>
1818
//! SigRec has first byte 31 + recovery id, followed by 64 byte sig.
1919
//!
2020
//! This implementation is compatible with both lnd's and c-lightning's
2121
//!
22-
//! https://lightning.readthedocs.io/lightning-signmessage.7.html
23-
//! https://api.lightning.community/#signmessage
22+
//! <https://lightning.readthedocs.io/lightning-signmessage.7.html>
23+
//! <https://api.lightning.community/#signmessage>
2424
2525
use std::str::FromStr;
2626
use std::ffi::c_void;
@@ -31,8 +31,8 @@ use crate::c_types::*;
3131
/// A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller.
3232
/// Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
3333
#[no_mangle]
34-
pub extern "C" fn sign(mut msg: crate::c_types::u8slice, mut sk: crate::c_types::SecretKey) -> crate::c_types::derived::CResult_StringErrorZ {
35-
let mut ret = lightning::util::message_signing::sign(msg.to_slice(), sk.into_rust());
34+
pub extern "C" fn sign(mut msg: crate::c_types::u8slice, sk: *const [u8; 32]) -> crate::c_types::derived::CResult_StringErrorZ {
35+
let mut ret = lightning::util::message_signing::sign(msg.to_slice(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *sk}[..]).unwrap());
3636
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
3737
local_ret
3838
}
@@ -49,7 +49,7 @@ pub extern "C" fn recover_pk(mut msg: crate::c_types::u8slice, mut sig: crate::c
4949
/// and the PublicKey.
5050
#[no_mangle]
5151
pub extern "C" fn verify(mut msg: crate::c_types::u8slice, mut sig: crate::c_types::Str, mut pk: crate::c_types::PublicKey) -> bool {
52-
let mut ret = lightning::util::message_signing::verify(msg.to_slice(), sig.into_str(), pk.into_rust());
52+
let mut ret = lightning::util::message_signing::verify(msg.to_slice(), sig.into_str(), &pk.into_rust());
5353
ret
5454
}
5555

lightning-c-bindings/src/lightning_invoice/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ use bitcoin::hashes::Hash;
110110
use crate::c_types::*;
111111

112112
}
113+
/// Default expiry time as defined by [BOLT 11].
114+
///
115+
/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
116+
117+
#[no_mangle]
118+
pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME;
119+
/// Default minimum final CLTV expiry as defined by [BOLT 11].
120+
///
121+
/// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is
122+
/// provided in [`MIN_FINAL_CLTV_EXPIRY`].
123+
///
124+
/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
125+
/// [`MIN_FINAL_CLTV_EXPIRY`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY
126+
127+
#[no_mangle]
128+
pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY;
113129
/// **Call this function on startup to ensure that all assumptions about the platform are valid.**
114130
///
115131
/// Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on

0 commit comments

Comments
 (0)