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::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.
47 * The `channel_keys_id` for the channel which this output came from.
49 * For channels which were generated on LDK 0.0.119 or later, this is the value which was
50 * passed to the [`SignerProvider::get_destination_script`] call which provided this
53 * For channels which were generated prior to LDK 0.0.119, no such argument existed,
54 * however this field may still be filled in if such data is available.
56 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
58 public byte[] channel_keys_id;
59 internal SpendableOutputDescriptor_StaticOutput(long ptr) : base(null, ptr) {
60 long outpoint = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(ptr);
61 org.ldk.structs.OutPoint outpoint_hu_conv = null; if (outpoint < 0 || outpoint > 4096) { outpoint_hu_conv = new org.ldk.structs.OutPoint(null, outpoint); }
62 if (outpoint_hu_conv != null) { outpoint_hu_conv.ptrs_to.AddLast(this); };
63 this.outpoint = outpoint_hu_conv;
64 long output = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_output(ptr);
65 TxOut output_conv = new TxOut(null, output);
66 this.output = output_conv;
67 long channel_keys_id = bindings.LDKSpendableOutputDescriptor_StaticOutput_get_channel_keys_id(ptr);
68 byte[] channel_keys_id_conv = InternalUtils.decodeUint8Array(channel_keys_id);
69 this.channel_keys_id = channel_keys_id_conv;
72 /** A SpendableOutputDescriptor of type DelayedPaymentOutput */
73 public class SpendableOutputDescriptor_DelayedPaymentOutput : SpendableOutputDescriptor {
74 public DelayedPaymentOutputDescriptor delayed_payment_output;
75 internal SpendableOutputDescriptor_DelayedPaymentOutput(long ptr) : base(null, ptr) {
76 long delayed_payment_output = bindings.LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(ptr);
77 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); }
78 if (delayed_payment_output_hu_conv != null) { delayed_payment_output_hu_conv.ptrs_to.AddLast(this); };
79 this.delayed_payment_output = delayed_payment_output_hu_conv;
82 /** A SpendableOutputDescriptor of type StaticPaymentOutput */
83 public class SpendableOutputDescriptor_StaticPaymentOutput : SpendableOutputDescriptor {
84 public StaticPaymentOutputDescriptor static_payment_output;
85 internal SpendableOutputDescriptor_StaticPaymentOutput(long ptr) : base(null, ptr) {
86 long static_payment_output = bindings.LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(ptr);
87 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); }
88 if (static_payment_output_hu_conv != null) { static_payment_output_hu_conv.ptrs_to.AddLast(this); };
89 this.static_payment_output = static_payment_output_hu_conv;
92 internal long clone_ptr() {
93 long ret = bindings.SpendableOutputDescriptor_clone_ptr(this.ptr);
99 * Creates a copy of the SpendableOutputDescriptor
101 public SpendableOutputDescriptor clone() {
102 long ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
111 * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor
113 public static SpendableOutputDescriptor static_output(org.ldk.structs.OutPoint outpoint, org.ldk.structs.TxOut output, byte[] channel_keys_id) {
114 long ret = bindings.SpendableOutputDescriptor_static_output(outpoint.ptr, output.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_keys_id, 32)));
115 GC.KeepAlive(outpoint);
116 GC.KeepAlive(output);
117 GC.KeepAlive(channel_keys_id);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
121 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };
126 * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
128 public static SpendableOutputDescriptor delayed_payment_output(org.ldk.structs.DelayedPaymentOutputDescriptor a) {
129 long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a.ptr);
131 if (ret >= 0 && ret <= 4096) { return null; }
132 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
133 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
134 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
139 * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
141 public static SpendableOutputDescriptor static_payment_output(org.ldk.structs.StaticPaymentOutputDescriptor a) {
142 long ret = bindings.SpendableOutputDescriptor_static_payment_output(a.ptr);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret);
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
152 * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor.
155 long ret = bindings.SpendableOutputDescriptor_hash(this.ptr);
160 public override int GetHashCode() {
161 return (int)this.hash();
164 * Checks if two SpendableOutputDescriptors contain equal inner contents.
165 * This ignores pointers and is_owned flags and looks at the values in fields.
167 public bool eq(org.ldk.structs.SpendableOutputDescriptor b) {
168 bool ret = bindings.SpendableOutputDescriptor_eq(this.ptr, b.ptr);
174 public override bool Equals(object o) {
175 if (!(o is SpendableOutputDescriptor)) return false;
176 return this.eq((SpendableOutputDescriptor)o);
179 * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
181 public byte[] write() {
182 long ret = bindings.SpendableOutputDescriptor_write(this.ptr);
184 if (ret >= 0 && ret <= 4096) { return null; }
185 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
190 * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write
192 public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) {
193 long ret = bindings.SpendableOutputDescriptor_read(InternalUtils.encodeUint8Array(ser));
195 if (ret >= 0 && ret <= 4096) { return null; }
196 Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);