3f5c2ba0dcbbb496a36906b5004ca81ab82550ae
[ldk-java] / src / main / java / org / ldk / structs / UserConfig.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  * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
11  * 
12  * Default::default() provides sane defaults for most configurations
13  * (but currently with 0 relay fees!)
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class UserConfig extends CommonBase {
17         UserConfig(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.UserConfig_free(ptr); }
22         }
23
24         /**
25          * Channel config that we propose to our counterparty.
26          */
27         public ChannelHandshakeConfig get_own_channel_config() {
28                 long ret = bindings.UserConfig_get_own_channel_config(this.ptr);
29                 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
30                 ret_hu_conv.ptrs_to.add(this);
31                 return ret_hu_conv;
32         }
33
34         /**
35          * Channel config that we propose to our counterparty.
36          */
37         public void set_own_channel_config(ChannelHandshakeConfig val) {
38                 bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1);
39                 this.ptrs_to.add(val);
40         }
41
42         /**
43          * Limits applied to our counterparty's proposed channel config settings.
44          */
45         public ChannelHandshakeLimits get_peer_channel_config_limits() {
46                 long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr);
47                 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
48                 ret_hu_conv.ptrs_to.add(this);
49                 return ret_hu_conv;
50         }
51
52         /**
53          * Limits applied to our counterparty's proposed channel config settings.
54          */
55         public void set_peer_channel_config_limits(ChannelHandshakeLimits val) {
56                 bindings.UserConfig_set_peer_channel_config_limits(this.ptr, val == null ? 0 : val.ptr & ~1);
57                 this.ptrs_to.add(val);
58         }
59
60         /**
61          * Channel config which affects behavior during channel lifetime.
62          */
63         public ChannelConfig get_channel_options() {
64                 long ret = bindings.UserConfig_get_channel_options(this.ptr);
65                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
66                 ret_hu_conv.ptrs_to.add(this);
67                 return ret_hu_conv;
68         }
69
70         /**
71          * Channel config which affects behavior during channel lifetime.
72          */
73         public void set_channel_options(ChannelConfig val) {
74                 bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1);
75                 this.ptrs_to.add(val);
76         }
77
78         /**
79          * Constructs a new UserConfig given each field
80          */
81         public static UserConfig of(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg) {
82                 long ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1);
83                 UserConfig ret_hu_conv = new UserConfig(null, ret);
84                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
85                 ret_hu_conv.ptrs_to.add(own_channel_config_arg);
86                 ret_hu_conv.ptrs_to.add(peer_channel_config_limits_arg);
87                 ret_hu_conv.ptrs_to.add(channel_options_arg);
88                 return ret_hu_conv;
89         }
90
91         /**
92          * Creates a copy of the UserConfig
93          */
94         public UserConfig clone() {
95                 long ret = bindings.UserConfig_clone(this.ptr);
96                 UserConfig ret_hu_conv = new UserConfig(null, ret);
97                 ret_hu_conv.ptrs_to.add(this);
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
103          */
104         public static UserConfig with_default() {
105                 long ret = bindings.UserConfig_default();
106                 UserConfig ret_hu_conv = new UserConfig(null, ret);
107                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
108                 return ret_hu_conv;
109         }
110
111 }