1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class SpendableOutputDescriptor extends CommonBase {
10 private SpendableOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
11 @Override @SuppressWarnings("deprecation")
12 protected void finalize() throws Throwable {
14 if (ptr != 0) { bindings.SpendableOutputDescriptor_free(ptr); }
16 static SpendableOutputDescriptor constr_from_ptr(long ptr) {
17 bindings.LDKSpendableOutputDescriptor raw_val = bindings.LDKSpendableOutputDescriptor_ref_from_ptr(ptr);
18 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticOutput.class) {
19 return new StaticOutput(ptr, (bindings.LDKSpendableOutputDescriptor.StaticOutput)raw_val);
21 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.DynamicOutputP2WSH.class) {
22 return new DynamicOutputP2WSH(ptr, (bindings.LDKSpendableOutputDescriptor.DynamicOutputP2WSH)raw_val);
24 if (raw_val.getClass() == bindings.LDKSpendableOutputDescriptor.StaticOutputCounterpartyPayment.class) {
25 return new StaticOutputCounterpartyPayment(ptr, (bindings.LDKSpendableOutputDescriptor.StaticOutputCounterpartyPayment)raw_val);
27 assert false; return null; // Unreachable without extending the (internal) bindings interface
30 public final static class StaticOutput extends SpendableOutputDescriptor {
31 public final OutPoint outpoint;
32 public final TxOut output;
33 private StaticOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticOutput obj) {
35 long outpoint = obj.outpoint;
36 OutPoint outpoint_hu_conv = new OutPoint(null, outpoint);
37 this.outpoint = outpoint_hu_conv;
38 long output = obj.output;
39 TxOut output_conv = new TxOut(null, output);
40 this.output = output_conv;
43 public final static class DynamicOutputP2WSH extends SpendableOutputDescriptor {
44 public final OutPoint outpoint;
45 public final byte[] per_commitment_point;
46 public final short to_self_delay;
47 public final TxOut output;
48 public final TwoTuple<Long, Long> key_derivation_params;
49 public final byte[] revocation_pubkey;
50 private DynamicOutputP2WSH(long ptr, bindings.LDKSpendableOutputDescriptor.DynamicOutputP2WSH obj) {
52 long outpoint = obj.outpoint;
53 OutPoint outpoint_hu_conv = new OutPoint(null, outpoint);
54 this.outpoint = outpoint_hu_conv;
55 this.per_commitment_point = obj.per_commitment_point;
56 this.to_self_delay = obj.to_self_delay;
57 long output = obj.output;
58 TxOut output_conv = new TxOut(null, output);
59 this.output = output_conv;
60 long key_derivation_params = obj.key_derivation_params;
61 long key_derivation_params_a = bindings.LDKC2Tuple_u64u64Z_get_a(key_derivation_params);
62 long key_derivation_params_b = bindings.LDKC2Tuple_u64u64Z_get_b(key_derivation_params);
63 TwoTuple<Long, Long> key_derivation_params_conv = new TwoTuple<Long, Long>(key_derivation_params_a, key_derivation_params_b);
64 this.key_derivation_params = key_derivation_params_conv;
65 this.revocation_pubkey = obj.revocation_pubkey;
68 public final static class StaticOutputCounterpartyPayment extends SpendableOutputDescriptor {
69 public final OutPoint outpoint;
70 public final TxOut output;
71 public final TwoTuple<Long, Long> key_derivation_params;
72 private StaticOutputCounterpartyPayment(long ptr, bindings.LDKSpendableOutputDescriptor.StaticOutputCounterpartyPayment obj) {
74 long outpoint = obj.outpoint;
75 OutPoint outpoint_hu_conv = new OutPoint(null, outpoint);
76 this.outpoint = outpoint_hu_conv;
77 long output = obj.output;
78 TxOut output_conv = new TxOut(null, output);
79 this.output = output_conv;
80 long key_derivation_params = obj.key_derivation_params;
81 long key_derivation_params_a = bindings.LDKC2Tuple_u64u64Z_get_a(key_derivation_params);
82 long key_derivation_params_b = bindings.LDKC2Tuple_u64u64Z_get_b(key_derivation_params);
83 TwoTuple<Long, Long> key_derivation_params_conv = new TwoTuple<Long, Long>(key_derivation_params_a, key_derivation_params_b);
84 this.key_derivation_params = key_derivation_params_conv;