1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Information about an HTLC as it appears in a commitment transaction
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class HTLCOutputInCommitment extends CommonBase {
15 HTLCOutputInCommitment(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.HTLCOutputInCommitment_free(ptr); }
23 * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
24 * Note that this is not the same as whether it is ountbound *from us*. To determine that you
25 * need to compare this value to whether the commitment transaction in question is that of
26 * the counterparty or our own.
28 public boolean get_offered() {
29 boolean ret = bindings.HTLCOutputInCommitment_get_offered(this.ptr);
34 * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
35 * Note that this is not the same as whether it is ountbound *from us*. To determine that you
36 * need to compare this value to whether the commitment transaction in question is that of
37 * the counterparty or our own.
39 public void set_offered(boolean val) {
40 bindings.HTLCOutputInCommitment_set_offered(this.ptr, val);
44 * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
45 * this divided by 1000.
47 public long get_amount_msat() {
48 long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this.ptr);
53 * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
54 * this divided by 1000.
56 public void set_amount_msat(long val) {
57 bindings.HTLCOutputInCommitment_set_amount_msat(this.ptr, val);
61 * The CLTV lock-time at which this HTLC expires.
63 public int get_cltv_expiry() {
64 int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this.ptr);
69 * The CLTV lock-time at which this HTLC expires.
71 public void set_cltv_expiry(int val) {
72 bindings.HTLCOutputInCommitment_set_cltv_expiry(this.ptr, val);
76 * The hash of the preimage which unlocks this HTLC.
78 public byte[] get_payment_hash() {
79 byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this.ptr);
84 * The hash of the preimage which unlocks this HTLC.
86 public void set_payment_hash(byte[] val) {
87 bindings.HTLCOutputInCommitment_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
91 * The position within the commitment transactions' outputs. This may be None if the value is
92 * below the dust limit (in which case no output appears in the commitment transaction and the
93 * value is spent to additional transaction fees).
95 public Option_u32Z get_transaction_output_index() {
96 long ret = bindings.HTLCOutputInCommitment_get_transaction_output_index(this.ptr);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
99 ret_hu_conv.ptrs_to.add(this);
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 void set_transaction_output_index(Option_u32Z val) {
109 bindings.HTLCOutputInCommitment_set_transaction_output_index(this.ptr, val.ptr);
113 * Constructs a new HTLCOutputInCommitment given each field
115 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) {
116 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);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
119 ret_hu_conv.ptrs_to.add(ret_hu_conv);
124 long ret = bindings.HTLCOutputInCommitment_clone_ptr(this.ptr);
129 * Creates a copy of the HTLCOutputInCommitment
131 public HTLCOutputInCommitment clone() {
132 long ret = bindings.HTLCOutputInCommitment_clone(this.ptr);
133 if (ret >= 0 && ret <= 4096) { return null; }
134 HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
135 ret_hu_conv.ptrs_to.add(this);
140 * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read
142 public byte[] write() {
143 byte[] ret = bindings.HTLCOutputInCommitment_write(this.ptr);
148 * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write
150 public static Result_HTLCOutputInCommitmentDecodeErrorZ read(byte[] ser) {
151 long ret = bindings.HTLCOutputInCommitment_read(ser);
152 if (ret >= 0 && ret <= 4096) { return null; }
153 Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);