Skip to content

Commit d950b8f

Browse files
committed
[Java] Update auto-generated bindings to LDK 0.1.1
1 parent d071d95 commit d950b8f

9 files changed

+168
-20
lines changed

src/main/java/org/ldk/impl/bindings.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,8 @@ public final static class Forward extends LDKPendingHTLCRouting {
18141814
public long onion_packet;
18151815
public long short_channel_id;
18161816
public long blinded;
1817-
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; }
1817+
public long incoming_cltv_expiry;
1818+
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; }
18181819
}
18191820
public final static class Receive extends LDKPendingHTLCRouting {
18201821
public long payment_data;
@@ -9147,8 +9148,8 @@ public final static class ScriptHash extends LDKFallback {
91479148
public static native long PendingHTLCRouting_clone_ptr(long arg);
91489149
// struct LDKPendingHTLCRouting PendingHTLCRouting_clone(const struct LDKPendingHTLCRouting *NONNULL_PTR orig);
91499150
public static native long PendingHTLCRouting_clone(long orig);
9150-
// struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded);
9151-
public static native long PendingHTLCRouting_forward(long onion_packet, long short_channel_id, long blinded);
9151+
// struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket onion_packet, uint64_t short_channel_id, struct LDKBlindedForward blinded, struct LDKCOption_u32Z incoming_cltv_expiry);
9152+
public static native long PendingHTLCRouting_forward(long onion_packet, long short_channel_id, long blinded, long incoming_cltv_expiry);
91529153
// 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);
91539154
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);
91549155
// 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 {
93199320
public static native void ChannelManager_force_close_all_channels_broadcasting_latest_txn(long this_arg, String error_message);
93209321
// void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message);
93219322
public static native void ChannelManager_force_close_all_channels_without_broadcasting_txn(long this_arg, String error_message);
9323+
// 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);
9324+
public static native long ChannelManager_send_payment_with_route(long this_arg, long route, byte[] payment_hash, long recipient_onion, byte[] payment_id);
93229325
// 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);
93239326
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);
93249327
// 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 {
1432914332
public static native long SpendableOutputDescriptor_read(byte[] ser);
1433014333
// 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);
1433114334
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);
14335+
// MUST_USE_RES struct LDKOutPoint SpendableOutputDescriptor_spendable_outpoint(const struct LDKSpendableOutputDescriptor *NONNULL_PTR this_arg);
14336+
public static native long SpendableOutputDescriptor_spendable_outpoint(long this_arg);
1433214337
// void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj);
1433314338
public static native void ChannelDerivationParameters_free(long this_obj);
1433414339
// uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr);

src/main/java/org/ldk/structs/ChannelManager.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,24 @@ public void force_close_all_channels_without_broadcasting_txn(java.lang.String e
11121112
Reference.reachabilityFence(error_message);
11131113
}
11141114

