[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / UtxoResult.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 result of a [`UtxoLookup::get_utxo`] call. A call may resolve either synchronously,
13  * returning the `Sync` variant, or asynchronously, returning an [`UtxoFuture`] in the `Async`
14  * variant.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UtxoResult extends CommonBase {
18         private UtxoResult(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UtxoResult_free(ptr); }
23         }
24         static UtxoResult constr_from_ptr(long ptr) {
25                 bindings.LDKUtxoResult raw_val = bindings.LDKUtxoResult_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKUtxoResult.Sync.class) {
27                         return new Sync(ptr, (bindings.LDKUtxoResult.Sync)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKUtxoResult.Async.class) {
30                         return new Async(ptr, (bindings.LDKUtxoResult.Async)raw_val);
31                 }
32                 assert false; return null; // Unreachable without extending the (internal) bindings interface
33         }
34
35         /**
36          * A result which was resolved synchronously. It either includes a [`TxOut`] for the output
37          * requested or a [`UtxoLookupError`].
38          */
39         public final static class Sync extends UtxoResult {
40                 public final org.ldk.structs.Result_TxOutUtxoLookupErrorZ sync;
41                 private Sync(long ptr, bindings.LDKUtxoResult.Sync obj) {
42                         super(null, ptr);
43                         long sync = obj.sync;
44                         Result_TxOutUtxoLookupErrorZ sync_hu_conv = Result_TxOutUtxoLookupErrorZ.constr_from_ptr(sync);
45                         this.sync = sync_hu_conv;
46                 }
47         }
48         /**
49          * A result which will be resolved asynchronously. It includes a [`UtxoFuture`], a `clone` of
50          * which you must keep locally and call [`UtxoFuture::resolve`] on once the lookup completes.
51          * 
52          * Note that in order to avoid runaway memory usage, the number of parallel checks is limited,
53          * but only fairly loosely. Because a pending checks block all message processing, leaving
54          * checks pending for an extended time may cause DoS of other functions. It is recommended you
55          * keep a tight timeout on lookups, on the order of a few seconds.
56          */
57         public final static class Async extends UtxoResult {
58                 public final org.ldk.structs.UtxoFuture async;
59                 private Async(long ptr, bindings.LDKUtxoResult.Async obj) {
60                         super(null, ptr);
61                         long async = obj.async;
62                         org.ldk.structs.UtxoFuture async_hu_conv = null; if (async < 0 || async > 4096) { async_hu_conv = new org.ldk.structs.UtxoFuture(null, async); }
63                         if (async_hu_conv != null) { async_hu_conv.ptrs_to.add(this); };
64                         this.async = async_hu_conv;
65                 }
66         }
67         long clone_ptr() {
68                 long ret = bindings.UtxoResult_clone_ptr(this.ptr);
69                 Reference.reachabilityFence(this);
70                 return ret;
71         }
72
73         /**
74          * Creates a copy of the UtxoResult
75          */
76         public UtxoResult clone() {
77                 long ret = bindings.UtxoResult_clone(this.ptr);
78                 Reference.reachabilityFence(this);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 org.ldk.structs.UtxoResult ret_hu_conv = org.ldk.structs.UtxoResult.constr_from_ptr(ret);
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
82                 return ret_hu_conv;
83         }
84
85         /**
86          * Utility method to constructs a new Sync-variant UtxoResult
87          */
88         public static UtxoResult sync(org.ldk.structs.Result_TxOutUtxoLookupErrorZ a) {
89                 long ret = bindings.UtxoResult_sync(a.ptr);
90                 Reference.reachabilityFence(a);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.UtxoResult ret_hu_conv = org.ldk.structs.UtxoResult.constr_from_ptr(ret);
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Utility method to constructs a new Async-variant UtxoResult
99          */
100         public static UtxoResult async(org.ldk.structs.UtxoFuture a) {
101                 long ret = bindings.UtxoResult_async(a.ptr);
102                 Reference.reachabilityFence(a);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.UtxoResult ret_hu_conv = org.ldk.structs.UtxoResult.constr_from_ptr(ret);
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
107                 return ret_hu_conv;
108         }
109
110 }