Skip to content

Commit

Permalink
Update auto-generated bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Feb 26, 2021
1 parent d10284b commit c6c15fa
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 82 deletions.
34 changes: 30 additions & 4 deletions lightning-c-bindings/include/lightning.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ typedef enum LDKSecp256k1Error {
LDKSecp256k1Error_InvalidSecretKey,
LDKSecp256k1Error_InvalidRecoveryId,
LDKSecp256k1Error_InvalidTweak,
LDKSecp256k1Error_TweakCheckFailed,
LDKSecp256k1Error_NotEnoughMemory,
LDKSecp256k1Error_CallbackPanicked,
/**
* Must be last for serialization purposes
*/
Expand Down Expand Up @@ -3451,6 +3451,25 @@ typedef struct LDKAccess {
void (*free)(void *this_arg);
} LDKAccess;

/**
* The `Listen` trait is used to be notified of when blocks have been connected or disconnected
* from the chain.
*
* Useful when needing to replay chain data upon startup or as new chain events occur.
*/
typedef struct LDKListen {
void *this_arg;
/**
* Notifies the listener that a block was added at the given height.
*/
void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height);
/**
* Notifies the listener that a block was removed at the given height.
*/
void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height);
void (*free)(void *this_arg);
} LDKListen;

/**
* The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
* channels.
Expand Down Expand Up @@ -3629,7 +3648,7 @@ typedef struct LDKChannelMessageHandler {
/**
* Handle an incoming shutdown message from the given peer.
*/
void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKShutdown *NONNULL_PTR msg);
void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInitFeatures *NONNULL_PTR their_features, const struct LDKShutdown *NONNULL_PTR msg);
/**
* Handle an incoming closing_signed message from the given peer.
*/
Expand Down Expand Up @@ -5117,6 +5136,11 @@ enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR ori
*/
void Access_free(struct LDKAccess this_ptr);

/**
* Calls the free function if one is set
*/
void Listen_free(struct LDKListen this_ptr);

/**
* Calls the free function if one is set
*/
Expand Down Expand Up @@ -5667,8 +5691,8 @@ void KeysManager_free(struct LDKKeysManager this_ptr);
MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos);

/**
* Derive an old set of Sign for per-channel secrets based on a key derivation
* parameters.
* Derive an old Sign containing per-channel secrets based on a key derivation parameters.
*
* Key derivation parameters are accessible through a per-channel secrets
* Sign::channel_keys_id and is provided inside DynamicOuputP2WSH in case of
* onchain output detection for which a corresponding delayed_payment_key must be derived.
Expand Down Expand Up @@ -6029,6 +6053,8 @@ struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(

struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg);

struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg);

/**
* Updates channel state based on transactions seen in a connected block.
*/
Expand Down
15 changes: 15 additions & 0 deletions lightning-c-bindings/include/lightningpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,21 @@ class Access {
const LDKAccess* operator &() const { return &self; }
const LDKAccess* operator ->() const { return &self; }
};
class Listen {
private:
LDKListen self;
public:
Listen(const Listen&) = delete;
Listen(Listen&& o) : self(o.self) { memset(&o, 0, sizeof(Listen)); }
Listen(LDKListen&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKListen)); }
operator LDKListen() && { LDKListen res = self; memset(&self, 0, sizeof(LDKListen)); return res; }
~Listen() { Listen_free(self); }
Listen& operator=(Listen&& o) { Listen_free(self); self = o.self; memset(&o, 0, sizeof(Listen)); return *this; }
LDKListen* operator &() { return &self; }
LDKListen* operator ->() { return &self; }
const LDKListen* operator &() const { return &self; }
const LDKListen* operator ->() const { return &self; }
};
class Watch {
private:
LDKWatch self;
Expand Down
8 changes: 4 additions & 4 deletions lightning-c-bindings/src/chain/chainmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ pub extern "C" fn ChainMonitor_as_Watch(this_arg: &ChainMonitor) -> crate::chain
use lightning::chain::Watch as WatchTraitImport;
#[must_use]
extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_outpoint: crate::chain::transaction::OutPoint, mut monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ {
let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.watch_channel(*unsafe { Box::from_raw(funding_outpoint.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) });
let mut ret = <nativeChainMonitor as WatchTraitImport<_>>::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_outpoint.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) });
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::ChannelMonitorUpdateErr::native_into(e) }).into() };
local_ret
}
#[must_use]
extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::chain::transaction::OutPoint, mut update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ {
let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.update_channel(*unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(update.take_inner()) });
let mut ret = <nativeChainMonitor as WatchTraitImport<_>>::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(update.take_inner()) });
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::ChannelMonitorUpdateErr::native_into(e) }).into() };
local_ret
}
#[must_use]
extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ {
let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.release_pending_monitor_events();
let mut ret = <nativeChainMonitor as WatchTraitImport<_>>::release_pending_monitor_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, );
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); };
local_ret.into()
}
Expand All @@ -178,7 +178,7 @@ pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: &ChainMonitor) -> cra
use lightning::util::events::EventsProvider as EventsProviderTraitImport;
#[must_use]
extern "C" fn ChainMonitor_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.get_and_clear_pending_events();
let mut ret = <nativeChainMonitor as EventsProviderTraitImport<>>::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, );
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
local_ret.into()
}
Expand Down
Loading

0 comments on commit c6c15fa

Please sign in to comment.