1115+
/**
1116+
* Sends a payment along a given route. See [`Self::send_payment`] for more info.
1117+
*
1118+
* LDK will not automatically retry this payment, though it may be manually re-sent after an
1119+
* [`Event::PaymentFailed`] is generated.
1120+
*/
1121+
public Result_NoneRetryableSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) {
1122+
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));
1123+
Reference.reachabilityFence(this);
1124+
Reference.reachabilityFence(route);
1125+
Reference.reachabilityFence(payment_hash);
1126+
Reference.reachabilityFence(recipient_onion);
1127+
Reference.reachabilityFence(payment_id);
1128+
if (ret >= 0 && ret <= 4096) { return null; }
1129+
Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret);
1130+
return ret_hu_conv;
1131+
}
1132+
11151133
/**
11161134
* Sends a payment to the route found using the provided [`RouteParameters`], retrying failed
11171135
* payment paths based on the provided `Retry`.
@@ -1139,7 +1157,8 @@ public void force_close_all_channels_without_broadcasting_txn(java.lang.String e
11391157
* [`ChannelManager::list_recent_payments`] for more information.
11401158
*
11411159
* Routes are automatically found using the [`Router] provided on startup. To fix a route for a
1142-
* particular payment, match the [`PaymentId`] passed to [`Router::find_route_with_id`].
1160+
* particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to
1161+
* [`Router::find_route_with_id`].
11431162
*
11441163
* [`Event::PaymentSent`]: events::Event::PaymentSent
11451164
* [`Event::PaymentFailed`]: events::Event::PaymentFailed

src/main/java/org/ldk/structs/ChannelMonitor.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,11 @@ public SpendableOutputDescriptor[] get_spendable_outputs(byte[] tx, int confirma
580580
*
581581
* This function returns a tuple of two booleans, the first indicating whether the monitor is
582582
* fully resolved, and the second whether the monitor needs persistence to ensure it is
583-
* reliably marked as resolved within 4032 blocks.
583+
* reliably marked as resolved within [`ARCHIVAL_DELAY_BLOCKS`] blocks.
584584
*
585-
* The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at least
586-
* 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets.
585+
* The first boolean is true only if [`Self::get_claimable_balances`] has been empty for at
586+
* least [`ARCHIVAL_DELAY_BLOCKS`] blocks as an additional protection against any bugs
587+
* resulting in spuriously empty balance sets.
587588
*/
588589
public TwoTuple_boolboolZ check_and_update_full_resolution_status(org.ldk.structs.Logger logger) {
589590
long ret = bindings.ChannelMonitor_check_and_update_full_resolution_status(this.ptr, logger.ptr);

src/main/java/org/ldk/structs/OutputSpendStatus.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ private PendingFirstConfirmation(long ptr, bindings.LDKOutputSpendStatus.Pending
7575
}
7676
/**
7777
* A transaction spending the output has been confirmed on-chain but will be tracked until it
78-
* reaches [`ANTI_REORG_DELAY`] confirmations.
78+
* reaches at least [`PRUNE_DELAY_BLOCKS`] confirmations to ensure [`Event::SpendableOutputs`]
79+
* stemming from lingering [`ChannelMonitor`]s can safely be replayed.
80+
*
81+
* [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs
82+
* [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
7983
*/
8084
public final static class PendingThresholdConfirmations extends OutputSpendStatus {
8185
/**

src/main/java/org/ldk/structs/PendingHTLCRouting.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public final static class Forward extends PendingHTLCRouting {
5656
* Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
5757
*/
5858
@Nullable public final org.ldk.structs.BlindedForward blinded;
59+
/**
60+
* The absolute CLTV of the inbound HTLC
61+
*/
62+
public final org.ldk.structs.Option_u32Z incoming_cltv_expiry;
5963
private Forward(long ptr, bindings.LDKPendingHTLCRouting.Forward obj) {
6064
super(null, ptr);
6165
long onion_packet = obj.onion_packet;
@@ -67,6 +71,10 @@ private Forward(long ptr, bindings.LDKPendingHTLCRouting.Forward obj) {
6771
org.ldk.structs.BlindedForward blinded_hu_conv = null; if (blinded < 0 || blinded > 4096) { blinded_hu_conv = new org.ldk.structs.BlindedForward(null, blinded); }
6872
if (blinded_hu_conv != null) { blinded_hu_conv.ptrs_to.add(this); };
6973
this.blinded = blinded_hu_conv;
74+
long incoming_cltv_expiry = obj.incoming_cltv_expiry;
75+
org.ldk.structs.Option_u32Z incoming_cltv_expiry_hu_conv = org.ldk.structs.Option_u32Z.constr_from_ptr(incoming_cltv_expiry);
76+
if (incoming_cltv_expiry_hu_conv != null) { incoming_cltv_expiry_hu_conv.ptrs_to.add(this); };
77+
this.incoming_cltv_expiry = incoming_cltv_expiry_hu_conv;
7078
}
7179
}
7280
/**
@@ -250,11 +258,12 @@ public PendingHTLCRouting clone() {
250258
/**
251259
* Utility method to constructs a new Forward-variant PendingHTLCRouting
252260
*/
253-
public static PendingHTLCRouting forward(org.ldk.structs.OnionPacket onion_packet, long short_channel_id, org.ldk.structs.BlindedForward blinded) {
254-
long ret = bindings.PendingHTLCRouting_forward(onion_packet.ptr, short_channel_id, blinded.ptr);
261+
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) {
262+
long ret = bindings.PendingHTLCRouting_forward(onion_packet.ptr, short_channel_id, blinded.ptr, incoming_cltv_expiry.ptr);
255263
Reference.reachabilityFence(onion_packet);
256264
Reference.reachabilityFence(short_channel_id);
257265
Reference.reachabilityFence(blinded);
266+
Reference.reachabilityFence(incoming_cltv_expiry);
258267
if (ret >= 0 && ret <= 4096) { return null; }
259268
org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
260269
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };

src/main/java/org/ldk/structs/SpendableOutputDescriptor.java

+12
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,16 @@ public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) {
267267
return ret_hu_conv;
268268
}
269269

270+
/**
271+
* Returns the outpoint of the spendable output.
272+
*/
273+
public OutPoint spendable_outpoint() {
274+
long ret = bindings.SpendableOutputDescriptor_spendable_outpoint(this.ptr);
275+
Reference.reachabilityFence(this);
276+
if (ret >= 0 && ret <= 4096) { return null; }
277+
org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
278+
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
279+
return ret_hu_conv;
280+
}
281+
270282
}

src/main/jni/bindings.c

