6 namespace org { namespace ldk { namespace structs {
10 * An [`init`] message to be sent to or received from a peer.
12 * [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
14 public class Init : CommonBase {
15 internal Init(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.Init_free(ptr); }
21 * The relevant features which the sender supports.
23 public InitFeatures get_features() {
24 long ret = bindings.Init_get_features(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
28 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
33 * The relevant features which the sender supports.
35 public void set_features(org.ldk.structs.InitFeatures val) {
36 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr);
39 if (this != null) { this.ptrs_to.AddLast(val); };
43 * Indicates chains the sender is interested in.
45 * If there are no common chains, the connection will be closed.
47 * Returns a copy of the field.
49 public Option_CVec_ChainHashZZ get_networks() {
50 long ret = bindings.Init_get_networks(this.ptr);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.Option_CVec_ChainHashZZ ret_hu_conv = org.ldk.structs.Option_CVec_ChainHashZZ.constr_from_ptr(ret);
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59 * Indicates chains the sender is interested in.
61 * If there are no common chains, the connection will be closed.
63 public void set_networks(org.ldk.structs.Option_CVec_ChainHashZZ val) {
64 bindings.Init_set_networks(this.ptr, val.ptr);
67 if (this != null) { this.ptrs_to.AddLast(val); };
71 * The receipient's network address.
73 * This adds the option to report a remote IP address back to a connecting peer using the init
74 * message. A node can decide to use that information to discover a potential update to its
75 * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
78 public Option_NetAddressZ get_remote_network_address() {
79 long ret = bindings.Init_get_remote_network_address(this.ptr);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 org.ldk.structs.Option_NetAddressZ ret_hu_conv = org.ldk.structs.Option_NetAddressZ.constr_from_ptr(ret);
83 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
88 * The receipient's network address.
90 * This adds the option to report a remote IP address back to a connecting peer using the init
91 * message. A node can decide to use that information to discover a potential update to its
92 * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
95 public void set_remote_network_address(org.ldk.structs.Option_NetAddressZ val) {
96 bindings.Init_set_remote_network_address(this.ptr, val.ptr);
99 if (this != null) { this.ptrs_to.AddLast(val); };
103 * Constructs a new Init given each field
105 public static Init of(org.ldk.structs.InitFeatures features_arg, org.ldk.structs.Option_CVec_ChainHashZZ networks_arg, org.ldk.structs.Option_NetAddressZ remote_network_address_arg) {
106 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr, networks_arg.ptr, remote_network_address_arg.ptr);
107 GC.KeepAlive(features_arg);
108 GC.KeepAlive(networks_arg);
109 GC.KeepAlive(remote_network_address_arg);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(networks_arg); };
115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(remote_network_address_arg); };
119 internal long clone_ptr() {
120 long ret = bindings.Init_clone_ptr(this.ptr);
126 * Creates a copy of the Init
128 public Init clone() {
129 long ret = bindings.Init_clone(this.ptr);
131 if (ret >= 0 && ret <= 4096) { return null; }
132 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
133 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
138 * Checks if two Inits contain equal inner contents.
139 * This ignores pointers and is_owned flags and looks at the values in fields.
140 * Two objects with NULL inner values will be considered "equal" here.
142 public bool eq(org.ldk.structs.Init b) {
143 bool ret = bindings.Init_eq(this.ptr, b == null ? 0 : b.ptr);
146 if (this != null) { this.ptrs_to.AddLast(b); };
150 public override bool Equals(object o) {
151 if (!(o is Init)) return false;
152 return this.eq((Init)o);
155 * Serialize the Init object into a byte array which can be read by Init_read
157 public byte[] write() {
158 byte[] ret = bindings.Init_write(this.ptr);
164 * Read a Init from a byte array, created by Init_write
166 public static Result_InitDecodeErrorZ read(byte[] ser) {
167 long ret = bindings.Init_read(ser);
169 if (ret >= 0 && ret <= 4096) { return null; }
170 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);