]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/HTLCOutputInCommitment.java
Merge pull request #94 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / HTLCOutputInCommitment.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Information about an HTLC as it appears in a commitment transaction
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.HTLCOutputInCommitment_free(ptr); }
21         }
22
23         /**
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.
28          */
29         public boolean get_offered() {
30                 boolean ret = bindings.HTLCOutputInCommitment_get_offered(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
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.
40          */
41         public void set_offered(boolean val) {
42                 bindings.HTLCOutputInCommitment_set_offered(this.ptr, val);
43                 Reference.reachabilityFence(this);
44                 Reference.reachabilityFence(val);
45         }
46
47         /**
48          * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
49          * this divided by 1000.
50          */
51         public long get_amount_msat() {
52                 long ret = bindings.HTLCOutputInCommitment_get_amount_msat(this.ptr);
53                 Reference.reachabilityFence(this);
54                 return ret;
55         }
56
57         /**
58          * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is
59          * this divided by 1000.
60          */
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);
65         }
66
67         /**
68          * The CLTV lock-time at which this HTLC expires.
69          */
70         public int get_cltv_expiry() {
71                 int ret = bindings.HTLCOutputInCommitment_get_cltv_expiry(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         /**
77          * The CLTV lock-time at which this HTLC expires.
78          */
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);
83         }
84
85         /**
86          * The hash of the preimage which unlocks this HTLC.
87          */
88         public byte[] get_payment_hash() {
89                 byte[] ret = bindings.HTLCOutputInCommitment_get_payment_hash(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * The hash of the preimage which unlocks this HTLC.
96          */
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);
101         }
102
103         /**
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).
107          */
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);
114                 return ret_hu_conv;
115         }
116
117         /**
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).
121          */
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);
126         }
127
128         /**
129          * Constructs a new HTLCOutputInCommitment given each field
130          */
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);
141                 return ret_hu_conv;
142         }
143
144         long clone_ptr() {
145                 long ret = bindings.HTLCOutputInCommitment_clone_ptr(this.ptr);
146                 Reference.reachabilityFence(this);
147                 return ret;
148         }
149
150         /**
151          * Creates a copy of the HTLCOutputInCommitment
152          */
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);
159                 return ret_hu_conv;
160         }
161
162         /**
163          * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read
164          */
165         public byte[] write() {
166                 byte[] ret = bindings.HTLCOutputInCommitment_write(this.ptr);
167                 Reference.reachabilityFence(this);
168                 return ret;
169         }
170
171         /**
172          * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write
173          */
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);
179                 return ret_hu_conv;
180         }
181
182 }