using org.ldk.impl; using org.ldk.enums; using org.ldk.util; using System; namespace org { namespace ldk { namespace structs { /** * An [`accept_channel`] message to be sent to or received from a peer. * * Used in V1 channel establishment * * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message */ public class AcceptChannel : CommonBase { internal AcceptChannel(object _dummy, long ptr) : base(ptr) { } ~AcceptChannel() { if (ptr != 0) { bindings.AcceptChannel_free(ptr); } } /** * Common fields of `accept_channel(2)`-like messages */ public CommonAcceptChannelFields get_common_fields() { long ret = bindings.AcceptChannel_get_common_fields(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.CommonAcceptChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonAcceptChannelFields(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; return ret_hu_conv; } /** * Common fields of `accept_channel(2)`-like messages */ public void set_common_fields(org.ldk.structs.CommonAcceptChannelFields val) { bindings.AcceptChannel_set_common_fields(this.ptr, val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ public long get_channel_reserve_satoshis() { long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr); GC.KeepAlive(this); return ret; } /** * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ public void set_channel_reserve_satoshis(long val) { bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val); GC.KeepAlive(this); GC.KeepAlive(val); } /** * Constructs a new AcceptChannel given each field */ public static AcceptChannel of(org.ldk.structs.CommonAcceptChannelFields common_fields_arg, long channel_reserve_satoshis_arg) { long ret = bindings.AcceptChannel_new(common_fields_arg.ptr, channel_reserve_satoshis_arg); GC.KeepAlive(common_fields_arg); GC.KeepAlive(channel_reserve_satoshis_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(common_fields_arg); }; return ret_hu_conv; } internal long clone_ptr() { long ret = bindings.AcceptChannel_clone_ptr(this.ptr); GC.KeepAlive(this); return ret; } /** * Creates a copy of the AcceptChannel */ public AcceptChannel clone() { long ret = bindings.AcceptChannel_clone(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; return ret_hu_conv; } /** * Generates a non-cryptographic 64-bit hash of the AcceptChannel. */ public long hash() { long ret = bindings.AcceptChannel_hash(this.ptr); GC.KeepAlive(this); return ret; } public override int GetHashCode() { return (int)this.hash(); } /** * Checks if two AcceptChannels contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ public bool eq(org.ldk.structs.AcceptChannel b) { bool ret = bindings.AcceptChannel_eq(this.ptr, b.ptr); GC.KeepAlive(this); GC.KeepAlive(b); if (this != null) { this.ptrs_to.AddLast(b); }; return ret; } public override bool Equals(object o) { if (!(o is AcceptChannel)) return false; return this.eq((AcceptChannel)o); } /** * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ public byte[] write() { long ret = bindings.AcceptChannel_write(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } byte[] ret_conv = InternalUtils.decodeUint8Array(ret); return ret_conv; } /** * Read a AcceptChannel from a byte array, created by AcceptChannel_write */ public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) { long ret = bindings.AcceptChannel_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } } } } }