6 namespace org { namespace ldk { namespace structs {
10 * A [`commitment_signed`] message to be sent to or received from a peer.
12 * [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
14 public class CommitmentSigned : CommonBase {
15 internal CommitmentSigned(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.CommitmentSigned_free(ptr); }
23 public ChannelId get_channel_id() {
24 long ret = bindings.CommitmentSigned_get_channel_id(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
35 public void set_channel_id(org.ldk.structs.ChannelId val) {
36 bindings.CommitmentSigned_set_channel_id(this.ptr, val.ptr);
42 * A signature on the commitment transaction
44 public byte[] get_signature() {
45 long ret = bindings.CommitmentSigned_get_signature(this.ptr);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
53 * A signature on the commitment transaction
55 public void set_signature(byte[] val) {
56 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
62 * Signatures on the HTLC transactions
64 * Returns a copy of the field.
66 public byte[][] get_htlc_signatures() {
67 long ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
71 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
72 for (int i = 0; i < ret_conv_8_len; i++) {
73 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
74 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
75 ret_conv_8_arr[i] = ret_conv_8_conv;
77 bindings.free_buffer(ret);
78 return ret_conv_8_arr;
82 * Signatures on the HTLC transactions
84 public void set_htlc_signatures(byte[][] val) {
85 bindings.CommitmentSigned_set_htlc_signatures(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val_conv_8, 64)))));
91 * Optional batch size and other parameters
93 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
95 public CommitmentSignedBatch get_batch() {
96 long ret = bindings.CommitmentSigned_get_batch(this.ptr);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 org.ldk.structs.CommitmentSignedBatch ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSignedBatch(null, ret); }
100 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
105 * Optional batch size and other parameters
107 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
109 public void set_batch(org.ldk.structs.CommitmentSignedBatch val) {
110 bindings.CommitmentSigned_set_batch(this.ptr, val == null ? 0 : val.ptr);
116 * Constructs a new CommitmentSigned given each field
118 * Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
120 public static CommitmentSigned of(org.ldk.structs.ChannelId channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg, org.ldk.structs.CommitmentSignedBatch batch_arg) {
121 long ret = bindings.CommitmentSigned_new(channel_id_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(htlc_signatures_arg, htlc_signatures_arg_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_signatures_arg_conv_8, 64)))), batch_arg == null ? 0 : batch_arg.ptr);
122 GC.KeepAlive(channel_id_arg);
123 GC.KeepAlive(signature_arg);
124 GC.KeepAlive(htlc_signatures_arg);
125 GC.KeepAlive(batch_arg);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
132 internal long clone_ptr() {
133 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
139 * Creates a copy of the CommitmentSigned
141 public CommitmentSigned clone() {
142 long ret = bindings.CommitmentSigned_clone(this.ptr);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
151 * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
154 long ret = bindings.CommitmentSigned_hash(this.ptr);
159 public override int GetHashCode() {
160 return (int)this.hash();
163 * Checks if two CommitmentSigneds contain equal inner contents.
164 * This ignores pointers and is_owned flags and looks at the values in fields.
165 * Two objects with NULL inner values will be considered "equal" here.
167 public bool eq(org.ldk.structs.CommitmentSigned b) {
168 bool ret = bindings.CommitmentSigned_eq(this.ptr, b.ptr);
171 if (this != null) { this.ptrs_to.AddLast(b); };
175 public override bool Equals(object o) {
176 if (!(o is CommitmentSigned)) return false;
177 return this.eq((CommitmentSigned)o);
180 * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
182 public byte[] write() {
183 long ret = bindings.CommitmentSigned_write(this.ptr);
185 if (ret >= 0 && ret <= 4096) { return null; }
186 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
191 * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
193 public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
194 long ret = bindings.CommitmentSigned_read(InternalUtils.encodeUint8Array(ser));
196 if (ret >= 0 && ret <= 4096) { return null; }
197 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);