X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FInMemorySigner.cs;h=d0c6655ad270df55dfa560848a9ac8ab24851afc;hb=8de7213fbf663ff60322896282dad51e8ab2f001;hp=bf18391a74429e5038e0df96c3234ac119d12716;hpb=afc50e5d491a11364849383b75a8f939df703bac;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/InMemorySigner.cs b/c_sharp/src/org/ldk/structs/InMemorySigner.cs index bf18391a..d0c6655a 100644 --- a/c_sharp/src/org/ldk/structs/InMemorySigner.cs +++ b/c_sharp/src/org/ldk/structs/InMemorySigner.cs @@ -23,9 +23,11 @@ public class InMemorySigner : CommonBase { * holder's anchor output in a commitment transaction, if one is present. */ public byte[] get_funding_key() { - byte[] ret = bindings.InMemorySigner_get_funding_key(this.ptr); + long ret = bindings.InMemorySigner_get_funding_key(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** @@ -33,7 +35,7 @@ public class InMemorySigner : CommonBase { * holder's anchor output in a commitment transaction, if one is present. */ public void set_funding_key(byte[] val) { - bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -42,16 +44,18 @@ public class InMemorySigner : CommonBase { * Holder secret key for blinded revocation pubkey. */ public byte[] get_revocation_base_key() { - byte[] ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr); + long ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Holder secret key for blinded revocation pubkey. */ public void set_revocation_base_key(byte[] val) { - bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -60,16 +64,18 @@ public class InMemorySigner : CommonBase { * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ public byte[] get_payment_key() { - byte[] ret = bindings.InMemorySigner_get_payment_key(this.ptr); + long ret = bindings.InMemorySigner_get_payment_key(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ public void set_payment_key(byte[] val) { - bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -78,16 +84,18 @@ public class InMemorySigner : CommonBase { * Holder secret key used in an HTLC transaction. */ public byte[] get_delayed_payment_base_key() { - byte[] ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr); + long ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Holder secret key used in an HTLC transaction. */ public void set_delayed_payment_base_key(byte[] val) { - bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -96,16 +104,18 @@ public class InMemorySigner : CommonBase { * Holder HTLC secret key used in commitment transaction HTLC outputs. */ public byte[] get_htlc_base_key() { - byte[] ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr); + long ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Holder HTLC secret key used in commitment transaction HTLC outputs. */ public void set_htlc_base_key(byte[] val) { - bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -114,16 +124,18 @@ public class InMemorySigner : CommonBase { * Commitment seed. */ public byte[] get_commitment_seed() { - byte[] ret = bindings.InMemorySigner_get_commitment_seed(this.ptr); + long ret = bindings.InMemorySigner_get_commitment_seed(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Commitment seed. */ public void set_commitment_seed(byte[] val) { - bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -150,7 +162,7 @@ public class InMemorySigner : CommonBase { * Creates a new [`InMemorySigner`]. */ public static InMemorySigner of(byte[] funding_key, byte[] revocation_base_key, byte[] payment_key, byte[] delayed_payment_base_key, byte[] htlc_base_key, byte[] commitment_seed, long channel_value_satoshis, byte[] channel_keys_id, byte[] rand_bytes_unique_start) { - long ret = bindings.InMemorySigner_new(InternalUtils.check_arr_len(funding_key, 32), InternalUtils.check_arr_len(revocation_base_key, 32), InternalUtils.check_arr_len(payment_key, 32), InternalUtils.check_arr_len(delayed_payment_base_key, 32), InternalUtils.check_arr_len(htlc_base_key, 32), InternalUtils.check_arr_len(commitment_seed, 32), channel_value_satoshis, InternalUtils.check_arr_len(channel_keys_id, 32), InternalUtils.check_arr_len(rand_bytes_unique_start, 32)); + long ret = bindings.InMemorySigner_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(revocation_base_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(delayed_payment_base_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_base_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_seed, 32)), channel_value_satoshis, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_keys_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(rand_bytes_unique_start, 32))); GC.KeepAlive(funding_key); GC.KeepAlive(revocation_base_key); GC.KeepAlive(payment_key); @@ -169,7 +181,10 @@ public class InMemorySigner : CommonBase { /** * Returns the counterparty's pubkeys. * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public ChannelPublicKeys counterparty_pubkeys() { long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr); @@ -185,12 +200,16 @@ public class InMemorySigner : CommonBase { * transactions, i.e., the amount of time that we have to wait to recover our funds if we * broadcast a transaction. * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ - public short counterparty_selected_contest_delay() { - short ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr); + public Option_u16Z counterparty_selected_contest_delay() { + long ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u16Z ret_hu_conv = org.ldk.structs.Option_u16Z.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; } /** @@ -198,29 +217,40 @@ public class InMemorySigner : CommonBase { * by our counterparty, i.e., the amount of time that they have to wait to recover their funds * if they broadcast a transaction. * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ - public short holder_selected_contest_delay() { - short ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr); + public Option_u16Z holder_selected_contest_delay() { + long ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u16Z ret_hu_conv = org.ldk.structs.Option_u16Z.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; } /** * Returns whether the holder is the initiator. * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ - public bool is_outbound() { - bool ret = bindings.InMemorySigner_is_outbound(this.ptr); + public Option_boolZ is_outbound() { + long ret = bindings.InMemorySigner_is_outbound(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_boolZ ret_hu_conv = org.ldk.structs.Option_boolZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; } /** * Funding outpoint * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public OutPoint funding_outpoint() { long ret = bindings.InMemorySigner_funding_outpoint(this.ptr); @@ -235,7 +265,10 @@ public class InMemorySigner : CommonBase { * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or * building transactions. * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public ChannelTransactionParameters get_channel_parameters() { long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr); @@ -250,7 +283,10 @@ public class InMemorySigner : CommonBase { * Returns the channel type features of the channel parameters. Should be helpful for * determining a channel's category, i. e. legacy/anchors/taproot/etc. * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public ChannelTypeFeatures channel_type_features() { long ret = bindings.InMemorySigner_channel_type_features(this.ptr); @@ -272,7 +308,7 @@ public class InMemorySigner : CommonBase { * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint */ public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, org.ldk.structs.StaticPaymentOutputDescriptor descriptor) { - long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr); + long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, InternalUtils.encodeUint8Array(spend_tx), input_idx, descriptor == null ? 0 : descriptor.ptr); GC.KeepAlive(this); GC.KeepAlive(spend_tx); GC.KeepAlive(input_idx); @@ -296,7 +332,7 @@ public class InMemorySigner : CommonBase { * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay */ public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, org.ldk.structs.DelayedPaymentOutputDescriptor descriptor) { - long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr); + long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, InternalUtils.encodeUint8Array(spend_tx), input_idx, descriptor == null ? 0 : descriptor.ptr); GC.KeepAlive(this); GC.KeepAlive(spend_tx); GC.KeepAlive(input_idx); @@ -363,16 +399,18 @@ public class InMemorySigner : CommonBase { * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ public byte[] write() { - byte[] ret = bindings.InMemorySigner_write(this.ptr); + long ret = bindings.InMemorySigner_write(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ public static Result_InMemorySignerDecodeErrorZ read(byte[] ser, org.ldk.structs.EntropySource arg) { - long ret = bindings.InMemorySigner_read(ser, arg.ptr); + long ret = bindings.InMemorySigner_read(InternalUtils.encodeUint8Array(ser), arg.ptr); GC.KeepAlive(ser); GC.KeepAlive(arg); if (ret >= 0 && ret <= 4096) { return null; }