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 details of the HTLC as it appears in the commitment transaction.
92 public HTLCOutputInCommitment get_htlc() {
93 long ret = bindings.HTLCDescriptor_get_htlc(this.ptr);
94 Reference.reachabilityFence(this);
95 if (ret >= 0 && ret <= 4096) { return null; }
96 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
97 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
102 * The details of the HTLC as it appears in the commitment transaction.
104 public void set_htlc(org.ldk.structs.HTLCOutputInCommitment val) {
105 bindings.HTLCDescriptor_set_htlc(this.ptr, val == null ? 0 : val.ptr);
106 Reference.reachabilityFence(this);
107 Reference.reachabilityFence(val);
108 if (this != null) { this.ptrs_to.add(val); };
112 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
115 public Option_ThirtyTwoBytesZ get_preimage() {
116 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
117 Reference.reachabilityFence(this);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
125 * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
128 public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
129 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
130 Reference.reachabilityFence(this);
131 Reference.reachabilityFence(val);
132 if (this != null) { this.ptrs_to.add(val); };
136 * The counterparty's signature required to spend the HTLC output.
138 public byte[] get_counterparty_sig() {
139 byte[] ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
140 Reference.reachabilityFence(this);
145 * The counterparty's signature required to spend the HTLC output.
147 public void set_counterparty_sig(byte[] val) {
148 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.check_arr_len(val, 64));
149 Reference.reachabilityFence(this);
150 Reference.reachabilityFence(val);
154 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
155 Reference.reachabilityFence(this);
160 * Creates a copy of the HTLCDescriptor
162 public HTLCDescriptor clone() {
163 long ret = bindings.HTLCDescriptor_clone(this.ptr);
164 Reference.reachabilityFence(this);
165 if (ret >= 0 && ret <= 4096) { return null; }
166 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
167 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
172 * Checks if two HTLCDescriptors contain equal inner contents.
173 * This ignores pointers and is_owned flags and looks at the values in fields.
174 * Two objects with NULL inner values will be considered "equal" here.
176 public boolean eq(org.ldk.structs.HTLCDescriptor b) {
177 boolean ret = bindings.HTLCDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
178 Reference.reachabilityFence(this);
179 Reference.reachabilityFence(b);
180 if (this != null) { this.ptrs_to.add(b); };
184 @Override public boolean equals(Object o) {
185 if (!(o instanceof HTLCDescriptor)) return false;
186 return this.eq((HTLCDescriptor)o);
189 * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
191 public byte[] write() {
192 byte[] ret = bindings.HTLCDescriptor_write(this.ptr);
193 Reference.reachabilityFence(this);
198 * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
200 public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
201 long ret = bindings.HTLCDescriptor_read(ser);
202 Reference.reachabilityFence(ser);
203 if (ret >= 0 && ret <= 4096) { return null; }
204 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
209 * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
210 * being spent by the HTLC input in the HTLC transaction.
212 public OutPoint outpoint() {
213 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
214 Reference.reachabilityFence(this);
215 if (ret >= 0 && ret <= 4096) { return null; }
216 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
217 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
222 * Returns the UTXO to be spent by the HTLC input, which can be obtained via
223 * [`Self::unsigned_tx_input`].
225 public TxOut previous_utxo() {
226 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
227 Reference.reachabilityFence(this);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 TxOut ret_conv = new TxOut(null, ret);
234 * Returns the unsigned transaction input spending the HTLC output in the commitment
237 public TxIn unsigned_tx_input() {
238 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
239 Reference.reachabilityFence(this);
240 if (ret >= 0 && ret <= 4096) { return null; }
241 TxIn ret_conv = new TxIn(null, ret);
246 * Returns the delayed output created as a result of spending the HTLC output in the commitment
249 public TxOut tx_output() {
250 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
251 Reference.reachabilityFence(this);
252 if (ret >= 0 && ret <= 4096) { return null; }
253 TxOut ret_conv = new TxOut(null, ret);
258 * Returns the witness script of the HTLC output in the commitment transaction.
260 public byte[] witness_script() {
261 byte[] ret = bindings.HTLCDescriptor_witness_script(this.ptr);
262 Reference.reachabilityFence(this);
267 * Returns the fully signed witness required to spend the HTLC output in the commitment
270 public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
271 byte[] ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.check_arr_len(signature, 64), witness_script);
272 Reference.reachabilityFence(this);
273 Reference.reachabilityFence(signature);
274 Reference.reachabilityFence(witness_script);
279 * Derives the channel signer required to sign the HTLC input.
281 public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
282 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
283 Reference.reachabilityFence(this);
284 Reference.reachabilityFence(signer_provider);
285 if (ret >= 0 && ret <= 4096) { return null; }
286 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
287 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
288 if (this != null) { this.ptrs_to.add(signer_provider); };