6 namespace org { namespace ldk { namespace structs {
9 * Describes the necessary information to spend a spendable output.
11 * When on-chain outputs are created by LDK (which our counterparty is not able to claim at any
12 * point in the future) a [`SpendableOutputs`] event is generated which you must track and be able
13 * to spend on-chain. The information needed to do this is provided in this enum, including the
14 * outpoint describing which `txid` and output `index` is available, the full output which exists
15 * at that `txid`/`index`, and any keys or other information required to sign.
17 * [`SpendableOutputs`]: crate::util::events::Event::SpendableOutputs
19 public class SpendableOutputDescriptor : CommonBase {
20 protected SpendableOutputDescriptor(object _dummy, long ptr) : base(ptr) { }
21 ~SpendableOutputDescriptor() {
22 if (ptr != 0) { bindings.SpendableOutputDescriptor_free(ptr); }
25 internal static SpendableOutputDescriptor constr_from_ptr(long ptr) {
26 long raw_ty = bindings.LDKSpendableOutputDescriptor_ty_from_ptr(ptr);
28 case 0: return new SpendableOutputDescriptor_StaticOutput(ptr);
29 case 1: return new SpendableOutputDescriptor_DelayedPaymentOutput(ptr);
30 case 2: return new SpendableOutputDescriptor_StaticPaymentOutput(ptr);
32 throw new ArgumentException("Impossible enum variant");
36 /** A SpendableOutputDescriptor of type StaticOutput */
37 public class SpendableOutputDescriptor_StaticOutput : SpendableOutputDescriptor {
39 * The outpoint which is spendable.
41 public OutPoint outpoint;
43 * The output which is referenced by the given outpoint.
46 internal SpendableOutputDescriptor_StaticOutput(long ptr) : base(null, ptr) {
47 long outpoint = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(ptr);
48 org.ldk.structs.OutPoint outpoint_hu_conv = null; if (outpoint < 0 || outpoint > 4096) { outpoint_hu_conv = new org.ldk.structs.OutPoint(null, outpoint); }
49 if (outpoint_hu_conv != null) { outpoint_hu_conv.ptrs_to.AddLast(this); };
50 this.outpoint = outpoint_hu_conv;
51 long output = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_output(ptr);
52 TxOut output_conv = new TxOut(null, output);
53 this.output = output_conv;
56 /** A SpendableOutputDescriptor of type DelayedPaymentOutput */
57 public class SpendableOutputDescriptor_DelayedPaymentOutput : SpendableOutputDescriptor {
58 public DelayedPaymentOutputDescriptor delayed_payment_output;
59 internal SpendableOutputDescriptor_DelayedPaymentOutput(long ptr) : base(null, ptr) {
60 long delayed_payment_output = bindings.LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(ptr);
61 org.ldk.structs.DelayedPaymentOutputDescriptor delayed_payment_output_hu_conv = null; if (delayed_payment_output < 0 || delayed_payment_output > 4096) { delayed_payment_output_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, delayed_payment_output); }
62 if (delayed_payment_output_hu_conv != null) { delayed_payment_output_hu_conv.ptrs_to.AddLast(this); };
63 this.delayed_payment_output = delayed_payment_output_hu_conv;
66 /** A SpendableOutputDescriptor of type StaticPaymentOutput */
67 public class SpendableOutputDescriptor_StaticPaymentOutput : SpendableOutputDescriptor {
68 public StaticPaymentOutputDescriptor static_payment_output;
69 internal SpendableOutputDescriptor_StaticPaymentOutput(long ptr) : base(null, ptr) {
70 long static_payment_output = bindings.LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(ptr);
71 org.ldk.structs.StaticPaymentOutputDescriptor static_payment_output_hu_conv = null; if (static_payment_output < 0 || static_payment_output > 4096) { static_payment_output_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, static_payment_output); }
72 if (static_payment_output_hu_conv != null) { static_payment_output_hu_conv.ptrs_to.AddLast(this); };
73 this.static_payment_output = static_payment_output_hu_conv;
76 internal long clone_ptr() {
77 long ret = bindings.SpendableOutputDescriptor_clone_ptr(this.ptr);
83 * Creates a copy of the SpendableOutputDescriptor
85 public SpendableOutputDescriptor clone() {
86 long ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95 * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor
97 public static SpendableOutputDescriptor static_output(org.ldk.structs.OutPoint outpoint, org.ldk.structs.TxOut output) {
98 long ret = bindings.SpendableOutputDescriptor_static_output(outpoint == null ? 0 : outpoint.ptr, output.ptr);
99 GC.KeepAlive(outpoint);
100 GC.KeepAlive(output);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };
109 * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
111 public static SpendableOutputDescriptor delayed_payment_output(org.ldk.structs.DelayedPaymentOutputDescriptor a) {
112 long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a == null ? 0 : a.ptr);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
122 * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
124 public static SpendableOutputDescriptor static_payment_output(org.ldk.structs.StaticPaymentOutputDescriptor a) {
125 long ret = bindings.SpendableOutputDescriptor_static_payment_output(a == null ? 0 : a.ptr);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
129 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
130 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
135 * Checks if two SpendableOutputDescriptors contain equal inner contents.
136 * This ignores pointers and is_owned flags and looks at the values in fields.
138 public bool eq(org.ldk.structs.SpendableOutputDescriptor b) {
139 bool ret = bindings.SpendableOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
145 public override bool Equals(object o) {
146 if (!(o is SpendableOutputDescriptor)) return false;
147 return this.eq((SpendableOutputDescriptor)o);
150 * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
152 public byte[] write() {
153 byte[] ret = bindings.SpendableOutputDescriptor_write(this.ptr);
159 * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
161 public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) {
162 long ret = bindings.SpendableOutputDescriptor_read(ser);
164 if (ret >= 0 && ret <= 4096) { return null; }
165 Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);