Skip to content

Commit 86706cd

Browse files
authored
Merge pull request #113 from TheBlueMatt/main
Update to latest LDK-C-Bindings and fix assorted TS bugs
2 parents 9efbdc5 + d2f3f4f commit 86706cd

39 files changed

+2043
-446
lines changed

gen_type_mapping.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
187187
if is_nullable:
188188
ret_conv = (ret_conv[0], ret_conv[1] + "\n}")
189189

190-
to_hu_conv = None
191-
to_hu_conv_name = None
192190
if subty.to_hu_conv is not None:
193191
to_hu_conv = self.consts.var_decl_statement(self.consts.c_type_map["uint32_t"][0], conv_name + "_len", self.consts.get_java_arr_len(arr_name)) + ";\n"
194192
to_hu_conv += self.consts.var_decl_statement(ty_info.java_hu_ty, conv_name + "_arr", self.consts.constr_hu_array(ty_info, conv_name + "_len"))
@@ -200,6 +198,12 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
200198
if cleanup is not None:
201199
to_hu_conv += "\n" + cleanup
202200
to_hu_conv_name = conv_name + "_arr"
201+
else:
202+
to_hu_conv = self.consts.primitive_arr_to_hu(ty_info.subty, None, arr_name, arr_name + "_conv")
203+
if to_hu_conv is not None:
204+
to_hu_conv_name = arr_name + "_conv"
205+
else:
206+
to_hu_conv_name = None
203207
from_hu_conv = self.consts.primitive_arr_from_hu(ty_info.subty, None, arr_name)
204208
if subty.from_hu_conv is not None:
205209
hu_conv_b = ""

