[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ForwardTlvs.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  * Data to construct a [`BlindedHop`] for forwarding a payment.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ForwardTlvs extends CommonBase {
16         ForwardTlvs(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ForwardTlvs_free(ptr); }
21         }
22
23         /**
24          * The short channel id this payment should be forwarded out over.
25          */
26         public long get_short_channel_id() {
27                 long ret = bindings.ForwardTlvs_get_short_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The short channel id this payment should be forwarded out over.
34          */
35         public void set_short_channel_id(long val) {
36                 bindings.ForwardTlvs_set_short_channel_id(this.ptr, val);
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * Payment parameters for relaying over [`Self::short_channel_id`].
43          */
44         public PaymentRelay get_payment_relay() {
45                 long ret = bindings.ForwardTlvs_get_payment_relay(this.ptr);
46                 Reference.reachabilityFence(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.PaymentRelay ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentRelay(null, ret); }
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
50                 return ret_hu_conv;
51         }
52
53         /**
54          * Payment parameters for relaying over [`Self::short_channel_id`].
55          */
56         public void set_payment_relay(org.ldk.structs.PaymentRelay val) {
57                 bindings.ForwardTlvs_set_payment_relay(this.ptr, val == null ? 0 : val.ptr);
58                 Reference.reachabilityFence(this);
59                 Reference.reachabilityFence(val);
60                 if (this != null) { this.ptrs_to.add(val); };
61         }
62
63         /**
64          * Payment constraints for relaying over [`Self::short_channel_id`].
65          */
66         public PaymentConstraints get_payment_constraints() {
67                 long ret = bindings.ForwardTlvs_get_payment_constraints(this.ptr);
68                 Reference.reachabilityFence(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Payment constraints for relaying over [`Self::short_channel_id`].
77          */
78         public void set_payment_constraints(org.ldk.structs.PaymentConstraints val) {
79                 bindings.ForwardTlvs_set_payment_constraints(this.ptr, val == null ? 0 : val.ptr);
80                 Reference.reachabilityFence(this);
81                 Reference.reachabilityFence(val);
82                 if (this != null) { this.ptrs_to.add(val); };
83         }
84
85         /**
86          * Supported and required features when relaying a payment onion containing this object's
87          * corresponding [`BlindedHop::encrypted_payload`].
88          * 
89          * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
90          */
91         public BlindedHopFeatures get_features() {
92                 long ret = bindings.ForwardTlvs_get_features(this.ptr);
93                 Reference.reachabilityFence(this);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 org.ldk.structs.BlindedHopFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedHopFeatures(null, ret); }
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Supported and required features when relaying a payment onion containing this object's
102          * corresponding [`BlindedHop::encrypted_payload`].
103          * 
104          * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
105          */
106         public void set_features(org.ldk.structs.BlindedHopFeatures val) {
107                 bindings.ForwardTlvs_set_features(this.ptr, val == null ? 0 : val.ptr);
108                 Reference.reachabilityFence(this);
109                 Reference.reachabilityFence(val);
110                 if (this != null) { this.ptrs_to.add(val); };
111         }
112
113         /**
114          * Constructs a new ForwardTlvs given each field
115          */
116         public static ForwardTlvs of(long short_channel_id_arg, org.ldk.structs.PaymentRelay payment_relay_arg, org.ldk.structs.PaymentConstraints payment_constraints_arg, org.ldk.structs.BlindedHopFeatures features_arg) {
117                 long ret = bindings.ForwardTlvs_new(short_channel_id_arg, payment_relay_arg == null ? 0 : payment_relay_arg.ptr, payment_constraints_arg == null ? 0 : payment_constraints_arg.ptr, features_arg == null ? 0 : features_arg.ptr);
118                 Reference.reachabilityFence(short_channel_id_arg);
119                 Reference.reachabilityFence(payment_relay_arg);
120                 Reference.reachabilityFence(payment_constraints_arg);
121                 Reference.reachabilityFence(features_arg);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.ForwardTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ForwardTlvs(null, ret); }
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_relay_arg); };
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_constraints_arg); };
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features_arg); };
128                 return ret_hu_conv;
129         }
130
131         long clone_ptr() {
132                 long ret = bindings.ForwardTlvs_clone_ptr(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Creates a copy of the ForwardTlvs
139          */
140         public ForwardTlvs clone() {
141                 long ret = bindings.ForwardTlvs_clone(this.ptr);
142                 Reference.reachabilityFence(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.ForwardTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ForwardTlvs(null, ret); }
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read
151          */
152         public byte[] write() {
153                 byte[] ret = bindings.ForwardTlvs_write(this.ptr);
154                 Reference.reachabilityFence(this);
155                 return ret;
156         }
157
158 }