Add handling for signed int64 type
[ldk-java] / src / main / java / org / ldk / structs / DataLossProtect.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 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Proof that the sender knows the per-commitment secret of the previous commitment transaction.
13  * 
14  * This is used to convince the recipient that the channel is at a certain commitment
15  * number even if they lost that data due to a local failure. Of course, the peer may lie
16  * and even later commitments may have been revoked.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class DataLossProtect extends CommonBase {
20         DataLossProtect(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.DataLossProtect_free(ptr); }
25         }
26
27         /**
28          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
29          * belonging to the recipient
30          */
31         public byte[] get_your_last_per_commitment_secret() {
32                 byte[] ret = bindings.DataLossProtect_get_your_last_per_commitment_secret(this.ptr);
33                 Reference.reachabilityFence(this);
34                 return ret;
35         }
36
37         /**
38          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
39          * belonging to the recipient
40          */
41         public void set_your_last_per_commitment_secret(byte[] val) {
42                 bindings.DataLossProtect_set_your_last_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
43                 Reference.reachabilityFence(this);
44                 Reference.reachabilityFence(val);
45         }
46
47         /**
48          * The sender's per-commitment point for their current commitment transaction
49          */
50         public byte[] get_my_current_per_commitment_point() {
51                 byte[] ret = bindings.DataLossProtect_get_my_current_per_commitment_point(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * The sender's per-commitment point for their current commitment transaction
58          */
59         public void set_my_current_per_commitment_point(byte[] val) {
60                 bindings.DataLossProtect_set_my_current_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * Constructs a new DataLossProtect given each field
67          */
68         public static DataLossProtect of(byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg) {
69                 long ret = bindings.DataLossProtect_new(InternalUtils.check_arr_len(your_last_per_commitment_secret_arg, 32), InternalUtils.check_arr_len(my_current_per_commitment_point_arg, 33));
70                 Reference.reachabilityFence(your_last_per_commitment_secret_arg);
71                 Reference.reachabilityFence(my_current_per_commitment_point_arg);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DataLossProtect(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75                 return ret_hu_conv;
76         }
77
78         long clone_ptr() {
79                 long ret = bindings.DataLossProtect_clone_ptr(this.ptr);
80                 Reference.reachabilityFence(this);
81                 return ret;
82         }
83
84         /**
85          * Creates a copy of the DataLossProtect
86          */
87         public DataLossProtect clone() {
88                 long ret = bindings.DataLossProtect_clone(this.ptr);
89                 Reference.reachabilityFence(this);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DataLossProtect(null, ret); }
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Checks if two DataLossProtects contain equal inner contents.
98          * This ignores pointers and is_owned flags and looks at the values in fields.
99          * Two objects with NULL inner values will be considered "equal" here.
100          */
101         public boolean eq(org.ldk.structs.DataLossProtect b) {
102                 boolean ret = bindings.DataLossProtect_eq(this.ptr, b == null ? 0 : b.ptr);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(b);
105                 if (this != null) { this.ptrs_to.add(b); };
106                 return ret;
107         }
108
109         @Override public boolean equals(Object o) {
110                 if (!(o instanceof DataLossProtect)) return false;
111                 return this.eq((DataLossProtect)o);
112         }
113 }