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 * Chain-related parameters used to construct a new `ChannelManager`.
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`.
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 {
23 if (ptr != 0) { bindings.ChainParameters_free(ptr); }
27 * The network for determining the `chain_hash` in Lightning messages.
29 public Network get_network() {
30 Network ret = bindings.ChainParameters_get_network(this.ptr);
35 * The network for determining the `chain_hash` in Lightning messages.
37 public void set_network(org.ldk.enums.Network val) {
38 bindings.ChainParameters_set_network(this.ptr, val);
42 * The hash and height of the latest block successfully connected.
44 * Used to track on-chain channel funding outputs and send payments with reliable timelocks.
46 public BestBlock get_best_block() {
47 long ret = bindings.ChainParameters_get_best_block(this.ptr);
48 if (ret < 1024) { return null; }
49 BestBlock ret_hu_conv = new BestBlock(null, ret);
50 ret_hu_conv.ptrs_to.add(this);
55 * The hash and height of the latest block successfully connected.
57 * Used to track on-chain channel funding outputs and send payments with reliable timelocks.
59 public void set_best_block(BestBlock val) {
60 bindings.ChainParameters_set_best_block(this.ptr, val == null ? 0 : val.ptr & ~1);
61 this.ptrs_to.add(val);
65 * Constructs a new ChainParameters given each field
67 public static ChainParameters of(org.ldk.enums.Network network_arg, BestBlock best_block_arg) {
68 long ret = bindings.ChainParameters_new(network_arg, best_block_arg == null ? 0 : best_block_arg.ptr & ~1);
69 if (ret < 1024) { return null; }
70 ChainParameters ret_hu_conv = new ChainParameters(null, ret);
71 ret_hu_conv.ptrs_to.add(ret_hu_conv);
72 ret_hu_conv.ptrs_to.add(best_block_arg);
77 * Creates a copy of the ChainParameters
79 public ChainParameters clone() {
80 long ret = bindings.ChainParameters_clone(this.ptr);
81 if (ret < 1024) { return null; }
82 ChainParameters ret_hu_conv = new ChainParameters(null, ret);
83 ret_hu_conv.ptrs_to.add(this);