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.
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.
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 {
24 if (ptr != 0) { bindings.DataLossProtect_free(ptr); }
28 * Proof that the sender knows the per-commitment secret of a specific commitment transaction
29 * belonging to the recipient
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);
38 * Proof that the sender knows the per-commitment secret of a specific commitment transaction
39 * belonging to the recipient
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);
48 * The sender's per-commitment point for their current commitment transaction
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);
57 * The sender's per-commitment point for their current commitment transaction
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);
66 * Constructs a new DataLossProtect given each field
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); };
79 long ret = bindings.DataLossProtect_clone_ptr(this.ptr);
80 Reference.reachabilityFence(this);
85 * Creates a copy of the DataLossProtect
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); };
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.
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); };
109 @Override public boolean equals(Object o) {
110 if (!(o instanceof DataLossProtect)) return false;
111 return this.eq((DataLossProtect)o);