Update auto-updated Java files
[ldk-java] / src / main / java / org / ldk / structs / ChainParameters.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  * Chain-related parameters used to construct a new `ChannelManager`.
13  * 
14  * Typically, the block-specific parameters are derived from the best block hash for the network,
15  * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
16  * are not needed when deserializing a previously constructed `ChannelManager`.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class ChainParameters extends CommonBase {
20         ChainParameters(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.ChainParameters_free(ptr); }
25         }
26
27         /**
28          * The network for determining the `chain_hash` in Lightning messages.
29          */
30         public Network get_network() {
31                 Network ret = bindings.ChainParameters_get_network(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * The network for determining the `chain_hash` in Lightning messages.
38          */
39         public void set_network(org.ldk.enums.Network val) {
40                 bindings.ChainParameters_set_network(this.ptr, val);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * The hash and height of the latest block successfully connected.
47          * 
48          * Used to track on-chain channel funding outputs and send payments with reliable timelocks.
49          */
50         public BestBlock get_best_block() {
51                 long ret = bindings.ChainParameters_get_best_block(this.ptr);
52                 Reference.reachabilityFence(this);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
55                 ret_hu_conv.ptrs_to.add(this);
56                 return ret_hu_conv;
57         }
58
59         /**
60          * The hash and height of the latest block successfully connected.
61          * 
62          * Used to track on-chain channel funding outputs and send payments with reliable timelocks.
63          */
64         public void set_best_block(BestBlock val) {
65                 bindings.ChainParameters_set_best_block(this.ptr, val == null ? 0 : val.ptr & ~1);
66                 Reference.reachabilityFence(this);
67                 Reference.reachabilityFence(val);
68         }
69
70         /**
71          * Constructs a new ChainParameters given each field
72          */
73         public static ChainParameters of(org.ldk.enums.Network network_arg, BestBlock best_block_arg) {
74                 long ret = bindings.ChainParameters_new(network_arg, best_block_arg == null ? 0 : best_block_arg.ptr & ~1);
75                 Reference.reachabilityFence(network_arg);
76                 Reference.reachabilityFence(best_block_arg);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 ChainParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChainParameters(null, ret); }
79                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
80                 return ret_hu_conv;
81         }
82
83         long clone_ptr() {
84                 long ret = bindings.ChainParameters_clone_ptr(this.ptr);
85                 Reference.reachabilityFence(this);
86                 return ret;
87         }
88
89         /**
90          * Creates a copy of the ChainParameters
91          */
92         public ChainParameters clone() {
93                 long ret = bindings.ChainParameters_clone(this.ptr);
94                 Reference.reachabilityFence(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 ChainParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChainParameters(null, ret); }
97                 ret_hu_conv.ptrs_to.add(this);
98                 return ret_hu_conv;
99         }
100
101 }