6 namespace org { namespace ldk { namespace structs {
10 * An [`open_channel`] message to be sent to or received from a peer.
12 * Used in V1 channel establishment
14 * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
16 public class OpenChannel : CommonBase {
17 internal OpenChannel(object _dummy, long ptr) : base(ptr) { }
19 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
23 * Common fields of `open_channel(2)`-like messages
25 public CommonOpenChannelFields get_common_fields() {
26 long ret = bindings.OpenChannel_get_common_fields(this.ptr);
28 if (ret >= 0 && ret <= 4096) { return null; }
29 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
30 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
35 * Common fields of `open_channel(2)`-like messages
37 public void set_common_fields(org.ldk.structs.CommonOpenChannelFields val) {
38 bindings.OpenChannel_set_common_fields(this.ptr, val.ptr);
41 if (this != null) { this.ptrs_to.AddLast(val); };
45 * The amount to push to the counterparty as part of the open, in milli-satoshi
47 public long get_push_msat() {
48 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
54 * The amount to push to the counterparty as part of the open, in milli-satoshi
56 public void set_push_msat(long val) {
57 bindings.OpenChannel_set_push_msat(this.ptr, val);
63 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
65 public long get_channel_reserve_satoshis() {
66 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
72 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
74 public void set_channel_reserve_satoshis(long val) {
75 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
81 * Constructs a new OpenChannel given each field
83 public static OpenChannel of(org.ldk.structs.CommonOpenChannelFields common_fields_arg, long push_msat_arg, long channel_reserve_satoshis_arg) {
84 long ret = bindings.OpenChannel_new(common_fields_arg.ptr, push_msat_arg, channel_reserve_satoshis_arg);
85 GC.KeepAlive(common_fields_arg);
86 GC.KeepAlive(push_msat_arg);
87 GC.KeepAlive(channel_reserve_satoshis_arg);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(common_fields_arg); };
95 internal long clone_ptr() {
96 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
102 * Creates a copy of the OpenChannel
104 public OpenChannel clone() {
105 long ret = bindings.OpenChannel_clone(this.ptr);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
114 * Generates a non-cryptographic 64-bit hash of the OpenChannel.
117 long ret = bindings.OpenChannel_hash(this.ptr);
122 public override int GetHashCode() {
123 return (int)this.hash();
126 * Checks if two OpenChannels contain equal inner contents.
127 * This ignores pointers and is_owned flags and looks at the values in fields.
128 * Two objects with NULL inner values will be considered "equal" here.
130 public bool eq(org.ldk.structs.OpenChannel b) {
131 bool ret = bindings.OpenChannel_eq(this.ptr, b.ptr);
134 if (this != null) { this.ptrs_to.AddLast(b); };
138 public override bool Equals(object o) {
139 if (!(o is OpenChannel)) return false;
140 return this.eq((OpenChannel)o);
143 * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
145 public byte[] write() {
146 long ret = bindings.OpenChannel_write(this.ptr);
148 if (ret >= 0 && ret <= 4096) { return null; }
149 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
154 * Read a OpenChannel from a byte array, created by OpenChannel_write
156 public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
157 long ret = bindings.OpenChannel_read(InternalUtils.encodeUint8Array(ser));
159 if (ret >= 0 && ret <= 4096) { return null; }
160 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);