7 void print_log(const void *this_arg, const char *record) {
11 uint32_t get_fee(const void *this_arg, LDKConfirmationTarget target) {
12 if (target == LDKConfirmationTarget_Background) {
19 void broadcast_tx(const void *this_arg, LDKTransaction tx) {
24 LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
25 return CResult_NoneChannelMonitorUpdateErrZ_ok();
27 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor) {
28 return CResult_NoneChannelMonitorUpdateErrZ_ok();
30 LDKCVec_MonitorEventZ monitors_pending_monitor_events(const void *this_arg) {
31 LDKCVec_MonitorEventZ empty_htlc_vec = {
35 return empty_htlc_vec;
39 uint8_t node_seed[32];
40 memset(node_seed, 0, 32);
42 LDKNetwork net = LDKNetwork_Bitcoin;
50 LDKFeeEstimator fee_est = {
52 .get_est_sat_per_1000_weight = get_fee,
58 .watch_channel = add_channel_monitor,
59 .update_channel = update_channel_monitor,
60 .release_pending_monitor_events = monitors_pending_monitor_events,
64 LDKBroadcasterInterface broadcast = {
65 broadcast.this_arg = NULL,
66 broadcast.broadcast_transaction = broadcast_tx,
70 LDKKeysManager keys = KeysManager_new(&node_seed, 0, 0);
71 LDKKeysInterface keys_source = KeysManager_as_KeysInterface(&keys);
73 LDKUserConfig config = UserConfig_default();
74 LDKThirtyTwoBytes chain_tip;
75 memset(&chain_tip, 0, 32);
76 LDKChainParameters chain = ChainParameters_new(net, BestBlock_new(chain_tip, 0));
77 LDKChannelManager cm = ChannelManager_new(fee_est, mon, broadcast, logger, keys_source, config, chain);
79 LDKCVec_ChannelDetailsZ channels = ChannelManager_list_channels(&cm);
80 assert((unsigned long)channels.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page
81 assert(channels.datalen == 0);
82 CVec_ChannelDetailsZ_free(channels);
84 LDKEventsProvider prov = ChannelManager_as_EventsProvider(&cm);
85 LDKCVec_EventZ events = (prov.get_and_clear_pending_events)(prov.this_arg);
86 assert((unsigned long)events.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page
87 assert(events.datalen == 0);
89 ChannelManager_free(cm);
90 KeysManager_free(keys);
92 // Check that passing empty vecs to rust doesn't blow it up:
93 LDKCVec_MonitorEventZ empty_htlc_vec = {
97 CVec_MonitorEventZ_free(empty_htlc_vec);