]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/OutputSpendStatus.java
[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / OutputSpendStatus.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * The current status of the output spend.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class OutputSpendStatus extends CommonBase {
16         private OutputSpendStatus(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.OutputSpendStatus_free(ptr); }
21         }
22         static OutputSpendStatus constr_from_ptr(long ptr) {
23                 bindings.LDKOutputSpendStatus raw_val = bindings.LDKOutputSpendStatus_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKOutputSpendStatus.PendingInitialBroadcast.class) {
25                         return new PendingInitialBroadcast(ptr, (bindings.LDKOutputSpendStatus.PendingInitialBroadcast)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKOutputSpendStatus.PendingFirstConfirmation.class) {
28                         return new PendingFirstConfirmation(ptr, (bindings.LDKOutputSpendStatus.PendingFirstConfirmation)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKOutputSpendStatus.PendingThresholdConfirmations.class) {
31                         return new PendingThresholdConfirmations(ptr, (bindings.LDKOutputSpendStatus.PendingThresholdConfirmations)raw_val);
32                 }
33                 assert false; return null; // Unreachable without extending the (internal) bindings interface
34         }
35
36         /**
37          * The output is tracked but an initial spending transaction hasn't been generated and
38          * broadcasted yet.
39          */
40         public final static class PendingInitialBroadcast extends OutputSpendStatus {
41                 /**
42                  * The height at which we will first generate and broadcast a spending transaction.
43                 */
44                 public final org.ldk.structs.Option_u32Z delayed_until_height;
45                 private PendingInitialBroadcast(long ptr, bindings.LDKOutputSpendStatus.PendingInitialBroadcast obj) {
46                         super(null, ptr);
47                         long delayed_until_height = obj.delayed_until_height;
48                         org.ldk.structs.Option_u32Z delayed_until_height_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(delayed_until_height);
49                         if (delayed_until_height_hu_conv != null) { delayed_until_height_hu_conv.ptrs_to.add(this); };
50                         this.delayed_until_height = delayed_until_height_hu_conv;
51                 }
52         }
53         /**
54          * A transaction spending the output has been broadcasted but is pending its first confirmation on-chain.
55          */
56         public final static class PendingFirstConfirmation extends OutputSpendStatus {
57                 /**
58                  * The hash of the chain tip when we first broadcast a transaction spending this output.
59                 */
60                 public final byte[] first_broadcast_hash;
61                 /**
62                  * The best height when we last broadcast a transaction spending this output.
63                 */
64                 public final int latest_broadcast_height;
65                 /**
66                  * The transaction spending this output we last broadcasted.
67                 */
68                 public final byte[] latest_spending_tx;
69                 private PendingFirstConfirmation(long ptr, bindings.LDKOutputSpendStatus.PendingFirstConfirmation obj) {
70                         super(null, ptr);
71                         this.first_broadcast_hash = obj.first_broadcast_hash;
72                         this.latest_broadcast_height = obj.latest_broadcast_height;
73                         this.latest_spending_tx = obj.latest_spending_tx;
74                 }
75         }
76         /**
77          * A transaction spending the output has been confirmed on-chain but will be tracked until it
78          * reaches [`ANTI_REORG_DELAY`] confirmations.
79          */
80         public final static class PendingThresholdConfirmations extends OutputSpendStatus {
81                 /**
82                  * The hash of the chain tip when we first broadcast a transaction spending this output.
83                 */
84                 public final byte[] first_broadcast_hash;
85                 /**
86                  * The best height when we last broadcast a transaction spending this output.
87                 */
88                 public final int latest_broadcast_height;
89                 /**
90                  * The transaction spending this output we saw confirmed on-chain.
91                 */
92                 public final byte[] latest_spending_tx;
93                 /**
94                  * The height at which the spending transaction was confirmed.
95                 */
96                 public final int confirmation_height;
97                 /**
98                  * The hash of the block in which the spending transaction was confirmed.
99                 */
100                 public final byte[] confirmation_hash;
101                 private PendingThresholdConfirmations(long ptr, bindings.LDKOutputSpendStatus.PendingThresholdConfirmations obj) {
102                         super(null, ptr);
103                         this.first_broadcast_hash = obj.first_broadcast_hash;
104                         this.latest_broadcast_height = obj.latest_broadcast_height;
105                         this.latest_spending_tx = obj.latest_spending_tx;
106                         this.confirmation_height = obj.confirmation_height;
107                         this.confirmation_hash = obj.confirmation_hash;
108                 }
109         }
110         long clone_ptr() {
111                 long ret = bindings.OutputSpendStatus_clone_ptr(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * Creates a copy of the OutputSpendStatus
118          */
119         public OutputSpendStatus clone() {
120                 long ret = bindings.OutputSpendStatus_clone(this.ptr);
121                 Reference.reachabilityFence(this);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
125                 return ret_hu_conv;
126         }
127
128         /**
129          * Utility method to constructs a new PendingInitialBroadcast-variant OutputSpendStatus
130          */
131         public static OutputSpendStatus pending_initial_broadcast(org.ldk.structs.Option_u32Z delayed_until_height) {
132                 long ret = bindings.OutputSpendStatus_pending_initial_broadcast(delayed_until_height.ptr);
133                 Reference.reachabilityFence(delayed_until_height);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(delayed_until_height); };
138                 return ret_hu_conv;
139         }
140
141         /**
142          * Utility method to constructs a new PendingFirstConfirmation-variant OutputSpendStatus
143          */
144         public static OutputSpendStatus pending_first_confirmation(byte[] first_broadcast_hash, int latest_broadcast_height, byte[] latest_spending_tx) {
145                 long ret = bindings.OutputSpendStatus_pending_first_confirmation(InternalUtils.check_arr_len(first_broadcast_hash, 32), latest_broadcast_height, latest_spending_tx);
146                 Reference.reachabilityFence(first_broadcast_hash);
147                 Reference.reachabilityFence(latest_broadcast_height);
148                 Reference.reachabilityFence(latest_spending_tx);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
151                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Utility method to constructs a new PendingThresholdConfirmations-variant OutputSpendStatus
157          */
158         public static OutputSpendStatus pending_threshold_confirmations(byte[] first_broadcast_hash, int latest_broadcast_height, byte[] latest_spending_tx, int confirmation_height, byte[] confirmation_hash) {
159                 long ret = bindings.OutputSpendStatus_pending_threshold_confirmations(InternalUtils.check_arr_len(first_broadcast_hash, 32), latest_broadcast_height, latest_spending_tx, confirmation_height, InternalUtils.check_arr_len(confirmation_hash, 32));
160                 Reference.reachabilityFence(first_broadcast_hash);
161                 Reference.reachabilityFence(latest_broadcast_height);
162                 Reference.reachabilityFence(latest_spending_tx);
163                 Reference.reachabilityFence(confirmation_height);
164                 Reference.reachabilityFence(confirmation_hash);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
168                 return ret_hu_conv;
169         }
170
171         /**
172          * Checks if two OutputSpendStatuss contain equal inner contents.
173          * This ignores pointers and is_owned flags and looks at the values in fields.
174          */
175         public boolean eq(org.ldk.structs.OutputSpendStatus b) {
176                 boolean ret = bindings.OutputSpendStatus_eq(this.ptr, b.ptr);
177                 Reference.reachabilityFence(this);
178                 Reference.reachabilityFence(b);
179                 return ret;
180         }
181
182         @Override public boolean equals(Object o) {
183                 if (!(o instanceof OutputSpendStatus)) return false;
184                 return this.eq((OutputSpendStatus)o);
185         }
186         /**
187          * Serialize the OutputSpendStatus object into a byte array which can be read by OutputSpendStatus_read
188          */
189         public byte[] write() {
190                 byte[] ret = bindings.OutputSpendStatus_write(this.ptr);
191                 Reference.reachabilityFence(this);
192                 return ret;
193         }
194
195         /**
196          * Read a OutputSpendStatus from a byte array, created by OutputSpendStatus_write
197          */
198         public static Result_OutputSpendStatusDecodeErrorZ read(byte[] ser) {
199                 long ret = bindings.OutputSpendStatus_read(ser);
200                 Reference.reachabilityFence(ser);
201                 if (ret >= 0 && ret <= 4096) { return null; }
202                 Result_OutputSpendStatusDecodeErrorZ ret_hu_conv = Result_OutputSpendStatusDecodeErrorZ.constr_from_ptr(ret);
203                 return ret_hu_conv;
204         }
205
206 }