[C#] Run tests against release library in determinism CI run
[ldk-java] / c_sharp / src / org / ldk / structs / AcceptChannel.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * An [`accept_channel`] message to be sent to or received from a peer.
11  * 
12  * Used in V1 channel establishment
13  * 
14  * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
15  */
16 public class AcceptChannel : CommonBase {
17         internal AcceptChannel(object _dummy, long ptr) : base(ptr) { }
18         ~AcceptChannel() {
19                 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
20         }
21
22         /**
23          * Common fields of `accept_channel(2)`-like messages
24          */
25         public CommonAcceptChannelFields get_common_fields() {
26                 long ret = bindings.AcceptChannel_get_common_fields(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 org.ldk.structs.CommonAcceptChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonAcceptChannelFields(null, ret); }
30                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
31                 return ret_hu_conv;
32         }
33
34         /**
35          * Common fields of `accept_channel(2)`-like messages
36          */
37         public void set_common_fields(org.ldk.structs.CommonAcceptChannelFields val) {
38                 bindings.AcceptChannel_set_common_fields(this.ptr, val.ptr);
39                 GC.KeepAlive(this);
40                 GC.KeepAlive(val);
41                 if (this != null) { this.ptrs_to.AddLast(val); };
42         }
43
44         /**
45          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
46          */
47         public long get_channel_reserve_satoshis() {
48                 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
49                 GC.KeepAlive(this);
50                 return ret;
51         }
52
53         /**
54          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
55          */
56         public void set_channel_reserve_satoshis(long val) {
57                 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * Constructs a new AcceptChannel given each field
64          */
65         public static AcceptChannel of(org.ldk.structs.CommonAcceptChannelFields common_fields_arg, long channel_reserve_satoshis_arg) {
66                 long ret = bindings.AcceptChannel_new(common_fields_arg.ptr, channel_reserve_satoshis_arg);
67                 GC.KeepAlive(common_fields_arg);
68                 GC.KeepAlive(channel_reserve_satoshis_arg);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(common_fields_arg); };
73                 return ret_hu_conv;
74         }
75
76         internal long clone_ptr() {
77                 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
78                 GC.KeepAlive(this);
79                 return ret;
80         }
81
82         /**
83          * Creates a copy of the AcceptChannel
84          */
85         public AcceptChannel clone() {
86                 long ret = bindings.AcceptChannel_clone(this.ptr);
87                 GC.KeepAlive(this);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Generates a non-cryptographic 64-bit hash of the AcceptChannel.
96          */
97         public long hash() {
98                 long ret = bindings.AcceptChannel_hash(this.ptr);
99                 GC.KeepAlive(this);
100                 return ret;
101         }
102
103         public override int GetHashCode() {
104                 return (int)this.hash();
105         }
106         /**
107          * Checks if two AcceptChannels contain equal inner contents.
108          * This ignores pointers and is_owned flags and looks at the values in fields.
109          * Two objects with NULL inner values will be considered "equal" here.
110          */
111         public bool eq(org.ldk.structs.AcceptChannel b) {
112                 bool ret = bindings.AcceptChannel_eq(this.ptr, b.ptr);
113                 GC.KeepAlive(this);
114                 GC.KeepAlive(b);
115                 if (this != null) { this.ptrs_to.AddLast(b); };
116                 return ret;
117         }
118
119         public override bool Equals(object o) {
120                 if (!(o is AcceptChannel)) return false;
121                 return this.eq((AcceptChannel)o);
122         }
123         /**
124          * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
125          */
126         public byte[] write() {
127                 long ret = bindings.AcceptChannel_write(this.ptr);
128                 GC.KeepAlive(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
131                 return ret_conv;
132         }
133
134         /**
135          * Read a AcceptChannel from a byte array, created by AcceptChannel_write
136          */
137         public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
138                 long ret = bindings.AcceptChannel_read(InternalUtils.encodeUint8Array(ser));
139                 GC.KeepAlive(ser);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
142                 return ret_hu_conv;
143         }
144
145 }
146 } } }