Skip to content

Commit 7ebc932

Browse files
committed
Update auto-generated bindings to LDK 0.0.116
1 parent 334f673 commit 7ebc932

Some content is hidden

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

46 files changed

+51228
-31734
lines changed

lightning-c-bindings/include/ldk_rust_types.h

Lines changed: 157 additions & 103 deletions
Large diffs are not rendered by default.

lightning-c-bindings/include/lightning.h

Lines changed: 24281 additions & 17236 deletions
Large diffs are not rendered by default.

lightning-c-bindings/include/lightningpp.hpp

Lines changed: 6044 additions & 4461 deletions
Large diffs are not rendered by default.

lightning-c-bindings/src/c_types/derived.rs

Lines changed: 11581 additions & 8148 deletions
Large diffs are not rendered by default.

lightning-c-bindings/src/lightning/blinded_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> bool {
213213
/// Errors if less than two hops are provided or if `node_pk`(s) are invalid.
214214
#[must_use]
215215
#[no_mangle]
216-
pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ {
216+
pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ {
217217
let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); };
218218
let mut ret = lightning::blinded_path::BlindedPath::new_for_message(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1);
219219
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };

lightning-c-bindings/src/lightning/chain/chaininterface.rs

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,20 @@ pub struct BroadcasterInterface {
2626
/// An opaque pointer which is passed to your function implementations as an argument.
2727
/// This has no meaning in the LDK, and can be NULL or any other value.
2828
pub this_arg: *mut c_void,
29-
/// Sends a transaction out to (hopefully) be mined.
30-
pub broadcast_transaction: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction),
29+
/// Sends a list of transactions out to (hopefully) be mined.
30+
/// This only needs to handle the actual broadcasting of transactions, LDK will automatically
31+
/// rebroadcast transactions that haven't made it into a block.
32+
///
33+
/// In some cases LDK may attempt to broadcast a transaction which double-spends another
34+
/// and this isn't a bug and can be safely ignored.
35+
///
36+
/// If more than one transaction is given, these transactions should be considered to be a
37+
/// package and broadcast together. Some of the transactions may or may not depend on each other,
38+
/// be sure to manage both cases correctly.
39+
///
40+
/// Bitcoin transaction packages are defined in BIP 331 and here:
41+
/// https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md
42+
pub broadcast_transactions: extern "C" fn (this_arg: *const c_void, txs: crate::c_types::derived::CVec_TransactionZ),
3143
/// Frees any resources associated with this object given its this_arg pointer.
3244
/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
3345
pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
@@ -38,15 +50,16 @@ unsafe impl Sync for BroadcasterInterface {}
3850
pub(crate) extern "C" fn BroadcasterInterface_clone_fields(orig: &BroadcasterInterface) -> BroadcasterInterface {
3951
BroadcasterInterface {
4052
this_arg: orig.this_arg,
41-
broadcast_transaction: Clone::clone(&orig.broadcast_transaction),
53+
broadcast_transactions: Clone::clone(&orig.broadcast_transactions),
4254
free: Clone::clone(&orig.free),
4355
}
4456
}
4557

