[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / CounterpartyCommitmentSecrets.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  * Implements the per-commitment secret storage scheme from
11  * [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage).
12  * 
13  * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes
14  * or so.
15  */
16 public class CounterpartyCommitmentSecrets : CommonBase {
17         internal CounterpartyCommitmentSecrets(object _dummy, long ptr) : base(ptr) { }
18         ~CounterpartyCommitmentSecrets() {
19                 if (ptr != 0) { bindings.CounterpartyCommitmentSecrets_free(ptr); }
20         }
21
22         internal long clone_ptr() {
23                 long ret = bindings.CounterpartyCommitmentSecrets_clone_ptr(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * Creates a copy of the CounterpartyCommitmentSecrets
30          */
31         public CounterpartyCommitmentSecrets clone() {
32                 long ret = bindings.CounterpartyCommitmentSecrets_clone(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.CounterpartyCommitmentSecrets ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyCommitmentSecrets(null, ret); }
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Creates a new empty `CounterpartyCommitmentSecrets` structure.
42          */
43         public static CounterpartyCommitmentSecrets of() {
44                 long ret = bindings.CounterpartyCommitmentSecrets_new();
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 org.ldk.structs.CounterpartyCommitmentSecrets ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CounterpartyCommitmentSecrets(null, ret); }
47                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
48                 return ret_hu_conv;
49         }
50
51         /**
52          * Returns the minimum index of all stored secrets. Note that indexes start
53          * at 1 << 48 and get decremented by one for each new secret.
54          */
55         public long get_min_seen_secret() {
56                 long ret = bindings.CounterpartyCommitmentSecrets_get_min_seen_secret(this.ptr);
57                 GC.KeepAlive(this);
58                 return ret;
59         }
60
61         /**
62          * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret
63          * was generated in accordance with BOLT 3 and is consistent with previous secrets.
64          */
65         public Result_NoneNoneZ provide_secret(long idx, byte[] secret) {
66                 long ret = bindings.CounterpartyCommitmentSecrets_provide_secret(this.ptr, idx, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(secret, 32)));
67                 GC.KeepAlive(this);
68                 GC.KeepAlive(idx);
69                 GC.KeepAlive(secret);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Returns the secret at `idx`.
77          * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`].
78          * 
79          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
80          */
81         public byte[] get_secret(long idx) {
82                 long ret = bindings.CounterpartyCommitmentSecrets_get_secret(this.ptr, idx);
83                 GC.KeepAlive(this);
84                 GC.KeepAlive(idx);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
87                 return ret_conv;
88         }
89
90         /**
91          * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read
92          */
93         public byte[] write() {
94                 long ret = bindings.CounterpartyCommitmentSecrets_write(this.ptr);
95                 GC.KeepAlive(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
98                 return ret_conv;
99         }
100
101         /**
102          * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write
103          */
104         public static Result_CounterpartyCommitmentSecretsDecodeErrorZ read(byte[] ser) {
105                 long ret = bindings.CounterpartyCommitmentSecrets_read(InternalUtils.encodeUint8Array(ser));
106                 GC.KeepAlive(ser);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 Result_CounterpartyCommitmentSecretsDecodeErrorZ ret_hu_conv = Result_CounterpartyCommitmentSecretsDecodeErrorZ.constr_from_ptr(ret);
109                 return ret_hu_conv;
110         }
111
112 }
113 } } }