diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27c8f7ef..c2893a06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -222,7 +222,7 @@ jobs: run: | cd c_sharp ./build-release-nupkg.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: org.ldk.nupkg path: c_sharp/org.ldk.nupkg @@ -456,11 +456,11 @@ jobs: ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" false false - name: Build deterministic release jar run: ./build-release-jar.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ldk-java.jar path: ldk-java.jar - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ldk-java-leaktracking.jar path: ldk-java-leaktracking.jar @@ -702,7 +702,7 @@ jobs: export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64" export PATH="$PATH:$ANDROID_TOOLCHAIN/bin" ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: LDK-release.aar path: LDK-release.aar diff --git a/c_sharp/bindings.c b/c_sharp/bindings.c index 80a4f593..110ebb22 100644 --- a/c_sharp/bindings.c +++ b/c_sharp/bindings.c @@ -7153,6 +7153,12 @@ int64_t CS_LDK_LDKPendingHTLCRouting_Forward_get_blinded(int64_t ptr) { blinded_ref = tag_ptr(blinded_var.inner, false); return blinded_ref; } +int64_t CS_LDK_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(int64_t ptr) { + LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); + CHECK(obj->tag == LDKPendingHTLCRouting_Forward); + int64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false); + return incoming_cltv_expiry_ref; +} int64_t CS_LDK_LDKPendingHTLCRouting_Receive_get_payment_data(int64_t ptr) { LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); CHECK(obj->tag == LDKPendingHTLCRouting_Receive); @@ -44632,7 +44638,7 @@ int64_t CS_LDK_PendingHTLCRouting_clone(int64_t orig) { return ret_ref; } -int64_t CS_LDK_PendingHTLCRouting_forward(int64_t onion_packet, int64_t short_channel_id, int64_t blinded) { +int64_t CS_LDK_PendingHTLCRouting_forward(int64_t onion_packet, int64_t short_channel_id, int64_t blinded, int64_t incoming_cltv_expiry) { LDKOnionPacket onion_packet_conv; onion_packet_conv.inner = untag_ptr(onion_packet); onion_packet_conv.is_owned = ptr_is_owned(onion_packet); @@ -44643,8 +44649,12 @@ int64_t CS_LDK_PendingHTLCRouting_forward(int64_t onion_packet, int64_t short_c blinded_conv.is_owned = ptr_is_owned(blinded); CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv); blinded_conv = BlindedForward_clone(&blinded_conv); + void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry); + CHECK_ACCESS(incoming_cltv_expiry_ptr); + LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr); + incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry)); LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting"); - *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv); + *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv); int64_t ret_ref = tag_ptr(ret_copy, true); return ret_ref; } @@ -45860,6 +45870,33 @@ void CS_LDK_ChannelManager_force_close_all_channels_without_broadcasting_txn(in ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv); } +int64_t CS_LDK_ChannelManager_send_payment_with_route(int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = untag_ptr(this_arg); + this_arg_conv.is_owned = ptr_is_owned(this_arg); + CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = untag_ptr(route); + route_conv.is_owned = ptr_is_owned(route); + CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv); + route_conv = Route_clone(&route_conv); + LDKThirtyTwoBytes payment_hash_ref; + CHECK(payment_hash->arr_len == 32); + memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash); + LDKRecipientOnionFields recipient_onion_conv; + recipient_onion_conv.inner = untag_ptr(recipient_onion); + recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion); + CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv); + recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv); + LDKThirtyTwoBytes payment_id_ref; + CHECK(payment_id->arr_len == 32); + memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id); + LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ"); + *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref); + return tag_ptr(ret_conv, true); +} + int64_t CS_LDK_ChannelManager_send_payment(int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) { LDKChannelManager this_arg_conv; this_arg_conv.inner = untag_ptr(this_arg); @@ -77340,6 +77377,15 @@ int64_t CS_LDK_SpendableOutputDescriptor_create_spendable_outputs_psbt(int64_tA return tag_ptr(ret_conv, true); } +int64_t CS_LDK_SpendableOutputDescriptor_spendable_outpoint(int64_t this_arg) { + LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg); + LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv); + int64_t ret_ref = 0; + CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var); + ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned); + return ret_ref; +} + void CS_LDK_ChannelDerivationParameters_free(int64_t this_obj) { LDKChannelDerivationParameters this_obj_conv; this_obj_conv.inner = untag_ptr(this_obj); diff --git a/c_sharp/bindings.c.body b/c_sharp/bindings.c.body index 6dea90dc..20551a4f 100644 --- a/c_sharp/bindings.c.body +++ b/c_sharp/bindings.c.body @@ -7149,6 +7149,12 @@ int64_t CS_LDK_LDKPendingHTLCRouting_Forward_get_blinded(int64_t ptr) { blinded_ref = tag_ptr(blinded_var.inner, false); return blinded_ref; } +int64_t CS_LDK_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(int64_t ptr) { + LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); + CHECK(obj->tag == LDKPendingHTLCRouting_Forward); + int64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false); + return incoming_cltv_expiry_ref; +} int64_t CS_LDK_LDKPendingHTLCRouting_Receive_get_payment_data(int64_t ptr) { LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); CHECK(obj->tag == LDKPendingHTLCRouting_Receive); @@ -44628,7 +44634,7 @@ int64_t CS_LDK_PendingHTLCRouting_clone(int64_t orig) { return ret_ref; } -int64_t CS_LDK_PendingHTLCRouting_forward(int64_t onion_packet, int64_t short_channel_id, int64_t blinded) { +int64_t CS_LDK_PendingHTLCRouting_forward(int64_t onion_packet, int64_t short_channel_id, int64_t blinded, int64_t incoming_cltv_expiry) { LDKOnionPacket onion_packet_conv; onion_packet_conv.inner = untag_ptr(onion_packet); onion_packet_conv.is_owned = ptr_is_owned(onion_packet); @@ -44639,8 +44645,12 @@ int64_t CS_LDK_PendingHTLCRouting_forward(int64_t onion_packet, int64_t short_c blinded_conv.is_owned = ptr_is_owned(blinded); CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv); blinded_conv = BlindedForward_clone(&blinded_conv); + void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry); + CHECK_ACCESS(incoming_cltv_expiry_ptr); + LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr); + incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry)); LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting"); - *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv); + *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv); int64_t ret_ref = tag_ptr(ret_copy, true); return ret_ref; } @@ -45856,6 +45866,33 @@ void CS_LDK_ChannelManager_force_close_all_channels_without_broadcasting_txn(in ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv); } +int64_t CS_LDK_ChannelManager_send_payment_with_route(int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = untag_ptr(this_arg); + this_arg_conv.is_owned = ptr_is_owned(this_arg); + CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = untag_ptr(route); + route_conv.is_owned = ptr_is_owned(route); + CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv); + route_conv = Route_clone(&route_conv); + LDKThirtyTwoBytes payment_hash_ref; + CHECK(payment_hash->arr_len == 32); + memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash); + LDKRecipientOnionFields recipient_onion_conv; + recipient_onion_conv.inner = untag_ptr(recipient_onion); + recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion); + CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv); + recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv); + LDKThirtyTwoBytes payment_id_ref; + CHECK(payment_id->arr_len == 32); + memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id); + LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ"); + *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref); + return tag_ptr(ret_conv, true); +} + int64_t CS_LDK_ChannelManager_send_payment(int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) { LDKChannelManager this_arg_conv; this_arg_conv.inner = untag_ptr(this_arg); @@ -77336,6 +77373,15 @@ int64_t CS_LDK_SpendableOutputDescriptor_create_spendable_outputs_psbt(int64_tA return tag_ptr(ret_conv, true); } +int64_t CS_LDK_SpendableOutputDescriptor_spendable_outpoint(int64_t this_arg) { + LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg); + LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv); + int64_t ret_ref = 0; + CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var); + ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned); + return ret_ref; +} + void CS_LDK_ChannelDerivationParameters_free(int64_t this_obj) { LDKChannelDerivationParameters this_obj_conv; this_obj_conv.inner = untag_ptr(this_obj); diff --git a/c_sharp/src/org/ldk/impl/bindings.cs b/c_sharp/src/org/ldk/impl/bindings.cs index 7c4b9d5c..ada70a0e 100644 --- a/c_sharp/src/org/ldk/impl/bindings.cs +++ b/c_sharp/src/org/ldk/impl/bindings.cs @@ -978,6 +978,7 @@ public static long[] LDKUtxoLookup_new(LDKUtxoLookup impl) { [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Forward_get_onion_packet")] public static extern long LDKPendingHTLCRouting_Forward_get_onion_packet(long ptr); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Forward_get_short_channel_id")] public static extern long LDKPendingHTLCRouting_Forward_get_short_channel_id(long ptr); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Forward_get_blinded")] public static extern long LDKPendingHTLCRouting_Forward_get_blinded(long ptr); + [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry")] public static extern long LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(long ptr); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Receive_get_payment_data")] public static extern long LDKPendingHTLCRouting_Receive_get_payment_data(long ptr); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Receive_get_payment_metadata")] public static extern long LDKPendingHTLCRouting_Receive_get_payment_metadata(long ptr); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_LDKPendingHTLCRouting_Receive_get_payment_context")] public static extern long LDKPendingHTLCRouting_Receive_get_payment_context(long ptr); @@ -8241,8 +8242,8 @@ public static long[] LDKWalletSource_new(LDKWalletSource impl) { [DllImport ("ldkcsharp", EntryPoint="CS_LDK_PendingHTLCRouting_clone_ptr")] public static extern long PendingHTLCRouting_clone_ptr(long _arg); // struct LDKPendingHTLCRouting PendingHTLCRouting_clone(const struct LDKPendingHTLCRouting *NONNULL_PTR orig); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_PendingHTLCRouting_clone")] public static extern long PendingHTLCRouting_clone(long _orig); - // struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded); - [DllImport ("ldkcsharp", EntryPoint="CS_LDK_PendingHTLCRouting_forward")] public static extern long PendingHTLCRouting_forward(long _onion_packet, long _short_channel_id, long _blinded); + // struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded, struct LDKCOption_u32Z incoming_cltv_expiry); + [DllImport ("ldkcsharp", EntryPoint="CS_LDK_PendingHTLCRouting_forward")] public static extern long PendingHTLCRouting_forward(long _onion_packet, long _short_channel_id, long _blinded, long _incoming_cltv_expiry); // struct LDKPendingHTLCRouting PendingHTLCRouting_receive(struct LDKFinalOnionHopData payment_data, struct LDKCOption_CVec_u8ZZ payment_metadata, struct LDKCOption_PaymentContextZ payment_context, uint32_t incoming_cltv_expiry, struct LDKThirtyTwoBytes phantom_shared_secret, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_PendingHTLCRouting_receive")] public static extern long PendingHTLCRouting_receive(long _payment_data, long _payment_metadata, long _payment_context, int _incoming_cltv_expiry, long _phantom_shared_secret, long _custom_tlvs, bool _requires_blinded_error); // struct LDKPendingHTLCRouting PendingHTLCRouting_receive_keysend(struct LDKFinalOnionHopData payment_data, struct LDKThirtyTwoBytes payment_preimage, struct LDKCOption_CVec_u8ZZ payment_metadata, uint32_t incoming_cltv_expiry, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error, bool has_recipient_created_payment_secret); @@ -8413,6 +8414,8 @@ public static long[] LDKWalletSource_new(LDKWalletSource impl) { [DllImport ("ldkcsharp", EntryPoint="CS_LDK_ChannelManager_force_close_all_channels_broadcasting_latest_txn")] public static extern void ChannelManager_force_close_all_channels_broadcasting_latest_txn(long _this_arg, long _error_message); // void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_ChannelManager_force_close_all_channels_without_broadcasting_txn")] public static extern void ChannelManager_force_close_all_channels_without_broadcasting_txn(long _this_arg, long _error_message); + // MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRoute route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); + [DllImport ("ldkcsharp", EntryPoint="CS_LDK_ChannelManager_send_payment_with_route")] public static extern long ChannelManager_send_payment_with_route(long _this_arg, long _route, long _payment_hash, long _recipient_onion, long _payment_id); // MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_ChannelManager_send_payment")] public static extern long ChannelManager_send_payment(long _this_arg, long _payment_hash, long _recipient_onion, long _payment_id, long _route_params, long _retry_strategy); // MUST_USE_RES struct LDKCResult_NoneBolt12PaymentErrorZ ChannelManager_send_payment_for_bolt12_invoice(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKBolt12Invoice *NONNULL_PTR invoice, struct LDKCOption_OffersContextZ context); @@ -13423,6 +13426,8 @@ public static long[] LDKWalletSource_new(LDKWalletSource impl) { [DllImport ("ldkcsharp", EntryPoint="CS_LDK_SpendableOutputDescriptor_read")] public static extern long SpendableOutputDescriptor_read(long _ser); // MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_SpendableOutputDescriptor_create_spendable_outputs_psbt")] public static extern long SpendableOutputDescriptor_create_spendable_outputs_psbt(long _descriptors, long _outputs, long _change_destination_script, int _feerate_sat_per_1000_weight, long _locktime); + // MUST_USE_RES struct LDKOutPoint SpendableOutputDescriptor_spendable_outpoint(const struct LDKSpendableOutputDescriptor *NONNULL_PTR this_arg); + [DllImport ("ldkcsharp", EntryPoint="CS_LDK_SpendableOutputDescriptor_spendable_outpoint")] public static extern long SpendableOutputDescriptor_spendable_outpoint(long _this_arg); // void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); [DllImport ("ldkcsharp", EntryPoint="CS_LDK_ChannelDerivationParameters_free")] public static extern void ChannelDerivationParameters_free(long _this_obj); // uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); diff --git a/c_sharp/src/org/ldk/structs/ChannelManager.cs b/c_sharp/src/org/ldk/structs/ChannelManager.cs index fbb39b82..d55aaaf6 100644 --- a/c_sharp/src/org/ldk/structs/ChannelManager.cs +++ b/c_sharp/src/org/ldk/structs/ChannelManager.cs @@ -1115,6 +1115,24 @@ public void force_close_all_channels_without_broadcasting_txn(string error_messa GC.KeepAlive(error_message); } + /** + * Sends a payment along a given route. See [`Self::send_payment`] for more info. + * + * LDK will not automatically retry this payment, though it may be manually re-sent after an + * [`Event::PaymentFailed`] is generated. + */ + public Result_NoneRetryableSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) { + long ret = bindings.ChannelManager_send_payment_with_route(this.ptr, route.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), recipient_onion.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32))); + GC.KeepAlive(this); + GC.KeepAlive(route); + GC.KeepAlive(payment_hash); + GC.KeepAlive(recipient_onion); + GC.KeepAlive(payment_id); + if (ret >= 0 && ret <= 4096) { return null; } + Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Sends a payment to the route found using the provided [`RouteParameters`], retrying failed * payment paths based on the provided `Retry`. @@ -1142,7 +1160,8 @@ public void force_close_all_channels_without_broadcasting_txn(string error_messa * [`ChannelManager::list_recent_payments`] for more information. * * Routes are automatically found using the [`Router] provided on startup. To fix a route for a - * particular payment, match the [`PaymentId`] passed to [`Router::find_route_with_id`]. + * particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to + * [`Router::find_route_with_id`]. * * [`Event::PaymentSent`]: events::Event::PaymentSent * [`Event::PaymentFailed`]: events::Event::PaymentFailed diff --git a/c_sharp/src/org/ldk/structs/ChannelMonitor.cs b/c_sharp/src/org/ldk/structs/ChannelMonitor.cs index 7146f6ee..965bbec0 100644 --- a/c_sharp/src/org/ldk/structs/ChannelMonitor.cs +++ b/c_sharp/src/org/ldk/structs/ChannelMonitor.cs @@ -593,10 +593,11 @@ public SpendableOutputDescriptor[] get_spendable_outputs(byte[] tx, int confirma * * This function returns a tuple of two booleans, the first indicating whether the monitor is * fully resolved, and the second whether the monitor needs persistence to ensure it is - * reliably marked as resolved within 4032 blocks. + * reliably marked as resolved within [`ARCHIVAL_DELAY_BLOCKS`] blocks. * - * The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at least - * 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. + * The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at + * least [`ARCHIVAL_DELAY_BLOCKS`] blocks as an additional protection against any bugs + * resulting in spuriously empty balance sets. */ public TwoTuple_boolboolZ check_and_update_full_resolution_status(org.ldk.structs.Logger logger) { long ret = bindings.ChannelMonitor_check_and_update_full_resolution_status(this.ptr, logger.ptr); diff --git a/c_sharp/src/org/ldk/structs/PendingHTLCRouting.cs b/c_sharp/src/org/ldk/structs/PendingHTLCRouting.cs index 1efc3b37..76db7001 100644 --- a/c_sharp/src/org/ldk/structs/PendingHTLCRouting.cs +++ b/c_sharp/src/org/ldk/structs/PendingHTLCRouting.cs @@ -46,6 +46,10 @@ public class PendingHTLCRouting_Forward : PendingHTLCRouting { * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ public BlindedForward blinded; + /** + * The absolute CLTV of the inbound HTLC + */ + public Option_u32Z incoming_cltv_expiry; internal PendingHTLCRouting_Forward(long ptr) : base(null, ptr) { long onion_packet = bindings.LDKPendingHTLCRouting_Forward_get_onion_packet(ptr); org.ldk.structs.OnionPacket onion_packet_hu_conv = null; if (onion_packet < 0 || onion_packet > 4096) { onion_packet_hu_conv = new org.ldk.structs.OnionPacket(null, onion_packet); } @@ -56,6 +60,10 @@ internal PendingHTLCRouting_Forward(long ptr) : base(null, ptr) { org.ldk.structs.BlindedForward blinded_hu_conv = null; if (blinded < 0 || blinded > 4096) { blinded_hu_conv = new org.ldk.structs.BlindedForward(null, blinded); } if (blinded_hu_conv != null) { blinded_hu_conv.ptrs_to.AddLast(this); }; this.blinded = blinded_hu_conv; + long incoming_cltv_expiry = bindings.LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(ptr); + org.ldk.structs.Option_u32Z incoming_cltv_expiry_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(incoming_cltv_expiry); + if (incoming_cltv_expiry_hu_conv != null) { incoming_cltv_expiry_hu_conv.ptrs_to.AddLast(this); }; + this.incoming_cltv_expiry = incoming_cltv_expiry_hu_conv; } } /** A PendingHTLCRouting of type Receive */ @@ -234,11 +242,12 @@ public PendingHTLCRouting clone() { /** * Utility method to constructs a new Forward-variant PendingHTLCRouting */ - public static PendingHTLCRouting forward(org.ldk.structs.OnionPacket onion_packet, long short_channel_id, org.ldk.structs.BlindedForward blinded) { - long ret = bindings.PendingHTLCRouting_forward(onion_packet.ptr, short_channel_id, blinded.ptr); + public static PendingHTLCRouting forward(org.ldk.structs.OnionPacket onion_packet, long short_channel_id, org.ldk.structs.BlindedForward blinded, org.ldk.structs.Option_u32Z incoming_cltv_expiry) { + long ret = bindings.PendingHTLCRouting_forward(onion_packet.ptr, short_channel_id, blinded.ptr, incoming_cltv_expiry.ptr); GC.KeepAlive(onion_packet); GC.KeepAlive(short_channel_id); GC.KeepAlive(blinded); + GC.KeepAlive(incoming_cltv_expiry); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; diff --git a/c_sharp/src/org/ldk/structs/SpendableOutputDescriptor.cs b/c_sharp/src/org/ldk/structs/SpendableOutputDescriptor.cs index 689b2447..ab72d1ff 100644 --- a/c_sharp/src/org/ldk/structs/SpendableOutputDescriptor.cs +++ b/c_sharp/src/org/ldk/structs/SpendableOutputDescriptor.cs @@ -194,5 +194,17 @@ public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) { return ret_hu_conv; } + /** + * Returns the outpoint of the spendable output. + */ + public OutPoint spendable_outpoint() { + long ret = bindings.SpendableOutputDescriptor_spendable_outpoint(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; + } + } } } } diff --git a/src/main/java/org/ldk/batteries/NioPeerHandler.java b/src/main/java/org/ldk/batteries/NioPeerHandler.java index 514d4b70..5ca15843 100644 --- a/src/main/java/org/ldk/batteries/NioPeerHandler.java +++ b/src/main/java/org/ldk/batteries/NioPeerHandler.java @@ -255,6 +255,10 @@ public NioPeerHandler(PeerManager manager) throws IOException { * @throws IOException If connecting to the remote endpoint fails or internal java.nio errors occur. */ public void connect(byte[] their_node_id, java.net.SocketAddress remote, int timeout_ms) throws IOException { + if (this.peer_manager.peer_by_node_id(their_node_id) != null) { + // The peer is already connected, no need to try to reconnect. + return; + } SocketChannel chan = SocketChannel.open(); boolean connected; try { diff --git a/src/main/java/org/ldk/impl/bindings.java b/src/main/java/org/ldk/impl/bindings.java index 43060154..0ce6ef77 100644 --- a/src/main/java/org/ldk/impl/bindings.java +++ b/src/main/java/org/ldk/impl/bindings.java @@ -1814,7 +1814,8 @@ public final static class Forward extends LDKPendingHTLCRouting { public long onion_packet; public long short_channel_id; public long blinded; - Forward(long onion_packet, long short_channel_id, long blinded) { this.onion_packet = onion_packet; this.short_channel_id = short_channel_id; this.blinded = blinded; } + public long incoming_cltv_expiry; + Forward(long onion_packet, long short_channel_id, long blinded, long incoming_cltv_expiry) { this.onion_packet = onion_packet; this.short_channel_id = short_channel_id; this.blinded = blinded; this.incoming_cltv_expiry = incoming_cltv_expiry; } } public final static class Receive extends LDKPendingHTLCRouting { public long payment_data; @@ -9147,8 +9148,8 @@ public final static class ScriptHash extends LDKFallback { public static native long PendingHTLCRouting_clone_ptr(long arg); // struct LDKPendingHTLCRouting PendingHTLCRouting_clone(const struct LDKPendingHTLCRouting *NONNULL_PTR orig); public static native long PendingHTLCRouting_clone(long orig); - // struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded); - public static native long PendingHTLCRouting_forward(long onion_packet, long short_channel_id, long blinded); + // struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded, struct LDKCOption_u32Z incoming_cltv_expiry); + public static native long PendingHTLCRouting_forward(long onion_packet, long short_channel_id, long blinded, long incoming_cltv_expiry); // struct LDKPendingHTLCRouting PendingHTLCRouting_receive(struct LDKFinalOnionHopData payment_data, struct LDKCOption_CVec_u8ZZ payment_metadata, struct LDKCOption_PaymentContextZ payment_context, uint32_t incoming_cltv_expiry, struct LDKThirtyTwoBytes phantom_shared_secret, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error); public static native long PendingHTLCRouting_receive(long payment_data, long payment_metadata, long payment_context, int incoming_cltv_expiry, byte[] phantom_shared_secret, long[] custom_tlvs, boolean requires_blinded_error); // struct LDKPendingHTLCRouting PendingHTLCRouting_receive_keysend(struct LDKFinalOnionHopData payment_data, struct LDKThirtyTwoBytes payment_preimage, struct LDKCOption_CVec_u8ZZ payment_metadata, uint32_t incoming_cltv_expiry, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error, bool has_recipient_created_payment_secret); @@ -9319,6 +9320,8 @@ public final static class ScriptHash extends LDKFallback { public static native void ChannelManager_force_close_all_channels_broadcasting_latest_txn(long this_arg, String error_message); // void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message); public static native void ChannelManager_force_close_all_channels_without_broadcasting_txn(long this_arg, String error_message); + // MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRoute route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); + public static native long ChannelManager_send_payment_with_route(long this_arg, long route, byte[] payment_hash, long recipient_onion, byte[] payment_id); // MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); public static native long ChannelManager_send_payment(long this_arg, byte[] payment_hash, long recipient_onion, byte[] payment_id, long route_params, long retry_strategy); // MUST_USE_RES struct LDKCResult_NoneBolt12PaymentErrorZ ChannelManager_send_payment_for_bolt12_invoice(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKBolt12Invoice *NONNULL_PTR invoice, struct LDKCOption_OffersContextZ context); @@ -14329,6 +14332,8 @@ public final static class ScriptHash extends LDKFallback { public static native long SpendableOutputDescriptor_read(byte[] ser); // MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); public static native long SpendableOutputDescriptor_create_spendable_outputs_psbt(long[] descriptors, long[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, long locktime); + // MUST_USE_RES struct LDKOutPoint SpendableOutputDescriptor_spendable_outpoint(const struct LDKSpendableOutputDescriptor *NONNULL_PTR this_arg); + public static native long SpendableOutputDescriptor_spendable_outpoint(long this_arg); // void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); public static native void ChannelDerivationParameters_free(long this_obj); // uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); diff --git a/src/main/java/org/ldk/structs/ChannelManager.java b/src/main/java/org/ldk/structs/ChannelManager.java index c51fad15..0b759613 100644 --- a/src/main/java/org/ldk/structs/ChannelManager.java +++ b/src/main/java/org/ldk/structs/ChannelManager.java @@ -1112,6 +1112,24 @@ public void force_close_all_channels_without_broadcasting_txn(java.lang.String e Reference.reachabilityFence(error_message); } + /** + * Sends a payment along a given route. See [`Self::send_payment`] for more info. + * + * LDK will not automatically retry this payment, though it may be manually re-sent after an + * [`Event::PaymentFailed`] is generated. + */ + public Result_NoneRetryableSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) { + long ret = bindings.ChannelManager_send_payment_with_route(this.ptr, route.ptr, InternalUtils.check_arr_len(payment_hash, 32), recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32)); + Reference.reachabilityFence(this); + Reference.reachabilityFence(route); + Reference.reachabilityFence(payment_hash); + Reference.reachabilityFence(recipient_onion); + Reference.reachabilityFence(payment_id); + if (ret >= 0 && ret <= 4096) { return null; } + Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Sends a payment to the route found using the provided [`RouteParameters`], retrying failed * payment paths based on the provided `Retry`. @@ -1139,7 +1157,8 @@ public void force_close_all_channels_without_broadcasting_txn(java.lang.String e * [`ChannelManager::list_recent_payments`] for more information. * * Routes are automatically found using the [`Router] provided on startup. To fix a route for a - * particular payment, match the [`PaymentId`] passed to [`Router::find_route_with_id`]. + * particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to + * [`Router::find_route_with_id`]. * * [`Event::PaymentSent`]: events::Event::PaymentSent * [`Event::PaymentFailed`]: events::Event::PaymentFailed diff --git a/src/main/java/org/ldk/structs/ChannelMonitor.java b/src/main/java/org/ldk/structs/ChannelMonitor.java index ddc0e7c1..83d53276 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitor.java +++ b/src/main/java/org/ldk/structs/ChannelMonitor.java @@ -580,10 +580,11 @@ public SpendableOutputDescriptor[] get_spendable_outputs(byte[] tx, int confirma * * This function returns a tuple of two booleans, the first indicating whether the monitor is * fully resolved, and the second whether the monitor needs persistence to ensure it is - * reliably marked as resolved within 4032 blocks. + * reliably marked as resolved within [`ARCHIVAL_DELAY_BLOCKS`] blocks. * - * The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at least - * 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. + * The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at + * least [`ARCHIVAL_DELAY_BLOCKS`] blocks as an additional protection against any bugs + * resulting in spuriously empty balance sets. */ public TwoTuple_boolboolZ check_and_update_full_resolution_status(org.ldk.structs.Logger logger) { long ret = bindings.ChannelMonitor_check_and_update_full_resolution_status(this.ptr, logger.ptr); diff --git a/src/main/java/org/ldk/structs/OutputSpendStatus.java b/src/main/java/org/ldk/structs/OutputSpendStatus.java index c5bd8fe1..c83a03e2 100644 --- a/src/main/java/org/ldk/structs/OutputSpendStatus.java +++ b/src/main/java/org/ldk/structs/OutputSpendStatus.java @@ -75,7 +75,11 @@ private PendingFirstConfirmation(long ptr, bindings.LDKOutputSpendStatus.Pending } /** * A transaction spending the output has been confirmed on-chain but will be tracked until it - * reaches [`ANTI_REORG_DELAY`] confirmations. + * reaches at least [`PRUNE_DELAY_BLOCKS`] confirmations to ensure [`Event::SpendableOutputs`] + * stemming from lingering [`ChannelMonitor`]s can safely be replayed. + * + * [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ public final static class PendingThresholdConfirmations extends OutputSpendStatus { /** diff --git a/src/main/java/org/ldk/structs/PendingHTLCRouting.java b/src/main/java/org/ldk/structs/PendingHTLCRouting.java index d3745f54..e3ec64d7 100644 --- a/src/main/java/org/ldk/structs/PendingHTLCRouting.java +++ b/src/main/java/org/ldk/structs/PendingHTLCRouting.java @@ -56,6 +56,10 @@ public final static class Forward extends PendingHTLCRouting { * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ @Nullable public final org.ldk.structs.BlindedForward blinded; + /** + * The absolute CLTV of the inbound HTLC + */ + public final org.ldk.structs.Option_u32Z incoming_cltv_expiry; private Forward(long ptr, bindings.LDKPendingHTLCRouting.Forward obj) { super(null, ptr); long onion_packet = obj.onion_packet; @@ -67,6 +71,10 @@ private Forward(long ptr, bindings.LDKPendingHTLCRouting.Forward obj) { org.ldk.structs.BlindedForward blinded_hu_conv = null; if (blinded < 0 || blinded > 4096) { blinded_hu_conv = new org.ldk.structs.BlindedForward(null, blinded); } if (blinded_hu_conv != null) { blinded_hu_conv.ptrs_to.add(this); }; this.blinded = blinded_hu_conv; + long incoming_cltv_expiry = obj.incoming_cltv_expiry; + org.ldk.structs.Option_u32Z incoming_cltv_expiry_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(incoming_cltv_expiry); + if (incoming_cltv_expiry_hu_conv != null) { incoming_cltv_expiry_hu_conv.ptrs_to.add(this); }; + this.incoming_cltv_expiry = incoming_cltv_expiry_hu_conv; } } /** @@ -250,11 +258,12 @@ public PendingHTLCRouting clone() { /** * Utility method to constructs a new Forward-variant PendingHTLCRouting */ - public static PendingHTLCRouting forward(org.ldk.structs.OnionPacket onion_packet, long short_channel_id, org.ldk.structs.BlindedForward blinded) { - long ret = bindings.PendingHTLCRouting_forward(onion_packet.ptr, short_channel_id, blinded.ptr); + public static PendingHTLCRouting forward(org.ldk.structs.OnionPacket onion_packet, long short_channel_id, org.ldk.structs.BlindedForward blinded, org.ldk.structs.Option_u32Z incoming_cltv_expiry) { + long ret = bindings.PendingHTLCRouting_forward(onion_packet.ptr, short_channel_id, blinded.ptr, incoming_cltv_expiry.ptr); Reference.reachabilityFence(onion_packet); Reference.reachabilityFence(short_channel_id); Reference.reachabilityFence(blinded); + Reference.reachabilityFence(incoming_cltv_expiry); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; diff --git a/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java b/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java index 97aebe4e..4f041567 100644 --- a/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java +++ b/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java @@ -267,4 +267,16 @@ public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) { return ret_hu_conv; } + /** + * Returns the outpoint of the spendable output. + */ + public OutPoint spendable_outpoint() { + long ret = bindings.SpendableOutputDescriptor_spendable_outpoint(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; + } + } diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 38ebe313..4ca63e60 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -9514,7 +9514,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPendingHTLCRouting_ini LDKPendingHTLCRouting_Forward_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPendingHTLCRouting$Forward")); CHECK(LDKPendingHTLCRouting_Forward_class != NULL); - LDKPendingHTLCRouting_Forward_meth = (*env)->GetMethodID(env, LDKPendingHTLCRouting_Forward_class, "", "(JJJ)V"); + LDKPendingHTLCRouting_Forward_meth = (*env)->GetMethodID(env, LDKPendingHTLCRouting_Forward_class, "", "(JJJJ)V"); CHECK(LDKPendingHTLCRouting_Forward_meth != NULL); LDKPendingHTLCRouting_Receive_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPendingHTLCRouting$Receive")); @@ -9540,7 +9540,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPendingHTLCRouting_1ref_ int64_t blinded_ref = 0; CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_var); blinded_ref = tag_ptr(blinded_var.inner, false); - return (*env)->NewObject(env, LDKPendingHTLCRouting_Forward_class, LDKPendingHTLCRouting_Forward_meth, onion_packet_ref, short_channel_id_conv, blinded_ref); + int64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false); + return (*env)->NewObject(env, LDKPendingHTLCRouting_Forward_class, LDKPendingHTLCRouting_Forward_meth, onion_packet_ref, short_channel_id_conv, blinded_ref, incoming_cltv_expiry_ref); } case LDKPendingHTLCRouting_Receive: { LDKFinalOnionHopData payment_data_var = obj->receive.payment_data; @@ -50579,7 +50580,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1clone(J return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward(JNIEnv *env, jclass clz, int64_t onion_packet, int64_t short_channel_id, int64_t blinded) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward(JNIEnv *env, jclass clz, int64_t onion_packet, int64_t short_channel_id, int64_t blinded, int64_t incoming_cltv_expiry) { LDKOnionPacket onion_packet_conv; onion_packet_conv.inner = untag_ptr(onion_packet); onion_packet_conv.is_owned = ptr_is_owned(onion_packet); @@ -50590,8 +50591,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward blinded_conv.is_owned = ptr_is_owned(blinded); CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv); blinded_conv = BlindedForward_clone(&blinded_conv); + void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry); + CHECK_ACCESS(incoming_cltv_expiry_ptr); + LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr); + incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry)); LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting"); - *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv); + *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv); int64_t ret_ref = tag_ptr(ret_copy, true); return ret_ref; } @@ -51807,6 +51812,33 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1 ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment_1with_1route(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = untag_ptr(this_arg); + this_arg_conv.is_owned = ptr_is_owned(this_arg); + CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = untag_ptr(route); + route_conv.is_owned = ptr_is_owned(route); + CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv); + route_conv = Route_clone(&route_conv); + LDKThirtyTwoBytes payment_hash_ref; + CHECK((*env)->GetArrayLength(env, payment_hash) == 32); + (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); + LDKRecipientOnionFields recipient_onion_conv; + recipient_onion_conv.inner = untag_ptr(recipient_onion); + recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion); + CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv); + recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv); + LDKThirtyTwoBytes payment_id_ref; + CHECK((*env)->GetArrayLength(env, payment_id) == 32); + (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data); + LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ"); + *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref); + return tag_ptr(ret_conv, true); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) { LDKChannelManager this_arg_conv; this_arg_conv.inner = untag_ptr(this_arg); @@ -83275,6 +83307,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1 return tag_ptr(ret_conv, true); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1spendable_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg); + LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv); + int64_t ret_ref = 0; + CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var); + ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned); + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDerivationParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelDerivationParameters this_obj_conv; this_obj_conv.inner = untag_ptr(this_obj); diff --git a/src/main/jni/bindings.c.body b/src/main/jni/bindings.c.body index 38275061..87475959 100644 --- a/src/main/jni/bindings.c.body +++ b/src/main/jni/bindings.c.body @@ -9510,7 +9510,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPendingHTLCRouting_ini LDKPendingHTLCRouting_Forward_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPendingHTLCRouting$Forward")); CHECK(LDKPendingHTLCRouting_Forward_class != NULL); - LDKPendingHTLCRouting_Forward_meth = (*env)->GetMethodID(env, LDKPendingHTLCRouting_Forward_class, "", "(JJJ)V"); + LDKPendingHTLCRouting_Forward_meth = (*env)->GetMethodID(env, LDKPendingHTLCRouting_Forward_class, "", "(JJJJ)V"); CHECK(LDKPendingHTLCRouting_Forward_meth != NULL); LDKPendingHTLCRouting_Receive_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPendingHTLCRouting$Receive")); @@ -9536,7 +9536,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPendingHTLCRouting_1ref_ int64_t blinded_ref = 0; CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_var); blinded_ref = tag_ptr(blinded_var.inner, false); - return (*env)->NewObject(env, LDKPendingHTLCRouting_Forward_class, LDKPendingHTLCRouting_Forward_meth, onion_packet_ref, short_channel_id_conv, blinded_ref); + int64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false); + return (*env)->NewObject(env, LDKPendingHTLCRouting_Forward_class, LDKPendingHTLCRouting_Forward_meth, onion_packet_ref, short_channel_id_conv, blinded_ref, incoming_cltv_expiry_ref); } case LDKPendingHTLCRouting_Receive: { LDKFinalOnionHopData payment_data_var = obj->receive.payment_data; @@ -50575,7 +50576,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1clone(J return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward(JNIEnv *env, jclass clz, int64_t onion_packet, int64_t short_channel_id, int64_t blinded) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward(JNIEnv *env, jclass clz, int64_t onion_packet, int64_t short_channel_id, int64_t blinded, int64_t incoming_cltv_expiry) { LDKOnionPacket onion_packet_conv; onion_packet_conv.inner = untag_ptr(onion_packet); onion_packet_conv.is_owned = ptr_is_owned(onion_packet); @@ -50586,8 +50587,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward blinded_conv.is_owned = ptr_is_owned(blinded); CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv); blinded_conv = BlindedForward_clone(&blinded_conv); + void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry); + CHECK_ACCESS(incoming_cltv_expiry_ptr); + LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr); + incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry)); LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting"); - *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv); + *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv); int64_t ret_ref = tag_ptr(ret_copy, true); return ret_ref; } @@ -51803,6 +51808,33 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1 ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment_1with_1route(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = untag_ptr(this_arg); + this_arg_conv.is_owned = ptr_is_owned(this_arg); + CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = untag_ptr(route); + route_conv.is_owned = ptr_is_owned(route); + CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv); + route_conv = Route_clone(&route_conv); + LDKThirtyTwoBytes payment_hash_ref; + CHECK((*env)->GetArrayLength(env, payment_hash) == 32); + (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data); + LDKRecipientOnionFields recipient_onion_conv; + recipient_onion_conv.inner = untag_ptr(recipient_onion); + recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion); + CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv); + recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv); + LDKThirtyTwoBytes payment_id_ref; + CHECK((*env)->GetArrayLength(env, payment_id) == 32); + (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data); + LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ"); + *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref); + return tag_ptr(ret_conv, true); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) { LDKChannelManager this_arg_conv; this_arg_conv.inner = untag_ptr(this_arg); @@ -83271,6 +83303,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1 return tag_ptr(ret_conv, true); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1spendable_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg); + LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv); + int64_t ret_ref = 0; + CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var); + ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned); + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDerivationParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelDerivationParameters this_obj_conv; this_obj_conv.inner = untag_ptr(this_obj); diff --git a/src/main/jni/org_ldk_impl_bindings.h b/src/main/jni/org_ldk_impl_bindings.h index 587d012c..86cff37f 100644 --- a/src/main/jni/org_ldk_impl_bindings.h +++ b/src/main/jni/org_ldk_impl_bindings.h @@ -27634,10 +27634,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1clone /* * Class: org_ldk_impl_bindings * Method: PendingHTLCRouting_forward - * Signature: (JJJ)J + * Signature: (JJJJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1forward - (JNIEnv *, jclass, jlong, jlong, jlong); + (JNIEnv *, jclass, jlong, jlong, jlong, jlong); /* * Class: org_ldk_impl_bindings @@ -28319,6 +28319,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn (JNIEnv *, jclass, jlong, jstring); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelManager_send_payment_with_route + * Signature: (JJ[BJ[B)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment_1with_1route + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jlong, jbyteArray); + /* * Class: org_ldk_impl_bindings * Method: ChannelManager_send_payment @@ -48359,6 +48367,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1re JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1create_1spendable_1outputs_1psbt (JNIEnv *, jclass, jlongArray, jlongArray, jbyteArray, jint, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: SpendableOutputDescriptor_spendable_outpoint + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1spendable_1outpoint + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: ChannelDerivationParameters_free diff --git a/ts/bindings.c b/ts/bindings.c index 54d05d45..a55b04f6 100644 --- a/ts/bindings.c +++ b/ts/bindings.c @@ -6510,6 +6510,12 @@ uint64_t __attribute__((export_name("TS_LDKPendingHTLCRouting_Forward_get_blinde blinded_ref = tag_ptr(blinded_var.inner, false); return blinded_ref; } +uint64_t __attribute__((export_name("TS_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry"))) TS_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(uint64_t ptr) { + LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); + assert(obj->tag == LDKPendingHTLCRouting_Forward); + uint64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false); + return incoming_cltv_expiry_ref; +} uint64_t __attribute__((export_name("TS_LDKPendingHTLCRouting_Receive_get_payment_data"))) TS_LDKPendingHTLCRouting_Receive_get_payment_data(uint64_t ptr) { LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); assert(obj->tag == LDKPendingHTLCRouting_Receive); @@ -44222,7 +44228,7 @@ uint64_t __attribute__((export_name("TS_PendingHTLCRouting_clone"))) TS_Pending return ret_ref; } -uint64_t __attribute__((export_name("TS_PendingHTLCRouting_forward"))) TS_PendingHTLCRouting_forward(uint64_t onion_packet, int64_t short_channel_id, uint64_t blinded) { +uint64_t __attribute__((export_name("TS_PendingHTLCRouting_forward"))) TS_PendingHTLCRouting_forward(uint64_t onion_packet, int64_t short_channel_id, uint64_t blinded, uint64_t incoming_cltv_expiry) { LDKOnionPacket onion_packet_conv; onion_packet_conv.inner = untag_ptr(onion_packet); onion_packet_conv.is_owned = ptr_is_owned(onion_packet); @@ -44233,8 +44239,12 @@ uint64_t __attribute__((export_name("TS_PendingHTLCRouting_forward"))) TS_Pendi blinded_conv.is_owned = ptr_is_owned(blinded); CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv); blinded_conv = BlindedForward_clone(&blinded_conv); + void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry); + CHECK_ACCESS(incoming_cltv_expiry_ptr); + LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr); + incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry)); LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting"); - *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv); + *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv); uint64_t ret_ref = tag_ptr(ret_copy, true); return ret_ref; } @@ -45450,6 +45460,33 @@ void __attribute__((export_name("TS_ChannelManager_force_close_all_channels_wit ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv); } +uint64_t __attribute__((export_name("TS_ChannelManager_send_payment_with_route"))) TS_ChannelManager_send_payment_with_route(uint64_t this_arg, uint64_t route, int8_tArray payment_hash, uint64_t recipient_onion, int8_tArray payment_id) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = untag_ptr(this_arg); + this_arg_conv.is_owned = ptr_is_owned(this_arg); + CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = untag_ptr(route); + route_conv.is_owned = ptr_is_owned(route); + CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv); + route_conv = Route_clone(&route_conv); + LDKThirtyTwoBytes payment_hash_ref; + CHECK(payment_hash->arr_len == 32); + memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash); + LDKRecipientOnionFields recipient_onion_conv; + recipient_onion_conv.inner = untag_ptr(recipient_onion); + recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion); + CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv); + recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv); + LDKThirtyTwoBytes payment_id_ref; + CHECK(payment_id->arr_len == 32); + memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id); + LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ"); + *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref); + return tag_ptr(ret_conv, true); +} + uint64_t __attribute__((export_name("TS_ChannelManager_send_payment"))) TS_ChannelManager_send_payment(uint64_t this_arg, int8_tArray payment_hash, uint64_t recipient_onion, int8_tArray payment_id, uint64_t route_params, uint64_t retry_strategy) { LDKChannelManager this_arg_conv; this_arg_conv.inner = untag_ptr(this_arg); @@ -76774,6 +76811,15 @@ uint64_t __attribute__((export_name("TS_SpendableOutputDescriptor_create_spenda return tag_ptr(ret_conv, true); } +uint64_t __attribute__((export_name("TS_SpendableOutputDescriptor_spendable_outpoint"))) TS_SpendableOutputDescriptor_spendable_outpoint(uint64_t this_arg) { + LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg); + LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv); + uint64_t ret_ref = 0; + CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var); + ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned); + return ret_ref; +} + void __attribute__((export_name("TS_ChannelDerivationParameters_free"))) TS_ChannelDerivationParameters_free(uint64_t this_obj) { LDKChannelDerivationParameters this_obj_conv; this_obj_conv.inner = untag_ptr(this_obj); diff --git a/ts/bindings.c.body b/ts/bindings.c.body index 6f92f4ac..ecb287ed 100644 --- a/ts/bindings.c.body +++ b/ts/bindings.c.body @@ -6508,6 +6508,12 @@ uint64_t __attribute__((export_name("TS_LDKPendingHTLCRouting_Forward_get_blinde blinded_ref = tag_ptr(blinded_var.inner, false); return blinded_ref; } +uint64_t __attribute__((export_name("TS_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry"))) TS_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(uint64_t ptr) { + LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); + assert(obj->tag == LDKPendingHTLCRouting_Forward); + uint64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false); + return incoming_cltv_expiry_ref; +} uint64_t __attribute__((export_name("TS_LDKPendingHTLCRouting_Receive_get_payment_data"))) TS_LDKPendingHTLCRouting_Receive_get_payment_data(uint64_t ptr) { LDKPendingHTLCRouting *obj = (LDKPendingHTLCRouting*)untag_ptr(ptr); assert(obj->tag == LDKPendingHTLCRouting_Receive); @@ -44220,7 +44226,7 @@ uint64_t __attribute__((export_name("TS_PendingHTLCRouting_clone"))) TS_Pending return ret_ref; } -uint64_t __attribute__((export_name("TS_PendingHTLCRouting_forward"))) TS_PendingHTLCRouting_forward(uint64_t onion_packet, int64_t short_channel_id, uint64_t blinded) { +uint64_t __attribute__((export_name("TS_PendingHTLCRouting_forward"))) TS_PendingHTLCRouting_forward(uint64_t onion_packet, int64_t short_channel_id, uint64_t blinded, uint64_t incoming_cltv_expiry) { LDKOnionPacket onion_packet_conv; onion_packet_conv.inner = untag_ptr(onion_packet); onion_packet_conv.is_owned = ptr_is_owned(onion_packet); @@ -44231,8 +44237,12 @@ uint64_t __attribute__((export_name("TS_PendingHTLCRouting_forward"))) TS_Pendi blinded_conv.is_owned = ptr_is_owned(blinded); CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv); blinded_conv = BlindedForward_clone(&blinded_conv); + void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry); + CHECK_ACCESS(incoming_cltv_expiry_ptr); + LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr); + incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry)); LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting"); - *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv); + *ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv); uint64_t ret_ref = tag_ptr(ret_copy, true); return ret_ref; } @@ -45448,6 +45458,33 @@ void __attribute__((export_name("TS_ChannelManager_force_close_all_channels_wit ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv); } +uint64_t __attribute__((export_name("TS_ChannelManager_send_payment_with_route"))) TS_ChannelManager_send_payment_with_route(uint64_t this_arg, uint64_t route, int8_tArray payment_hash, uint64_t recipient_onion, int8_tArray payment_id) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = untag_ptr(this_arg); + this_arg_conv.is_owned = ptr_is_owned(this_arg); + CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = untag_ptr(route); + route_conv.is_owned = ptr_is_owned(route); + CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv); + route_conv = Route_clone(&route_conv); + LDKThirtyTwoBytes payment_hash_ref; + CHECK(payment_hash->arr_len == 32); + memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash); + LDKRecipientOnionFields recipient_onion_conv; + recipient_onion_conv.inner = untag_ptr(recipient_onion); + recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion); + CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv); + recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv); + LDKThirtyTwoBytes payment_id_ref; + CHECK(payment_id->arr_len == 32); + memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id); + LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ"); + *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref); + return tag_ptr(ret_conv, true); +} + uint64_t __attribute__((export_name("TS_ChannelManager_send_payment"))) TS_ChannelManager_send_payment(uint64_t this_arg, int8_tArray payment_hash, uint64_t recipient_onion, int8_tArray payment_id, uint64_t route_params, uint64_t retry_strategy) { LDKChannelManager this_arg_conv; this_arg_conv.inner = untag_ptr(this_arg); @@ -76772,6 +76809,15 @@ uint64_t __attribute__((export_name("TS_SpendableOutputDescriptor_create_spenda return tag_ptr(ret_conv, true); } +uint64_t __attribute__((export_name("TS_SpendableOutputDescriptor_spendable_outpoint"))) TS_SpendableOutputDescriptor_spendable_outpoint(uint64_t this_arg) { + LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg); + LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv); + uint64_t ret_ref = 0; + CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var); + ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned); + return ret_ref; +} + void __attribute__((export_name("TS_ChannelDerivationParameters_free"))) TS_ChannelDerivationParameters_free(uint64_t this_obj) { LDKChannelDerivationParameters this_obj_conv; this_obj_conv.inner = untag_ptr(this_obj); diff --git a/ts/bindings.mts b/ts/bindings.mts index ff7492cb..1178e359 100644 --- a/ts/bindings.mts +++ b/ts/bindings.mts @@ -5921,6 +5921,14 @@ export function LDKPendingHTLCRouting_Forward_get_blinded(ptr: bigint): bigint { return nativeResponseValue; } /* @internal */ +export function LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(ptr: bigint): bigint { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TS_LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(ptr); + return nativeResponseValue; +} +/* @internal */ export function LDKPendingHTLCRouting_Receive_get_payment_data(ptr: bigint): bigint { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -36676,13 +36684,13 @@ export function PendingHTLCRouting_clone(orig: bigint): bigint { const nativeResponseValue = wasm.TS_PendingHTLCRouting_clone(orig); return nativeResponseValue; } - // struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded); + // struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded, struct LDKCOption_u32Z incoming_cltv_expiry); /* @internal */ -export function PendingHTLCRouting_forward(onion_packet: bigint, short_channel_id: bigint, blinded: bigint): bigint { +export function PendingHTLCRouting_forward(onion_packet: bigint, short_channel_id: bigint, blinded: bigint, incoming_cltv_expiry: bigint): bigint { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.TS_PendingHTLCRouting_forward(onion_packet, short_channel_id, blinded); + const nativeResponseValue = wasm.TS_PendingHTLCRouting_forward(onion_packet, short_channel_id, blinded, incoming_cltv_expiry); return nativeResponseValue; } // struct LDKPendingHTLCRouting PendingHTLCRouting_receive(struct LDKFinalOnionHopData payment_data, struct LDKCOption_CVec_u8ZZ payment_metadata, struct LDKCOption_PaymentContextZ payment_context, uint32_t incoming_cltv_expiry, struct LDKThirtyTwoBytes phantom_shared_secret, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error); @@ -37449,6 +37457,15 @@ export function ChannelManager_force_close_all_channels_without_broadcasting_txn } const nativeResponseValue = wasm.TS_ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg, error_message); // debug statements here +} + // MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRoute route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); +/* @internal */ +export function ChannelManager_send_payment_with_route(this_arg: bigint, route: bigint, payment_hash: number, recipient_onion: bigint, payment_id: number): bigint { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TS_ChannelManager_send_payment_with_route(this_arg, route, payment_hash, recipient_onion, payment_id); + return nativeResponseValue; } // MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); /* @internal */ @@ -59904,6 +59921,15 @@ export function SpendableOutputDescriptor_create_spendable_outputs_psbt(descript } const nativeResponseValue = wasm.TS_SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors, outputs, change_destination_script, feerate_sat_per_1000_weight, locktime); return nativeResponseValue; +} + // MUST_USE_RES struct LDKOutPoint SpendableOutputDescriptor_spendable_outpoint(const struct LDKSpendableOutputDescriptor *NONNULL_PTR this_arg); +/* @internal */ +export function SpendableOutputDescriptor_spendable_outpoint(this_arg: bigint): bigint { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.TS_SpendableOutputDescriptor_spendable_outpoint(this_arg); + return nativeResponseValue; } // void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); /* @internal */ diff --git a/ts/structs/ChannelManager.mts b/ts/structs/ChannelManager.mts index 98223931..f270775f 100644 --- a/ts/structs/ChannelManager.mts +++ b/ts/structs/ChannelManager.mts @@ -1793,6 +1793,18 @@ export class ChannelManager extends CommonBase { bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr, bindings.encodeString(error_message)); } + /** + * Sends a payment along a given route. See [`Self::send_payment`] for more info. + * + * LDK will not automatically retry this payment, though it may be manually re-sent after an + * [`Event::PaymentFailed`] is generated. + */ + public send_payment_with_route(route: Route, payment_hash: Uint8Array, recipient_onion: RecipientOnionFields, payment_id: Uint8Array): Result_NoneRetryableSendFailureZ { + const ret: bigint = bindings.ChannelManager_send_payment_with_route(this.ptr, CommonBase.get_ptr_of(route), bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), CommonBase.get_ptr_of(recipient_onion), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32))); + const ret_hu_conv: Result_NoneRetryableSendFailureZ = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Sends a payment to the route found using the provided [`RouteParameters`], retrying failed * payment paths based on the provided `Retry`. @@ -1820,7 +1832,8 @@ export class ChannelManager extends CommonBase { * [`ChannelManager::list_recent_payments`] for more information. * * Routes are automatically found using the [`Router] provided on startup. To fix a route for a - * particular payment, match the [`PaymentId`] passed to [`Router::find_route_with_id`]. + * particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to + * [`Router::find_route_with_id`]. * * [`Event::PaymentSent`]: events::Event::PaymentSent * [`Event::PaymentFailed`]: events::Event::PaymentFailed diff --git a/ts/structs/ChannelMonitor.mts b/ts/structs/ChannelMonitor.mts index e813e202..945e4d96 100644 --- a/ts/structs/ChannelMonitor.mts +++ b/ts/structs/ChannelMonitor.mts @@ -1232,10 +1232,11 @@ export class ChannelMonitor extends CommonBase { * * This function returns a tuple of two booleans, the first indicating whether the monitor is * fully resolved, and the second whether the monitor needs persistence to ensure it is - * reliably marked as resolved within 4032 blocks. + * reliably marked as resolved within [`ARCHIVAL_DELAY_BLOCKS`] blocks. * - * The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at least - * 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. + * The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at + * least [`ARCHIVAL_DELAY_BLOCKS`] blocks as an additional protection against any bugs + * resulting in spuriously empty balance sets. */ public check_and_update_full_resolution_status(logger: Logger): TwoTuple_boolboolZ { const ret: bigint = bindings.ChannelMonitor_check_and_update_full_resolution_status(this.ptr, CommonBase.get_ptr_of(logger)); diff --git a/ts/structs/PendingHTLCRouting.mts b/ts/structs/PendingHTLCRouting.mts index 5e2b5e8c..aed93be7 100644 --- a/ts/structs/PendingHTLCRouting.mts +++ b/ts/structs/PendingHTLCRouting.mts @@ -774,8 +774,8 @@ export class PendingHTLCRouting extends CommonBase { /** * Utility method to constructs a new Forward-variant PendingHTLCRouting */ - public static constructor_forward(onion_packet: OnionPacket, short_channel_id: bigint, blinded: BlindedForward): PendingHTLCRouting { - const ret: bigint = bindings.PendingHTLCRouting_forward(CommonBase.get_ptr_of(onion_packet), short_channel_id, CommonBase.get_ptr_of(blinded)); + public static constructor_forward(onion_packet: OnionPacket, short_channel_id: bigint, blinded: BlindedForward, incoming_cltv_expiry: Option_u32Z): PendingHTLCRouting { + const ret: bigint = bindings.PendingHTLCRouting_forward(CommonBase.get_ptr_of(onion_packet), short_channel_id, CommonBase.get_ptr_of(blinded), CommonBase.get_ptr_of(incoming_cltv_expiry)); const ret_hu_conv: PendingHTLCRouting = PendingHTLCRouting.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; @@ -841,6 +841,10 @@ export class PendingHTLCRouting_Forward extends PendingHTLCRouting { * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ public blinded: BlindedForward; + /** + * The absolute CLTV of the inbound HTLC + */ + public incoming_cltv_expiry: Option_u32Z; /* @internal */ public constructor(ptr: bigint) { super(null, ptr); @@ -853,6 +857,10 @@ export class PendingHTLCRouting_Forward extends PendingHTLCRouting { const blinded_hu_conv: BlindedForward = new BlindedForward(null, blinded); CommonBase.add_ref_from(blinded_hu_conv, this); this.blinded = blinded_hu_conv; + const incoming_cltv_expiry: bigint = bindings.LDKPendingHTLCRouting_Forward_get_incoming_cltv_expiry(ptr); + const incoming_cltv_expiry_hu_conv: Option_u32Z = Option_u32Z.constr_from_ptr(incoming_cltv_expiry); + CommonBase.add_ref_from(incoming_cltv_expiry_hu_conv, this); + this.incoming_cltv_expiry = incoming_cltv_expiry_hu_conv; } } /** A PendingHTLCRouting of type Receive */ diff --git a/ts/structs/SpendableOutputDescriptor.mts b/ts/structs/SpendableOutputDescriptor.mts index 433fd085..3d4bf860 100644 --- a/ts/structs/SpendableOutputDescriptor.mts +++ b/ts/structs/SpendableOutputDescriptor.mts @@ -844,6 +844,16 @@ export class SpendableOutputDescriptor extends CommonBase { return ret_hu_conv; } + /** + * Returns the outpoint of the spendable output. + */ + public spendable_outpoint(): OutPoint { + const ret: bigint = bindings.SpendableOutputDescriptor_spendable_outpoint(this.ptr); + const ret_hu_conv: OutPoint = new OutPoint(null, ret); + CommonBase.add_ref_from(ret_hu_conv, this); + return ret_hu_conv; + } + } /** A SpendableOutputDescriptor of type StaticOutput */ export class SpendableOutputDescriptor_StaticOutput extends SpendableOutputDescriptor {