Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / ChannelCounterparty.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  * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
12  * to better separate parameters.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelCounterparty extends CommonBase {
16         ChannelCounterparty(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelCounterparty_free(ptr); }
21         }
22
23         /**
24          * The node_id of our counterparty
25          */
26         public byte[] get_node_id() {
27                 byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr);
28                 return ret;
29         }
30
31         /**
32          * The node_id of our counterparty
33          */
34         public void set_node_id(byte[] val) {
35                 bindings.ChannelCounterparty_set_node_id(this.ptr, val);
36         }
37
38         /**
39          * The Features the channel counterparty provided upon last connection.
40          * Useful for routing as it is the most up-to-date copy of the counterparty's features and
41          * many routing-relevant features are present in the init context.
42          */
43         public InitFeatures get_features() {
44                 long ret = bindings.ChannelCounterparty_get_features(this.ptr);
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
47                 ret_hu_conv.ptrs_to.add(this);
48                 return ret_hu_conv;
49         }
50
51         /**
52          * The Features the channel counterparty provided upon last connection.
53          * Useful for routing as it is the most up-to-date copy of the counterparty's features and
54          * many routing-relevant features are present in the init context.
55          */
56         public void set_features(InitFeatures val) {
57                 bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
58         }
59
60         /**
61          * The value, in satoshis, that must always be held in the channel for our counterparty. This
62          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
63          * claiming at least this value on chain.
64          * 
65          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
66          * 
67          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
68          */
69         public long get_unspendable_punishment_reserve() {
70                 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
71                 return ret;
72         }
73
74         /**
75          * The value, in satoshis, that must always be held in the channel for our counterparty. This
76          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
77          * claiming at least this value on chain.
78          * 
79          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
80          * 
81          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
82          */
83         public void set_unspendable_punishment_reserve(long val) {
84                 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
85         }
86
87         /**
88          * Information on the fees and requirements that the counterparty requires when forwarding
89          * payments to us through this channel.
90          * 
91          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
92          */
93         @Nullable
94         public CounterpartyForwardingInfo get_forwarding_info() {
95                 long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyForwardingInfo(null, ret); }
98                 ret_hu_conv.ptrs_to.add(this);
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Information on the fees and requirements that the counterparty requires when forwarding
104          * payments to us through this channel.
105          * 
106          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
107          */
108         public void set_forwarding_info(@Nullable CounterpartyForwardingInfo val) {
109                 bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr & ~1);
110         }
111
112         /**
113          * Constructs a new ChannelCounterparty given each field
114          */
115         public static ChannelCounterparty of(byte[] node_id_arg, InitFeatures features_arg, long unspendable_punishment_reserve_arg, CounterpartyForwardingInfo forwarding_info_arg) {
116                 long ret = bindings.ChannelCounterparty_new(node_id_arg, features_arg == null ? 0 : features_arg.ptr & ~1, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr & ~1);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
119                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
120                 return ret_hu_conv;
121         }
122
123         /**
124          * Creates a copy of the ChannelCounterparty
125          */
126         public ChannelCounterparty clone() {
127                 long ret = bindings.ChannelCounterparty_clone(this.ptr);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
130                 ret_hu_conv.ptrs_to.add(this);
131                 return ret_hu_conv;
132         }
133
134 }