1 #include "include/rust_types.h"
2 #include "include/lightning.h"
8 void print_log(const void *this_arg, const char *record) {
12 uint32_t get_fee(const void *this_arg, LDKConfirmationTarget target) {
13 if (target == LDKConfirmationTarget_Background) {
20 void broadcast_tx(const void *this_arg, LDKTransaction tx) {
25 LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
26 return CResult_NoneChannelMonitorUpdateErrZ_ok();
28 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor) {
29 return CResult_NoneChannelMonitorUpdateErrZ_ok();
31 LDKCVec_MonitorEventZ monitors_pending_monitor_events(const void *this_arg) {
32 LDKCVec_MonitorEventZ empty_htlc_vec = {
36 return empty_htlc_vec;
40 uint8_t node_seed[32];
41 memset(node_seed, 0, 32);
43 LDKNetwork net = LDKNetwork_Bitcoin;
51 LDKFeeEstimator fee_est = {
53 .get_est_sat_per_1000_weight = get_fee,
59 .watch_channel = add_channel_monitor,
60 .update_channel = update_channel_monitor,
61 .release_pending_monitor_events = monitors_pending_monitor_events,
65 LDKBroadcasterInterface broadcast = {
66 broadcast.this_arg = NULL,
67 broadcast.broadcast_transaction = broadcast_tx,
71 LDKKeysManager keys = KeysManager_new(&node_seed, 0, 0);
72 LDKKeysInterface keys_source = KeysManager_as_KeysInterface(&keys);
74 LDKUserConfig config = UserConfig_default();
76 LDKChannelManager cm = ChannelManager_new(net, fee_est, mon, broadcast, logger, keys_source, config, 0);
78 LDKCVec_ChannelDetailsZ channels = ChannelManager_list_channels(&cm);
79 assert((unsigned long)channels.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page
80 assert(channels.datalen == 0);
81 CVec_ChannelDetailsZ_free(channels);
83 LDKEventsProvider prov = ChannelManager_as_EventsProvider(&cm);
84 LDKCVec_EventZ events = (prov.get_and_clear_pending_events)(prov.this_arg);
85 assert((unsigned long)events.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page
86 assert(events.datalen == 0);
88 ChannelManager_free(cm);
89 KeysManager_free(keys);
91 // Check that passing empty vecs to rust doesn't blow it up:
92 LDKCVec_MonitorEventZ empty_htlc_vec = {
96 CVec_MonitorEventZ_free(empty_htlc_vec);