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 * Data to construct a [`BlindedHop`] for forwarding a payment.
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 {
20 if (ptr != 0) { bindings.ForwardTlvs_free(ptr); }
24 * The short channel id this payment should be forwarded out over.
26 public long get_short_channel_id() {
27 long ret = bindings.ForwardTlvs_get_short_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
33 * The short channel id this payment should be forwarded out over.
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);
42 * Payment parameters for relaying over [`Self::short_channel_id`].
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); };
54 * Payment parameters for relaying over [`Self::short_channel_id`].
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); };
64 * Payment constraints for relaying over [`Self::short_channel_id`].
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); };
76 * Payment constraints for relaying over [`Self::short_channel_id`].
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); };
86 * Supported and required features when relaying a payment onion containing this object's
87 * corresponding [`BlindedHop::encrypted_payload`].
89 * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
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); };
101 * Supported and required features when relaying a payment onion containing this object's
102 * corresponding [`BlindedHop::encrypted_payload`].
104 * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
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); };
114 * Constructs a new ForwardTlvs given each field
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); };
132 long ret = bindings.ForwardTlvs_clone_ptr(this.ptr);
133 Reference.reachabilityFence(this);
138 * Creates a copy of the ForwardTlvs
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); };
150 * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read
152 public byte[] write() {
153 byte[] ret = bindings.ForwardTlvs_write(this.ptr);
154 Reference.reachabilityFence(this);