1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
12 * transaction updates if they were pending.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class CommitmentUpdate extends CommonBase {
16 CommitmentUpdate(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
24 * update_add_htlc messages which should be sent
26 public void set_update_add_htlcs(UpdateAddHTLC[] val) {
27 bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15 == null ? 0 : val_conv_15.ptr & ~1).toArray() : null);
28 /* TODO 2 UpdateAddHTLC */;
32 * update_fulfill_htlc messages which should be sent
34 public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) {
35 bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_19 -> val_conv_19 == null ? 0 : val_conv_19.ptr & ~1).toArray() : null);
36 /* TODO 2 UpdateFulfillHTLC */;
40 * update_fail_htlc messages which should be sent
42 public void set_update_fail_htlcs(UpdateFailHTLC[] val) {
43 bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_16 -> val_conv_16 == null ? 0 : val_conv_16.ptr & ~1).toArray() : null);
44 /* TODO 2 UpdateFailHTLC */;
48 * update_fail_malformed_htlc messages which should be sent
50 public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) {
51 bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_25 -> val_conv_25 == null ? 0 : val_conv_25.ptr & ~1).toArray() : null);
52 /* TODO 2 UpdateFailMalformedHTLC */;
56 * An update_fee message which should be sent
58 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
61 public UpdateFee get_update_fee() {
62 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
63 if (ret < 1024) { return null; }
64 UpdateFee ret_hu_conv = new UpdateFee(null, ret);
65 ret_hu_conv.ptrs_to.add(this);
70 * An update_fee message which should be sent
72 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
74 public void set_update_fee(@Nullable UpdateFee val) {
75 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr & ~1);
76 this.ptrs_to.add(val);
80 * Finally, the commitment_signed message which should be sent
82 public CommitmentSigned get_commitment_signed() {
83 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
84 if (ret < 1024) { return null; }
85 CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret);
86 ret_hu_conv.ptrs_to.add(this);
91 * Finally, the commitment_signed message which should be sent
93 public void set_commitment_signed(CommitmentSigned val) {
94 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr & ~1);
95 this.ptrs_to.add(val);
99 * Constructs a new CommitmentUpdate given each field
101 public static CommitmentUpdate of(UpdateAddHTLC[] update_add_htlcs_arg, UpdateFulfillHTLC[] update_fulfill_htlcs_arg, UpdateFailHTLC[] update_fail_htlcs_arg, UpdateFailMalformedHTLC[] update_fail_malformed_htlcs_arg, UpdateFee update_fee_arg, CommitmentSigned commitment_signed_arg) {
102 long ret = bindings.CommitmentUpdate_new(update_add_htlcs_arg != null ? Arrays.stream(update_add_htlcs_arg).mapToLong(update_add_htlcs_arg_conv_15 -> update_add_htlcs_arg_conv_15 == null ? 0 : update_add_htlcs_arg_conv_15.ptr & ~1).toArray() : null, update_fulfill_htlcs_arg != null ? Arrays.stream(update_fulfill_htlcs_arg).mapToLong(update_fulfill_htlcs_arg_conv_19 -> update_fulfill_htlcs_arg_conv_19 == null ? 0 : update_fulfill_htlcs_arg_conv_19.ptr & ~1).toArray() : null, update_fail_htlcs_arg != null ? Arrays.stream(update_fail_htlcs_arg).mapToLong(update_fail_htlcs_arg_conv_16 -> update_fail_htlcs_arg_conv_16 == null ? 0 : update_fail_htlcs_arg_conv_16.ptr & ~1).toArray() : null, update_fail_malformed_htlcs_arg != null ? Arrays.stream(update_fail_malformed_htlcs_arg).mapToLong(update_fail_malformed_htlcs_arg_conv_25 -> update_fail_malformed_htlcs_arg_conv_25 == null ? 0 : update_fail_malformed_htlcs_arg_conv_25.ptr & ~1).toArray() : null, update_fee_arg == null ? 0 : update_fee_arg.ptr & ~1, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr & ~1);
103 if (ret < 1024) { return null; }
104 CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret);
105 ret_hu_conv.ptrs_to.add(ret_hu_conv);
106 /* TODO 2 UpdateAddHTLC */;
107 /* TODO 2 UpdateFulfillHTLC */;
108 /* TODO 2 UpdateFailHTLC */;
109 /* TODO 2 UpdateFailMalformedHTLC */;
110 ret_hu_conv.ptrs_to.add(update_fee_arg);
111 ret_hu_conv.ptrs_to.add(commitment_signed_arg);
116 * Creates a copy of the CommitmentUpdate
118 public CommitmentUpdate clone() {
119 long ret = bindings.CommitmentUpdate_clone(this.ptr);
120 if (ret < 1024) { return null; }
121 CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret);
122 ret_hu_conv.ptrs_to.add(this);