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 * The state of a spendable output currently tracked by an [`OutputSweeper`].
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class TrackedSpendableOutput extends CommonBase {
16 TrackedSpendableOutput(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.TrackedSpendableOutput_free(ptr); }
24 * The tracked output descriptor.
26 public SpendableOutputDescriptor get_descriptor() {
27 long ret = bindings.TrackedSpendableOutput_get_descriptor(this.ptr);
28 Reference.reachabilityFence(this);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36 * The tracked output descriptor.
38 public void set_descriptor(org.ldk.structs.SpendableOutputDescriptor val) {
39 bindings.TrackedSpendableOutput_set_descriptor(this.ptr, val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
42 if (this != null) { this.ptrs_to.add(val); };
46 * The channel this output belongs to.
48 * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
50 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
53 public ChannelId get_channel_id() {
54 long ret = bindings.TrackedSpendableOutput_get_channel_id(this.ptr);
55 Reference.reachabilityFence(this);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
58 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
63 * The channel this output belongs to.
65 * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
67 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
69 public void set_channel_id(@Nullable org.ldk.structs.ChannelId val) {
70 bindings.TrackedSpendableOutput_set_channel_id(this.ptr, val == null ? 0 : val.ptr);
71 Reference.reachabilityFence(this);
72 Reference.reachabilityFence(val);
73 if (this != null) { this.ptrs_to.add(val); };
77 * The current status of the output spend.
79 public OutputSpendStatus get_status() {
80 long ret = bindings.TrackedSpendableOutput_get_status(this.ptr);
81 Reference.reachabilityFence(this);
82 if (ret >= 0 && ret <= 4096) { return null; }
83 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
84 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
89 * The current status of the output spend.
91 public void set_status(org.ldk.structs.OutputSpendStatus val) {
92 bindings.TrackedSpendableOutput_set_status(this.ptr, val.ptr);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
95 if (this != null) { this.ptrs_to.add(val); };
99 * Constructs a new TrackedSpendableOutput given each field
101 * Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
103 public static TrackedSpendableOutput of(org.ldk.structs.SpendableOutputDescriptor descriptor_arg, @Nullable org.ldk.structs.ChannelId channel_id_arg, org.ldk.structs.OutputSpendStatus status_arg) {
104 long ret = bindings.TrackedSpendableOutput_new(descriptor_arg.ptr, channel_id_arg == null ? 0 : channel_id_arg.ptr, status_arg.ptr);
105 Reference.reachabilityFence(descriptor_arg);
106 Reference.reachabilityFence(channel_id_arg);
107 Reference.reachabilityFence(status_arg);
108 if (ret >= 0 && ret <= 4096) { return null; }
109 org.ldk.structs.TrackedSpendableOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrackedSpendableOutput(null, ret); }
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
111 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(descriptor_arg); };
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(status_arg); };
118 long ret = bindings.TrackedSpendableOutput_clone_ptr(this.ptr);
119 Reference.reachabilityFence(this);
124 * Creates a copy of the TrackedSpendableOutput
126 public TrackedSpendableOutput clone() {
127 long ret = bindings.TrackedSpendableOutput_clone(this.ptr);
128 Reference.reachabilityFence(this);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.TrackedSpendableOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrackedSpendableOutput(null, ret); }
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
136 * Checks if two TrackedSpendableOutputs contain equal inner contents.
137 * This ignores pointers and is_owned flags and looks at the values in fields.
138 * Two objects with NULL inner values will be considered "equal" here.
140 public boolean eq(org.ldk.structs.TrackedSpendableOutput b) {
141 boolean ret = bindings.TrackedSpendableOutput_eq(this.ptr, b.ptr);
142 Reference.reachabilityFence(this);
143 Reference.reachabilityFence(b);
144 if (this != null) { this.ptrs_to.add(b); };
148 @Override public boolean equals(Object o) {
149 if (!(o instanceof TrackedSpendableOutput)) return false;
150 return this.eq((TrackedSpendableOutput)o);
153 * Returns whether the output is spent in the given transaction.
155 public boolean is_spent_in(byte[] tx) {
156 boolean ret = bindings.TrackedSpendableOutput_is_spent_in(this.ptr, tx);
157 Reference.reachabilityFence(this);
158 Reference.reachabilityFence(tx);
163 * Serialize the TrackedSpendableOutput object into a byte array which can be read by TrackedSpendableOutput_read
165 public byte[] write() {
166 byte[] ret = bindings.TrackedSpendableOutput_write(this.ptr);
167 Reference.reachabilityFence(this);
172 * Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write
174 public static Result_TrackedSpendableOutputDecodeErrorZ read(byte[] ser) {
175 long ret = bindings.TrackedSpendableOutput_read(ser);
176 Reference.reachabilityFence(ser);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 Result_TrackedSpendableOutputDecodeErrorZ ret_hu_conv = Result_TrackedSpendableOutputDecodeErrorZ.constr_from_ptr(ret);