Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / CommitmentUpdate.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8
9 /**
10  * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
11  * transaction updates if they were pending.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class CommitmentUpdate extends CommonBase {
15         CommitmentUpdate(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
20         }
21
22         /**
23          * update_add_htlc messages which should be sent
24          */
25         public void set_update_add_htlcs(UpdateAddHTLC[] val) {
26                 bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15 == null ? 0 : val_conv_15.ptr & ~1).toArray());
27                 /* TODO 2 UpdateAddHTLC  */;
28         }
29
30         /**
31          * update_fulfill_htlc messages which should be sent
32          */
33         public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) {
34                 bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, Arrays.stream(val).mapToLong(val_conv_19 -> val_conv_19 == null ? 0 : val_conv_19.ptr & ~1).toArray());
35                 /* TODO 2 UpdateFulfillHTLC  */;
36         }
37
38         /**
39          * update_fail_htlc messages which should be sent
40          */
41         public void set_update_fail_htlcs(UpdateFailHTLC[] val) {
42                 bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, Arrays.stream(val).mapToLong(val_conv_16 -> val_conv_16 == null ? 0 : val_conv_16.ptr & ~1).toArray());
43                 /* TODO 2 UpdateFailHTLC  */;
44         }
45
46         /**
47          * update_fail_malformed_htlc messages which should be sent
48          */
49         public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) {
50                 bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, Arrays.stream(val).mapToLong(val_conv_25 -> val_conv_25 == null ? 0 : val_conv_25.ptr & ~1).toArray());
51                 /* TODO 2 UpdateFailMalformedHTLC  */;
52         }
53
54         /**
55          * An update_fee message which should be sent
56          * 
57          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
58          */
59         @Nullable
60         public UpdateFee get_update_fee() {
61                 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
62                 if (ret < 1024) { return null; }
63                 UpdateFee ret_hu_conv = new UpdateFee(null, ret);
64                 ret_hu_conv.ptrs_to.add(this);
65                 return ret_hu_conv;
66         }
67
68         /**
69          * An update_fee message which should be sent
70          * 
71          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
72          */
73         public void set_update_fee(@Nullable UpdateFee val) {
74                 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr & ~1);
75                 this.ptrs_to.add(val);
76         }
77
78         /**
79          * Finally, the commitment_signed message which should be sent
80          */
81         public CommitmentSigned get_commitment_signed() {
82                 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
83                 if (ret < 1024) { return null; }
84                 CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret);
85                 ret_hu_conv.ptrs_to.add(this);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Finally, the commitment_signed message which should be sent
91          */
92         public void set_commitment_signed(CommitmentSigned val) {
93                 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr & ~1);
94                 this.ptrs_to.add(val);
95         }
96
97         /**
98          * Constructs a new CommitmentUpdate given each field
99          */
100         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) {
101                 long ret = bindings.CommitmentUpdate_new(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(), 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(), 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(), 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(), update_fee_arg == null ? 0 : update_fee_arg.ptr & ~1, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr & ~1);
102                 if (ret < 1024) { return null; }
103                 CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret);
104                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
105                 /* TODO 2 UpdateAddHTLC  */;
106                 /* TODO 2 UpdateFulfillHTLC  */;
107                 /* TODO 2 UpdateFailHTLC  */;
108                 /* TODO 2 UpdateFailMalformedHTLC  */;
109                 ret_hu_conv.ptrs_to.add(update_fee_arg);
110                 ret_hu_conv.ptrs_to.add(commitment_signed_arg);
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Creates a copy of the CommitmentUpdate
116          */
117         public CommitmentUpdate clone() {
118                 long ret = bindings.CommitmentUpdate_clone(this.ptr);
119                 if (ret < 1024) { return null; }
120                 CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret);
121                 ret_hu_conv.ptrs_to.add(this);
122                 return ret_hu_conv;
123         }
124
125 }