6 namespace org { namespace ldk { namespace structs {
10 * An [`open_channel`] message to be sent to or received from a peer.
12 * Used in V1 channel establishment
14 * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
16 public class OpenChannel : CommonBase {
17 internal OpenChannel(object _dummy, long ptr) : base(ptr) { }
19 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
23 * The genesis hash of the blockchain where the channel is to be opened
25 public byte[] get_chain_hash() {
26 long ret = bindings.OpenChannel_get_chain_hash(this.ptr);
28 if (ret >= 0 && ret <= 4096) { return null; }
29 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
34 * The genesis hash of the blockchain where the channel is to be opened
36 public void set_chain_hash(byte[] val) {
37 bindings.OpenChannel_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
43 * A temporary channel ID, until the funding outpoint is announced
45 public byte[] get_temporary_channel_id() {
46 long ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
54 * A temporary channel ID, until the funding outpoint is announced
56 public void set_temporary_channel_id(byte[] val) {
57 bindings.OpenChannel_set_temporary_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
65 public long get_funding_satoshis() {
66 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
74 public void set_funding_satoshis(long val) {
75 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
81 * The amount to push to the counterparty as part of the open, in milli-satoshi
83 public long get_push_msat() {
84 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
90 * The amount to push to the counterparty as part of the open, in milli-satoshi
92 public void set_push_msat(long val) {
93 bindings.OpenChannel_set_push_msat(this.ptr, val);
99 * The threshold below which outputs on transactions broadcast by sender will be omitted
101 public long get_dust_limit_satoshis() {
102 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
108 * The threshold below which outputs on transactions broadcast by sender will be omitted
110 public void set_dust_limit_satoshis(long val) {
111 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
117 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
119 public long get_max_htlc_value_in_flight_msat() {
120 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
126 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
128 public void set_max_htlc_value_in_flight_msat(long val) {
129 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
135 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
137 public long get_channel_reserve_satoshis() {
138 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
144 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
146 public void set_channel_reserve_satoshis(long val) {
147 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
153 * The minimum HTLC size incoming to sender, in milli-satoshi
155 public long get_htlc_minimum_msat() {
156 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
162 * The minimum HTLC size incoming to sender, in milli-satoshi
164 public void set_htlc_minimum_msat(long val) {
165 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
171 * The feerate per 1000-weight of sender generated transactions, until updated by
174 public int get_feerate_per_kw() {
175 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
181 * The feerate per 1000-weight of sender generated transactions, until updated by
184 public void set_feerate_per_kw(int val) {
185 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
191 * The number of blocks which the counterparty will have to wait to claim on-chain funds if
192 * they broadcast a commitment transaction
194 public short get_to_self_delay() {
195 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
201 * The number of blocks which the counterparty will have to wait to claim on-chain funds if
202 * they broadcast a commitment transaction
204 public void set_to_self_delay(short val) {
205 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
211 * The maximum number of inbound HTLCs towards sender
213 public short get_max_accepted_htlcs() {
214 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
220 * The maximum number of inbound HTLCs towards sender
222 public void set_max_accepted_htlcs(short val) {
223 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
229 * The sender's key controlling the funding transaction
231 public byte[] get_funding_pubkey() {
232 long ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
240 * The sender's key controlling the funding transaction
242 public void set_funding_pubkey(byte[] val) {
243 bindings.OpenChannel_set_funding_pubkey(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
249 * Used to derive a revocation key for transactions broadcast by counterparty
251 public byte[] get_revocation_basepoint() {
252 long ret = bindings.OpenChannel_get_revocation_basepoint(this.ptr);
254 if (ret >= 0 && ret <= 4096) { return null; }
255 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
260 * Used to derive a revocation key for transactions broadcast by counterparty
262 public void set_revocation_basepoint(byte[] val) {
263 bindings.OpenChannel_set_revocation_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
269 * A payment key to sender for transactions broadcast by counterparty
271 public byte[] get_payment_point() {
272 long ret = bindings.OpenChannel_get_payment_point(this.ptr);
274 if (ret >= 0 && ret <= 4096) { return null; }
275 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
280 * A payment key to sender for transactions broadcast by counterparty
282 public void set_payment_point(byte[] val) {
283 bindings.OpenChannel_set_payment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
289 * Used to derive a payment key to sender for transactions broadcast by sender
291 public byte[] get_delayed_payment_basepoint() {
292 long ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
294 if (ret >= 0 && ret <= 4096) { return null; }
295 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
300 * Used to derive a payment key to sender for transactions broadcast by sender
302 public void set_delayed_payment_basepoint(byte[] val) {
303 bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
309 * Used to derive an HTLC payment key to sender
311 public byte[] get_htlc_basepoint() {
312 long ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
314 if (ret >= 0 && ret <= 4096) { return null; }
315 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
320 * Used to derive an HTLC payment key to sender
322 public void set_htlc_basepoint(byte[] val) {
323 bindings.OpenChannel_set_htlc_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
329 * The first to-be-broadcast-by-sender transaction's per commitment point
331 public byte[] get_first_per_commitment_point() {
332 long ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
334 if (ret >= 0 && ret <= 4096) { return null; }
335 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
340 * The first to-be-broadcast-by-sender transaction's per commitment point
342 public void set_first_per_commitment_point(byte[] val) {
343 bindings.OpenChannel_set_first_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
349 * The channel flags to be used
351 public byte get_channel_flags() {
352 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
358 * The channel flags to be used
360 public void set_channel_flags(byte val) {
361 bindings.OpenChannel_set_channel_flags(this.ptr, val);
367 * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
369 public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
370 long ret = bindings.OpenChannel_get_shutdown_scriptpubkey(this.ptr);
372 if (ret >= 0 && ret <= 4096) { return null; }
373 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
374 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
379 * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
381 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
382 bindings.OpenChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
385 if (this != null) { this.ptrs_to.AddLast(val); };
389 * The channel type that this channel will represent
391 * If this is `None`, we derive the channel type from the intersection of our
392 * feature bits with our counterparty's feature bits from the [`Init`] message.
394 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
396 public ChannelTypeFeatures get_channel_type() {
397 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
399 if (ret >= 0 && ret <= 4096) { return null; }
400 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
401 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
406 * The channel type that this channel will represent
408 * If this is `None`, we derive the channel type from the intersection of our
409 * feature bits with our counterparty's feature bits from the [`Init`] message.
411 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
413 public void set_channel_type(org.ldk.structs.ChannelTypeFeatures val) {
414 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
417 if (this != null) { this.ptrs_to.AddLast(val); };
421 * Constructs a new OpenChannel given each field
423 * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
425 public static OpenChannel of(byte[] chain_hash_arg, byte[] temporary_channel_id_arg, long funding_satoshis_arg, long push_msat_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 feerate_per_kw_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, byte channel_flags_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
426 long ret = bindings.OpenChannel_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(temporary_channel_id_arg, 32)), funding_satoshis_arg, push_msat_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, feerate_per_kw_arg, to_self_delay_arg, max_accepted_htlcs_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(revocation_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_point_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(first_per_commitment_point_arg, 33)), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
427 GC.KeepAlive(chain_hash_arg);
428 GC.KeepAlive(temporary_channel_id_arg);
429 GC.KeepAlive(funding_satoshis_arg);
430 GC.KeepAlive(push_msat_arg);
431 GC.KeepAlive(dust_limit_satoshis_arg);
432 GC.KeepAlive(max_htlc_value_in_flight_msat_arg);
433 GC.KeepAlive(channel_reserve_satoshis_arg);
434 GC.KeepAlive(htlc_minimum_msat_arg);
435 GC.KeepAlive(feerate_per_kw_arg);
436 GC.KeepAlive(to_self_delay_arg);
437 GC.KeepAlive(max_accepted_htlcs_arg);
438 GC.KeepAlive(funding_pubkey_arg);
439 GC.KeepAlive(revocation_basepoint_arg);
440 GC.KeepAlive(payment_point_arg);
441 GC.KeepAlive(delayed_payment_basepoint_arg);
442 GC.KeepAlive(htlc_basepoint_arg);
443 GC.KeepAlive(first_per_commitment_point_arg);
444 GC.KeepAlive(channel_flags_arg);
445 GC.KeepAlive(shutdown_scriptpubkey_arg);
446 GC.KeepAlive(channel_type_arg);
447 if (ret >= 0 && ret <= 4096) { return null; }
448 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
449 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
450 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(shutdown_scriptpubkey_arg); };
451 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_type_arg); };
455 internal long clone_ptr() {
456 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
462 * Creates a copy of the OpenChannel
464 public OpenChannel clone() {
465 long ret = bindings.OpenChannel_clone(this.ptr);
467 if (ret >= 0 && ret <= 4096) { return null; }
468 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
469 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
474 * Generates a non-cryptographic 64-bit hash of the OpenChannel.
477 long ret = bindings.OpenChannel_hash(this.ptr);
482 public override int GetHashCode() {
483 return (int)this.hash();
486 * Checks if two OpenChannels contain equal inner contents.
487 * This ignores pointers and is_owned flags and looks at the values in fields.
488 * Two objects with NULL inner values will be considered "equal" here.
490 public bool eq(org.ldk.structs.OpenChannel b) {
491 bool ret = bindings.OpenChannel_eq(this.ptr, b == null ? 0 : b.ptr);
494 if (this != null) { this.ptrs_to.AddLast(b); };
498 public override bool Equals(object o) {
499 if (!(o is OpenChannel)) return false;
500 return this.eq((OpenChannel)o);
503 * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
505 public byte[] write() {
506 long ret = bindings.OpenChannel_write(this.ptr);
508 if (ret >= 0 && ret <= 4096) { return null; }
509 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
514 * Read a OpenChannel from a byte array, created by OpenChannel_write
516 public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
517 long ret = bindings.OpenChannel_read(InternalUtils.encodeUint8Array(ser));
519 if (ret >= 0 && ret <= 4096) { return null; }
520 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);