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 * Information about an HTLC as it appears in a commitment transaction
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class HTLCOutputInCommitment extends CommonBase {
16 HTLCOutputInCommitment(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.HTLCOutputInCommitment_free(ptr); }
24 * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
25 * Note that this is not the same as whether it is ountbound *from us*. To determine that you
26 * need to compare this value to whether the commitment transaction in question is that of
27 * the counterparty or our own.
29 public boolean get_offered() {
30 boolean ret = bindings.HTLCOutputInCommitment_get_offered(this.ptr);
31 Reference.reachabilityFence(this);
36 * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
37 * Note that this is not the same as whether it is ountbound *from us*. To determine that you
38 * need to compare this value to whether the commitment transaction in question is that of
39 * the counterparty or our own.
41 public void set_offered(boolean val) {
42 bindings.HTLCOutputInCommitment_set_offered(this.ptr, val);
43 Reference.reachabilityFence(this);
44 Reference.reachabilityFence(val);
48 * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
49 * this divided by 1000.
51 public long get_amount_msat() {
52 long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this.ptr);
53 Reference.reachabilityFence(this);
58 * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
59 * this divided by 1000.
61 public void set_amount_msat(long val) {
62 bindings.HTLCOutputInCommitment_set_amount_msat(this.ptr, val);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
68 * The CLTV lock-time at which this HTLC expires.
70 public int get_cltv_expiry() {
71 int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this.ptr);
72 Reference.reachabilityFence(this);
77 * The CLTV lock-time at which this HTLC expires.
79 public void set_cltv_expiry(int val) {
80 bindings.HTLCOutputInCommitment_set_cltv_expiry(this.ptr, val);
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(val);
86 * The hash of the preimage which unlocks this HTLC.
88 public byte[] get_payment_hash() {
89 byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this.ptr);
90 Reference.reachabilityFence(this);
95 * The hash of the preimage which unlocks this HTLC.
97 public void set_payment_hash(byte[] val) {
98 bindings.HTLCOutputInCommitment_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(val);
104 * The position within the commitment transactions' outputs. This may be None if the value is
105 * below the dust limit (in which case no output appears in the commitment transaction and the
106 * value is spent to additional transaction fees).
108 public Option_u32Z get_transaction_output_index() {
109 long ret = bindings.HTLCOutputInCommitment_get_transaction_output_index(this.ptr);
110 Reference.reachabilityFence(this);
111 if (ret >= 0 && ret <= 4096) { return null; }
112 org.ldk.structs.Option_u32Z ret_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(ret);
113 ret_hu_conv.ptrs_to.add(this);
118 * The position within the commitment transactions' outputs. This may be None if the value is
119 * below the dust limit (in which case no output appears in the commitment transaction and the
120 * value is spent to additional transaction fees).
122 public void set_transaction_output_index(Option_u32Z val) {
123 bindings.HTLCOutputInCommitment_set_transaction_output_index(this.ptr, val.ptr);
124 Reference.reachabilityFence(this);
125 Reference.reachabilityFence(val);
129 * Constructs a new HTLCOutputInCommitment given each field
131 public static HTLCOutputInCommitment of(boolean offered_arg, long amount_msat_arg, int cltv_expiry_arg, byte[] payment_hash_arg, Option_u32Z transaction_output_index_arg) {
132 long ret = bindings.HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, InternalUtils.check_arr_len(payment_hash_arg, 32), transaction_output_index_arg.ptr);
133 Reference.reachabilityFence(offered_arg);
134 Reference.reachabilityFence(amount_msat_arg);
135 Reference.reachabilityFence(cltv_expiry_arg);
136 Reference.reachabilityFence(payment_hash_arg);
137 Reference.reachabilityFence(transaction_output_index_arg);
138 if (ret >= 0 && ret <= 4096) { return null; }
139 HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
140 ret_hu_conv.ptrs_to.add(ret_hu_conv);
145 long ret = bindings.HTLCOutputInCommitment_clone_ptr(this.ptr);
146 Reference.reachabilityFence(this);
151 * Creates a copy of the HTLCOutputInCommitment
153 public HTLCOutputInCommitment clone() {
154 long ret = bindings.HTLCOutputInCommitment_clone(this.ptr);
155 Reference.reachabilityFence(this);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
158 ret_hu_conv.ptrs_to.add(this);
163 * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read
165 public byte[] write() {
166 byte[] ret = bindings.HTLCOutputInCommitment_write(this.ptr);
167 Reference.reachabilityFence(this);
172 * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write
174 public static Result_HTLCOutputInCommitmentDecodeErrorZ read(byte[] ser) {
175 long ret = bindings.HTLCOutputInCommitment_read(ser);
176 Reference.reachabilityFence(ser);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);