1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Proof that the sender knows the per-commitment secret of the previous commitment transaction.
13 * This is used to convince the recipient that the channel is at a certain commitment
14 * number even if they lost that data due to a local failure. Of course, the peer may lie
15 * and even later commitments may have been revoked.
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class DataLossProtect extends CommonBase {
19 DataLossProtect(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.DataLossProtect_free(ptr); }
27 * Proof that the sender knows the per-commitment secret of a specific commitment transaction
28 * belonging to the recipient
30 public byte[] get_your_last_per_commitment_secret() {
31 byte[] ret = bindings.DataLossProtect_get_your_last_per_commitment_secret(this.ptr);
32 Reference.reachabilityFence(this);
37 * Proof that the sender knows the per-commitment secret of a specific commitment transaction
38 * belonging to the recipient
40 public void set_your_last_per_commitment_secret(byte[] val) {
41 bindings.DataLossProtect_set_your_last_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
47 * The sender's per-commitment point for their current commitment transaction
49 public byte[] get_my_current_per_commitment_point() {
50 byte[] ret = bindings.DataLossProtect_get_my_current_per_commitment_point(this.ptr);
51 Reference.reachabilityFence(this);
56 * The sender's per-commitment point for their current commitment transaction
58 public void set_my_current_per_commitment_point(byte[] val) {
59 bindings.DataLossProtect_set_my_current_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
60 Reference.reachabilityFence(this);
61 Reference.reachabilityFence(val);
65 * Constructs a new DataLossProtect given each field
67 public static DataLossProtect of(byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg) {
68 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));
69 Reference.reachabilityFence(your_last_per_commitment_secret_arg);
70 Reference.reachabilityFence(my_current_per_commitment_point_arg);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DataLossProtect(null, ret); }
73 ret_hu_conv.ptrs_to.add(ret_hu_conv);
78 long ret = bindings.DataLossProtect_clone_ptr(this.ptr);
79 Reference.reachabilityFence(this);
84 * Creates a copy of the DataLossProtect
86 public DataLossProtect clone() {
87 long ret = bindings.DataLossProtect_clone(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DataLossProtect(null, ret); }
91 ret_hu_conv.ptrs_to.add(this);