[C#] Run tests against release library in determinism CI run
[ldk-java] / src / main / java / org / ldk / structs / AcceptChannel.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 [`accept_channel`] message to be sent to or received from a peer.
13  * 
14  * Used in V1 channel establishment
15  * 
16  * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class AcceptChannel extends CommonBase {
20         AcceptChannel(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
25         }
26
27         /**
28          * Common fields of `accept_channel(2)`-like messages
29          */
30         public CommonAcceptChannelFields get_common_fields() {
31                 long ret = bindings.AcceptChannel_get_common_fields(this.ptr);
32                 Reference.reachabilityFence(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 org.ldk.structs.CommonAcceptChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonAcceptChannelFields(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 `accept_channel(2)`-like messages
41          */
42         public void set_common_fields(org.ldk.structs.CommonAcceptChannelFields val) {
43                 bindings.AcceptChannel_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 minimum value unencumbered by HTLCs for the counterparty to keep in the channel
51          */
52         public long get_channel_reserve_satoshis() {
53                 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
54                 Reference.reachabilityFence(this);
55                 return ret;
56         }
57
58         /**
59          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
60          */
61         public void set_channel_reserve_satoshis(long val) {
62                 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * Constructs a new AcceptChannel given each field
69          */
70         public static AcceptChannel of(org.ldk.structs.CommonAcceptChannelFields common_fields_arg, long channel_reserve_satoshis_arg) {
71                 long ret = bindings.AcceptChannel_new(common_fields_arg.ptr, channel_reserve_satoshis_arg);
72                 Reference.reachabilityFence(common_fields_arg);
73                 Reference.reachabilityFence(channel_reserve_satoshis_arg);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(common_fields_arg); };
78                 return ret_hu_conv;
79         }
80
81         long clone_ptr() {
82                 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
83                 Reference.reachabilityFence(this);
84                 return ret;
85         }
86
87         /**
88          * Creates a copy of the AcceptChannel
89          */
90         public AcceptChannel clone() {
91                 long ret = bindings.AcceptChannel_clone(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Generates a non-cryptographic 64-bit hash of the AcceptChannel.
101          */
102         public long hash() {
103                 long ret = bindings.AcceptChannel_hash(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         @Override public int hashCode() {
109                 return (int)this.hash();
110         }
111         /**
112          * Checks if two AcceptChannels contain equal inner contents.
113          * This ignores pointers and is_owned flags and looks at the values in fields.
114          * Two objects with NULL inner values will be considered "equal" here.
115          */
116         public boolean eq(org.ldk.structs.AcceptChannel b) {
117                 boolean ret = bindings.AcceptChannel_eq(this.ptr, b.ptr);
118                 Reference.reachabilityFence(this);
119                 Reference.reachabilityFence(b);
120                 if (this != null) { this.ptrs_to.add(b); };
121                 return ret;
122         }
123
124         @Override public boolean equals(Object o) {
125                 if (!(o instanceof AcceptChannel)) return false;
126                 return this.eq((AcceptChannel)o);
127         }
128         /**
129          * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
130          */
131         public byte[] write() {
132                 byte[] ret = bindings.AcceptChannel_write(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Read a AcceptChannel from a byte array, created by AcceptChannel_write
139          */
140         public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
141                 long ret = bindings.AcceptChannel_read(ser);
142                 Reference.reachabilityFence(ser);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
145                 return ret_hu_conv;
146         }
147
148 }