1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Represents a future resolution of a [`UtxoLookup::get_utxo`] query resolving async.
14 * See [`UtxoResult::Async`] and [`UtxoFuture::resolve`] for more info.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UtxoFuture extends CommonBase {
18 UtxoFuture(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UtxoFuture_free(ptr); }
26 long ret = bindings.UtxoFuture_clone_ptr(this.ptr);
27 Reference.reachabilityFence(this);
32 * Creates a copy of the UtxoFuture
34 public UtxoFuture clone() {
35 long ret = bindings.UtxoFuture_clone(this.ptr);
36 Reference.reachabilityFence(this);
37 if (ret >= 0 && ret <= 4096) { return null; }
38 org.ldk.structs.UtxoFuture ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UtxoFuture(null, ret); }
39 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
44 * Builds a new future for later resolution.
46 public static UtxoFuture of() {
47 long ret = bindings.UtxoFuture_new();
48 if (ret >= 0 && ret <= 4096) { return null; }
49 org.ldk.structs.UtxoFuture ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UtxoFuture(null, ret); }
50 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
55 * Resolves this future against the given `graph` and with the given `result`.
57 * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling
58 * forwarding the validated gossip message onwards to peers.
60 * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order
61 * to allow us to interact with peers again, you should call [`PeerManager::process_events`]
64 * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high
65 * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
67 public void resolve_without_forwarding(org.ldk.structs.NetworkGraph graph, org.ldk.structs.Result_TxOutUtxoLookupErrorZ result) {
68 bindings.UtxoFuture_resolve_without_forwarding(this.ptr, graph.ptr, result.ptr);
69 Reference.reachabilityFence(this);
70 Reference.reachabilityFence(graph);
71 Reference.reachabilityFence(result);
72 if (this != null) { this.ptrs_to.add(graph); };
76 * Resolves this future against the given `graph` and with the given `result`.
78 * The given `gossip` is used to broadcast any validated messages onwards to all peers which
79 * have available buffer space.
81 * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order
82 * to allow us to interact with peers again, you should call [`PeerManager::process_events`]
85 * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high
86 * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
88 public void resolve(org.ldk.structs.NetworkGraph graph, org.ldk.structs.P2PGossipSync gossip, org.ldk.structs.Result_TxOutUtxoLookupErrorZ result) {
89 bindings.UtxoFuture_resolve(this.ptr, graph.ptr, gossip.ptr, result.ptr);
90 Reference.reachabilityFence(this);
91 Reference.reachabilityFence(graph);
92 Reference.reachabilityFence(gossip);
93 Reference.reachabilityFence(result);
94 if (this != null) { this.ptrs_to.add(graph); };
95 if (this != null) { this.ptrs_to.add(gossip); };