Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / ChainMonitor.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8
9 /**
10  * An implementation of [`chain::Watch`] for monitoring channels.
11  * 
12  * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by
13  * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally
14  * or used independently to monitor channels remotely. See the [module-level documentation] for
15  * details.
16  * 
17  * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
18  * [module-level documentation]: crate::chain::chainmonitor
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class ChainMonitor extends CommonBase {
22         ChainMonitor(Object _dummy, long ptr) { super(ptr); }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 super.finalize();
26                 if (ptr != 0) { bindings.ChainMonitor_free(ptr); }
27         }
28
29         /**
30          * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels.
31          * 
32          * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor
33          * will call back to it indicating transactions and outputs of interest. This allows clients to
34          * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may
35          * always need to fetch full blocks absent another means for determining which blocks contain
36          * transactions relevant to the watched channels.
37          */
38         public static ChainMonitor of(Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) {
39                 long ret = bindings.ChainMonitor_new(chain_source == null ? 0 : chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr);
40                 ChainMonitor ret_hu_conv = new ChainMonitor(null, ret);
41                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
42                 ret_hu_conv.ptrs_to.add(chain_source);
43                 ret_hu_conv.ptrs_to.add(broadcaster);
44                 ret_hu_conv.ptrs_to.add(logger);
45                 ret_hu_conv.ptrs_to.add(feeest);
46                 ret_hu_conv.ptrs_to.add(persister);
47                 return ret_hu_conv;
48         }
49
50         /**
51          * Constructs a new Listen which calls the relevant methods on this_arg.
52          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
53          */
54         public Listen as_Listen() {
55                 long ret = bindings.ChainMonitor_as_Listen(this.ptr);
56                 Listen ret_hu_conv = new Listen(null, ret);
57                 ret_hu_conv.ptrs_to.add(this);
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Constructs a new Confirm which calls the relevant methods on this_arg.
63          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
64          */
65         public Confirm as_Confirm() {
66                 long ret = bindings.ChainMonitor_as_Confirm(this.ptr);
67                 Confirm ret_hu_conv = new Confirm(null, ret);
68                 ret_hu_conv.ptrs_to.add(this);
69                 return ret_hu_conv;
70         }
71
72         /**
73          * Constructs a new Watch which calls the relevant methods on this_arg.
74          * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is
75          */
76         public Watch as_Watch() {
77                 long ret = bindings.ChainMonitor_as_Watch(this.ptr);
78                 Watch ret_hu_conv = new Watch(null, ret);
79                 ret_hu_conv.ptrs_to.add(this);
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
85          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
86          */
87         public EventsProvider as_EventsProvider() {
88                 long ret = bindings.ChainMonitor_as_EventsProvider(this.ptr);
89                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
90                 ret_hu_conv.ptrs_to.add(this);
91                 return ret_hu_conv;
92         }
93
94 }