Skip to content

Commit 8a4b001

Browse files
committed
- bindings updates
1 parent 6742343 commit 8a4b001

File tree

8 files changed

+279
-105
lines changed

8 files changed

+279
-105
lines changed

lightning-c-bindings/include/lightning.h

Lines changed: 110 additions & 43 deletions
Large diffs are not rendered by default.

lightning-c-bindings/include/lightningpp.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,21 @@ class ChannelManager {
806806
const LDKChannelManager* operator &() const { return &self; }
807807
const LDKChannelManager* operator ->() const { return &self; }
808808
};
809+
class ChainParameters {
810+
private:
811+
LDKChainParameters self;
812+
public:
813+
ChainParameters(const ChainParameters&) = delete;
814+
ChainParameters(ChainParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChainParameters)); }
815+
ChainParameters(LDKChainParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainParameters)); }
816+
operator LDKChainParameters() && { LDKChainParameters res = self; memset(&self, 0, sizeof(LDKChainParameters)); return res; }
817+
~ChainParameters() { ChainParameters_free(self); }
818+
ChainParameters& operator=(ChainParameters&& o) { ChainParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChainParameters)); return *this; }
819+
LDKChainParameters* operator &() { return &self; }
820+
LDKChainParameters* operator ->() { return &self; }
821+
const LDKChainParameters* operator &() const { return &self; }
822+
const LDKChainParameters* operator ->() const { return &self; }
823+
};
809824
class ChannelDetails {
810825
private:
811826
LDKChannelDetails self;

lightning-c-bindings/include/rust_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ struct nativeChannelMonitorOpaque;
8181
typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor;
8282
struct nativeChannelManagerOpaque;
8383
typedef struct nativeChannelManagerOpaque LDKnativeChannelManager;
84+
struct nativeChainParametersOpaque;
85+
typedef struct nativeChainParametersOpaque LDKnativeChainParameters;
8486
struct nativeChannelDetailsOpaque;
8587
typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
8688
struct nativeChannelManagerReadArgsOpaque;

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ type nativeChannelMonitor = nativeChannelMonitorImport<crate::chain::keysinterfa
455455
/// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
456456
/// gotten are fully handled before re-serializing the new state.
457457
///
458-
/// Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
458+
/// Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which
459459
/// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
460460
/// the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
461461
/// returned block hash and the the current chain and then reconnecting blocks to get to the
@@ -507,8 +507,8 @@ pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate:
507507
/// panics if the given update is not the next update by update_id.
508508
#[must_use]
509509
#[no_mangle]
510-
pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &mut ChannelMonitor, updates: &crate::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::chain::chaininterface::FeeEstimator, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
511-
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.update_monitor(unsafe { &*updates.inner }, broadcaster, fee_estimator, logger);
510+
pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &ChannelMonitor, updates: &crate::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::chain::chaininterface::FeeEstimator, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
511+
let mut ret = unsafe { &*this_arg.inner }.update_monitor(unsafe { &*updates.inner }, broadcaster, fee_estimator, logger);
512512
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
513513
local_ret
514514
}
@@ -527,7 +527,7 @@ pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor)
527527
#[no_mangle]
528528
pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ {
529529
let mut ret = unsafe { &*this_arg.inner }.get_funding_txo();
530-
let (ref orig_ret_0, ref orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*orig_ret_0) as *const _) as *mut _) }, is_owned: false }, orig_ret_1.clone().into_bytes().into()).into();
530+
let (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(orig_ret_0)), is_owned: true }, orig_ret_1.into_bytes().into()).into();
531531
local_ret
532532
}
533533

@@ -537,8 +537,8 @@ pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> c
537537
/// [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
538538
#[must_use]
539539
#[no_mangle]
540-
pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
541-
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events();
540+
pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
541+
let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_monitor_events();
542542
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); };
543543
local_ret.into()
544544
}
@@ -551,8 +551,8 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg:
551551
/// no internal locking in ChannelMonitors.
552552
#[must_use]
553553
#[no_mangle]
554-
pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
555-
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events();
554+
pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
555+
let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_events();
556556
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
557557
local_ret.into()
558558
}
@@ -568,8 +568,8 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut Cha
568568
/// In any-case, choice is up to the user.
569569
#[must_use]
570570
#[no_mangle]
571-
pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
572-
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger);
571+
pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
572+
let mut ret = unsafe { &*this_arg.inner }.get_latest_holder_commitment_txn(logger);
573573
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); };
574574
local_ret.into()
575575
}
@@ -587,18 +587,18 @@ pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut
587587
/// [`get_outputs_to_watch`]: #method.get_outputs_to_watch
588588
#[must_use]
589589
#[no_mangle]
590-
pub extern "C" fn ChannelMonitor_block_connected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
590+
pub extern "C" fn ChannelMonitor_block_connected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
591591
let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
592-
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height, broadcaster, fee_estimator, logger);
592+
let mut ret = unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height, broadcaster, fee_estimator, logger);
593593
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 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); };
594594
local_ret.into()
595595
}
596596

597597
/// Determines if the disconnected block contained any transactions of interest and updates
598598
/// appropriately.
599599
#[no_mangle]
600-
pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) {
601-
unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger)
600+
pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) {
601+
unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger)
602602
}
603603

604604
/// `Persist` defines behavior for persisting channel monitors: this could mean

0 commit comments

Comments
 (0)