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 == null ? 0 : val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
42 if (this != null) { this.ptrs_to.add(val); };
46 * The number of the commitment transaction in which the HTLC output lives.
48 public long get_per_commitment_number() {
49 long ret = bindings.HTLCDescriptor_get_per_commitment_number(this.ptr);
50 Reference.reachabilityFence(this);
55 * The number of the commitment transaction in which the HTLC output lives.
57 public void set_per_commitment_number(long val) {
58 bindings.HTLCDescriptor_set_per_commitment_number(this.ptr, val);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
64 * The key tweak corresponding to the number of the commitment transaction in which the HTLC
65 * output lives. This tweak is applied to all the basepoints for both parties in the channel to
66 * arrive at unique keys per commitment.
68 * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
70 public byte[] get_per_commitment_point() {
71 byte[] ret = bindings.HTLCDescriptor_get_per_commitment_point(this.ptr);
72 Reference.reachabilityFence(this);
77 * The key tweak corresponding to the number of the commitment transaction in which the HTLC
78 * output lives. This tweak is applied to all the basepoints for both parties in the channel to
79 * arrive at unique keys per commitment.
81 * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
83 public void set_per_commitment_point(byte[] val) {
84 bindings.HTLCDescriptor_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
85 Reference.reachabilityFence(this);
86 Reference.reachabilityFence(val);
90 * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
91 * originating from a channel supporting anchor outputs, otherwise it is the channel's
92 * negotiated feerate at the time the commitment transaction was built.
94 public int get_feerate_per_kw() {
95 int ret = bindings.HTLCDescriptor_get_feerate_per_kw(this.ptr);
96 Reference.reachabilityFence(this);
101 * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
102 * originating from a channel supporting anchor outputs, otherwise it is the channel's
103 * negotiated feerate at the time the commitment transaction was built.
105 public void set_feerate_per_kw(int val) {
106 bindings.HTLCDescriptor_set_feerate_per_kw(this.ptr, val);
107 Reference.reachabilityFence(this);
108 Reference.reachabilityFence(val);
112 * The details of the HTLC as it appears in the commitment transaction.
114 public HTLCOutputInCommitment get_htlc() {
115 long ret = bindings.HTLCDescriptor_get_htlc(this.ptr);
116 Reference.reachabilityFence(this);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
124 * The details of the HTLC as it appears in the commitment transaction.
126 public void set_htlc(org.ldk.structs.HTLCOutputInCommitment val) {
127 bindings.HTLCDescriptor_set_htlc(this.ptr, val == null ? 0 : val.ptr);
128 Reference.reachabilityFence(this);
129 Reference.reachabilityFence(val);
130 if (this != null) { this.ptrs_to.add(val); };
134 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
137 public Option_ThirtyTwoBytesZ get_preimage() {
138 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
139 Reference.reachabilityFence(this);
140 if (ret >= 0 && ret <= 4096) { return null; }
141 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
142 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
147 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
150 public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
151 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
152 Reference.reachabilityFence(this);
153 Reference.reachabilityFence(val);
154 if (this != null) { this.ptrs_to.add(val); };
158 * The counterparty's signature required to spend the HTLC output.
160 public byte[] get_counterparty_sig() {
161 byte[] ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
162 Reference.reachabilityFence(this);
167 * The counterparty's signature required to spend the HTLC output.
169 public void set_counterparty_sig(byte[] val) {
170 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.check_arr_len(val, 64));
171 Reference.reachabilityFence(this);
172 Reference.reachabilityFence(val);
176 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
177 Reference.reachabilityFence(this);
182 * Creates a copy of the HTLCDescriptor
184 public HTLCDescriptor clone() {
185 long ret = bindings.HTLCDescriptor_clone(this.ptr);
186 Reference.reachabilityFence(this);
187 if (ret >= 0 && ret <= 4096) { return null; }
188 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
189 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
194 * Checks if two HTLCDescriptors contain equal inner contents.
195 * This ignores pointers and is_owned flags and looks at the values in fields.
196 * Two objects with NULL inner values will be considered "equal" here.
198 public boolean eq(org.ldk.structs.HTLCDescriptor b) {
199 boolean ret = bindings.HTLCDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
200 Reference.reachabilityFence(this);
201 Reference.reachabilityFence(b);
202 if (this != null) { this.ptrs_to.add(b); };
206 @Override public boolean equals(Object o) {
207 if (!(o instanceof HTLCDescriptor)) return false;
208 return this.eq((HTLCDescriptor)o);
211 * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
213 public byte[] write() {
214 byte[] ret = bindings.HTLCDescriptor_write(this.ptr);
215 Reference.reachabilityFence(this);
220 * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
222 public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
223 long ret = bindings.HTLCDescriptor_read(ser);
224 Reference.reachabilityFence(ser);
225 if (ret >= 0 && ret <= 4096) { return null; }
226 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
231 * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
232 * being spent by the HTLC input in the HTLC transaction.
234 public OutPoint outpoint() {
235 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
236 Reference.reachabilityFence(this);
237 if (ret >= 0 && ret <= 4096) { return null; }
238 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
239 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
244 * Returns the UTXO to be spent by the HTLC input, which can be obtained via
245 * [`Self::unsigned_tx_input`].
247 public TxOut previous_utxo() {
248 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
249 Reference.reachabilityFence(this);
250 if (ret >= 0 && ret <= 4096) { return null; }
251 TxOut ret_conv = new TxOut(null, ret);
256 * Returns the unsigned transaction input spending the HTLC output in the commitment
259 public TxIn unsigned_tx_input() {
260 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
261 Reference.reachabilityFence(this);
262 if (ret >= 0 && ret <= 4096) { return null; }
263 TxIn ret_conv = new TxIn(null, ret);
268 * Returns the delayed output created as a result of spending the HTLC output in the commitment
271 public TxOut tx_output() {
272 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
273 Reference.reachabilityFence(this);
274 if (ret >= 0 && ret <= 4096) { return null; }
275 TxOut ret_conv = new TxOut(null, ret);
280 * Returns the witness script of the HTLC output in the commitment transaction.
282 public byte[] witness_script() {
283 byte[] ret = bindings.HTLCDescriptor_witness_script(this.ptr);
284 Reference.reachabilityFence(this);
289 * Returns the fully signed witness required to spend the HTLC output in the commitment
292 public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
293 byte[] ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.check_arr_len(signature, 64), witness_script);
294 Reference.reachabilityFence(this);
295 Reference.reachabilityFence(signature);
296 Reference.reachabilityFence(witness_script);
301 * Derives the channel signer required to sign the HTLC input.
303 public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
304 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
305 Reference.reachabilityFence(this);
306 Reference.reachabilityFence(signer_provider);
307 if (ret >= 0 && ret <= 4096) { return null; }
308 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
309 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
310 if (this != null) { this.ptrs_to.add(signer_provider); };