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 byte[] ret = bindings.OpenChannel_get_chain_hash(this.ptr);
32 * The genesis hash of the blockchain where the channel is to be opened
34 public void set_chain_hash(byte[] val) {
35 bindings.OpenChannel_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
41 * A temporary channel ID, until the funding outpoint is announced
43 public byte[] get_temporary_channel_id() {
44 byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
50 * A temporary channel ID, until the funding outpoint is announced
52 public void set_temporary_channel_id(byte[] val) {
53 bindings.OpenChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
61 public long get_funding_satoshis() {
62 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
70 public void set_funding_satoshis(long val) {
71 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
77 * The amount to push to the counterparty as part of the open, in milli-satoshi
79 public long get_push_msat() {
80 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
86 * The amount to push to the counterparty as part of the open, in milli-satoshi
88 public void set_push_msat(long val) {
89 bindings.OpenChannel_set_push_msat(this.ptr, val);
95 * The threshold below which outputs on transactions broadcast by sender will be omitted
97 public long get_dust_limit_satoshis() {
98 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
104 * The threshold below which outputs on transactions broadcast by sender will be omitted
106 public void set_dust_limit_satoshis(long val) {
107 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
113 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
115 public long get_max_htlc_value_in_flight_msat() {
116 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
122 * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
124 public void set_max_htlc_value_in_flight_msat(long val) {
125 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
131 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
133 public long get_channel_reserve_satoshis() {
134 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
140 * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
142 public void set_channel_reserve_satoshis(long val) {
143 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
149 * The minimum HTLC size incoming to sender, in milli-satoshi
151 public long get_htlc_minimum_msat() {
152 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
158 * The minimum HTLC size incoming to sender, in milli-satoshi
160 public void set_htlc_minimum_msat(long val) {
161 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
167 * The feerate per 1000-weight of sender generated transactions, until updated by
170 public int get_feerate_per_kw() {
171 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
177 * The feerate per 1000-weight of sender generated transactions, until updated by
180 public void set_feerate_per_kw(int val) {
181 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
187 * The number of blocks which the counterparty will have to wait to claim on-chain funds if
188 * they broadcast a commitment transaction
190 public short get_to_self_delay() {
191 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
197 * The number of blocks which the counterparty will have to wait to claim on-chain funds if
198 * they broadcast a commitment transaction
200 public void set_to_self_delay(short val) {
201 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
207 * The maximum number of inbound HTLCs towards sender
209 public short get_max_accepted_htlcs() {
210 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
216 * The maximum number of inbound HTLCs towards sender
218 public void set_max_accepted_htlcs(short val) {
219 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
225 * The sender's key controlling the funding transaction
227 public byte[] get_funding_pubkey() {
228 byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
234 * The sender's key controlling the funding transaction
236 public void set_funding_pubkey(byte[] val) {
237 bindings.OpenChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
243 * Used to derive a revocation key for transactions broadcast by counterparty
245 public byte[] get_revocation_basepoint() {
246 byte[] ret = bindings.OpenChannel_get_revocation_basepoint(this.ptr);
252 * Used to derive a revocation key for transactions broadcast by counterparty
254 public void set_revocation_basepoint(byte[] val) {
255 bindings.OpenChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
261 * A payment key to sender for transactions broadcast by counterparty
263 public byte[] get_payment_point() {
264 byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr);
270 * A payment key to sender for transactions broadcast by counterparty
272 public void set_payment_point(byte[] val) {
273 bindings.OpenChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
279 * Used to derive a payment key to sender for transactions broadcast by sender
281 public byte[] get_delayed_payment_basepoint() {
282 byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
288 * Used to derive a payment key to sender for transactions broadcast by sender
290 public void set_delayed_payment_basepoint(byte[] val) {
291 bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
297 * Used to derive an HTLC payment key to sender
299 public byte[] get_htlc_basepoint() {
300 byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
306 * Used to derive an HTLC payment key to sender
308 public void set_htlc_basepoint(byte[] val) {
309 bindings.OpenChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
315 * The first to-be-broadcast-by-sender transaction's per commitment point
317 public byte[] get_first_per_commitment_point() {
318 byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
324 * The first to-be-broadcast-by-sender transaction's per commitment point
326 public void set_first_per_commitment_point(byte[] val) {
327 bindings.OpenChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
333 * The channel flags to be used
335 public byte get_channel_flags() {
336 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
342 * The channel flags to be used
344 public void set_channel_flags(byte val) {
345 bindings.OpenChannel_set_channel_flags(this.ptr, val);
351 * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
353 public Option_ScriptZ get_shutdown_scriptpubkey() {
354 long ret = bindings.OpenChannel_get_shutdown_scriptpubkey(this.ptr);
356 if (ret >= 0 && ret <= 4096) { return null; }
357 org.ldk.structs.Option_ScriptZ ret_hu_conv = org.ldk.structs.Option_ScriptZ.constr_from_ptr(ret);
358 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
363 * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
365 public void set_shutdown_scriptpubkey(org.ldk.structs.Option_ScriptZ val) {
366 bindings.OpenChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
369 if (this != null) { this.ptrs_to.AddLast(val); };
373 * The channel type that this channel will represent
375 * If this is `None`, we derive the channel type from the intersection of our
376 * feature bits with our counterparty's feature bits from the [`Init`] message.
378 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
380 public ChannelTypeFeatures get_channel_type() {
381 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
383 if (ret >= 0 && ret <= 4096) { return null; }
384 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
385 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
390 * The channel type that this channel will represent
392 * If this is `None`, we derive the channel type from the intersection of our
393 * feature bits with our counterparty's feature bits from the [`Init`] message.
395 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
397 public void set_channel_type(org.ldk.structs.ChannelTypeFeatures val) {
398 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
401 if (this != null) { this.ptrs_to.AddLast(val); };
405 * Constructs a new OpenChannel given each field
407 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_ScriptZ shutdown_scriptpubkey_arg, org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
408 long ret = bindings.OpenChannel_new(InternalUtils.check_arr_len(chain_hash_arg, 32), 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.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), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
409 GC.KeepAlive(chain_hash_arg);
410 GC.KeepAlive(temporary_channel_id_arg);
411 GC.KeepAlive(funding_satoshis_arg);
412 GC.KeepAlive(push_msat_arg);
413 GC.KeepAlive(dust_limit_satoshis_arg);
414 GC.KeepAlive(max_htlc_value_in_flight_msat_arg);
415 GC.KeepAlive(channel_reserve_satoshis_arg);
416 GC.KeepAlive(htlc_minimum_msat_arg);
417 GC.KeepAlive(feerate_per_kw_arg);
418 GC.KeepAlive(to_self_delay_arg);
419 GC.KeepAlive(max_accepted_htlcs_arg);
420 GC.KeepAlive(funding_pubkey_arg);
421 GC.KeepAlive(revocation_basepoint_arg);
422 GC.KeepAlive(payment_point_arg);
423 GC.KeepAlive(delayed_payment_basepoint_arg);
424 GC.KeepAlive(htlc_basepoint_arg);
425 GC.KeepAlive(first_per_commitment_point_arg);
426 GC.KeepAlive(channel_flags_arg);
427 GC.KeepAlive(shutdown_scriptpubkey_arg);
428 GC.KeepAlive(channel_type_arg);
429 if (ret >= 0 && ret <= 4096) { return null; }
430 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
431 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
432 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(shutdown_scriptpubkey_arg); };
433 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_type_arg); };
437 internal long clone_ptr() {
438 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
444 * Creates a copy of the OpenChannel
446 public OpenChannel clone() {
447 long ret = bindings.OpenChannel_clone(this.ptr);
449 if (ret >= 0 && ret <= 4096) { return null; }
450 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
451 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
456 * Checks if two OpenChannels contain equal inner contents.
457 * This ignores pointers and is_owned flags and looks at the values in fields.
458 * Two objects with NULL inner values will be considered "equal" here.
460 public bool eq(org.ldk.structs.OpenChannel b) {
461 bool ret = bindings.OpenChannel_eq(this.ptr, b == null ? 0 : b.ptr);
464 if (this != null) { this.ptrs_to.AddLast(b); };
468 public override bool Equals(object o) {
469 if (!(o is OpenChannel)) return false;
470 return this.eq((OpenChannel)o);
473 * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
475 public byte[] write() {
476 byte[] ret = bindings.OpenChannel_write(this.ptr);
482 * Read a OpenChannel from a byte array, created by OpenChannel_write
484 public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
485 long ret = bindings.OpenChannel_read(ser);
487 if (ret >= 0 && ret <= 4096) { return null; }
488 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);