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