/**
- * An accept_channel message to be sent or received from a peer
+ * An [`accept_channel`] message to be sent to or received from a peer.
+ *
+ * Used in V1 channel establishment
+ *
+ * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
*/
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
public class AcceptChannel extends CommonBase {
}
/**
- * The channel type that this channel will represent. If none is set, we derive the channel
- * type from the intersection of our feature bits with our counterparty's feature bits from
- * the Init message.
+ * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
+ */
+ public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
+ long ret = bindings.AcceptChannel_get_shutdown_scriptpubkey(this.ptr);
+ Reference.reachabilityFence(this);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
+ */
+ public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
+ bindings.AcceptChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(val);
+ if (this != null) { this.ptrs_to.add(val); };
+ }
+
+ /**
+ * The channel type that this channel will represent.
*
+ * If this is `None`, we derive the channel type from the intersection of
+ * our feature bits with our counterparty's feature bits from the [`Init`] message.
* This is required to match the equivalent field in [`OpenChannel::channel_type`].
*
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
Reference.reachabilityFence(this);
if (ret >= 0 && ret <= 4096) { return null; }
org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
- ret_hu_conv.ptrs_to.add(this);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
return ret_hu_conv;
}
/**
- * The channel type that this channel will represent. If none is set, we derive the channel
- * type from the intersection of our feature bits with our counterparty's feature bits from
- * the Init message.
+ * The channel type that this channel will represent.
*
+ * If this is `None`, we derive the channel type from the intersection of
+ * our feature bits with our counterparty's feature bits from the [`Init`] message.
* This is required to match the equivalent field in [`OpenChannel::channel_type`].
*
* Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- public void set_channel_type(@Nullable ChannelTypeFeatures val) {
- bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr & ~1);
+ public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
+ bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
Reference.reachabilityFence(this);
Reference.reachabilityFence(val);
+ if (this != null) { this.ptrs_to.add(val); };
+ }
+
+ /**
+ * Constructs a new AcceptChannel given each field
+ *
+ * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ public static AcceptChannel of(byte[] temporary_channel_id_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long channel_reserve_satoshis_arg, long htlc_minimum_msat_arg, int minimum_depth_arg, short to_self_delay_arg, short max_accepted_htlcs_arg, byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg, byte[] first_per_commitment_point_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
+ long ret = bindings.AcceptChannel_new(InternalUtils.check_arr_len(temporary_channel_id_arg, 32), dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, InternalUtils.check_arr_len(funding_pubkey_arg, 33), InternalUtils.check_arr_len(revocation_basepoint_arg, 33), InternalUtils.check_arr_len(payment_point_arg, 33), InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33), InternalUtils.check_arr_len(htlc_basepoint_arg, 33), InternalUtils.check_arr_len(first_per_commitment_point_arg, 33), shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
+ Reference.reachabilityFence(temporary_channel_id_arg);
+ Reference.reachabilityFence(dust_limit_satoshis_arg);
+ Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
+ Reference.reachabilityFence(channel_reserve_satoshis_arg);
+ Reference.reachabilityFence(htlc_minimum_msat_arg);
+ Reference.reachabilityFence(minimum_depth_arg);
+ Reference.reachabilityFence(to_self_delay_arg);
+ Reference.reachabilityFence(max_accepted_htlcs_arg);
+ Reference.reachabilityFence(funding_pubkey_arg);
+ Reference.reachabilityFence(revocation_basepoint_arg);
+ Reference.reachabilityFence(payment_point_arg);
+ Reference.reachabilityFence(delayed_payment_basepoint_arg);
+ Reference.reachabilityFence(htlc_basepoint_arg);
+ Reference.reachabilityFence(first_per_commitment_point_arg);
+ Reference.reachabilityFence(shutdown_scriptpubkey_arg);
+ Reference.reachabilityFence(channel_type_arg);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
+ return ret_hu_conv;
}
long clone_ptr() {
Reference.reachabilityFence(this);
if (ret >= 0 && ret <= 4096) { return null; }
org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
- ret_hu_conv.ptrs_to.add(this);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
return ret_hu_conv;
}
+ /**
+ * Generates a non-cryptographic 64-bit hash of the AcceptChannel.
+ */
+ public long hash() {
+ long ret = bindings.AcceptChannel_hash(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+ @Override public int hashCode() {
+ return (int)this.hash();
+ }
+ /**
+ * Checks if two AcceptChannels contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ * Two objects with NULL inner values will be considered "equal" here.
+ */
+ public boolean eq(org.ldk.structs.AcceptChannel b) {
+ boolean ret = bindings.AcceptChannel_eq(this.ptr, b == null ? 0 : b.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(b);
+ if (this != null) { this.ptrs_to.add(b); };
+ return ret;
+ }
+
+ @Override public boolean equals(Object o) {
+ if (!(o instanceof AcceptChannel)) return false;
+ return this.eq((AcceptChannel)o);
+ }
/**
* Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
*/