[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / DelayedPaymentKey.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  * A derived key built from a [`DelayedPaymentBasepoint`] and `per_commitment_point`.
11  * 
12  * The delayed payment key is used to pay the commitment state broadcaster their
13  * non-HTLC-encumbered funds after a delay. This delay gives their counterparty a chance to
14  * punish and claim all the channel funds if the state broadcasted was previously revoked.
15  * 
16  * [See the BOLT specs]
17  * (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
18  * for more information on key derivation details.
19  */
20 public class DelayedPaymentKey : CommonBase {
21         internal DelayedPaymentKey(object _dummy, long ptr) : base(ptr) { }
22         ~DelayedPaymentKey() {
23                 if (ptr != 0) { bindings.DelayedPaymentKey_free(ptr); }
24         }
25
26         public byte[] get_a() {
27                 long ret = bindings.DelayedPaymentKey_get_a(this.ptr);
28                 GC.KeepAlive(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
31                 return ret_conv;
32         }
33
34         public void set_a(byte[] val) {
35                 bindings.DelayedPaymentKey_set_a(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * Constructs a new DelayedPaymentKey given each field
42          */
43         public static DelayedPaymentKey of(byte[] a_arg) {
44                 long ret = bindings.DelayedPaymentKey_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a_arg, 33)));
45                 GC.KeepAlive(a_arg);
46                 if (ret >= 0 && ret <= 4096) { return null; }
47                 org.ldk.structs.DelayedPaymentKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentKey(null, ret); }
48                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
49                 return ret_hu_conv;
50         }
51
52         /**
53          * Checks if two DelayedPaymentKeys contain equal inner contents.
54          * This ignores pointers and is_owned flags and looks at the values in fields.
55          * Two objects with NULL inner values will be considered "equal" here.
56          */
57         public bool eq(org.ldk.structs.DelayedPaymentKey b) {
58                 bool ret = bindings.DelayedPaymentKey_eq(this.ptr, b == null ? 0 : b.ptr);
59                 GC.KeepAlive(this);
60                 GC.KeepAlive(b);
61                 if (this != null) { this.ptrs_to.AddLast(b); };
62                 return ret;
63         }
64
65         public override bool Equals(object o) {
66                 if (!(o is DelayedPaymentKey)) return false;
67                 return this.eq((DelayedPaymentKey)o);
68         }
69         internal long clone_ptr() {
70                 long ret = bindings.DelayedPaymentKey_clone_ptr(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * Creates a copy of the DelayedPaymentKey
77          */
78         public DelayedPaymentKey clone() {
79                 long ret = bindings.DelayedPaymentKey_clone(this.ptr);
80                 GC.KeepAlive(this);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.DelayedPaymentKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentKey(null, ret); }
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
84                 return ret_hu_conv;
85         }
86
87         /**
88          * Derive a public delayedpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint`
89          */
90         public static DelayedPaymentKey from_basepoint(org.ldk.structs.DelayedPaymentBasepoint countersignatory_basepoint, byte[] per_commitment_point) {
91                 long ret = bindings.DelayedPaymentKey_from_basepoint(countersignatory_basepoint == null ? 0 : countersignatory_basepoint.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)));
92                 GC.KeepAlive(countersignatory_basepoint);
93                 GC.KeepAlive(per_commitment_point);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 org.ldk.structs.DelayedPaymentKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentKey(null, ret); }
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_basepoint); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Build a delayedpubkey directly from an already-derived private key
103          */
104         public static DelayedPaymentKey from_secret_key(byte[] sk) {
105                 long ret = bindings.DelayedPaymentKey_from_secret_key(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(sk, 32)));
106                 GC.KeepAlive(sk);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.DelayedPaymentKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentKey(null, ret); }
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Get inner Public Key
115          */
116         public byte[] to_public_key() {
117                 long ret = bindings.DelayedPaymentKey_to_public_key(this.ptr);
118                 GC.KeepAlive(this);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
121                 return ret_conv;
122         }
123
124         /**
125          * Serialize the DelayedPaymentKey object into a byte array which can be read by DelayedPaymentKey_read
126          */
127         public byte[] write() {
128                 long ret = bindings.DelayedPaymentKey_write(this.ptr);
129                 GC.KeepAlive(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
132                 return ret_conv;
133         }
134
135         /**
136          * Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write
137          */
138         public static Result_DelayedPaymentKeyDecodeErrorZ read(byte[] ser) {
139                 long ret = bindings.DelayedPaymentKey_read(InternalUtils.encodeUint8Array(ser));
140                 GC.KeepAlive(ser);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 Result_DelayedPaymentKeyDecodeErrorZ ret_hu_conv = Result_DelayedPaymentKeyDecodeErrorZ.constr_from_ptr(ret);
143                 return ret_hu_conv;
144         }
145
146 }
147 } } }