Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / NetworkGraph.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  * Represents the network as nodes and channels between them
11  */
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class NetworkGraph extends CommonBase {
14         NetworkGraph(Object _dummy, long ptr) { super(ptr); }
15         @Override @SuppressWarnings("deprecation")
16         protected void finalize() throws Throwable {
17                 super.finalize();
18                 if (ptr != 0) { bindings.NetworkGraph_free(ptr); }
19         }
20
21         /**
22          * Creates a copy of the NetworkGraph
23          */
24         public NetworkGraph clone() {
25                 long ret = bindings.NetworkGraph_clone(this.ptr);
26                 NetworkGraph ret_hu_conv = new NetworkGraph(null, ret);
27                 ret_hu_conv.ptrs_to.add(this);
28                 return ret_hu_conv;
29         }
30
31         /**
32          * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read
33          */
34         public byte[] write() {
35                 byte[] ret = bindings.NetworkGraph_write(this.ptr);
36                 return ret;
37         }
38
39         /**
40          * Read a NetworkGraph from a byte array, created by NetworkGraph_write
41          */
42         public static Result_NetworkGraphDecodeErrorZ read(byte[] ser) {
43                 long ret = bindings.NetworkGraph_read(ser);
44                 Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
45                 return ret_hu_conv;
46         }
47
48         /**
49          * Creates a new, empty, network graph.
50          */
51         public static NetworkGraph of(byte[] genesis_hash) {
52                 long ret = bindings.NetworkGraph_new(genesis_hash);
53                 NetworkGraph ret_hu_conv = new NetworkGraph(null, ret);
54                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
55                 return ret_hu_conv;
56         }
57
58         /**
59          * For an already known node (from channel announcements), update its stored properties from a
60          * given node announcement.
61          * 
62          * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
63          * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
64          * routing messages from a source using a protocol other than the lightning P2P protocol.
65          */
66         public Result_NoneLightningErrorZ update_node_from_announcement(NodeAnnouncement msg) {
67                 long ret = bindings.NetworkGraph_update_node_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
68                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
69                 this.ptrs_to.add(msg);
70                 return ret_hu_conv;
71         }
72
73         /**
74          * For an already known node (from channel announcements), update its stored properties from a
75          * given node announcement without verifying the associated signatures. Because we aren't
76          * given the associated signatures here we cannot relay the node announcement to any of our
77          * peers.
78          */
79         public Result_NoneLightningErrorZ update_node_from_unsigned_announcement(UnsignedNodeAnnouncement msg) {
80                 long ret = bindings.NetworkGraph_update_node_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
81                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
82                 this.ptrs_to.add(msg);
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Store or update channel info from a channel announcement.
88          * 
89          * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
90          * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
91          * routing messages from a source using a protocol other than the lightning P2P protocol.
92          * 
93          * If a `chain::Access` object is provided via `chain_access`, it will be called to verify
94          * the corresponding UTXO exists on chain and is correctly-formatted.
95          */
96         public Result_NoneLightningErrorZ update_channel_from_announcement(ChannelAnnouncement msg, Access chain_access) {
97                 long ret = bindings.NetworkGraph_update_channel_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access == null ? 0 : chain_access.ptr);
98                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
99                 this.ptrs_to.add(msg);
100                 this.ptrs_to.add(chain_access);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Store or update channel info from a channel announcement without verifying the associated
106          * signatures. Because we aren't given the associated signatures here we cannot relay the
107          * channel announcement to any of our peers.
108          * 
109          * If a `chain::Access` object is provided via `chain_access`, it will be called to verify
110          * the corresponding UTXO exists on chain and is correctly-formatted.
111          */
112         public Result_NoneLightningErrorZ update_channel_from_unsigned_announcement(UnsignedChannelAnnouncement msg, Access chain_access) {
113                 long ret = bindings.NetworkGraph_update_channel_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1, chain_access == null ? 0 : chain_access.ptr);
114                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
115                 this.ptrs_to.add(msg);
116                 this.ptrs_to.add(chain_access);
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Close a channel if a corresponding HTLC fail was sent.
122          * If permanent, removes a channel from the local storage.
123          * May cause the removal of nodes too, if this was their last channel.
124          * If not permanent, makes channels unavailable for routing.
125          */
126         public void close_channel_from_update(long short_channel_id, boolean is_permanent) {
127                 bindings.NetworkGraph_close_channel_from_update(this.ptr, short_channel_id, is_permanent);
128         }
129
130         /**
131          * For an already known (from announcement) channel, update info about one of the directions
132          * of the channel.
133          * 
134          * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
135          * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
136          * routing messages from a source using a protocol other than the lightning P2P protocol.
137          */
138         public Result_NoneLightningErrorZ update_channel(ChannelUpdate msg) {
139                 long ret = bindings.NetworkGraph_update_channel(this.ptr, msg == null ? 0 : msg.ptr & ~1);
140                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
141                 this.ptrs_to.add(msg);
142                 return ret_hu_conv;
143         }
144
145         /**
146          * For an already known (from announcement) channel, update info about one of the directions
147          * of the channel without verifying the associated signatures. Because we aren't given the
148          * associated signatures here we cannot relay the channel update to any of our peers.
149          */
150         public Result_NoneLightningErrorZ update_channel_unsigned(UnsignedChannelUpdate msg) {
151                 long ret = bindings.NetworkGraph_update_channel_unsigned(this.ptr, msg == null ? 0 : msg.ptr & ~1);
152                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
153                 this.ptrs_to.add(msg);
154                 return ret_hu_conv;
155         }
156
157 }