1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Chain-related parameters used to construct a new `ChannelManager`.
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`.
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 {
24 if (ptr != 0) { bindings.ChainParameters_free(ptr); }
28 * The network for determining the `chain_hash` in Lightning messages.
30 public Network get_network() {
31 Network ret = bindings.ChainParameters_get_network(this.ptr);
32 Reference.reachabilityFence(this);
37 * The network for determining the `chain_hash` in Lightning messages.
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);
46 * The hash and height of the latest block successfully connected.
48 * Used to track on-chain channel funding outputs and send payments with reliable timelocks.
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 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
55 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
60 * The hash and height of the latest block successfully connected.
62 * Used to track on-chain channel funding outputs and send payments with reliable timelocks.
64 public void set_best_block(BestBlock val) {
65 bindings.ChainParameters_set_best_block(this.ptr, val == null ? 0 : val.ptr);
66 Reference.reachabilityFence(this);
67 Reference.reachabilityFence(val);
68 if (this != null) { this.ptrs_to.add(val); };
72 * Constructs a new ChainParameters given each field
74 public static ChainParameters of(org.ldk.enums.Network network_arg, BestBlock best_block_arg) {
75 long ret = bindings.ChainParameters_new(network_arg, best_block_arg == null ? 0 : best_block_arg.ptr);
76 Reference.reachabilityFence(network_arg);
77 Reference.reachabilityFence(best_block_arg);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 org.ldk.structs.ChainParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChainParameters(null, ret); }
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
81 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(best_block_arg); };
86 long ret = bindings.ChainParameters_clone_ptr(this.ptr);
87 Reference.reachabilityFence(this);
92 * Creates a copy of the ChainParameters
94 public ChainParameters clone() {
95 long ret = bindings.ChainParameters_clone(this.ptr);
96 Reference.reachabilityFence(this);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 org.ldk.structs.ChainParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChainParameters(null, ret); }
99 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };