[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / SpendableOutputDescriptor.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  * Describes the necessary information to spend a spendable output.
10  * 
11  * When on-chain outputs are created by LDK (which our counterparty is not able to claim at any
12  * point in the future) a [`SpendableOutputs`] event is generated which you must track and be able
13  * to spend on-chain. The information needed to do this is provided in this enum, including the
14  * outpoint describing which `txid` and output `index` is available, the full output which exists
15  * at that `txid`/`index`, and any keys or other information required to sign.
16  * 
17  * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs
18  */
19 public class SpendableOutputDescriptor : CommonBase {
20         protected SpendableOutputDescriptor(object _dummy, long ptr) : base(ptr) { }
21         ~SpendableOutputDescriptor() {
22                 if (ptr != 0) { bindings.SpendableOutputDescriptor_free(ptr); }
23         }
24
25         internal static SpendableOutputDescriptor constr_from_ptr(long ptr) {
26                 long raw_ty = bindings.LDKSpendableOutputDescriptor_ty_from_ptr(ptr);
27                 switch (raw_ty) {
28                         case 0: return new SpendableOutputDescriptor_StaticOutput(ptr);
29                         case 1: return new SpendableOutputDescriptor_DelayedPaymentOutput(ptr);
30                         case 2: return new SpendableOutputDescriptor_StaticPaymentOutput(ptr);
31                         default:
32                                 throw new ArgumentException("Impossible enum variant");
33                 }
34         }
35
36         /** A SpendableOutputDescriptor of type StaticOutput */
37         public class SpendableOutputDescriptor_StaticOutput : SpendableOutputDescriptor {
38                 /**
39                  * The outpoint which is spendable.
40                  */
41                 public OutPoint outpoint;
42                 /**
43                  * The output which is referenced by the given outpoint.
44                  */
45                 public TxOut output;
46                 /**
47                  * The `channel_keys_id` for the channel which this output came from.
48                  * 
49                  * For channels which were generated on LDK 0.0.119 or later, this is the value which was
50                  * passed to the [`SignerProvider::get_destination_script`] call which provided this
51                  * output script.
52                  * 
53                  * For channels which were generated prior to LDK 0.0.119, no such argument existed,
54                  * however this field may still be filled in if such data is available.
55                  * 
56                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
57                  */
58                 public byte[] channel_keys_id;
59                 internal SpendableOutputDescriptor_StaticOutput(long ptr) : base(null, ptr) {
60                         long outpoint = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(ptr);
61                         org.ldk.structs.OutPoint outpoint_hu_conv = null; if (outpoint < 0 || outpoint > 4096) { outpoint_hu_conv = new org.ldk.structs.OutPoint(null, outpoint); }
62                         if (outpoint_hu_conv != null) { outpoint_hu_conv.ptrs_to.AddLast(this); };
63                         this.outpoint = outpoint_hu_conv;
64                         long output = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_output(ptr);
65                         TxOut output_conv = new TxOut(null, output);
66                         this.output = output_conv;
67                         long channel_keys_id = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_channel_keys_id(ptr);
68                         byte[] channel_keys_id_conv = InternalUtils.decodeUint8Array(channel_keys_id);
69                         this.channel_keys_id = channel_keys_id_conv;
70                 }
71         }
72         /** A SpendableOutputDescriptor of type DelayedPaymentOutput */
73         public class SpendableOutputDescriptor_DelayedPaymentOutput : SpendableOutputDescriptor {
74                 public DelayedPaymentOutputDescriptor delayed_payment_output;
75                 internal SpendableOutputDescriptor_DelayedPaymentOutput(long ptr) : base(null, ptr) {
76                         long delayed_payment_output = bindings.LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(ptr);
77                         org.ldk.structs.DelayedPaymentOutputDescriptor delayed_payment_output_hu_conv = null; if (delayed_payment_output < 0 || delayed_payment_output > 4096) { delayed_payment_output_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, delayed_payment_output); }
78                         if (delayed_payment_output_hu_conv != null) { delayed_payment_output_hu_conv.ptrs_to.AddLast(this); };
79                         this.delayed_payment_output = delayed_payment_output_hu_conv;
80                 }
81         }
82         /** A SpendableOutputDescriptor of type StaticPaymentOutput */
83         public class SpendableOutputDescriptor_StaticPaymentOutput : SpendableOutputDescriptor {
84                 public StaticPaymentOutputDescriptor static_payment_output;
85                 internal SpendableOutputDescriptor_StaticPaymentOutput(long ptr) : base(null, ptr) {
86                         long static_payment_output = bindings.LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(ptr);
87                         org.ldk.structs.StaticPaymentOutputDescriptor static_payment_output_hu_conv = null; if (static_payment_output < 0 || static_payment_output > 4096) { static_payment_output_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, static_payment_output); }
88                         if (static_payment_output_hu_conv != null) { static_payment_output_hu_conv.ptrs_to.AddLast(this); };
89                         this.static_payment_output = static_payment_output_hu_conv;
90                 }
91         }
92         internal long clone_ptr() {
93                 long ret = bindings.SpendableOutputDescriptor_clone_ptr(this.ptr);
94                 GC.KeepAlive(this);
95                 return ret;
96         }
97
98         /**
99          * Creates a copy of the SpendableOutputDescriptor
100          */
101         public SpendableOutputDescriptor clone() {
102                 long ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
103                 GC.KeepAlive(this);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
107                 return ret_hu_conv;
108         }
109
110         /**
111          * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor
112          */
113         public static SpendableOutputDescriptor static_output(org.ldk.structs.OutPoint outpoint, org.ldk.structs.TxOut output, byte[] channel_keys_id) {
114                 long ret = bindings.SpendableOutputDescriptor_static_output(outpoint == null ? 0 : outpoint.ptr, output.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_keys_id, 32)));
115                 GC.KeepAlive(outpoint);
116                 GC.KeepAlive(output);
117                 GC.KeepAlive(channel_keys_id);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
127          */
128         public static SpendableOutputDescriptor delayed_payment_output(org.ldk.structs.DelayedPaymentOutputDescriptor a) {
129                 long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a == null ? 0 : a.ptr);
130                 GC.KeepAlive(a);
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
133                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
134                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
140          */
141         public static SpendableOutputDescriptor static_payment_output(org.ldk.structs.StaticPaymentOutputDescriptor a) {
142                 long ret = bindings.SpendableOutputDescriptor_static_payment_output(a == null ? 0 : a.ptr);
143                 GC.KeepAlive(a);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
146                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor.
153          */
154         public long hash() {
155                 long ret = bindings.SpendableOutputDescriptor_hash(this.ptr);
156                 GC.KeepAlive(this);
157                 return ret;
158         }
159
160         public override int GetHashCode() {
161                 return (int)this.hash();
162         }
163         /**
164          * Checks if two SpendableOutputDescriptors contain equal inner contents.
165          * This ignores pointers and is_owned flags and looks at the values in fields.
166          */
167         public bool eq(org.ldk.structs.SpendableOutputDescriptor b) {
168                 bool ret = bindings.SpendableOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
169                 GC.KeepAlive(this);
170                 GC.KeepAlive(b);
171                 return ret;
172         }
173
174         public override bool Equals(object o) {
175                 if (!(o is SpendableOutputDescriptor)) return false;
176                 return this.eq((SpendableOutputDescriptor)o);
177         }
178         /**
179          * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
180          */
181         public byte[] write() {
182                 long ret = bindings.SpendableOutputDescriptor_write(this.ptr);
183                 GC.KeepAlive(this);
184                 if (ret >= 0 && ret <= 4096) { return null; }
185                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
186                 return ret_conv;
187         }
188
189         /**
190          * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
191          */
192         public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) {
193                 long ret = bindings.SpendableOutputDescriptor_read(InternalUtils.encodeUint8Array(ser));
194                 GC.KeepAlive(ser);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
197                 return ret_hu_conv;
198         }
199
200 }
201 } } }