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 * Positive duration that defines when (relatively to the timestamp) in the future the invoice
15 * The number of seconds this expiry time represents has to be in the range
16 * `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class ExpiryTime extends CommonBase {
21 ExpiryTime(Object _dummy, long ptr) { super(ptr); }
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
25 if (ptr != 0) { bindings.ExpiryTime_free(ptr); }
29 * Creates a copy of the ExpiryTime
31 public ExpiryTime clone() {
32 long ret = bindings.ExpiryTime_clone(this.ptr);
33 if (ret < 1024) { return null; }
34 ExpiryTime ret_hu_conv = new ExpiryTime(null, ret);
35 ret_hu_conv.ptrs_to.add(this);
40 * Checks if two ExpiryTimes contain equal inner contents.
43 long ret = bindings.ExpiryTime_hash(this.ptr);
48 * Checks if two ExpiryTimes contain equal inner contents.
49 * This ignores pointers and is_owned flags and looks at the values in fields.
50 * Two objects with NULL inner values will be considered "equal" here.
52 public boolean eq(ExpiryTime b) {
53 boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
59 * Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would
60 * overflow on adding the `EpiryTime` to it then this function will return a
61 * `CreationError::ExpiryTimeOutOfBounds`.
63 public static Result_ExpiryTimeCreationErrorZ from_seconds(long seconds) {
64 long ret = bindings.ExpiryTime_from_seconds(seconds);
65 if (ret < 1024) { return null; }
66 Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
71 * Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which
72 * would overflow on adding the `EpiryTime` to it then this function will return a
73 * `CreationError::ExpiryTimeOutOfBounds`.
75 public static Result_ExpiryTimeCreationErrorZ from_duration(long duration) {
76 long ret = bindings.ExpiryTime_from_duration(duration);
77 if (ret < 1024) { return null; }
78 Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
83 * Returns the expiry time in seconds
85 public long as_seconds() {
86 long ret = bindings.ExpiryTime_as_seconds(this.ptr);
91 * Returns a reference to the underlying `Duration` (=expiry time)
93 public long as_duration() {
94 long ret = bindings.ExpiryTime_as_duration(this.ptr);