1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A descriptor used to sign for a commitment transaction's HTLC output.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class HTLCDescriptor extends CommonBase {
16 HTLCDescriptor(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.HTLCDescriptor_free(ptr); }
24 * The parameters required to derive the signer for the HTLC input.
26 public ChannelDerivationParameters get_channel_derivation_parameters() {
27 long ret = bindings.HTLCDescriptor_get_channel_derivation_parameters(this.ptr);
28 Reference.reachabilityFence(this);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
36 * The parameters required to derive the signer for the HTLC input.
38 public void set_channel_derivation_parameters(org.ldk.structs.ChannelDerivationParameters val) {
39 bindings.HTLCDescriptor_set_channel_derivation_parameters(this.ptr, val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
45 * The txid of the commitment transaction in which the HTLC output lives.
47 public byte[] get_commitment_txid() {
48 byte[] ret = bindings.HTLCDescriptor_get_commitment_txid(this.ptr);
49 Reference.reachabilityFence(this);
54 * The txid of the commitment transaction in which the HTLC output lives.
56 public void set_commitment_txid(byte[] val) {
57 bindings.HTLCDescriptor_set_commitment_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
58 Reference.reachabilityFence(this);
59 Reference.reachabilityFence(val);
63 * The number of the commitment transaction in which the HTLC output lives.
65 public long get_per_commitment_number() {
66 long ret = bindings.HTLCDescriptor_get_per_commitment_number(this.ptr);
67 Reference.reachabilityFence(this);
72 * The number of the commitment transaction in which the HTLC output lives.
74 public void set_per_commitment_number(long val) {
75 bindings.HTLCDescriptor_set_per_commitment_number(this.ptr, val);
76 Reference.reachabilityFence(this);
77 Reference.reachabilityFence(val);
81 * The key tweak corresponding to the number of the commitment transaction in which the HTLC
82 * output lives. This tweak is applied to all the basepoints for both parties in the channel to
83 * arrive at unique keys per commitment.
85 * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
87 public byte[] get_per_commitment_point() {
88 byte[] ret = bindings.HTLCDescriptor_get_per_commitment_point(this.ptr);
89 Reference.reachabilityFence(this);
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.check_arr_len(val, 33));
102 Reference.reachabilityFence(this);
103 Reference.reachabilityFence(val);
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);
113 Reference.reachabilityFence(this);
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);
124 Reference.reachabilityFence(this);
125 Reference.reachabilityFence(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);
133 Reference.reachabilityFence(this);
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.add(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);
145 Reference.reachabilityFence(this);
146 Reference.reachabilityFence(val);
150 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
153 public Option_ThirtyTwoBytesZ get_preimage() {
154 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
155 Reference.reachabilityFence(this);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
158 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
163 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
166 public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
167 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
168 Reference.reachabilityFence(this);
169 Reference.reachabilityFence(val);
173 * The counterparty's signature required to spend the HTLC output.
175 public byte[] get_counterparty_sig() {
176 byte[] ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
177 Reference.reachabilityFence(this);
182 * The counterparty's signature required to spend the HTLC output.
184 public void set_counterparty_sig(byte[] val) {
185 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.check_arr_len(val, 64));
186 Reference.reachabilityFence(this);
187 Reference.reachabilityFence(val);
191 * Constructs a new HTLCDescriptor given each field
193 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) {
194 long ret = bindings.HTLCDescriptor_new(channel_derivation_parameters_arg.ptr, InternalUtils.check_arr_len(commitment_txid_arg, 32), per_commitment_number_arg, InternalUtils.check_arr_len(per_commitment_point_arg, 33), feerate_per_kw_arg, htlc_arg.ptr, preimage_arg.ptr, InternalUtils.check_arr_len(counterparty_sig_arg, 64));
195 Reference.reachabilityFence(channel_derivation_parameters_arg);
196 Reference.reachabilityFence(commitment_txid_arg);
197 Reference.reachabilityFence(per_commitment_number_arg);
198 Reference.reachabilityFence(per_commitment_point_arg);
199 Reference.reachabilityFence(feerate_per_kw_arg);
200 Reference.reachabilityFence(htlc_arg);
201 Reference.reachabilityFence(preimage_arg);
202 Reference.reachabilityFence(counterparty_sig_arg);
203 if (ret >= 0 && ret <= 4096) { return null; }
204 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
205 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
210 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
211 Reference.reachabilityFence(this);
216 * Creates a copy of the HTLCDescriptor
218 public HTLCDescriptor clone() {
219 long ret = bindings.HTLCDescriptor_clone(this.ptr);
220 Reference.reachabilityFence(this);
221 if (ret >= 0 && ret <= 4096) { return null; }
222 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
223 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
228 * Checks if two HTLCDescriptors contain equal inner contents.
229 * This ignores pointers and is_owned flags and looks at the values in fields.
230 * Two objects with NULL inner values will be considered "equal" here.
232 public boolean eq(org.ldk.structs.HTLCDescriptor b) {
233 boolean ret = bindings.HTLCDescriptor_eq(this.ptr, b.ptr);
234 Reference.reachabilityFence(this);
235 Reference.reachabilityFence(b);
236 if (this != null) { this.ptrs_to.add(b); };
240 @Override public boolean equals(Object o) {
241 if (!(o instanceof HTLCDescriptor)) return false;
242 return this.eq((HTLCDescriptor)o);
245 * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
247 public byte[] write() {
248 byte[] ret = bindings.HTLCDescriptor_write(this.ptr);
249 Reference.reachabilityFence(this);
254 * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
256 public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
257 long ret = bindings.HTLCDescriptor_read(ser);
258 Reference.reachabilityFence(ser);
259 if (ret >= 0 && ret <= 4096) { return null; }
260 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
265 * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
266 * being spent by the HTLC input in the HTLC transaction.
268 public OutPoint outpoint() {
269 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
270 Reference.reachabilityFence(this);
271 if (ret >= 0 && ret <= 4096) { return null; }
272 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
273 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
278 * Returns the UTXO to be spent by the HTLC input, which can be obtained via
279 * [`Self::unsigned_tx_input`].
281 public TxOut previous_utxo() {
282 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
283 Reference.reachabilityFence(this);
284 if (ret >= 0 && ret <= 4096) { return null; }
285 TxOut ret_conv = new TxOut(null, ret);
290 * Returns the unsigned transaction input spending the HTLC output in the commitment
293 public TxIn unsigned_tx_input() {
294 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
295 Reference.reachabilityFence(this);
296 if (ret >= 0 && ret <= 4096) { return null; }
297 TxIn ret_conv = new TxIn(null, ret);
302 * Returns the delayed output created as a result of spending the HTLC output in the commitment
305 public TxOut tx_output() {
306 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
307 Reference.reachabilityFence(this);
308 if (ret >= 0 && ret <= 4096) { return null; }
309 TxOut ret_conv = new TxOut(null, ret);
314 * Returns the witness script of the HTLC output in the commitment transaction.
316 public byte[] witness_script() {
317 byte[] ret = bindings.HTLCDescriptor_witness_script(this.ptr);
318 Reference.reachabilityFence(this);
323 * Returns the fully signed witness required to spend the HTLC output in the commitment
326 public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
327 byte[] ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.check_arr_len(signature, 64), witness_script);
328 Reference.reachabilityFence(this);
329 Reference.reachabilityFence(signature);
330 Reference.reachabilityFence(witness_script);
335 * Derives the channel signer required to sign the HTLC input.
337 public EcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
338 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
339 Reference.reachabilityFence(this);
340 Reference.reachabilityFence(signer_provider);
341 if (ret >= 0 && ret <= 4096) { return null; }
342 EcdsaChannelSigner ret_hu_conv = new EcdsaChannelSigner(null, ret);
343 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
344 if (this != null) { this.ptrs_to.add(signer_provider); };