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