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);
39 if (this != null) { this.ptrs_to.AddLast(val); };
43 * A signature on the commitment transaction
45 public byte[] get_signature() {
46 long ret = bindings.CommitmentSigned_get_signature(this.ptr);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
54 * A signature on the commitment transaction
56 public void set_signature(byte[] val) {
57 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
63 * Signatures on the HTLC transactions
65 * Returns a copy of the field.
67 public byte[][] get_htlc_signatures() {
68 long ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
72 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
73 for (int i = 0; i < ret_conv_8_len; i++) {
74 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
75 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
76 ret_conv_8_arr[i] = ret_conv_8_conv;
78 bindings.free_buffer(ret);
79 return ret_conv_8_arr;
83 * Signatures on the HTLC transactions
85 public void set_htlc_signatures(byte[][] val) {
86 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)))));
92 * Constructs a new CommitmentSigned given each field
94 public static CommitmentSigned of(org.ldk.structs.ChannelId channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
95 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)))));
96 GC.KeepAlive(channel_id_arg);
97 GC.KeepAlive(signature_arg);
98 GC.KeepAlive(htlc_signatures_arg);
99 if (ret >= 0 && ret <= 4096) { return null; }
100 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
101 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
102 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
106 internal long clone_ptr() {
107 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
113 * Creates a copy of the CommitmentSigned
115 public CommitmentSigned clone() {
116 long ret = bindings.CommitmentSigned_clone(this.ptr);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
125 * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
128 long ret = bindings.CommitmentSigned_hash(this.ptr);
133 public override int GetHashCode() {
134 return (int)this.hash();
137 * Checks if two CommitmentSigneds contain equal inner contents.
138 * This ignores pointers and is_owned flags and looks at the values in fields.
139 * Two objects with NULL inner values will be considered "equal" here.
141 public bool eq(org.ldk.structs.CommitmentSigned b) {
142 bool ret = bindings.CommitmentSigned_eq(this.ptr, b.ptr);
145 if (this != null) { this.ptrs_to.AddLast(b); };
149 public override bool Equals(object o) {
150 if (!(o is CommitmentSigned)) return false;
151 return this.eq((CommitmentSigned)o);
154 * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
156 public byte[] write() {
157 long ret = bindings.CommitmentSigned_write(this.ptr);
159 if (ret >= 0 && ret <= 4096) { return null; }
160 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
165 * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
167 public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
168 long ret = bindings.CommitmentSigned_read(InternalUtils.encodeUint8Array(ser));
170 if (ret >= 0 && ret <= 4096) { return null; }
171 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);