Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / SpendableOutputDescriptor.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
8
9 /**
10  * When on-chain outputs are created by rust-lightning (which our counterparty is not able to
11  * claim at any point in the future) an event is generated which you must track and be able to
12  * spend on-chain. The information needed to do this is provided in this enum, including the
13  * outpoint describing which txid and output index is available, the full output which exists at
14  * that txid/index, and any keys or other information required to sign.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class SpendableOutputDescriptor extends CommonBase {
18         private SpendableOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.SpendableOutputDescriptor_free(ptr); }
23         }
24         static SpendableOutputDescriptor constr_from_ptr(long ptr) {
25                 bindings.LDKSpendableOutputDescriptor raw_val = bindings.LDKSpendableOutputDescriptor_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticOutput.class) {
27                         return new StaticOutput(ptr, (bindings.LDKSpendableOutputDescriptor.StaticOutput)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput.class) {
30                         return new DelayedPaymentOutput(ptr, (bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput.class) {
33                         return new StaticPaymentOutput(ptr, (bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput)raw_val);
34                 }
35                 assert false; return null; // Unreachable without extending the (internal) bindings interface
36         }
37
38         public final static class StaticOutput extends SpendableOutputDescriptor {
39                 public final OutPoint outpoint;
40                 public final TxOut output;
41                 private StaticOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticOutput obj) {
42                         super(null, ptr);
43                         long outpoint = obj.outpoint;
44                         OutPoint outpoint_hu_conv = new OutPoint(null, outpoint);
45                         outpoint_hu_conv.ptrs_to.add(this);
46                         this.outpoint = outpoint_hu_conv;
47                         long output = obj.output;
48                         TxOut output_conv = new TxOut(null, output);
49                         this.output = output_conv;
50                 }
51         }
52         public final static class DelayedPaymentOutput extends SpendableOutputDescriptor {
53                 public final DelayedPaymentOutputDescriptor delayed_payment_output;
54                 private DelayedPaymentOutput(long ptr, bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput obj) {
55                         super(null, ptr);
56                         long delayed_payment_output = obj.delayed_payment_output;
57                         DelayedPaymentOutputDescriptor delayed_payment_output_hu_conv = new DelayedPaymentOutputDescriptor(null, delayed_payment_output);
58                         delayed_payment_output_hu_conv.ptrs_to.add(this);
59                         this.delayed_payment_output = delayed_payment_output_hu_conv;
60                 }
61         }
62         public final static class StaticPaymentOutput extends SpendableOutputDescriptor {
63                 public final StaticPaymentOutputDescriptor static_payment_output;
64                 private StaticPaymentOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput obj) {
65                         super(null, ptr);
66                         long static_payment_output = obj.static_payment_output;
67                         StaticPaymentOutputDescriptor static_payment_output_hu_conv = new StaticPaymentOutputDescriptor(null, static_payment_output);
68                         static_payment_output_hu_conv.ptrs_to.add(this);
69                         this.static_payment_output = static_payment_output_hu_conv;
70                 }
71         }
72         /**
73          * Creates a copy of the SpendableOutputDescriptor
74          */
75         public SpendableOutputDescriptor clone() {
76                 long ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
77                 SpendableOutputDescriptor ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
78                 ret_hu_conv.ptrs_to.add(this);
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
84          */
85         public byte[] write() {
86                 byte[] ret = bindings.SpendableOutputDescriptor_write(this.ptr);
87                 return ret;
88         }
89
90         /**
91          * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
92          */
93         public static Result_SpendableOutputDescriptorDecodeErrorZ constructor_read(byte[] ser) {
94                 long ret = bindings.SpendableOutputDescriptor_read(ser);
95                 Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
96                 return ret_hu_conv;
97         }
98
99 }