[C#] Run tests against release library in determinism CI run
[ldk-java] / src / main / java / org / ldk / structs / OpenChannel.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 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An [`open_channel`] message to be sent to or received from a peer.
13  * 
14  * Used in V1 channel establishment
15  * 
16  * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class OpenChannel extends CommonBase {
20         OpenChannel(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
25         }
26
27         /**
28          * Common fields of `open_channel(2)`-like messages
29          */
30         public CommonOpenChannelFields get_common_fields() {
31                 long ret = bindings.OpenChannel_get_common_fields(this.ptr);
32                 Reference.reachabilityFence(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
35                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36                 return ret_hu_conv;
37         }
38
39         /**
40          * Common fields of `open_channel(2)`-like messages
41          */
42         public void set_common_fields(org.ldk.structs.CommonOpenChannelFields val) {
43                 bindings.OpenChannel_set_common_fields(this.ptr, val.ptr);
44                 Reference.reachabilityFence(this);
45                 Reference.reachabilityFence(val);
46                 if (this != null) { this.ptrs_to.add(val); };
47         }
48
49         /**
50          * The amount to push to the counterparty as part of the open, in milli-satoshi
51          */
52         public long get_push_msat() {
53                 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
54                 Reference.reachabilityFence(this);
55                 return ret;
56         }
57
58         /**
59          * The amount to push to the counterparty as part of the open, in milli-satoshi
60          */
61         public void set_push_msat(long val) {
62                 bindings.OpenChannel_set_push_msat(this.ptr, val);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
69          */
70         public long get_channel_reserve_satoshis() {
71                 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         /**
77          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
78          */
79         public void set_channel_reserve_satoshis(long val) {
80                 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
81                 Reference.reachabilityFence(this);
82                 Reference.reachabilityFence(val);
83         }
84
85         /**
86          * Constructs a new OpenChannel given each field
87          */
88         public static OpenChannel of(org.ldk.structs.CommonOpenChannelFields common_fields_arg, long push_msat_arg, long channel_reserve_satoshis_arg) {
89                 long ret = bindings.OpenChannel_new(common_fields_arg.ptr, push_msat_arg, channel_reserve_satoshis_arg);
90                 Reference.reachabilityFence(common_fields_arg);
91                 Reference.reachabilityFence(push_msat_arg);
92                 Reference.reachabilityFence(channel_reserve_satoshis_arg);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(common_fields_arg); };
97                 return ret_hu_conv;
98         }
99
100         long clone_ptr() {
101                 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * Creates a copy of the OpenChannel
108          */
109         public OpenChannel clone() {
110                 long ret = bindings.OpenChannel_clone(this.ptr);
111                 Reference.reachabilityFence(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * Generates a non-cryptographic 64-bit hash of the OpenChannel.
120          */
121         public long hash() {
122                 long ret = bindings.OpenChannel_hash(this.ptr);
123                 Reference.reachabilityFence(this);
124                 return ret;
125         }
126
127         @Override public int hashCode() {
128                 return (int)this.hash();
129         }
130         /**
131          * Checks if two OpenChannels contain equal inner contents.
132          * This ignores pointers and is_owned flags and looks at the values in fields.
133          * Two objects with NULL inner values will be considered "equal" here.
134          */
135         public boolean eq(org.ldk.structs.OpenChannel b) {
136                 boolean ret = bindings.OpenChannel_eq(this.ptr, b.ptr);
137                 Reference.reachabilityFence(this);
138                 Reference.reachabilityFence(b);
139                 if (this != null) { this.ptrs_to.add(b); };
140                 return ret;
141         }
142
143         @Override public boolean equals(Object o) {
144                 if (!(o instanceof OpenChannel)) return false;
145                 return this.eq((OpenChannel)o);
146         }
147         /**
148          * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
149          */
150         public byte[] write() {
151                 byte[] ret = bindings.OpenChannel_write(this.ptr);
152                 Reference.reachabilityFence(this);
153                 return ret;
154         }
155
156         /**
157          * Read a OpenChannel from a byte array, created by OpenChannel_write
158          */
159         public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
160                 long ret = bindings.OpenChannel_read(ser);
161                 Reference.reachabilityFence(ser);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
164                 return ret_hu_conv;
165         }
166
167 }