Class CounterpartyCommitmentSecrets


  • public class CounterpartyCommitmentSecrets
    extends Object
    Implements the per-commitment secret storage scheme from [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes or so.
    • Method Detail

      • get_min_seen_secret

        public long get_min_seen_secret()
        Returns the minimum index of all stored secrets. Note that indexes start at 1 << 48 and get decremented by one for each new secret.
      • provide_secret

        public Result_NoneNoneZ provide_secret​(long idx,
                                               byte[] secret)
        Inserts the `secret` at `idx`. Returns `Ok(())` if the secret was generated in accordance with BOLT 3 and is consistent with previous secrets.
      • get_secret

        @Nullable
        public byte[] get_secret​(long idx)
        Returns the secret at `idx`. Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
      • write

        public byte[] write()
        Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read