1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A splice message to be sent by or received from the stfu initiator (splice initiator).
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Splice extends CommonBase {
16 Splice(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Splice_free(ptr); }
24 * The channel ID where splicing is intended
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.Splice_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
33 * The channel ID where splicing is intended
35 public void set_channel_id(byte[] val) {
36 bindings.Splice_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The genesis hash of the blockchain where the channel is intended to be spliced
44 public byte[] get_chain_hash() {
45 byte[] ret = bindings.Splice_get_chain_hash(this.ptr);
46 Reference.reachabilityFence(this);
51 * The genesis hash of the blockchain where the channel is intended to be spliced
53 public void set_chain_hash(byte[] val) {
54 bindings.Splice_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * The intended change in channel capacity: the amount to be added (positive value)
61 * or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
63 public long get_relative_satoshis() {
64 long ret = bindings.Splice_get_relative_satoshis(this.ptr);
65 Reference.reachabilityFence(this);
70 * The intended change in channel capacity: the amount to be added (positive value)
71 * or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
73 public void set_relative_satoshis(long val) {
74 bindings.Splice_set_relative_satoshis(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The feerate for the new funding transaction, set by the splice initiator
82 public int get_funding_feerate_perkw() {
83 int ret = bindings.Splice_get_funding_feerate_perkw(this.ptr);
84 Reference.reachabilityFence(this);
89 * The feerate for the new funding transaction, set by the splice initiator
91 public void set_funding_feerate_perkw(int val) {
92 bindings.Splice_set_funding_feerate_perkw(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * The locktime for the new funding transaction
100 public int get_locktime() {
101 int ret = bindings.Splice_get_locktime(this.ptr);
102 Reference.reachabilityFence(this);
107 * The locktime for the new funding transaction
109 public void set_locktime(int val) {
110 bindings.Splice_set_locktime(this.ptr, val);
111 Reference.reachabilityFence(this);
112 Reference.reachabilityFence(val);
116 * The key of the sender (splice initiator) controlling the new funding transaction
118 public byte[] get_funding_pubkey() {
119 byte[] ret = bindings.Splice_get_funding_pubkey(this.ptr);
120 Reference.reachabilityFence(this);
125 * The key of the sender (splice initiator) controlling the new funding transaction
127 public void set_funding_pubkey(byte[] val) {
128 bindings.Splice_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
129 Reference.reachabilityFence(this);
130 Reference.reachabilityFence(val);
134 * Constructs a new Splice given each field
136 public static Splice of(byte[] channel_id_arg, byte[] chain_hash_arg, long relative_satoshis_arg, int funding_feerate_perkw_arg, int locktime_arg, byte[] funding_pubkey_arg) {
137 long ret = bindings.Splice_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(chain_hash_arg, 32), relative_satoshis_arg, funding_feerate_perkw_arg, locktime_arg, InternalUtils.check_arr_len(funding_pubkey_arg, 33));
138 Reference.reachabilityFence(channel_id_arg);
139 Reference.reachabilityFence(chain_hash_arg);
140 Reference.reachabilityFence(relative_satoshis_arg);
141 Reference.reachabilityFence(funding_feerate_perkw_arg);
142 Reference.reachabilityFence(locktime_arg);
143 Reference.reachabilityFence(funding_pubkey_arg);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.Splice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Splice(null, ret); }
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
151 long ret = bindings.Splice_clone_ptr(this.ptr);
152 Reference.reachabilityFence(this);
157 * Creates a copy of the Splice
159 public Splice clone() {
160 long ret = bindings.Splice_clone(this.ptr);
161 Reference.reachabilityFence(this);
162 if (ret >= 0 && ret <= 4096) { return null; }
163 org.ldk.structs.Splice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Splice(null, ret); }
164 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
169 * Checks if two Splices contain equal inner contents.
170 * This ignores pointers and is_owned flags and looks at the values in fields.
171 * Two objects with NULL inner values will be considered "equal" here.
173 public boolean eq(org.ldk.structs.Splice b) {
174 boolean ret = bindings.Splice_eq(this.ptr, b == null ? 0 : b.ptr);
175 Reference.reachabilityFence(this);
176 Reference.reachabilityFence(b);
177 if (this != null) { this.ptrs_to.add(b); };
181 @Override public boolean equals(Object o) {
182 if (!(o instanceof Splice)) return false;
183 return this.eq((Splice)o);
186 * Serialize the Splice object into a byte array which can be read by Splice_read
188 public byte[] write() {
189 byte[] ret = bindings.Splice_write(this.ptr);
190 Reference.reachabilityFence(this);
195 * Read a Splice from a byte array, created by Splice_write
197 public static Result_SpliceDecodeErrorZ read(byte[] ser) {
198 long ret = bindings.Splice_read(ser);
199 Reference.reachabilityFence(ser);
200 if (ret >= 0 && ret <= 4096) { return null; }
201 Result_SpliceDecodeErrorZ ret_hu_conv = Result_SpliceDecodeErrorZ.constr_from_ptr(ret);