39e9f85b94c26216a36df9e4da1f301d6ef69af5
[ldk-java] / src / main / java / org / ldk / structs / TxAckRbf.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_ack_rbf message which acknowledges replacement of the transaction after it's been
13  * completed.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class TxAckRbf extends CommonBase {
17         TxAckRbf(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.TxAckRbf_free(ptr); }
22         }
23
24         /**
25          * The channel ID
26          */
27         public byte[] get_channel_id() {
28                 byte[] ret = bindings.TxAckRbf_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.TxAckRbf_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
38                 Reference.reachabilityFence(this);
39                 Reference.reachabilityFence(val);
40         }
41
42         /**
43          * The number of satoshis the sender will contribute to or, if negative, remove from
44          * (e.g. splice-out) the funding output of the transaction
45          */
46         public Option_i64Z get_funding_output_contribution() {
47                 long ret = bindings.TxAckRbf_get_funding_output_contribution(this.ptr);
48                 Reference.reachabilityFence(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.Option_i64Z ret_hu_conv = org.ldk.structs.Option_i64Z.constr_from_ptr(ret);
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The number of satoshis the sender will contribute to or, if negative, remove from
57          * (e.g. splice-out) the funding output of the transaction
58          */
59         public void set_funding_output_contribution(org.ldk.structs.Option_i64Z val) {
60                 bindings.TxAckRbf_set_funding_output_contribution(this.ptr, val.ptr);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63                 if (this != null) { this.ptrs_to.add(val); };
64         }
65
66         /**
67          * Constructs a new TxAckRbf given each field
68          */
69         public static TxAckRbf of(byte[] channel_id_arg, org.ldk.structs.Option_i64Z funding_output_contribution_arg) {
70                 long ret = bindings.TxAckRbf_new(InternalUtils.check_arr_len(channel_id_arg, 32), funding_output_contribution_arg.ptr);
71                 Reference.reachabilityFence(channel_id_arg);
72                 Reference.reachabilityFence(funding_output_contribution_arg);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.TxAckRbf ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAckRbf(null, ret); }
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_output_contribution_arg); };
77                 return ret_hu_conv;
78         }
79
80         long clone_ptr() {
81                 long ret = bindings.TxAckRbf_clone_ptr(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         /**
87          * Creates a copy of the TxAckRbf
88          */
89         public TxAckRbf clone() {
90                 long ret = bindings.TxAckRbf_clone(this.ptr);
91                 Reference.reachabilityFence(this);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.TxAckRbf ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAckRbf(null, ret); }
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Checks if two TxAckRbfs contain equal inner contents.
100          * This ignores pointers and is_owned flags and looks at the values in fields.
101          * Two objects with NULL inner values will be considered "equal" here.
102          */
103         public boolean eq(org.ldk.structs.TxAckRbf b) {
104                 boolean ret = bindings.TxAckRbf_eq(this.ptr, b == null ? 0 : b.ptr);
105                 Reference.reachabilityFence(this);
106                 Reference.reachabilityFence(b);
107                 if (this != null) { this.ptrs_to.add(b); };
108                 return ret;
109         }
110
111         @Override public boolean equals(Object o) {
112                 if (!(o instanceof TxAckRbf)) return false;
113                 return this.eq((TxAckRbf)o);
114         }
115         /**
116          * Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
117          */
118         public byte[] write() {
119                 byte[] ret = bindings.TxAckRbf_write(this.ptr);
120                 Reference.reachabilityFence(this);
121                 return ret;
122         }
123
124         /**
125          * Read a TxAckRbf from a byte array, created by TxAckRbf_write
126          */
127         public static Result_TxAckRbfDecodeErrorZ read(byte[] ser) {
128                 long ret = bindings.TxAckRbf_read(ser);
129                 Reference.reachabilityFence(ser);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 Result_TxAckRbfDecodeErrorZ ret_hu_conv = Result_TxAckRbfDecodeErrorZ.constr_from_ptr(ret);
132                 return ret_hu_conv;
133         }
134
135 }