import org.ldk.enums.*;
import org.ldk.util.*;
import java.util.Arrays;
+import java.lang.ref.Reference;
import javax.annotation.Nullable;
* ChannelMonitor closes may use seed/1'
* Cooperative closes may use seed/2'
* The two close keys may be needed to claim on-chain funds!
+ *
+ * This struct cannot be used for nodes that wish to support receiving phantom payments;
+ * [`PhantomKeysManager`] must be used instead.
+ *
+ * Note that switching between this struct and [`PhantomKeysManager`] will invalidate any
+ * previously issued invoices and attempts to pay previous invoices will fail.
*/
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
public class KeysManager extends CommonBase {
* detailed description of the guarantee.
*/
public static KeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos) {
- long ret = bindings.KeysManager_new(seed, starting_time_secs, starting_time_nanos);
+ long ret = bindings.KeysManager_new(InternalUtils.check_arr_len(seed, 32), starting_time_secs, starting_time_nanos);
+ Reference.reachabilityFence(seed);
+ Reference.reachabilityFence(starting_time_secs);
+ Reference.reachabilityFence(starting_time_nanos);
if (ret >= 0 && ret <= 4096) { return null; }
KeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new KeysManager(null, ret); }
ret_hu_conv.ptrs_to.add(ret_hu_conv);
* onchain output detection for which a corresponding delayed_payment_key must be derived.
*/
public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] params) {
- long ret = bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, params);
+ long ret = bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.check_arr_len(params, 32));
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(channel_value_satoshis);
+ Reference.reachabilityFence(params);
if (ret >= 0 && ret <= 4096) { return null; }
InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
ret_hu_conv.ptrs_to.add(this);
* output to the given change destination (if sufficient change value remains). The
* transaction will have a feerate, at least, of the given value.
*
- * Returns `Err(())` if the output value is greater than the input value minus required fee or
- * if a descriptor was duplicated.
+ * 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.
*
* We do not enforce that outputs meet the dust limit or that any output scripts are standard.
*
*/
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 ? Arrays.stream(descriptors).mapToLong(descriptors_conv_27 -> descriptors_conv_27.ptr).toArray() : null, outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_7 -> outputs_conv_7.ptr).toArray() : null, change_destination_script, feerate_sat_per_1000_weight);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(descriptors);
+ Reference.reachabilityFence(outputs);
+ Reference.reachabilityFence(change_destination_script);
+ Reference.reachabilityFence(feerate_sat_per_1000_weight);
if (ret >= 0 && ret <= 4096) { return null; }
Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
return ret_hu_conv;
*/
public KeysInterface as_KeysInterface() {
long ret = bindings.KeysManager_as_KeysInterface(this.ptr);
+ Reference.reachabilityFence(this);
if (ret >= 0 && ret <= 4096) { return null; }
KeysInterface ret_hu_conv = new KeysInterface(null, ret);
ret_hu_conv.ptrs_to.add(this);