6 namespace org { namespace ldk { namespace structs {
10 * A descriptor used to sign for a commitment transaction's HTLC output.
12 public class HTLCDescriptor : CommonBase {
13 internal HTLCDescriptor(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.HTLCDescriptor_free(ptr); }
19 * The parameters required to derive the signer for the HTLC input.
21 public ChannelDerivationParameters get_channel_derivation_parameters() {
22 long ret = bindings.HTLCDescriptor_get_channel_derivation_parameters(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
26 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
31 * The parameters required to derive the signer for the HTLC input.
33 public void set_channel_derivation_parameters(org.ldk.structs.ChannelDerivationParameters val) {
34 bindings.HTLCDescriptor_set_channel_derivation_parameters(this.ptr, val.ptr);
37 if (this != null) { this.ptrs_to.AddLast(val); };
41 * The txid of the commitment transaction in which the HTLC output lives.
43 public byte[] get_commitment_txid() {
44 long ret = bindings.HTLCDescriptor_get_commitment_txid(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
52 * The txid of the commitment transaction in which the HTLC output lives.
54 public void set_commitment_txid(byte[] val) {
55 bindings.HTLCDescriptor_set_commitment_txid(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
61 * The number of the commitment transaction in which the HTLC output lives.
63 public long get_per_commitment_number() {
64 long ret = bindings.HTLCDescriptor_get_per_commitment_number(this.ptr);
70 * The number of the commitment transaction in which the HTLC output lives.
72 public void set_per_commitment_number(long val) {
73 bindings.HTLCDescriptor_set_per_commitment_number(this.ptr, val);
79 * The key tweak corresponding to the number of the commitment transaction in which the HTLC
80 * output lives. This tweak is applied to all the basepoints for both parties in the channel to
81 * arrive at unique keys per commitment.
83 * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
85 public byte[] get_per_commitment_point() {
86 long ret = bindings.HTLCDescriptor_get_per_commitment_point(this.ptr);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
94 * The key tweak corresponding to the number of the commitment transaction in which the HTLC
95 * output lives. This tweak is applied to all the basepoints for both parties in the channel to
96 * arrive at unique keys per commitment.
98 * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
100 public void set_per_commitment_point(byte[] val) {
101 bindings.HTLCDescriptor_set_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
107 * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
108 * originating from a channel supporting anchor outputs, otherwise it is the channel's
109 * negotiated feerate at the time the commitment transaction was built.
111 public int get_feerate_per_kw() {
112 int ret = bindings.HTLCDescriptor_get_feerate_per_kw(this.ptr);
118 * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
119 * originating from a channel supporting anchor outputs, otherwise it is the channel's
120 * negotiated feerate at the time the commitment transaction was built.
122 public void set_feerate_per_kw(int val) {
123 bindings.HTLCDescriptor_set_feerate_per_kw(this.ptr, val);
129 * The details of the HTLC as it appears in the commitment transaction.
131 public HTLCOutputInCommitment get_htlc() {
132 long ret = bindings.HTLCDescriptor_get_htlc(this.ptr);
134 if (ret >= 0 && ret <= 4096) { return null; }
135 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
136 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
141 * The details of the HTLC as it appears in the commitment transaction.
143 public void set_htlc(org.ldk.structs.HTLCOutputInCommitment val) {
144 bindings.HTLCDescriptor_set_htlc(this.ptr, val.ptr);
147 if (this != null) { this.ptrs_to.AddLast(val); };
151 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
154 public Option_ThirtyTwoBytesZ get_preimage() {
155 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
157 if (ret >= 0 && ret <= 4096) { return null; }
158 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
159 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
164 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
167 public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
168 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
171 if (this != null) { this.ptrs_to.AddLast(val); };
175 * The counterparty's signature required to spend the HTLC output.
177 public byte[] get_counterparty_sig() {
178 long ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
180 if (ret >= 0 && ret <= 4096) { return null; }
181 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
186 * The counterparty's signature required to spend the HTLC output.
188 public void set_counterparty_sig(byte[] val) {
189 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
195 * Constructs a new HTLCDescriptor given each field
197 public static HTLCDescriptor of(org.ldk.structs.ChannelDerivationParameters channel_derivation_parameters_arg, byte[] commitment_txid_arg, long per_commitment_number_arg, byte[] per_commitment_point_arg, int feerate_per_kw_arg, org.ldk.structs.HTLCOutputInCommitment htlc_arg, org.ldk.structs.Option_ThirtyTwoBytesZ preimage_arg, byte[] counterparty_sig_arg) {
198 long ret = bindings.HTLCDescriptor_new(channel_derivation_parameters_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_txid_arg, 32)), per_commitment_number_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point_arg, 33)), feerate_per_kw_arg, htlc_arg.ptr, preimage_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_sig_arg, 64)));
199 GC.KeepAlive(channel_derivation_parameters_arg);
200 GC.KeepAlive(commitment_txid_arg);
201 GC.KeepAlive(per_commitment_number_arg);
202 GC.KeepAlive(per_commitment_point_arg);
203 GC.KeepAlive(feerate_per_kw_arg);
204 GC.KeepAlive(htlc_arg);
205 GC.KeepAlive(preimage_arg);
206 GC.KeepAlive(counterparty_sig_arg);
207 if (ret >= 0 && ret <= 4096) { return null; }
208 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
209 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_derivation_parameters_arg); };
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlc_arg); };
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(preimage_arg); };
216 internal long clone_ptr() {
217 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
223 * Creates a copy of the HTLCDescriptor
225 public HTLCDescriptor clone() {
226 long ret = bindings.HTLCDescriptor_clone(this.ptr);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
230 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
235 * Checks if two HTLCDescriptors contain equal inner contents.
236 * This ignores pointers and is_owned flags and looks at the values in fields.
237 * Two objects with NULL inner values will be considered "equal" here.
239 public bool eq(org.ldk.structs.HTLCDescriptor b) {
240 bool ret = bindings.HTLCDescriptor_eq(this.ptr, b.ptr);
243 if (this != null) { this.ptrs_to.AddLast(b); };
247 public override bool Equals(object o) {
248 if (!(o is HTLCDescriptor)) return false;
249 return this.eq((HTLCDescriptor)o);
252 * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
254 public byte[] write() {
255 long ret = bindings.HTLCDescriptor_write(this.ptr);
257 if (ret >= 0 && ret <= 4096) { return null; }
258 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
263 * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
265 public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
266 long ret = bindings.HTLCDescriptor_read(InternalUtils.encodeUint8Array(ser));
268 if (ret >= 0 && ret <= 4096) { return null; }
269 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
274 * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
275 * being spent by the HTLC input in the HTLC transaction.
277 public OutPoint outpoint() {
278 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
280 if (ret >= 0 && ret <= 4096) { return null; }
281 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
282 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
287 * Returns the UTXO to be spent by the HTLC input, which can be obtained via
288 * [`Self::unsigned_tx_input`].
290 public TxOut previous_utxo() {
291 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
293 if (ret >= 0 && ret <= 4096) { return null; }
294 TxOut ret_conv = new TxOut(null, ret);
299 * Returns the unsigned transaction input spending the HTLC output in the commitment
302 public TxIn unsigned_tx_input() {
303 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
305 if (ret >= 0 && ret <= 4096) { return null; }
306 TxIn ret_conv = new TxIn(null, ret);
311 * Returns the delayed output created as a result of spending the HTLC output in the commitment
314 public TxOut tx_output() {
315 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
317 if (ret >= 0 && ret <= 4096) { return null; }
318 TxOut ret_conv = new TxOut(null, ret);
323 * Returns the witness script of the HTLC output in the commitment transaction.
325 public byte[] witness_script() {
326 long ret = bindings.HTLCDescriptor_witness_script(this.ptr);
328 if (ret >= 0 && ret <= 4096) { return null; }
329 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
334 * Returns the fully signed witness required to spend the HTLC output in the commitment
337 public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
338 long ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature, 64)), InternalUtils.encodeUint8Array(witness_script));
340 GC.KeepAlive(signature);
341 GC.KeepAlive(witness_script);
342 if (ret >= 0 && ret <= 4096) { return null; }
343 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
348 * Derives the channel signer required to sign the HTLC input.
350 public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
351 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
353 GC.KeepAlive(signer_provider);
354 if (ret >= 0 && ret <= 4096) { return null; }
355 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
356 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
357 if (this != null) { this.ptrs_to.AddLast(signer_provider); };