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 byte[] get_channel_id() {
24 long ret = bindings.CommitmentSigned_get_channel_id(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
34 public void set_channel_id(byte[] val) {
35 bindings.CommitmentSigned_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
41 * A signature on the commitment transaction
43 public byte[] get_signature() {
44 long ret = bindings.CommitmentSigned_get_signature(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
52 * A signature on the commitment transaction
54 public void set_signature(byte[] val) {
55 bindings.CommitmentSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
61 * Signatures on the HTLC transactions
63 * Returns a copy of the field.
65 public byte[][] get_htlc_signatures() {
66 long ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
70 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
71 for (int i = 0; i < ret_conv_8_len; i++) {
72 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
73 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
74 ret_conv_8_arr[i] = ret_conv_8_conv;
76 bindings.free_buffer(ret);
77 return ret_conv_8_arr;
81 * Signatures on the HTLC transactions
83 public void set_htlc_signatures(byte[][] val) {
84 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)))));
90 * Constructs a new CommitmentSigned given each field
92 public static CommitmentSigned of(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
93 long ret = bindings.CommitmentSigned_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), 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)))));
94 GC.KeepAlive(channel_id_arg);
95 GC.KeepAlive(signature_arg);
96 GC.KeepAlive(htlc_signatures_arg);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
99 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
103 internal long clone_ptr() {
104 long ret = bindings.CommitmentSigned_clone_ptr(this.ptr);
110 * Creates a copy of the CommitmentSigned
112 public CommitmentSigned clone() {
113 long ret = bindings.CommitmentSigned_clone(this.ptr);
115 if (ret >= 0 && ret <= 4096) { return null; }
116 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
122 * Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
125 long ret = bindings.CommitmentSigned_hash(this.ptr);
130 public override int GetHashCode() {
131 return (int)this.hash();
134 * Checks if two CommitmentSigneds contain equal inner contents.
135 * This ignores pointers and is_owned flags and looks at the values in fields.
136 * Two objects with NULL inner values will be considered "equal" here.
138 public bool eq(org.ldk.structs.CommitmentSigned b) {
139 bool ret = bindings.CommitmentSigned_eq(this.ptr, b == null ? 0 : b.ptr);
142 if (this != null) { this.ptrs_to.AddLast(b); };
146 public override bool Equals(object o) {
147 if (!(o is CommitmentSigned)) return false;
148 return this.eq((CommitmentSigned)o);
151 * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
153 public byte[] write() {
154 long ret = bindings.CommitmentSigned_write(this.ptr);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
162 * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
164 public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
165 long ret = bindings.CommitmentSigned_read(InternalUtils.encodeUint8Array(ser));
167 if (ret >= 0 && ret <= 4096) { return null; }
168 Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);