4658
use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface;
4759
impl rustBroadcasterInterface for BroadcasterInterface {
48-
fn broadcast_transaction(&self, mut tx: &bitcoin::blockdata::transaction::Transaction) {
49-
(self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(tx))
60+
fn broadcast_transactions(&self, mut txs: &[&bitcoin::blockdata::transaction::Transaction]) {
61+
let mut local_txs = Vec::new(); for item in txs.iter() { local_txs.push( { crate::c_types::Transaction::from_bitcoin((*item)) }); };
62+
(self.broadcast_transactions)(self.this_arg, local_txs.into())
5063
}
5164
}
5265

@@ -68,17 +81,26 @@ impl Drop for BroadcasterInterface {
6881
}
6982
}
7083
}
71-
/// An enum that represents the speed at which we want a transaction to confirm used for feerate
84+
/// An enum that represents the priority at which we want a transaction to confirm used for feerate
7285
/// estimation.
7386
#[derive(Clone)]
7487
#[must_use]
7588
#[repr(C)]
7689
pub enum ConfirmationTarget {
77-
/// We are happy with this transaction confirming slowly when feerate drops some.
90+
/// We'd like a transaction to confirm in the future, but don't want to commit most of the fees
91+
/// required to do so yet. The remaining fees will come via a Child-Pays-For-Parent (CPFP) fee
92+
/// bump of the transaction.
93+
///
94+
/// The feerate returned should be the absolute minimum feerate required to enter most node
95+
/// mempools across the network. Note that if you are not able to obtain this feerate estimate,
96+
/// you should likely use the furthest-out estimate allowed by your fee estimator.
97+
MempoolMinimum,
98+
/// We are happy with a transaction confirming slowly, at least within a day or so worth of
99+
/// blocks.
78100
Background,
79-
/// We'd like this transaction to confirm without major delay, but 12-18 blocks is fine.
101+
/// We'd like a transaction to confirm without major delayed, i.e., within the next 12-24 blocks.
80102
Normal,
81-
/// We'd like this transaction to confirm in the next few blocks.
103+
/// We'd like a transaction to confirm in the next few blocks.
82104
HighPriority,
83105
}
84106
use lightning::chain::chaininterface::ConfirmationTarget as ConfirmationTargetImport;
@@ -88,6 +110,7 @@ impl ConfirmationTarget {
88110
#[allow(unused)]
89111
pub(crate) fn to_native(&self) -> nativeConfirmationTarget {
90112
match self {
113+
ConfirmationTarget::MempoolMinimum => nativeConfirmationTarget::MempoolMinimum,
91114
ConfirmationTarget::Background => nativeConfirmationTarget::Background,
92115
ConfirmationTarget::Normal => nativeConfirmationTarget::Normal,
93116
ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority,
@@ -96,6 +119,7 @@ impl ConfirmationTarget {
96119
#[allow(unused)]
97120
pub(crate) fn into_native(self) -> nativeConfirmationTarget {
98121
match self {
122+
ConfirmationTarget::MempoolMinimum => nativeConfirmationTarget::MempoolMinimum,
99123
ConfirmationTarget::Background => nativeConfirmationTarget::Background,
100124
ConfirmationTarget::Normal => nativeConfirmationTarget::Normal,
101125
ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority,
@@ -104,6 +128,7 @@ impl ConfirmationTarget {
104128
#[allow(unused)]
105129
pub(crate) fn from_native(native: &nativeConfirmationTarget) -> Self {
106130
match native {
131+
nativeConfirmationTarget::MempoolMinimum => ConfirmationTarget::MempoolMinimum,
107132
nativeConfirmationTarget::Background => ConfirmationTarget::Background,
108133
nativeConfirmationTarget::Normal => ConfirmationTarget::Normal,
109134
nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority,
@@ -112,6 +137,7 @@ impl ConfirmationTarget {
112137
#[allow(unused)]
113138
pub(crate) fn native_into(native: nativeConfirmationTarget) -> Self {
114139
match native {
140+
nativeConfirmationTarget::MempoolMinimum => ConfirmationTarget::MempoolMinimum,
115141
nativeConfirmationTarget::Background => ConfirmationTarget::Background,
116142
nativeConfirmationTarget::Normal => ConfirmationTarget::Normal,
117143
nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority,
@@ -124,6 +150,10 @@ pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> Confirm
124150
orig.clone()
125151
}
126152
#[no_mangle]
153+
/// Utility method to constructs a new MempoolMinimum-variant ConfirmationTarget
154+
pub extern "C" fn ConfirmationTarget_mempool_minimum() -> ConfirmationTarget {
155+
ConfirmationTarget::MempoolMinimum}
156+
#[no_mangle]
127157
/// Utility method to constructs a new Background-variant ConfirmationTarget
128158
pub extern "C" fn ConfirmationTarget_background() -> ConfirmationTarget {
129159
ConfirmationTarget::Background}
@@ -153,6 +183,11 @@ pub extern "C" fn ConfirmationTarget_eq(a: &ConfirmationTarget, b: &Confirmation
153183
/// A trait which should be implemented to provide feerate information on a number of time
154184
/// horizons.
155185
///
186+
/// If access to a local mempool is not feasible, feerate estimates should be fetched from a set of
187+
/// third-parties hosting them. Note that this enables them to affect the propagation of your
188+
/// pre-signed transactions at any time and therefore endangers the safety of channels funds. It
189+
/// should be considered carefully as a deployment.
190+
///
156191
/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
157192
/// called from inside the library in response to chain events, P2P events, or timer events).
158193
#[repr(C)]
@@ -168,7 +203,6 @@ pub struct FeeEstimator {
168203
/// The following unit conversions can be used to convert to sats/KW:
169204
/// * satoshis-per-byte * 250
170205
/// * satoshis-per-kbyte / 4
171-
#[must_use]
172206
pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: crate::lightning::chain::chaininterface::ConfirmationTarget) -> u32,
173207
/// Frees any resources associated with this object given its this_arg pointer.
174208
/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.

lightning-c-bindings/src/lightning/chain/chainmonitor.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ pub struct Persist {
159159
///
160160
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
161161
/// [`Writeable::write`]: crate::util::ser::Writeable::write
162-
#[must_use]
163162
pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus,
164163
/// Update one channel's data. The provided [`ChannelMonitor`] has already applied the given
165164
/// update.
@@ -196,7 +195,6 @@ pub struct Persist {
196195
/// [`Writeable::write`]: crate::util::ser::Writeable::write
197196
///
198197
/// Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None
199-
#[must_use]
200198
pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus,
201199
/// Frees any resources associated with this object given its this_arg pointer.
202200
/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
@@ -215,12 +213,12 @@ pub(crate) extern "C" fn Persist_clone_fields(orig: &Persist) -> Persist {
215213
}
216214

217215
use lightning::chain::chainmonitor::Persist as rustPersist;
218-
impl rustPersist<crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner> for Persist {
219-
fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner>, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus {
216+
impl rustPersist<crate::lightning::sign::WriteableEcdsaChannelSigner> for Persist {
217+
fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::sign::WriteableEcdsaChannelSigner>, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus {
220218
let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true });
221219
ret.into_native()
222220
}
223-
fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner>, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus {
221+
fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::sign::WriteableEcdsaChannelSigner>, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus {
224222
let mut local_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false };
225223
let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, local_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true });
226224
ret.into_native()
@@ -247,7 +245,7 @@ impl Drop for Persist {
247245
}
248246

249247
use lightning::chain::chainmonitor::LockedChannelMonitor as nativeLockedChannelMonitorImport;
250-
pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner>;
248+
pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::WriteableEcdsaChannelSigner>;
251249

252250
/// A read-only reference to a current ChannelMonitor.
253251
///
@@ -301,7 +299,7 @@ impl LockedChannelMonitor {
301299
}
302300

303301
use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport;
304-
pub(crate) type nativeChainMonitor = nativeChainMonitorImport<crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner, crate::lightning::chain::Filter, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger, crate::lightning::chain::chainmonitor::Persist>;
302+
pub(crate) type nativeChainMonitor = nativeChainMonitorImport<crate::lightning::sign::WriteableEcdsaChannelSigner, crate::lightning::chain::Filter, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger, crate::lightning::chain::chainmonitor::Persist>;
305303

306304
/// An implementation of [`chain::Watch`] for monitoring channels.
307305
///
@@ -547,9 +545,9 @@ extern "C" fn ChainMonitor_Confirm_best_block_updated(this_arg: *const c_void, h
547545
<nativeChainMonitor as lightning::chain::Confirm<>>::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
548546
}
549547
#[must_use]
550-
extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ {
548+
extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ {
551549
let mut ret = <nativeChainMonitor as lightning::chain::Confirm<>>::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, );
552-
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); };
550+
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); };
553551
local_ret.into()
554552
}
555553

0 commit comments

Comments
 (0)