7 void print_log(const void *this_arg, const LDKRecord *record) {
8 LDKStr mod = Record_get_module_path(record);
9 LDKStr str = Record_get_args(record);
10 printf("%.*s:%d - %.*s\n", (int)mod.len, mod.chars, Record_get_line(record), (int)str.len, str.chars);
15 uint32_t get_fee(const void *this_arg, LDKConfirmationTarget target) {
16 if (target == LDKConfirmationTarget_Background) {
23 void broadcast_tx(const void *this_arg, LDKTransaction tx) {
28 LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
29 return CResult_NoneChannelMonitorUpdateErrZ_ok();
31 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor) {
32 return CResult_NoneChannelMonitorUpdateErrZ_ok();
34 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) {
35 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ empty_htlc_vec = {
39 return empty_htlc_vec;
42 void never_handle_event(const void *this_arg, const struct LDKEvent* event) {
43 // Note that we never actually generate any events to handle in the code below.
48 uint8_t node_seed[32];
49 memset(node_seed, 0, 32);
51 LDKNetwork net = LDKNetwork_Bitcoin;
59 LDKFeeEstimator fee_est = {
61 .get_est_sat_per_1000_weight = get_fee,
67 .watch_channel = add_channel_monitor,
68 .update_channel = update_channel_monitor,
69 .release_pending_monitor_events = monitors_pending_monitor_events,
73 LDKBroadcasterInterface broadcast = {
74 broadcast.this_arg = NULL,
75 broadcast.broadcast_transaction = broadcast_tx,
79 LDKKeysManager keys = KeysManager_new(&node_seed, 0, 0);
80 LDKKeysInterface keys_source = KeysManager_as_KeysInterface(&keys);
82 LDKUserConfig config = UserConfig_default();
83 LDKThirtyTwoBytes chain_tip;
84 memset(&chain_tip, 0, 32);
85 LDKChainParameters chain = ChainParameters_new(net, BestBlock_new(chain_tip, 0));
86 LDKChannelManager cm = ChannelManager_new(fee_est, mon, broadcast, logger, keys_source, config, chain);
88 LDKCVec_ChannelDetailsZ channels = ChannelManager_list_channels(&cm);
89 assert((unsigned long)channels.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page
90 assert(channels.datalen == 0);
91 CVec_ChannelDetailsZ_free(channels);
93 LDKEventsProvider prov = ChannelManager_as_EventsProvider(&cm);
94 // Check that no events were generated by asserting if any events are passed to never_handle_event.
95 LDKEventHandler handler = { .handle_event = never_handle_event, .free = NULL };
96 (prov.process_pending_events)(prov.this_arg, handler);
98 ChannelManager_free(cm);
99 KeysManager_free(keys);
101 // Check that passing empty vecs to rust doesn't blow it up:
102 LDKCVec_MonitorEventZ empty_htlc_vec = {
106 CVec_MonitorEventZ_free(empty_htlc_vec);