]> git.bitcoin.ninja Git - ldk-java/blobdiff - c_sharp/src/org/ldk/structs/KeysManager.cs
[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / KeysManager.cs
index 0fbd5f64b98ed81ee2ea008633da1928f7ba76da..1b7802854c8c68d8bfa0cfe44bc1f4b087c2579f 100644 (file)
@@ -7,8 +7,8 @@ namespace org { namespace ldk { namespace structs {
 
 
 /**
- * Simple [`KeysInterface`] implementation that takes a 32-byte seed for use as a BIP 32 extended
- * key and derives keys from that.
+ * Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a
+ * 32-byte seed for use as a BIP 32 extended key and derives keys from that.
  * 
  * Your `node_id` is seed/0'.
  * Unilateral closes may use seed/1'.
@@ -47,7 +47,7 @@ public class KeysManager : CommonBase {
         * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
         */
        public static KeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos) {
-               long ret = bindings.KeysManager_new(InternalUtils.check_arr_len(seed, 32), starting_time_secs, starting_time_nanos);
+               long ret = bindings.KeysManager_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(seed, 32)), starting_time_secs, starting_time_nanos);
                GC.KeepAlive(seed);
                GC.KeepAlive(starting_time_secs);
                GC.KeepAlive(starting_time_nanos);
@@ -58,10 +58,21 @@ public class KeysManager : CommonBase {
        }
 
        /**
-        * Derive an old [`Sign`] containing per-channel secrets based on a key derivation parameters.
+        * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc.
+        */
+       public byte[] get_node_secret_key() {
+               long ret = bindings.KeysManager_get_node_secret_key(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+               return ret_conv;
+       }
+
+       /**
+        * Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters.
         */
        public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] _params) {
-               long ret = bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.check_arr_len(_params, 32));
+               long ret = bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(_params, 32)));
                GC.KeepAlive(this);
                GC.KeepAlive(channel_value_satoshis);
                GC.KeepAlive(_params);
@@ -71,11 +82,37 @@ public class KeysManager : CommonBase {
                return ret_hu_conv;
        }
 
+       /**
+        * Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s.
+        * The resulting inputs will be finalized and the PSBT will be ready for broadcast if there
+        * are no other inputs that need signing.
+        * 
+        * Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign.
+        * 
+        * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used
+        * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
+        */
+       public Result_CVec_u8ZNoneZ sign_spendable_outputs_psbt(SpendableOutputDescriptor[] descriptors, byte[] psbt) {
+               long ret = bindings.KeysManager_sign_spendable_outputs_psbt(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr)), InternalUtils.encodeUint8Array(psbt));
+               GC.KeepAlive(this);
+               GC.KeepAlive(descriptors);
+               GC.KeepAlive(psbt);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_CVec_u8ZNoneZ ret_hu_conv = Result_CVec_u8ZNoneZ.constr_from_ptr(ret);
+               foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (this != null) { this.ptrs_to.AddLast(descriptors_conv_27); }; };
+               return ret_hu_conv;
+       }
+
        /**
         * Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an
         * output to the given change destination (if sufficient change value remains). The
         * transaction will have a feerate, at least, of the given value.
         * 
+        * The `locktime` argument is used to set the transaction's locktime. If `None`, the
+        * transaction will have a locktime of 0. It it recommended to set this to the current block
+        * height to avoid fee sniping, unless you have some specific reason to use a different
+        * locktime.
+        * 
         * Returns `Err(())` if the output value is greater than the input value minus required fee,
         * if a descriptor was duplicated, or if an output descriptor `script_pubkey`
         * does not match the one we can spend.
@@ -85,27 +122,56 @@ public class KeysManager : CommonBase {
         * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used
         * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
         */
-       public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight) {
-               long ret = bindings.KeysManager_spend_spendable_outputs(this.ptr, descriptors != null ? InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr) : null, outputs != null ? InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr) : null, change_destination_script, feerate_sat_per_1000_weight);
+       public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_u32Z locktime) {
+               long ret = bindings.KeysManager_spend_spendable_outputs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr)), InternalUtils.encodeUint8Array(change_destination_script), feerate_sat_per_1000_weight, locktime.ptr);
                GC.KeepAlive(this);
                GC.KeepAlive(descriptors);
                GC.KeepAlive(outputs);
                GC.KeepAlive(change_destination_script);
                GC.KeepAlive(feerate_sat_per_1000_weight);
+               GC.KeepAlive(locktime);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
+               foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (this != null) { this.ptrs_to.AddLast(descriptors_conv_27); }; };
+               if (this != null) { this.ptrs_to.AddLast(locktime); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Constructs a new EntropySource which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
+        */
+       public EntropySource as_EntropySource() {
+               long ret = bindings.KeysManager_as_EntropySource(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               EntropySource ret_hu_conv = new EntropySource(null, ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Constructs a new NodeSigner which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is
+        */
+       public NodeSigner as_NodeSigner() {
+               long ret = bindings.KeysManager_as_NodeSigner(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeSigner ret_hu_conv = new NodeSigner(null, ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
                return ret_hu_conv;
        }
 
        /**
-        * Constructs a new KeysInterface which calls the relevant methods on this_arg.
-        * This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is
+        * Constructs a new SignerProvider which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is
         */
-       public KeysInterface as_KeysInterface() {
-               long ret = bindings.KeysManager_as_KeysInterface(this.ptr);
+       public SignerProvider as_SignerProvider() {
+               long ret = bindings.KeysManager_as_SignerProvider(this.ptr);
                GC.KeepAlive(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               KeysInterface ret_hu_conv = new KeysInterface(null, ret);
+               SignerProvider ret_hu_conv = new SignerProvider(null, ret);
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
                return ret_hu_conv;
        }