+45-4
Original file line numberDiff line numberDiff line change
@@ -9514,7 +9514,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPendingHTLCRouting_ini
95149514
LDKPendingHTLCRouting_Forward_class =
95159515
(*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPendingHTLCRouting$Forward"));
95169516
CHECK(LDKPendingHTLCRouting_Forward_class != NULL);
9517-
LDKPendingHTLCRouting_Forward_meth = (*env)->GetMethodID(env, LDKPendingHTLCRouting_Forward_class, "<init>", "(JJJ)V");
9517+
LDKPendingHTLCRouting_Forward_meth = (*env)->GetMethodID(env, LDKPendingHTLCRouting_Forward_class, "<init>", "(JJJJ)V");
95189518
CHECK(LDKPendingHTLCRouting_Forward_meth != NULL);
95199519
LDKPendingHTLCRouting_Receive_class =
95209520
(*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_
95409540
int64_t blinded_ref = 0;
95419541
CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_var);
95429542
blinded_ref = tag_ptr(blinded_var.inner, false);
9543-
return (*env)->NewObject(env, LDKPendingHTLCRouting_Forward_class, LDKPendingHTLCRouting_Forward_meth, onion_packet_ref, short_channel_id_conv, blinded_ref);
9543+
int64_t incoming_cltv_expiry_ref = tag_ptr(&obj->forward.incoming_cltv_expiry, false);
9544+
return (*env)->NewObject(env, LDKPendingHTLCRouting_Forward_class, LDKPendingHTLCRouting_Forward_meth, onion_packet_ref, short_channel_id_conv, blinded_ref, incoming_cltv_expiry_ref);
95449545
}
95459546
case LDKPendingHTLCRouting_Receive: {
95469547
LDKFinalOnionHopData payment_data_var = obj->receive.payment_data;
@@ -50579,7 +50580,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PendingHTLCRouting_1clone(J
5057950580
return ret_ref;
5058050581
}
5058150582

50582-
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) {
50583+
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) {
5058350584
LDKOnionPacket onion_packet_conv;
5058450585
onion_packet_conv.inner = untag_ptr(onion_packet);
5058550586
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
5059050591
blinded_conv.is_owned = ptr_is_owned(blinded);
5059150592
CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_conv);
5059250593
blinded_conv = BlindedForward_clone(&blinded_conv);
50594+
void* incoming_cltv_expiry_ptr = untag_ptr(incoming_cltv_expiry);
50595+
CHECK_ACCESS(incoming_cltv_expiry_ptr);
50596+
LDKCOption_u32Z incoming_cltv_expiry_conv = *(LDKCOption_u32Z*)(incoming_cltv_expiry_ptr);
50597+
incoming_cltv_expiry_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(incoming_cltv_expiry));
5059350598
LDKPendingHTLCRouting *ret_copy = MALLOC(sizeof(LDKPendingHTLCRouting), "LDKPendingHTLCRouting");
50594-
*ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv);
50599+
*ret_copy = PendingHTLCRouting_forward(onion_packet_conv, short_channel_id, blinded_conv, incoming_cltv_expiry_conv);
5059550600
int64_t ret_ref = tag_ptr(ret_copy, true);
5059650601
return ret_ref;
5059750602
}
@@ -51807,6 +51812,33 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1
5180751812
ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv, error_message_conv);
5180851813
}
5180951814

51815+
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) {
51816+
LDKChannelManager this_arg_conv;
51817+
this_arg_conv.inner = untag_ptr(this_arg);
51818+
this_arg_conv.is_owned = ptr_is_owned(this_arg);
51819+
CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51820+
this_arg_conv.is_owned = false;
51821+
LDKRoute route_conv;
51822+
route_conv.inner = untag_ptr(route);
51823+
route_conv.is_owned = ptr_is_owned(route);
51824+
CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
51825+
route_conv = Route_clone(&route_conv);
51826+
LDKThirtyTwoBytes payment_hash_ref;
51827+
CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51828+
(*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
51829+
LDKRecipientOnionFields recipient_onion_conv;
51830+
recipient_onion_conv.inner = untag_ptr(recipient_onion);
51831+
recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
51832+
CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
51833+
recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
51834+
LDKThirtyTwoBytes payment_id_ref;
51835+
CHECK((*env)->GetArrayLength(env, payment_id) == 32);
51836+
(*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
51837+
LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
51838+
*ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
51839+
return tag_ptr(ret_conv, true);
51840+
}
51841+
5181051842
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) {
5181151843
LDKChannelManager this_arg_conv;
5181251844
this_arg_conv.inner = untag_ptr(this_arg);
@@ -83275,6 +83307,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1
8327583307
return tag_ptr(ret_conv, true);
8327683308
}
8327783309

83310+
JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1spendable_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
83311+
LDKSpendableOutputDescriptor* this_arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(this_arg);
83312+
LDKOutPoint ret_var = SpendableOutputDescriptor_spendable_outpoint(this_arg_conv);
83313+
int64_t ret_ref = 0;
83314+
CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
83315+
ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
83316+
return ret_ref;
83317+
}
83318+
8327883319
JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDerivationParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
8327983320
LDKChannelDerivationParameters this_obj_conv;
8328083321
this_obj_conv.inner = untag_ptr(this_obj);

0 commit comments

Comments
 (0)