genbindings.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ else
237237
NODE_V="$(node --version)"
238238
if [ "${NODE_V:1:2}" -gt 14 ]; then
239239
cd ../ts
240-
node test/node.mjs
240+
node --stack_trace_limit=200 --trace-uncaught test/node.mjs
241241
cd ../node-net
242-
node test/test.mjs
242+
node --stack_trace_limit=200 --trace-uncaught test/test.mjs
243243
fi
244244
fi
245245
fi

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4621,6 +4621,8 @@ public final static class Timeout extends LDKRetry {
46214621
public static native short DelayedPaymentOutputDescriptor_get_to_self_delay(long this_ptr);
46224622
// void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val);
46234623
public static native void DelayedPaymentOutputDescriptor_set_to_self_delay(long this_ptr, short val);
4624+
// struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
4625+
public static native long DelayedPaymentOutputDescriptor_get_output(long this_ptr);
46244626
// void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val);
46254627
public static native void DelayedPaymentOutputDescriptor_set_output(long this_ptr, long val);
46264628
// struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
@@ -4651,6 +4653,8 @@ public final static class Timeout extends LDKRetry {
46514653
public static native long StaticPaymentOutputDescriptor_get_outpoint(long this_ptr);
46524654
// void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val);
46534655
public static native void StaticPaymentOutputDescriptor_set_outpoint(long this_ptr, long val);
4656+
// struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr);
4657+
public static native long StaticPaymentOutputDescriptor_get_output(long this_ptr);
46544658
// void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val);
46554659
public static native void StaticPaymentOutputDescriptor_set_output(long this_ptr, long val);
46564660
// const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32];
@@ -5561,6 +5565,8 @@ public final static class Timeout extends LDKRetry {
55615565
public static native byte[] CommitmentSigned_get_signature(long this_ptr);
55625566
// void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val);
55635567
public static native void CommitmentSigned_set_signature(long this_ptr, byte[] val);
5568+
// struct LDKCVec_SignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr);
5569+
public static native byte[][] CommitmentSigned_get_htlc_signatures(long this_ptr);
55645570
// void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val);
55655571
public static native void CommitmentSigned_set_htlc_signatures(long this_ptr, byte[][] val);
55665572
// MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg);
@@ -5705,6 +5711,8 @@ public final static class Timeout extends LDKRetry {
57055711
public static native byte[] UnsignedNodeAnnouncement_get_alias(long this_ptr);
57065712
// void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
57075713
public static native void UnsignedNodeAnnouncement_set_alias(long this_ptr, byte[] val);
5714+
// struct LDKCVec_NetAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr);
5715+
public static native long[] UnsignedNodeAnnouncement_get_addresses(long this_ptr);
57085716
// void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val);
57095717
public static native void UnsignedNodeAnnouncement_set_addresses(long this_ptr, long[] val);
57105718
// uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg);
@@ -5827,6 +5835,8 @@ public final static class Timeout extends LDKRetry {
58275835
public static native int UnsignedChannelUpdate_get_fee_proportional_millionths(long this_ptr);
58285836
// void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val);
58295837
public static native void UnsignedChannelUpdate_set_fee_proportional_millionths(long this_ptr, int val);
5838+
// struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr);
5839+
public static native byte[] UnsignedChannelUpdate_get_excess_data(long this_ptr);
58305840
// void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val);
58315841
public static native void UnsignedChannelUpdate_set_excess_data(long this_ptr, byte[] val);
58325842
// MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg);
@@ -5889,6 +5899,8 @@ public final static class Timeout extends LDKRetry {
58895899
public static native boolean ReplyChannelRange_get_sync_complete(long this_ptr);
58905900
// void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val);
58915901
public static native void ReplyChannelRange_set_sync_complete(long this_ptr, boolean val);
5902+
// struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr);
5903+
public static native long[] ReplyChannelRange_get_short_channel_ids(long this_ptr);
58925904
// void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val);
58935905
public static native void ReplyChannelRange_set_short_channel_ids(long this_ptr, long[] val);
58945906
// MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg);
@@ -5903,6 +5915,8 @@ public final static class Timeout extends LDKRetry {
59035915
public static native byte[] QueryShortChannelIds_get_chain_hash(long this_ptr);
59045916
// void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
59055917
public static native void QueryShortChannelIds_set_chain_hash(long this_ptr, byte[] val);
5918+
// struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr);
5919+
public static native long[] QueryShortChannelIds_get_short_channel_ids(long this_ptr);
59065920
// void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val);
59075921
public static native void QueryShortChannelIds_set_short_channel_ids(long this_ptr, long[] val);
59085922
// MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg);
@@ -6453,6 +6467,8 @@ public final static class Timeout extends LDKRetry {
64536467
public static native byte[] HolderCommitmentTransaction_get_counterparty_sig(long this_ptr);
64546468
// void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val);
64556469
public static native void HolderCommitmentTransaction_set_counterparty_sig(long this_ptr, byte[] val);
6470+
// struct LDKCVec_SignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr);
6471+
public static native byte[][] HolderCommitmentTransaction_get_counterparty_htlc_sigs(long this_ptr);
64566472
// void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val);
64576473
public static native void HolderCommitmentTransaction_set_counterparty_htlc_sigs(long this_ptr, byte[][] val);
64586474
// uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg);
@@ -7143,6 +7159,8 @@ public final static class Timeout extends LDKRetry {
71437159
public static native long NodeAnnouncementInfo_get_alias(long this_ptr);
71447160
// void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val);
71457161
public static native void NodeAnnouncementInfo_set_alias(long this_ptr, long val);
7162+
// struct LDKCVec_NetAddressZ NodeAnnouncementInfo_get_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr);
7163+
public static native long[] NodeAnnouncementInfo_get_addresses(long this_ptr);
71467164
// void NodeAnnouncementInfo_set_addresses(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val);
71477165
public static native void NodeAnnouncementInfo_set_addresses(long this_ptr, long[] val);
71487166
// struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr);
@@ -7177,6 +7195,8 @@ public final static class Timeout extends LDKRetry {
71777195
public static native long NodeAlias_read(byte[] ser);
71787196
// void NodeInfo_free(struct LDKNodeInfo this_obj);
71797197
public static native void NodeInfo_free(long this_obj);
7198+
// struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr);
7199+
public static native long[] NodeInfo_get_channels(long this_ptr);
71807200
// void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val);
71817201
public static native void NodeInfo_set_channels(long this_ptr, long[] val);
71827202
// struct LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const struct LDKNodeInfo *NONNULL_PTR this_ptr);
@@ -7233,8 +7253,12 @@ public final static class Timeout extends LDKRetry {
72337253
public static native long NetworkGraph_update_channel_unsigned(long this_arg, long msg);
72347254
// MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id);
72357255
public static native long ReadOnlyNetworkGraph_channel(long this_arg, long short_channel_id);
7256+
// MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg);
7257+
public static native long[] ReadOnlyNetworkGraph_list_channels(long this_arg);
72367258
// MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id);
72377259
public static native long ReadOnlyNetworkGraph_node(long this_arg, long node_id);
7260+
// MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg);
7261+
public static native long[] ReadOnlyNetworkGraph_list_nodes(long this_arg);
72387262
// MUST_USE_RES struct LDKCOption_CVec_NetAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey);
72397263
public static native long ReadOnlyNetworkGraph_get_addresses(long this_arg, byte[] pubkey);
72407264
// void RouteHop_free(struct LDKRouteHop this_obj);
@@ -7359,6 +7383,8 @@ public final static class Timeout extends LDKRetry {
73597383
public static native byte PaymentParameters_get_max_channel_saturation_power_of_half(long this_ptr);
73607384
// void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val);
73617385
public static native void PaymentParameters_set_max_channel_saturation_power_of_half(long this_ptr, byte val);
7386+
// struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr);
7387+
public static native long[] PaymentParameters_get_previously_failed_channels(long this_ptr);
73627388
// void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val);
73637389
public static native void PaymentParameters_set_previously_failed_channels(long this_ptr, long[] val);
73647390
// MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ public void set_signature(byte[] val) {
5656
Reference.reachabilityFence(val);
5757
}
5858

59+
/**
60+
* Signatures on the HTLC transactions
61+
*
62+
* Returns a copy of the field.
63+
*/
64+
public byte[][] get_htlc_signatures() {
65+
byte[][] ret = bindings.CommitmentSigned_get_htlc_signatures(this.ptr);
66+
Reference.reachabilityFence(this);
67+
return ret;
68+
}
69+
5970
/**
6071
* Signatures on the HTLC transactions
6172
*/

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ public void set_to_self_delay(short val) {
8080
Reference.reachabilityFence(val);
8181
}
8282

83+
/**
84+
* The output which is referenced by the given outpoint
85+
*
86+
* Returns a copy of the field.
87+
*/
88+
public TxOut get_output() {
89+
long ret = bindings.DelayedPaymentOutputDescriptor_get_output(this.ptr);
90+
Reference.reachabilityFence(this);
91+
if (ret >= 0 && ret <= 4096) { return null; }
92+
TxOut ret_conv = new TxOut(null, ret);
93+
return ret_conv;
94+
}
95+
8396
/**
8497
* The output which is referenced by the given outpoint
8598
*/

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public void set_counterparty_sig(byte[] val) {
4040
Reference.reachabilityFence(val);
4141
}
4242

43+
/**
44+
* All non-dust counterparty HTLC signatures, in the order they appear in the transaction
45+
*
46+
* Returns a copy of the field.
47+
*/
48+
public byte[][] get_counterparty_htlc_sigs() {
49+
byte[][] ret = bindings.HolderCommitmentTransaction_get_counterparty_htlc_sigs(this.ptr);
50+
Reference.reachabilityFence(this);
51+
return ret;
52+
}
53+
4354
/**
4455
* All non-dust counterparty HTLC signatures, in the order they appear in the transaction
4556
*/

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ public void set_alias(NodeAlias val) {
104104
Reference.reachabilityFence(val);
105105
}
106106

107+
/**
108+
* Internet-level addresses via which one can connect to the node
109+
*
110+
* Returns a copy of the field.
111+
*/
112+
public NetAddress[] get_addresses() {
113+
long[] ret = bindings.NodeAnnouncementInfo_get_addresses(this.ptr);
114+
Reference.reachabilityFence(this);
115+
int ret_conv_12_len = ret.length;
116+
NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
117+
for (int m = 0; m < ret_conv_12_len; m++) {
118+
long ret_conv_12 = ret[m];
119+
org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
120+
ret_conv_12_hu_conv.ptrs_to.add(this);
121+
ret_conv_12_arr[m] = ret_conv_12_hu_conv;
122+
}
123+
return ret_conv_12_arr;
124+
}
125+
107126
/**
108127
* Internet-level addresses via which one can connect to the node
109128
*/

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ protected void finalize() throws Throwable {
2020
if (ptr != 0) { bindings.NodeInfo_free(ptr); }
2121
}
2222

23+
/**
24+
* All valid channels a node has announced
25+
*
26+
* Returns a copy of the field.
27+
*/
28+
public long[] get_channels() {
29+
long[] ret = bindings.NodeInfo_get_channels(this.ptr);
30+
Reference.reachabilityFence(this);
31+
return ret;
32+
}
33+
2334
/**
2435
* All valid channels a node has announced
2536
*/

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ public void set_max_channel_saturation_power_of_half(byte val) {
203203
Reference.reachabilityFence(val);
204204
}
205205

206+
/**
207+
* A list of SCIDs which this payment was previously attempted over and which caused the
208+
* payment to fail. Future attempts for the same payment shouldn't be relayed through any of
209+
* these SCIDs.
210+
*
211+
* Returns a copy of the field.
212+
*/
213+
public long[] get_previously_failed_channels() {
214+
long[] ret = bindings.PaymentParameters_get_previously_failed_channels(this.ptr);
215+
Reference.reachabilityFence(this);
216+
return ret;
217+
}
218+
206219
/**
207220
* A list of SCIDs which this payment was previously attempted over and which caused the
208221
* payment to fail. Future attempts for the same payment shouldn't be relayed through any of

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ public void set_chain_hash(byte[] val) {
4545
Reference.reachabilityFence(val);
4646
}
4747

48+
/**
49+
* The short_channel_ids that are being queried
50+
*
51+
* Returns a copy of the field.
52+
*/
53+
public long[] get_short_channel_ids() {
54+
long[] ret = bindings.QueryShortChannelIds_get_short_channel_ids(this.ptr);
55+
Reference.reachabilityFence(this);
56+
return ret;
57+
}
58+
4859
/**
4960
* The short_channel_ids that are being queried
5061
*/

0 commit comments

Comments
 (0)