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          * Note that chain_source (or a relevant inner pointer) may be NULL or all-0s to represent None
39          */
40         public static ChainMonitor of(@Nullable Filter chain_source, BroadcasterInterface broadcaster, Logger logger, FeeEstimator feeest, Persist persister) {
41                 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);
42                 if (ret < 1024) { return null; }
43                 ChainMonitor ret_hu_conv = new ChainMonitor(null, ret);
44                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
45                 ret_hu_conv.ptrs_to.add(chain_source);
46                 ret_hu_conv.ptrs_to.add(broadcaster);
47                 ret_hu_conv.ptrs_to.add(logger);
48                 ret_hu_conv.ptrs_to.add(feeest);
49                 ret_hu_conv.ptrs_to.add(persister);
50                 return ret_hu_conv;
51         }
52
53         /**
54          * Constructs a new Listen which calls the relevant methods on this_arg.
55          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
56          */
57         public Listen as_Listen() {
58                 long ret = bindings.ChainMonitor_as_Listen(this.ptr);
59                 if (ret < 1024) { return null; }
60                 Listen ret_hu_conv = new Listen(null, ret);
61                 ret_hu_conv.ptrs_to.add(this);
62                 return ret_hu_conv;
63         }
64
65         /**
66          * Constructs a new Confirm which calls the relevant methods on this_arg.
67          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
68          */
69         public Confirm as_Confirm() {
70                 long ret = bindings.ChainMonitor_as_Confirm(this.ptr);
71                 if (ret < 1024) { return null; }
72                 Confirm ret_hu_conv = new Confirm(null, ret);
73                 ret_hu_conv.ptrs_to.add(this);
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Constructs a new Watch which calls the relevant methods on this_arg.
79          * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is
80          */
81         public Watch as_Watch() {
82                 long ret = bindings.ChainMonitor_as_Watch(this.ptr);
83                 if (ret < 1024) { return null; }
84                 Watch ret_hu_conv = new Watch(null, ret);
85                 ret_hu_conv.ptrs_to.add(this);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
91          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
92          */
93         public EventsProvider as_EventsProvider() {
94                 long ret = bindings.ChainMonitor_as_EventsProvider(this.ptr);
95                 if (ret < 1024) { return null; }
96                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
97                 ret_hu_conv.ptrs_to.add(this);
98                 return ret_hu_conv;
99         }
100
101 }