[C#] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / c_sharp / src / org / ldk / structs / TrackedSpendableOutput.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * The state of a spendable output currently tracked by an [`OutputSweeper`].
11  */
12 public class TrackedSpendableOutput : CommonBase {
13         internal TrackedSpendableOutput(object _dummy, long ptr) : base(ptr) { }
14         ~TrackedSpendableOutput() {
15                 if (ptr != 0) { bindings.TrackedSpendableOutput_free(ptr); }
16         }
17
18         /**
19          * The tracked output descriptor.
20          */
21         public SpendableOutputDescriptor get_descriptor() {
22                 long ret = bindings.TrackedSpendableOutput_get_descriptor(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * The tracked output descriptor.
32          */
33         public void set_descriptor(org.ldk.structs.SpendableOutputDescriptor val) {
34                 bindings.TrackedSpendableOutput_set_descriptor(this.ptr, val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * The channel this output belongs to.
42          * 
43          * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
44          * 
45          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
46          */
47         public ChannelId get_channel_id() {
48                 long ret = bindings.TrackedSpendableOutput_get_channel_id(this.ptr);
49                 GC.KeepAlive(this);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
52                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53                 return ret_hu_conv;
54         }
55
56         /**
57          * The channel this output belongs to.
58          * 
59          * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`]
60          * 
61          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
62          */
63         public void set_channel_id(org.ldk.structs.ChannelId val) {
64                 bindings.TrackedSpendableOutput_set_channel_id(this.ptr, val == null ? 0 : val.ptr);
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(val);
67                 if (this != null) { this.ptrs_to.AddLast(val); };
68         }
69
70         /**
71          * The current status of the output spend.
72          */
73         public OutputSpendStatus get_status() {
74                 long ret = bindings.TrackedSpendableOutput_get_status(this.ptr);
75                 GC.KeepAlive(this);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 org.ldk.structs.OutputSpendStatus ret_hu_conv = org.ldk.structs.OutputSpendStatus.constr_from_ptr(ret);
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
79                 return ret_hu_conv;
80         }
81
82         /**
83          * The current status of the output spend.
84          */
85         public void set_status(org.ldk.structs.OutputSpendStatus val) {
86                 bindings.TrackedSpendableOutput_set_status(this.ptr, val.ptr);
87                 GC.KeepAlive(this);
88                 GC.KeepAlive(val);
89                 if (this != null) { this.ptrs_to.AddLast(val); };
90         }
91
92         /**
93          * Constructs a new TrackedSpendableOutput given each field
94          * 
95          * Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
96          */
97         public static TrackedSpendableOutput of(org.ldk.structs.SpendableOutputDescriptor descriptor_arg, org.ldk.structs.ChannelId channel_id_arg, org.ldk.structs.OutputSpendStatus status_arg) {
98                 long ret = bindings.TrackedSpendableOutput_new(descriptor_arg.ptr, channel_id_arg == null ? 0 : channel_id_arg.ptr, status_arg.ptr);
99                 GC.KeepAlive(descriptor_arg);
100                 GC.KeepAlive(channel_id_arg);
101                 GC.KeepAlive(status_arg);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.TrackedSpendableOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrackedSpendableOutput(null, ret); }
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(descriptor_arg); };
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(status_arg); };
108                 return ret_hu_conv;
109         }
110
111         internal long clone_ptr() {
112                 long ret = bindings.TrackedSpendableOutput_clone_ptr(this.ptr);
113                 GC.KeepAlive(this);
114                 return ret;
115         }
116
117         /**
118          * Creates a copy of the TrackedSpendableOutput
119          */
120         public TrackedSpendableOutput clone() {
121                 long ret = bindings.TrackedSpendableOutput_clone(this.ptr);
122                 GC.KeepAlive(this);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.TrackedSpendableOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrackedSpendableOutput(null, ret); }
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Checks if two TrackedSpendableOutputs contain equal inner contents.
131          * This ignores pointers and is_owned flags and looks at the values in fields.
132          * Two objects with NULL inner values will be considered "equal" here.
133          */
134         public bool eq(org.ldk.structs.TrackedSpendableOutput b) {
135                 bool ret = bindings.TrackedSpendableOutput_eq(this.ptr, b.ptr);
136                 GC.KeepAlive(this);
137                 GC.KeepAlive(b);
138                 if (this != null) { this.ptrs_to.AddLast(b); };
139                 return ret;
140         }
141
142         public override bool Equals(object o) {
143                 if (!(o is TrackedSpendableOutput)) return false;
144                 return this.eq((TrackedSpendableOutput)o);
145         }
146         /**
147          * Returns whether the output is spent in the given transaction.
148          */
149         public bool is_spent_in(byte[] tx) {
150                 bool ret = bindings.TrackedSpendableOutput_is_spent_in(this.ptr, InternalUtils.encodeUint8Array(tx));
151                 GC.KeepAlive(this);
152                 GC.KeepAlive(tx);
153                 return ret;
154         }
155
156         /**
157          * Serialize the TrackedSpendableOutput object into a byte array which can be read by TrackedSpendableOutput_read
158          */
159         public byte[] write() {
160                 long ret = bindings.TrackedSpendableOutput_write(this.ptr);
161                 GC.KeepAlive(this);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
164                 return ret_conv;
165         }
166
167         /**
168          * Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write
169          */
170         public static Result_TrackedSpendableOutputDecodeErrorZ read(byte[] ser) {
171                 long ret = bindings.TrackedSpendableOutput_read(InternalUtils.encodeUint8Array(ser));
172                 GC.KeepAlive(ser);
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 Result_TrackedSpendableOutputDecodeErrorZ ret_hu_conv = Result_TrackedSpendableOutputDecodeErrorZ.constr_from_ptr(ret);
175                 return ret_hu_conv;
176         }
177
178 }
179 } } }