[C#] Run tests against release library in determinism CI run
[ldk-java] / c_sharp / src / org / ldk / structs / OutputSpendStatus.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  * The current status of the output spend.
10  */
11 public class OutputSpendStatus : CommonBase {
12         protected OutputSpendStatus(object _dummy, long ptr) : base(ptr) { }
13         ~OutputSpendStatus() {
14                 if (ptr != 0) { bindings.OutputSpendStatus_free(ptr); }
15         }
16
17         internal static OutputSpendStatus constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKOutputSpendStatus_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new OutputSpendStatus_PendingInitialBroadcast(ptr);
21                         case 1: return new OutputSpendStatus_PendingFirstConfirmation(ptr);
22                         case 2: return new OutputSpendStatus_PendingThresholdConfirmations(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A OutputSpendStatus of type PendingInitialBroadcast */
29         public class OutputSpendStatus_PendingInitialBroadcast : OutputSpendStatus {
30                 /**
31                  * The height at which we will first generate and broadcast a spending transaction.
32                  */
33                 public Option_u32Z delayed_until_height;
34                 internal OutputSpendStatus_PendingInitialBroadcast(long ptr) : base(null, ptr) {
35                         long delayed_until_height = bindings.LDKOutputSpendStatus_PendingInitialBroadcast_get_delayed_until_height(ptr);
36                         org.ldk.structs.Option_u32Z delayed_until_height_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(delayed_until_height);
37                         if (delayed_until_height_hu_conv != null) { delayed_until_height_hu_conv.ptrs_to.AddLast(this); };
38                         this.delayed_until_height = delayed_until_height_hu_conv;
39                 }
40         }
41         /** A OutputSpendStatus of type PendingFirstConfirmation */
42         public class OutputSpendStatus_PendingFirstConfirmation : OutputSpendStatus {
43                 /**
44                  * The hash of the chain tip when we first broadcast a transaction spending this output.
45                  */
46                 public byte[] first_broadcast_hash;
47                 /**
48                  * The best height when we last broadcast a transaction spending this output.
49                  */
50                 public int latest_broadcast_height;
51                 /**
52                  * The transaction spending this output we last broadcasted.
53                  */
54                 public byte[] latest_spending_tx;
55                 internal OutputSpendStatus_PendingFirstConfirmation(long ptr) : base(null, ptr) {
56                         long first_broadcast_hash = bindings.LDKOutputSpendStatus_PendingFirstConfirmation_get_first_broadcast_hash(ptr);
57                         byte[] first_broadcast_hash_conv = InternalUtils.decodeUint8Array(first_broadcast_hash);
58                         this.first_broadcast_hash = first_broadcast_hash_conv;
59                         this.latest_broadcast_height = bindings.LDKOutputSpendStatus_PendingFirstConfirmation_get_latest_broadcast_height(ptr);
60                         long latest_spending_tx = bindings.LDKOutputSpendStatus_PendingFirstConfirmation_get_latest_spending_tx(ptr);
61                         byte[] latest_spending_tx_conv = InternalUtils.decodeUint8Array(latest_spending_tx);
62                         this.latest_spending_tx = latest_spending_tx_conv;
63                 }
64         }
65         /** A OutputSpendStatus of type PendingThresholdConfirmations */
66         public class OutputSpendStatus_PendingThresholdConfirmations : OutputSpendStatus {
67                 /**
68                  * The hash of the chain tip when we first broadcast a transaction spending this output.
69                  */
70                 public byte[] first_broadcast_hash;
71                 /**
72                  * The best height when we last broadcast a transaction spending this output.
73                  */
74                 public int latest_broadcast_height;
75                 /**
76                  * The transaction spending this output we saw confirmed on-chain.
77                  */
78                 public byte[] latest_spending_tx;
79                 /**
80                  * The height at which the spending transaction was confirmed.
81                  */
82                 public int confirmation_height;
83                 /**
84                  * The hash of the block in which the spending transaction was confirmed.
85                  */
86                 public byte[] confirmation_hash;
87                 internal OutputSpendStatus_PendingThresholdConfirmations(long ptr) : base(null, ptr) {
88                         long first_broadcast_hash = bindings.LDKOutputSpendStatus_PendingThresholdConfirmations_get_first_broadcast_hash(ptr);
89                         byte[] first_broadcast_hash_conv = InternalUtils.decodeUint8Array(first_broadcast_hash);
90                         this.first_broadcast_hash = first_broadcast_hash_conv;
91                         this.latest_broadcast_height = bindings.LDKOutputSpendStatus_PendingThresholdConfirmations_get_latest_broadcast_height(ptr);
92                         long latest_spending_tx = bindings.LDKOutputSpendStatus_PendingThresholdConfirmations_get_latest_spending_tx(ptr);
93                         byte[] latest_spending_tx_conv = InternalUtils.decodeUint8Array(latest_spending_tx);
94                         this.latest_spending_tx = latest_spending_tx_conv;
95                         this.confirmation_height = bindings.LDKOutputSpendStatus_PendingThresholdConfirmations_get_confirmation_height(ptr);
96                         long confirmation_hash = bindings.LDKOutputSpendStatus_PendingThresholdConfirmations_get_confirmation_hash(ptr);
97                         byte[] confirmation_hash_conv = InternalUtils.decodeUint8Array(confirmation_hash);
98                         this.confirmation_hash = confirmation_hash_conv;
99                 }
100         }
101         internal long clone_ptr() {
102                 long ret = bindings.OutputSpendStatus_clone_ptr(this.ptr);
103                 GC.KeepAlive(this);
104                 return ret;
105         }
106
107         /**
108          * Creates a copy of the OutputSpendStatus
109          */
110         public OutputSpendStatus clone() {
111                 long ret = bindings.OutputSpendStatus_clone(this.ptr);
112                 GC.KeepAlive(this);
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
116                 return ret_hu_conv;
117         }
118
119         /**
120          * Utility method to constructs a new PendingInitialBroadcast-variant OutputSpendStatus
121          */
122         public static OutputSpendStatus pending_initial_broadcast(org.ldk.structs.Option_u32Z delayed_until_height) {
123                 long ret = bindings.OutputSpendStatus_pending_initial_broadcast(delayed_until_height.ptr);
124                 GC.KeepAlive(delayed_until_height);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(delayed_until_height); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Utility method to constructs a new PendingFirstConfirmation-variant OutputSpendStatus
134          */
135         public static OutputSpendStatus pending_first_confirmation(byte[] first_broadcast_hash, int latest_broadcast_height, byte[] latest_spending_tx) {
136                 long ret = bindings.OutputSpendStatus_pending_first_confirmation(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(first_broadcast_hash, 32)), latest_broadcast_height, InternalUtils.encodeUint8Array(latest_spending_tx));
137                 GC.KeepAlive(first_broadcast_hash);
138                 GC.KeepAlive(latest_broadcast_height);
139                 GC.KeepAlive(latest_spending_tx);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Utility method to constructs a new PendingThresholdConfirmations-variant OutputSpendStatus
148          */
149         public static OutputSpendStatus pending_threshold_confirmations(byte[] first_broadcast_hash, int latest_broadcast_height, byte[] latest_spending_tx, int confirmation_height, byte[] confirmation_hash) {
150                 long ret = bindings.OutputSpendStatus_pending_threshold_confirmations(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(first_broadcast_hash, 32)), latest_broadcast_height, InternalUtils.encodeUint8Array(latest_spending_tx), confirmation_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(confirmation_hash, 32)));
151                 GC.KeepAlive(first_broadcast_hash);
152                 GC.KeepAlive(latest_broadcast_height);
153                 GC.KeepAlive(latest_spending_tx);
154                 GC.KeepAlive(confirmation_height);
155                 GC.KeepAlive(confirmation_hash);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
159                 return ret_hu_conv;
160         }
161
162         /**
163          * Checks if two OutputSpendStatuss contain equal inner contents.
164          * This ignores pointers and is_owned flags and looks at the values in fields.
165          */
166         public bool eq(org.ldk.structs.OutputSpendStatus b) {
167                 bool ret = bindings.OutputSpendStatus_eq(this.ptr, b.ptr);
168                 GC.KeepAlive(this);
169                 GC.KeepAlive(b);
170                 return ret;
171         }
172
173         public override bool Equals(object o) {
174                 if (!(o is OutputSpendStatus)) return false;
175                 return this.eq((OutputSpendStatus)o);
176         }
177         /**
178          * Serialize the OutputSpendStatus object into a byte array which can be read by OutputSpendStatus_read
179          */
180         public byte[] write() {
181                 long ret = bindings.OutputSpendStatus_write(this.ptr);
182                 GC.KeepAlive(this);
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
185                 return ret_conv;
186         }
187
188         /**
189          * Read a OutputSpendStatus from a byte array, created by OutputSpendStatus_write
190          */
191         public static Result_OutputSpendStatusDecodeErrorZ read(byte[] ser) {
192                 long ret = bindings.OutputSpendStatus_read(InternalUtils.encodeUint8Array(ser));
193                 GC.KeepAlive(ser);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 Result_OutputSpendStatusDecodeErrorZ ret_hu_conv = Result_OutputSpendStatusDecodeErrorZ.constr_from_ptr(ret);
196                 return ret_hu_conv;
197         }
198
199 }
200 } } }