+ /**
+ * Read a NetworkGraph from a byte array, created by NetworkGraph_write
+ */
+ public static Result_NetworkGraphDecodeErrorZ read(byte[] ser) {
+ long ret = bindings.NetworkGraph_read(ser);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates a new, empty, network graph.
+ */
+ public static NetworkGraph of(byte[] genesis_hash) {
+ long ret = bindings.NetworkGraph_new(InternalUtils.check_arr_len(genesis_hash, 32));
+ if (ret >= 0 && ret <= 4096) { return null; }
+ NetworkGraph ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NetworkGraph(null, ret); }
+ ret_hu_conv.ptrs_to.add(ret_hu_conv);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Returns a read-only view of the network graph.
+ */
+ public ReadOnlyNetworkGraph read_only() {
+ long ret = bindings.NetworkGraph_read_only(this.ptr);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ ReadOnlyNetworkGraph ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ReadOnlyNetworkGraph(null, ret); }
+ ret_hu_conv.ptrs_to.add(this);
+ return ret_hu_conv;
+ }
+
+ /**
+ * For an already known node (from channel announcements), update its stored properties from a
+ * given node announcement.
+ *
+ * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
+ * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
+ * routing messages from a source using a protocol other than the lightning P2P protocol.
+ */
+ public Result_NoneLightningErrorZ update_node_from_announcement(NodeAnnouncement msg) {
+ long ret = bindings.NetworkGraph_update_node_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(msg);
+ return ret_hu_conv;
+ }
+
+ /**
+ * For an already known node (from channel announcements), update its stored properties from a
+ * given node announcement without verifying the associated signatures. Because we aren't
+ * given the associated signatures here we cannot relay the node announcement to any of our
+ * peers.
+ */
+ public Result_NoneLightningErrorZ update_node_from_unsigned_announcement(UnsignedNodeAnnouncement msg) {
+ long ret = bindings.NetworkGraph_update_node_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(msg);
+ return ret_hu_conv;