]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/SpendingDelay.java
[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / SpendingDelay.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  * A `enum` signalling to the [`OutputSweeper`] that it should delay spending an output until a
13  * future block height is reached.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class SpendingDelay extends CommonBase {
17         private SpendingDelay(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.SpendingDelay_free(ptr); }
22         }
23         static SpendingDelay constr_from_ptr(long ptr) {
24                 bindings.LDKSpendingDelay raw_val = bindings.LDKSpendingDelay_ref_from_ptr(ptr);
25                 if (raw_val.getClass() == bindings.LDKSpendingDelay.Relative.class) {
26                         return new Relative(ptr, (bindings.LDKSpendingDelay.Relative)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKSpendingDelay.Absolute.class) {
29                         return new Absolute(ptr, (bindings.LDKSpendingDelay.Absolute)raw_val);
30                 }
31                 assert false; return null; // Unreachable without extending the (internal) bindings interface
32         }
33
34         /**
35          * A relative delay indicating we shouldn't spend the output before `cur_height + num_blocks`
36          * is reached.
37          */
38         public final static class Relative extends SpendingDelay {
39                 /**
40                  * The number of blocks until we'll generate and broadcast the spending transaction.
41                 */
42                 public final int num_blocks;
43                 private Relative(long ptr, bindings.LDKSpendingDelay.Relative obj) {
44                         super(null, ptr);
45                         this.num_blocks = obj.num_blocks;
46                 }
47         }
48         /**
49          * An absolute delay indicating we shouldn't spend the output before `height` is reached.
50          */
51         public final static class Absolute extends SpendingDelay {
52                 /**
53                  * The height at which we'll generate and broadcast the spending transaction.
54                 */
55                 public final int height;
56                 private Absolute(long ptr, bindings.LDKSpendingDelay.Absolute obj) {
57                         super(null, ptr);
58                         this.height = obj.height;
59                 }
60         }
61         long clone_ptr() {
62                 long ret = bindings.SpendingDelay_clone_ptr(this.ptr);
63                 Reference.reachabilityFence(this);
64                 return ret;
65         }
66
67         /**
68          * Creates a copy of the SpendingDelay
69          */
70         public SpendingDelay clone() {
71                 long ret = bindings.SpendingDelay_clone(this.ptr);
72                 Reference.reachabilityFence(this);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.SpendingDelay ret_hu_conv = org.ldk.structs.SpendingDelay.constr_from_ptr(ret);
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Utility method to constructs a new Relative-variant SpendingDelay
81          */
82         public static SpendingDelay relative(int num_blocks) {
83                 long ret = bindings.SpendingDelay_relative(num_blocks);
84                 Reference.reachabilityFence(num_blocks);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.SpendingDelay ret_hu_conv = org.ldk.structs.SpendingDelay.constr_from_ptr(ret);
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
88                 return ret_hu_conv;
89         }
90
91         /**
92          * Utility method to constructs a new Absolute-variant SpendingDelay
93          */
94         public static SpendingDelay absolute(int height) {
95                 long ret = bindings.SpendingDelay_absolute(height);
96                 Reference.reachabilityFence(height);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 org.ldk.structs.SpendingDelay ret_hu_conv = org.ldk.structs.SpendingDelay.constr_from_ptr(ret);
99                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
100                 return ret_hu_conv;
101         }
102
103 }