09e40947f473492d02e6fb0afca741f3a557ac3c
[ldk-java] / src / main / java / org / ldk / structs / TxInitRbf.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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A tx_init_rbf message which initiates a replacement of the transaction after it's been
13  * completed.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class TxInitRbf extends CommonBase {
17         TxInitRbf(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.TxInitRbf_free(ptr); }
22         }
23
24         /**
25          * The channel ID
26          */
27         public byte[] get_channel_id() {
28                 byte[] ret = bindings.TxInitRbf_get_channel_id(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * The channel ID
35          */
36         public void set_channel_id(byte[] val) {
37                 bindings.TxInitRbf_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
38                 Reference.reachabilityFence(this);
39                 Reference.reachabilityFence(val);
40         }
41
42         /**
43          * The locktime of the transaction
44          */
45         public int get_locktime() {
46                 int ret = bindings.TxInitRbf_get_locktime(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * The locktime of the transaction
53          */
54         public void set_locktime(int val) {
55                 bindings.TxInitRbf_set_locktime(this.ptr, val);
56                 Reference.reachabilityFence(this);
57                 Reference.reachabilityFence(val);
58         }
59
60         /**
61          * The feerate of the transaction
62          */
63         public int get_feerate_sat_per_1000_weight() {
64                 int ret = bindings.TxInitRbf_get_feerate_sat_per_1000_weight(this.ptr);
65                 Reference.reachabilityFence(this);
66                 return ret;
67         }
68
69         /**
70          * The feerate of the transaction
71          */
72         public void set_feerate_sat_per_1000_weight(int val) {
73                 bindings.TxInitRbf_set_feerate_sat_per_1000_weight(this.ptr, val);
74                 Reference.reachabilityFence(this);
75                 Reference.reachabilityFence(val);
76         }
77
78         /**
79          * The number of satoshis the sender will contribute to or, if negative, remove from
80          * (e.g. splice-out) the funding output of the transaction
81          */
82         public Option_i64Z get_funding_output_contribution() {
83                 long ret = bindings.TxInitRbf_get_funding_output_contribution(this.ptr);
84                 Reference.reachabilityFence(this);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.Option_i64Z ret_hu_conv = org.ldk.structs.Option_i64Z.constr_from_ptr(ret);
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
88                 return ret_hu_conv;
89         }
90
91         /**
92          * The number of satoshis the sender will contribute to or, if negative, remove from
93          * (e.g. splice-out) the funding output of the transaction
94          */
95         public void set_funding_output_contribution(org.ldk.structs.Option_i64Z val) {
96                 bindings.TxInitRbf_set_funding_output_contribution(this.ptr, val.ptr);
97                 Reference.reachabilityFence(this);
98                 Reference.reachabilityFence(val);
99                 if (this != null) { this.ptrs_to.add(val); };
100         }
101
102         /**
103          * Constructs a new TxInitRbf given each field
104          */
105         public static TxInitRbf of(byte[] channel_id_arg, int locktime_arg, int feerate_sat_per_1000_weight_arg, org.ldk.structs.Option_i64Z funding_output_contribution_arg) {
106                 long ret = bindings.TxInitRbf_new(InternalUtils.check_arr_len(channel_id_arg, 32), locktime_arg, feerate_sat_per_1000_weight_arg, funding_output_contribution_arg.ptr);
107                 Reference.reachabilityFence(channel_id_arg);
108                 Reference.reachabilityFence(locktime_arg);
109                 Reference.reachabilityFence(feerate_sat_per_1000_weight_arg);
110                 Reference.reachabilityFence(funding_output_contribution_arg);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 org.ldk.structs.TxInitRbf ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxInitRbf(null, ret); }
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_output_contribution_arg); };
115                 return ret_hu_conv;
116         }
117
118         long clone_ptr() {
119                 long ret = bindings.TxInitRbf_clone_ptr(this.ptr);
120                 Reference.reachabilityFence(this);
121                 return ret;
122         }
123
124         /**
125          * Creates a copy of the TxInitRbf
126          */
127         public TxInitRbf clone() {
128                 long ret = bindings.TxInitRbf_clone(this.ptr);
129                 Reference.reachabilityFence(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 org.ldk.structs.TxInitRbf ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxInitRbf(null, ret); }
132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133                 return ret_hu_conv;
134         }
135
136         /**
137          * Checks if two TxInitRbfs contain equal inner contents.
138          * This ignores pointers and is_owned flags and looks at the values in fields.
139          * Two objects with NULL inner values will be considered "equal" here.
140          */
141         public boolean eq(org.ldk.structs.TxInitRbf b) {
142                 boolean ret = bindings.TxInitRbf_eq(this.ptr, b == null ? 0 : b.ptr);
143                 Reference.reachabilityFence(this);
144                 Reference.reachabilityFence(b);
145                 if (this != null) { this.ptrs_to.add(b); };
146                 return ret;
147         }
148
149         @Override public boolean equals(Object o) {
150                 if (!(o instanceof TxInitRbf)) return false;
151                 return this.eq((TxInitRbf)o);
152         }
153         /**
154          * Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
155          */
156         public byte[] write() {
157                 byte[] ret = bindings.TxInitRbf_write(this.ptr);
158                 Reference.reachabilityFence(this);
159                 return ret;
160         }
161
162         /**
163          * Read a TxInitRbf from a byte array, created by TxInitRbf_write
164          */
165         public static Result_TxInitRbfDecodeErrorZ read(byte[] ser) {
166                 long ret = bindings.TxInitRbf_read(ser);
167                 Reference.reachabilityFence(ser);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 Result_TxInitRbfDecodeErrorZ ret_hu_conv = Result_TxInitRbfDecodeErrorZ.constr_from_ptr(ret);
170                 return ret_hu_conv;
171         }
172
173 }