c8a2ac1c0f2535244fab4a1b9da29e64ee97d243
[ldk-java] / c_sharp / src / org / ldk / structs / DataLossProtect.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Proof that the sender knows the per-commitment secret of the previous commitment transaction.
11  * This is used to convince the recipient that the channel is at a certain commitment
12  * number even if they lost that data due to a local failure.  Of course, the peer may lie
13  * and even later commitments may have been revoked.
14  */
15 public class DataLossProtect : CommonBase {
16         internal DataLossProtect(object _dummy, long ptr) : base(ptr) { }
17         ~DataLossProtect() {
18                 if (ptr != 0) { bindings.DataLossProtect_free(ptr); }
19         }
20
21         /**
22          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
23          * belonging to the recipient
24          */
25         public byte[] get_your_last_per_commitment_secret() {
26                 byte[] ret = bindings.DataLossProtect_get_your_last_per_commitment_secret(this.ptr);
27                 GC.KeepAlive(this);
28                 return ret;
29         }
30
31         /**
32          * Proof that the sender knows the per-commitment secret of a specific commitment transaction
33          * belonging to the recipient
34          */
35         public void set_your_last_per_commitment_secret(byte[] val) {
36                 bindings.DataLossProtect_set_your_last_per_commitment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39         }
40
41         /**
42          * The sender's per-commitment point for their current commitment transaction
43          */
44         public byte[] get_my_current_per_commitment_point() {
45                 byte[] ret = bindings.DataLossProtect_get_my_current_per_commitment_point(this.ptr);
46                 GC.KeepAlive(this);
47                 return ret;
48         }
49
50         /**
51          * The sender's per-commitment point for their current commitment transaction
52          */
53         public void set_my_current_per_commitment_point(byte[] val) {
54                 bindings.DataLossProtect_set_my_current_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
55                 GC.KeepAlive(this);
56                 GC.KeepAlive(val);
57         }
58
59         /**
60          * Constructs a new DataLossProtect given each field
61          */
62         public static DataLossProtect of(byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg) {
63                 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));
64                 GC.KeepAlive(your_last_per_commitment_secret_arg);
65                 GC.KeepAlive(my_current_per_commitment_point_arg);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 org.ldk.structs.DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DataLossProtect(null, ret); }
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
69                 return ret_hu_conv;
70         }
71
72         internal long clone_ptr() {
73                 long ret = bindings.DataLossProtect_clone_ptr(this.ptr);
74                 GC.KeepAlive(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the DataLossProtect
80          */
81         public DataLossProtect clone() {
82                 long ret = bindings.DataLossProtect_clone(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DataLossProtect(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Checks if two DataLossProtects contain equal inner contents.
92          * This ignores pointers and is_owned flags and looks at the values in fields.
93          * Two objects with NULL inner values will be considered "equal" here.
94          */
95         public bool eq(org.ldk.structs.DataLossProtect b) {
96                 bool ret = bindings.DataLossProtect_eq(this.ptr, b == null ? 0 : b.ptr);
97                 GC.KeepAlive(this);
98                 GC.KeepAlive(b);
99                 if (this != null) { this.ptrs_to.AddLast(b); };
100                 return ret;
101         }
102
103         public override bool Equals(object o) {
104                 if (!(o is DataLossProtect)) return false;
105                 return this.eq((DataLossProtect)o);
106         }
107 }
108 } } }