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 * Information about a spendable output to our \"payment key\".
14 * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class StaticPaymentOutputDescriptor extends CommonBase {
18 StaticPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.StaticPaymentOutputDescriptor_free(ptr); }
26 * The outpoint which is spendable.
28 public OutPoint get_outpoint() {
29 long ret = bindings.StaticPaymentOutputDescriptor_get_outpoint(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38 * The outpoint which is spendable.
40 public void set_outpoint(org.ldk.structs.OutPoint val) {
41 bindings.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * The output which is referenced by the given outpoint.
50 public TxOut get_output() {
51 long ret = bindings.StaticPaymentOutputDescriptor_get_output(this.ptr);
52 Reference.reachabilityFence(this);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 TxOut ret_conv = new TxOut(null, ret);
59 * The output which is referenced by the given outpoint.
61 public void set_output(org.ldk.structs.TxOut val) {
62 bindings.StaticPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
68 * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
69 * This may be useful in re-deriving keys used in the channel to spend the output.
71 public byte[] get_channel_keys_id() {
72 byte[] ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
73 Reference.reachabilityFence(this);
78 * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
79 * This may be useful in re-deriving keys used in the channel to spend the output.
81 public void set_channel_keys_id(byte[] val) {
82 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
83 Reference.reachabilityFence(this);
84 Reference.reachabilityFence(val);
88 * The value of the channel which this transactions spends.
90 public long get_channel_value_satoshis() {
91 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
92 Reference.reachabilityFence(this);
97 * The value of the channel which this transactions spends.
99 public void set_channel_value_satoshis(long val) {
100 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(val);
106 * Constructs a new StaticPaymentOutputDescriptor given each field
108 public static StaticPaymentOutputDescriptor of(org.ldk.structs.OutPoint outpoint_arg, org.ldk.structs.TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
109 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, output_arg.ptr, InternalUtils.check_arr_len(channel_keys_id_arg, 32), channel_value_satoshis_arg);
110 Reference.reachabilityFence(outpoint_arg);
111 Reference.reachabilityFence(output_arg);
112 Reference.reachabilityFence(channel_keys_id_arg);
113 Reference.reachabilityFence(channel_value_satoshis_arg);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
122 long ret = bindings.StaticPaymentOutputDescriptor_clone_ptr(this.ptr);
123 Reference.reachabilityFence(this);
128 * Creates a copy of the StaticPaymentOutputDescriptor
130 public StaticPaymentOutputDescriptor clone() {
131 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
132 Reference.reachabilityFence(this);
133 if (ret >= 0 && ret <= 4096) { return null; }
134 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
135 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
140 * Checks if two StaticPaymentOutputDescriptors contain equal inner contents.
141 * This ignores pointers and is_owned flags and looks at the values in fields.
142 * Two objects with NULL inner values will be considered "equal" here.
144 public boolean eq(org.ldk.structs.StaticPaymentOutputDescriptor b) {
145 boolean ret = bindings.StaticPaymentOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
146 Reference.reachabilityFence(this);
147 Reference.reachabilityFence(b);
148 if (this != null) { this.ptrs_to.add(b); };
152 @Override public boolean equals(Object o) {
153 if (!(o instanceof StaticPaymentOutputDescriptor)) return false;
154 return this.eq((StaticPaymentOutputDescriptor)o);
157 * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
159 public byte[] write() {
160 byte[] ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
161 Reference.reachabilityFence(this);
166 * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
168 public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
169 long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
170 Reference.reachabilityFence(ser);
171 if (ret >= 0 && ret <= 4096) { return null; }
172 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);