6 namespace org { namespace ldk { namespace structs {
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).
13 * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes
16 public class CounterpartyCommitmentSecrets : CommonBase {
17 internal CounterpartyCommitmentSecrets(object _dummy, long ptr) : base(ptr) { }
18 ~CounterpartyCommitmentSecrets() {
19 if (ptr != 0) { bindings.CounterpartyCommitmentSecrets_free(ptr); }
22 internal long clone_ptr() {
23 long ret = bindings.CounterpartyCommitmentSecrets_clone_ptr(this.ptr);
29 * Creates a copy of the CounterpartyCommitmentSecrets
31 public CounterpartyCommitmentSecrets clone() {
32 long ret = bindings.CounterpartyCommitmentSecrets_clone(this.ptr);
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); };
41 * Creates a new empty `CounterpartyCommitmentSecrets` structure.
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); };
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.
55 public long get_min_seen_secret() {
56 long ret = bindings.CounterpartyCommitmentSecrets_get_min_seen_secret(this.ptr);
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.
65 public Result_NoneNoneZ provide_secret(long idx, byte[] secret) {
66 long ret = bindings.CounterpartyCommitmentSecrets_provide_secret(this.ptr, idx, InternalUtils.check_arr_len(secret, 32));
70 if (ret >= 0 && ret <= 4096) { return null; }
71 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
76 * Returns the secret at `idx`.
77 * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`].
79 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
81 public byte[] get_secret(long idx) {
82 byte[] ret = bindings.CounterpartyCommitmentSecrets_get_secret(this.ptr, idx);
89 * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read
91 public byte[] write() {
92 byte[] ret = bindings.CounterpartyCommitmentSecrets_write(this.ptr);
98 * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write
100 public static Result_CounterpartyCommitmentSecretsDecodeErrorZ read(byte[] ser) {
101 long ret = bindings.CounterpartyCommitmentSecrets_read(ser);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 Result_CounterpartyCommitmentSecretsDecodeErrorZ ret_hu_conv = Result_CounterpartyCommitmentSecretsDecodeErrorZ.constr_from_ptr(ret);