[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                 internal SpendableOutputDescriptor_StaticOutput(long ptr) : base(null, ptr) {
47                         long outpoint = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(ptr);
48                         org.ldk.structs.OutPoint outpoint_hu_conv = null; if (outpoint < 0 || outpoint > 4096) { outpoint_hu_conv = new org.ldk.structs.OutPoint(null, outpoint); }
49                         if (outpoint_hu_conv != null) { outpoint_hu_conv.ptrs_to.AddLast(this); };
50                         this.outpoint = outpoint_hu_conv;
51                         long output = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_output(ptr);
52                         TxOut output_conv = new TxOut(null, output);
53                         this.output = output_conv;
54                 }
55         }
56         /** A SpendableOutputDescriptor of type DelayedPaymentOutput */
57         public class SpendableOutputDescriptor_DelayedPaymentOutput : SpendableOutputDescriptor {
58                 public DelayedPaymentOutputDescriptor delayed_payment_output;
59                 internal SpendableOutputDescriptor_DelayedPaymentOutput(long ptr) : base(null, ptr) {
60                         long delayed_payment_output = bindings.LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(ptr);
61                         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); }
62                         if (delayed_payment_output_hu_conv != null) { delayed_payment_output_hu_conv.ptrs_to.AddLast(this); };
63                         this.delayed_payment_output = delayed_payment_output_hu_conv;
64                 }
65         }
66         /** A SpendableOutputDescriptor of type StaticPaymentOutput */
67         public class SpendableOutputDescriptor_StaticPaymentOutput : SpendableOutputDescriptor {
68                 public StaticPaymentOutputDescriptor static_payment_output;
69                 internal SpendableOutputDescriptor_StaticPaymentOutput(long ptr) : base(null, ptr) {
70                         long static_payment_output = bindings.LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(ptr);
71                         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); }
72                         if (static_payment_output_hu_conv != null) { static_payment_output_hu_conv.ptrs_to.AddLast(this); };
73                         this.static_payment_output = static_payment_output_hu_conv;
74                 }
75         }
76         internal long clone_ptr() {
77                 long ret = bindings.SpendableOutputDescriptor_clone_ptr(this.ptr);
78                 GC.KeepAlive(this);
79                 return ret;
80         }
81
82         /**
83          * Creates a copy of the SpendableOutputDescriptor
84          */
85         public SpendableOutputDescriptor clone() {
86                 long ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
87                 GC.KeepAlive(this);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor
96          */
97         public static SpendableOutputDescriptor static_output(org.ldk.structs.OutPoint outpoint, org.ldk.structs.TxOut output) {
98                 long ret = bindings.SpendableOutputDescriptor_static_output(outpoint == null ? 0 : outpoint.ptr, output.ptr);
99                 GC.KeepAlive(outpoint);
100                 GC.KeepAlive(output);
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
110          */
111         public static SpendableOutputDescriptor delayed_payment_output(org.ldk.structs.DelayedPaymentOutputDescriptor a) {
112                 long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a == null ? 0 : a.ptr);
113                 GC.KeepAlive(a);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
123          */
124         public static SpendableOutputDescriptor static_payment_output(org.ldk.structs.StaticPaymentOutputDescriptor a) {
125                 long ret = bindings.SpendableOutputDescriptor_static_payment_output(a == null ? 0 : a.ptr);
126                 GC.KeepAlive(a);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
130                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor.
136          */
137         public long hash() {
138                 long ret = bindings.SpendableOutputDescriptor_hash(this.ptr);
139                 GC.KeepAlive(this);
140                 return ret;
141         }
142
143         public override int GetHashCode() {
144                 return (int)this.hash();
145         }
146         /**
147          * Checks if two SpendableOutputDescriptors contain equal inner contents.
148          * This ignores pointers and is_owned flags and looks at the values in fields.
149          */
150         public bool eq(org.ldk.structs.SpendableOutputDescriptor b) {
151                 bool ret = bindings.SpendableOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
152                 GC.KeepAlive(this);
153                 GC.KeepAlive(b);
154                 return ret;
155         }
156
157         public override bool Equals(object o) {
158                 if (!(o is SpendableOutputDescriptor)) return false;
159                 return this.eq((SpendableOutputDescriptor)o);
160         }
161         /**
162          * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
163          */
164         public byte[] write() {
165                 long ret = bindings.SpendableOutputDescriptor_write(this.ptr);
166                 GC.KeepAlive(this);
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
169                 return ret_conv;
170         }
171
172         /**
173          * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
174          */
175         public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) {
176                 long ret = bindings.SpendableOutputDescriptor_read(InternalUtils.encodeUint8Array(ser));
177                 GC.KeepAlive(ser);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
180                 return ret_hu_conv;
181         }
182
183 }
184 } } }