1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
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.
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 {
22 if (ptr != 0) { bindings.SpendableOutputDescriptor_free(ptr); }
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);
29 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput.class) {
30 return new DelayedPaymentOutput(ptr, (bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput)raw_val);
32 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput.class) {
33 return new StaticPaymentOutput(ptr, (bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput)raw_val);
35 assert false; return null; // Unreachable without extending the (internal) bindings interface
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) {
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;
52 public final static class DelayedPaymentOutput extends SpendableOutputDescriptor {
53 public final DelayedPaymentOutputDescriptor delayed_payment_output;
54 private DelayedPaymentOutput(long ptr, bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput obj) {
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;
62 public final static class StaticPaymentOutput extends SpendableOutputDescriptor {
63 public final StaticPaymentOutputDescriptor static_payment_output;
64 private StaticPaymentOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput obj) {
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;
73 * Creates a copy of the SpendableOutputDescriptor
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);
83 * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
85 public byte[] write() {
86 byte[] ret = bindings.SpendableOutputDescriptor_write(this.ptr);
91 * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
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);