6 namespace org { namespace ldk { namespace structs {
10 * The revocation key is used to allow a channel party to revoke their state - giving their
11 * counterparty the required material to claim all of their funds if they broadcast that state.
13 * Each commitment transaction has a revocation key based on the basepoint and
14 * per_commitment_point which is used in both commitment and HTLC transactions.
16 * See [the BOLT spec for derivation details]
17 * (https://github.com/lightning/bolts/blob/master/03-transactions.md#revocationpubkey-derivation)
19 public class RevocationKey : CommonBase {
20 internal RevocationKey(object _dummy, long ptr) : base(ptr) { }
22 if (ptr != 0) { bindings.RevocationKey_free(ptr); }
25 public byte[] get_a() {
26 long ret = bindings.RevocationKey_get_a(this.ptr);
28 if (ret >= 0 && ret <= 4096) { return null; }
29 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
33 public void set_a(byte[] val) {
34 bindings.RevocationKey_set_a(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
40 * Constructs a new RevocationKey given each field
42 public static RevocationKey of(byte[] a_arg) {
43 long ret = bindings.RevocationKey_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a_arg, 33)));
45 if (ret >= 0 && ret <= 4096) { return null; }
46 org.ldk.structs.RevocationKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationKey(null, ret); }
47 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
52 * Checks if two RevocationKeys contain equal inner contents.
53 * This ignores pointers and is_owned flags and looks at the values in fields.
54 * Two objects with NULL inner values will be considered "equal" here.
56 public bool eq(org.ldk.structs.RevocationKey b) {
57 bool ret = bindings.RevocationKey_eq(this.ptr, b.ptr);
60 if (this != null) { this.ptrs_to.AddLast(b); };
64 public override bool Equals(object o) {
65 if (!(o is RevocationKey)) return false;
66 return this.eq((RevocationKey)o);
68 internal long clone_ptr() {
69 long ret = bindings.RevocationKey_clone_ptr(this.ptr);
75 * Creates a copy of the RevocationKey
77 public RevocationKey clone() {
78 long ret = bindings.RevocationKey_clone(this.ptr);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.RevocationKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationKey(null, ret); }
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87 * Generates a non-cryptographic 64-bit hash of the RevocationKey.
90 long ret = bindings.RevocationKey_hash(this.ptr);
95 public override int GetHashCode() {
96 return (int)this.hash();
99 * Derives a per-commitment-transaction revocation public key from one party's per-commitment
100 * point and the other party's [`RevocationBasepoint`]. This is the public equivalent of
101 * [`chan_utils::derive_private_revocation_key`] - using only public keys to derive a public
102 * key instead of private keys.
104 * Note that this is infallible iff we trust that at least one of the two input keys are randomly
105 * generated (ie our own).
107 * [`chan_utils::derive_private_revocation_key`]: crate::ln::chan_utils::derive_private_revocation_key
109 public static RevocationKey from_basepoint(org.ldk.structs.RevocationBasepoint countersignatory_basepoint, byte[] per_commitment_point) {
110 long ret = bindings.RevocationKey_from_basepoint(countersignatory_basepoint.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)));
111 GC.KeepAlive(countersignatory_basepoint);
112 GC.KeepAlive(per_commitment_point);
113 if (ret >= 0 && ret <= 4096) { return null; }
114 org.ldk.structs.RevocationKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationKey(null, ret); }
115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_basepoint); };
121 * Get inner Public Key
123 public byte[] to_public_key() {
124 long ret = bindings.RevocationKey_to_public_key(this.ptr);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
132 * Serialize the RevocationKey object into a byte array which can be read by RevocationKey_read
134 public byte[] write() {
135 long ret = bindings.RevocationKey_write(this.ptr);
137 if (ret >= 0 && ret <= 4096) { return null; }
138 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
143 * Read a RevocationKey from a byte array, created by RevocationKey_write
145 public static Result_RevocationKeyDecodeErrorZ read(byte[] ser) {
146 long ret = bindings.RevocationKey_read(InternalUtils.encodeUint8Array(ser));
148 if (ret >= 0 && ret <= 4096) { return null; }
149 Result_RevocationKeyDecodeErrorZ ret_hu_conv = Result_RevocationKeyDecodeErrorZ.constr_from_ptr(ret);