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\". See
13 * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class StaticPaymentOutputDescriptor extends CommonBase {
17 StaticPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.StaticPaymentOutputDescriptor_free(ptr); }
25 * The outpoint which is spendable
27 public OutPoint get_outpoint() {
28 long ret = bindings.StaticPaymentOutputDescriptor_get_outpoint(this.ptr);
29 Reference.reachabilityFence(this);
30 if (ret >= 0 && ret <= 4096) { return null; }
31 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
32 ret_hu_conv.ptrs_to.add(this);
37 * The outpoint which is spendable
39 public void set_outpoint(OutPoint val) {
40 bindings.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
46 * The output which is referenced by the given outpoint
48 * Returns a copy of the field.
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(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
69 * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
70 * the channel to spend the output.
72 public byte[] get_channel_keys_id() {
73 byte[] ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
74 Reference.reachabilityFence(this);
79 * Arbitrary identification information returned by a call to
80 * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
81 * the channel to spend the output.
83 public void set_channel_keys_id(byte[] val) {
84 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
85 Reference.reachabilityFence(this);
86 Reference.reachabilityFence(val);
90 * The value of the channel which this transactions spends.
92 public long get_channel_value_satoshis() {
93 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
94 Reference.reachabilityFence(this);
99 * The value of the channel which this transactions spends.
101 public void set_channel_value_satoshis(long val) {
102 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
103 Reference.reachabilityFence(this);
104 Reference.reachabilityFence(val);
108 * Constructs a new StaticPaymentOutputDescriptor given each field
110 public static StaticPaymentOutputDescriptor of(OutPoint outpoint_arg, TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
111 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, output_arg.ptr, InternalUtils.check_arr_len(channel_keys_id_arg, 32), channel_value_satoshis_arg);
112 Reference.reachabilityFence(outpoint_arg);
113 Reference.reachabilityFence(output_arg);
114 Reference.reachabilityFence(channel_keys_id_arg);
115 Reference.reachabilityFence(channel_value_satoshis_arg);
116 if (ret >= 0 && ret <= 4096) { return null; }
117 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
118 ret_hu_conv.ptrs_to.add(ret_hu_conv);
123 long ret = bindings.StaticPaymentOutputDescriptor_clone_ptr(this.ptr);
124 Reference.reachabilityFence(this);
129 * Creates a copy of the StaticPaymentOutputDescriptor
131 public StaticPaymentOutputDescriptor clone() {
132 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
133 Reference.reachabilityFence(this);
134 if (ret >= 0 && ret <= 4096) { return null; }
135 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
136 ret_hu_conv.ptrs_to.add(this);
141 * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
143 public byte[] write() {
144 byte[] ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
145 Reference.reachabilityFence(this);
150 * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
152 public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
153 long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
154 Reference.reachabilityFence(ser);
155 if (ret >= 0 && ret <= 4096) { return null; }
156 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);