[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / TrackedSpendableOutput.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 state of a spendable output currently tracked by an [`OutputSweeper`].
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.TrackedSpendableOutput_free(ptr); }
21         }
22
23         /**
24          * The tracked output descriptor.
25          */
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); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The tracked output descriptor.
37          */
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); };
43         }
44
45         /**
46          * The channel this output belongs to.
47          * 
48          * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
49          * 
50          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
51          */
52         @Nullable
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); };
59                 return ret_hu_conv;
60         }
61
62         /**
63          * The channel this output belongs to.
64          * 
65          * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
66          * 
67          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
68          */
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); };
74         }
75
76         /**
77          * The current status of the output spend.
78          */
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); };
85                 return ret_hu_conv;
86         }
87
88         /**
89          * The current status of the output spend.
90          */
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); };
96         }
97
98         /**
99          * Constructs a new TrackedSpendableOutput given each field
100          * 
101          * Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
102          */
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); };
114                 return ret_hu_conv;
115         }
116
117         long clone_ptr() {
118                 long ret = bindings.TrackedSpendableOutput_clone_ptr(this.ptr);
119                 Reference.reachabilityFence(this);
120                 return ret;
121         }
122
123         /**
124          * Creates a copy of the TrackedSpendableOutput
125          */
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); };
132                 return ret_hu_conv;
133         }
134
135         /**
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.
139          */
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); };
145                 return ret;
146         }
147
148         @Override public boolean equals(Object o) {
149                 if (!(o instanceof TrackedSpendableOutput)) return false;
150                 return this.eq((TrackedSpendableOutput)o);
151         }
152         /**
153          * Returns whether the output is spent in the given transaction.
154          */
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);
159                 return ret;
160         }
161
162         /**
163          * Serialize the TrackedSpendableOutput object into a byte array which can be read by TrackedSpendableOutput_read
164          */
165         public byte[] write() {
166                 byte[] ret = bindings.TrackedSpendableOutput_write(this.ptr);
167                 Reference.reachabilityFence(this);
168                 return ret;
169         }
170
171         /**
172          * Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write
173          */
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);
179                 return ret_hu_conv;
180         }
181
182 }