X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fchain%2Fchannelmonitor.rs;h=a5429bcba4a320ae57653cffbe18ea64843e1b1c;hp=6bfd3c3863cfed993240faa41ccb5cd428de8ef1;hb=033f4f3b2750dcd5afc8b158d7474242b29b24f3;hpb=9e34ca7e68bc8caca0b76f29efbac903ce5b9d2b diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index 6bfd3c3..a5429bc 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -479,6 +479,11 @@ pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_type let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res } +/// Number of blocks we wait on seeing a HTLC output being solved before we fail corresponding inbound +/// HTLCs. This prevents us from failing backwards and then getting a reorg resulting in us losing money. + +#[no_mangle] +pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY; use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; type nativeChannelMonitor = nativeChannelMonitorImport; @@ -715,6 +720,15 @@ pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &ChannelMonitor) - local_ret.into() } +/// Gets the latest best block which was connected either via the [`chain::Listen`] or +/// [`chain::Confirm`] interfaces. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_current_best_block(this_arg: &ChannelMonitor) -> crate::lightning::chain::BestBlock { + let mut ret = unsafe { &*this_arg.inner }.current_best_block(); + crate::lightning::chain::BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + /// `Persist` defines behavior for persisting channel monitors: this could mean /// writing once to disk, and/or uploading to one or more backup services. /// @@ -769,6 +783,8 @@ pub struct Persist { /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, } +unsafe impl Send for Persist {} +unsafe impl Sync for Persist {} use lightning::chain::channelmonitor::Persist as rustPersist; impl rustPersist for Persist {