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 communicated in the onion to the recipient for multi-part tracking and proof that
13 * the payment is associated with an invoice.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class FinalOnionHopData extends CommonBase {
17 FinalOnionHopData(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.FinalOnionHopData_free(ptr); }
25 * When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
26 * Because it is generated by the recipient and included in the invoice, it also provides
27 * proof to the recipient that the payment was sent by someone with the generated invoice.
29 public byte[] get_payment_secret() {
30 byte[] ret = bindings.FinalOnionHopData_get_payment_secret(this.ptr);
31 Reference.reachabilityFence(this);
36 * When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
37 * Because it is generated by the recipient and included in the invoice, it also provides
38 * proof to the recipient that the payment was sent by someone with the generated invoice.
40 public void set_payment_secret(byte[] val) {
41 bindings.FinalOnionHopData_set_payment_secret(this.ptr, InternalUtils.check_arr_len(val, 32));
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
47 * The intended total amount that this payment is for.
49 * Message serialization may panic if this value is more than 21 million Bitcoin.
51 public long get_total_msat() {
52 long ret = bindings.FinalOnionHopData_get_total_msat(this.ptr);
53 Reference.reachabilityFence(this);
58 * The intended total amount that this payment is for.
60 * Message serialization may panic if this value is more than 21 million Bitcoin.
62 public void set_total_msat(long val) {
63 bindings.FinalOnionHopData_set_total_msat(this.ptr, val);
64 Reference.reachabilityFence(this);
65 Reference.reachabilityFence(val);
69 * Constructs a new FinalOnionHopData given each field
71 public static FinalOnionHopData of(byte[] payment_secret_arg, long total_msat_arg) {
72 long ret = bindings.FinalOnionHopData_new(InternalUtils.check_arr_len(payment_secret_arg, 32), total_msat_arg);
73 Reference.reachabilityFence(payment_secret_arg);
74 Reference.reachabilityFence(total_msat_arg);
75 if (ret >= 0 && ret <= 4096) { return null; }
76 org.ldk.structs.FinalOnionHopData ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FinalOnionHopData(null, ret); }
77 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
82 long ret = bindings.FinalOnionHopData_clone_ptr(this.ptr);
83 Reference.reachabilityFence(this);
88 * Creates a copy of the FinalOnionHopData
90 public FinalOnionHopData clone() {
91 long ret = bindings.FinalOnionHopData_clone(this.ptr);
92 Reference.reachabilityFence(this);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 org.ldk.structs.FinalOnionHopData ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FinalOnionHopData(null, ret); }
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
100 * Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
102 public byte[] write() {
103 byte[] ret = bindings.FinalOnionHopData_write(this.ptr);
104 Reference.reachabilityFence(this);
109 * Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
111 public static Result_FinalOnionHopDataDecodeErrorZ read(byte[] ser) {
112 long ret = bindings.FinalOnionHopData_read(ser);
113 Reference.reachabilityFence(ser);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 Result_FinalOnionHopDataDecodeErrorZ ret_hu_conv = Result_FinalOnionHopDataDecodeErrorZ.constr_from_ptr(ret);