535c6a0ae152e29490f475b863e823e827959615
[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 < 1024) { return null; }
46                 InitFeatures 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                 this.ptrs_to.add(val);
59         }
60
61         /**
62          * The value, in satoshis, that must always be held in the channel for our counterparty. This
63          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
64          * claiming at least this value on chain.
65          * 
66          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
67          * 
68          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
69          */
70         public long get_unspendable_punishment_reserve() {
71                 long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr);
72                 return ret;
73         }
74
75         /**
76          * The value, in satoshis, that must always be held in the channel for our counterparty. This
77          * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
78          * claiming at least this value on chain.
79          * 
80          * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
81          * 
82          * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
83          */
84         public void set_unspendable_punishment_reserve(long val) {
85                 bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val);
86         }
87
88         /**
89          * Creates a copy of the ChannelCounterparty
90          */
91         public ChannelCounterparty clone() {
92                 long ret = bindings.ChannelCounterparty_clone(this.ptr);
93                 if (ret < 1024) { return null; }
94                 ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret);
95                 ret_hu_conv.ptrs_to.add(this);
96                 return ret_hu_conv;
97         }
98
99 }