6 namespace org { namespace ldk { namespace structs {
10 * An [`accept_channel`] message to be sent to or received from a peer.
12 * Used in V1 channel establishment
14 * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
16 public class AcceptChannel : CommonBase {
17 internal AcceptChannel(object _dummy, long ptr) : base(ptr) { }
19 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
23 * Common fields of `accept_channel(2)`-like messages
25 public CommonAcceptChannelFields get_common_fields() {
26 long ret = bindings.AcceptChannel_get_common_fields(this.ptr);
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); };
35 * Common fields of `accept_channel(2)`-like messages
37 public void set_common_fields(org.ldk.structs.CommonAcceptChannelFields val) {
38 bindings.AcceptChannel_set_common_fields(this.ptr, val.ptr);
41 if (this != null) { this.ptrs_to.AddLast(val); };
45 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
47 public long get_channel_reserve_satoshis() {
48 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
54 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
56 public void set_channel_reserve_satoshis(long val) {
57 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
63 * Constructs a new AcceptChannel given each field
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); };
76 internal long clone_ptr() {
77 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
83 * Creates a copy of the AcceptChannel
85 public AcceptChannel clone() {
86 long ret = bindings.AcceptChannel_clone(this.ptr);
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); };
95 * Generates a non-cryptographic 64-bit hash of the AcceptChannel.
98 long ret = bindings.AcceptChannel_hash(this.ptr);
103 public override int GetHashCode() {
104 return (int)this.hash();
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.
111 public bool eq(org.ldk.structs.AcceptChannel b) {
112 bool ret = bindings.AcceptChannel_eq(this.ptr, b.ptr);
115 if (this != null) { this.ptrs_to.AddLast(b); };
119 public override bool Equals(object o) {
120 if (!(o is AcceptChannel)) return false;
121 return this.eq((AcceptChannel)o);
124 * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
126 public byte[] write() {
127 long ret = bindings.AcceptChannel_write(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
135 * Read a AcceptChannel from a byte array, created by AcceptChannel_write
137 public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
138 long ret = bindings.AcceptChannel_read(InternalUtils.encodeUint8Array(ser));
140 if (ret >= 0 && ret <= 4096) { return null; }
141 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);