Skip to content

Commit a3b7733

Browse files
authored
Merge pull request #9 from TheBlueMatt/2021-03-cleanup-debug
Move debug builds to a separate file
2 parents 7df17e5 + 7926bd3 commit a3b7733

16 files changed

+469
-42
lines changed

genbindings.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/i
3131
rm src/main/java/org/ldk/enums/*.class src/main/java/org/ldk/impl/bindings*.class
3232

3333
echo "Building Java bindings..."
34-
COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -ldl -Wl,--no-undefined -o liblightningjni.so -shared -fPIC"
34+
COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -ldl -Wl,--no-undefined -shared -fPIC"
3535
if [ "$3" = "true" ]; then
36-
$COMPILE -g -fsanitize=address -shared-libasan -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,reallocarray -Wl,-wrap,malloc -Wl,-wrap,free -rdynamic -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/debug/libldk.a -lm
36+
$COMPILE -o liblightningjni_debug.so -g -fsanitize=address -shared-libasan -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,reallocarray -Wl,-wrap,malloc -Wl,-wrap,free -rdynamic -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/debug/libldk.a -lm
3737
else
38-
$COMPILE -Wl,--version-script=libcode.version -flto -fuse-ld=lld -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/release/libldk.a
38+
$COMPILE -o liblightningjni_release.so -Wl,--version-script=libcode.version -flto -fuse-ld=lld -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/release/libldk.a
3939
fi
4040

4141
echo "Creating TS bindings..."

java_strings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ class CommonBase {
197197
void __attribute__((destructor)) check_leaks() {
198198
size_t alloc_count = 0;
199199
size_t alloc_size = 0;
200+
fprintf(stderr, "The following LDK-allocated blocks still remain.\\n");
201+
fprintf(stderr, "Note that this is only accurate if System.gc(); System.runFinalization()\\n");
202+
fprintf(stderr, "was called prior to exit after all LDK objects were out of scope.\\n");
200203
for (allocation* a = allocation_ll; a != NULL; a = a->next) {
201204
fprintf(stderr, "%s %p (%lu bytes) remains:\\n", a->struct_name, a->ptr, a->alloc_len);
202205
backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
@@ -205,7 +208,8 @@ class CommonBase {
205208
alloc_size += a->alloc_len;
206209
}
207210
fprintf(stderr, "%lu allocations remained for %lu bytes.\\n", alloc_count, alloc_size);
208-
DO_ASSERT(allocation_ll == NULL);
211+
fprintf(stderr, "Note that this is only accurate if System.gc(); System.runFinalization()\\n");
212+
fprintf(stderr, "was called prior to exit after all LDK objects were out of scope.\\n");
209213
}
210214
"""
211215
self.c_file_pfx = self.c_file_pfx + """

liblightningjni.so

-6.62 MB
Binary file not shown.

liblightningjni.so

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
liblightningjni_release.so

liblightningjni_debug.so

67.2 MB
Binary file not shown.

liblightningjni_release.so

6.61 MB
Binary file not shown.

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ public final static class SendShortIdsQuery extends LDKMessageSendEvent {
237237
public static native boolean LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(long arg);
238238
public static native long LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(long arg);
239239
public static native long LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(long arg);
240+
public static native boolean LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(long arg);
241+
public static native long LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(long arg);
242+
public static native long LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(long arg);
240243
public static native boolean LDKCResult_ChannelConfigDecodeErrorZ_result_ok(long arg);
241244
public static native long LDKCResult_ChannelConfigDecodeErrorZ_get_ok(long arg);
242245
public static native long LDKCResult_ChannelConfigDecodeErrorZ_get_err(long arg);
@@ -1023,6 +1026,12 @@ public interface LDKSocketDescriptor {
10231026
public static native long CResult_ChannelFeaturesDecodeErrorZ_err(long e);
10241027
// void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res);
10251028
public static native void CResult_ChannelFeaturesDecodeErrorZ_free(long _res);
1029+
// struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o);
1030+
public static native long CResult_InvoiceFeaturesDecodeErrorZ_ok(long o);
1031+
// struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
1032+
public static native long CResult_InvoiceFeaturesDecodeErrorZ_err(long e);
1033+
// void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res);
1034+
public static native void CResult_InvoiceFeaturesDecodeErrorZ_free(long _res);
10261035
// struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o);
10271036
public static native long CResult_ChannelConfigDecodeErrorZ_ok(long o);
10281037
// struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e);
@@ -3005,8 +3014,8 @@ public interface LDKSocketDescriptor {
30053014
public static native void PeerManager_socket_disconnected(long this_arg, long descriptor);
30063015
// void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible);
30073016
public static native void PeerManager_disconnect_by_node_id(long this_arg, byte[] node_id, boolean no_connection_possible);
3008-
// void PeerManager_timer_tick_occured(const struct LDKPeerManager *NONNULL_PTR this_arg);
3009-
public static native void PeerManager_timer_tick_occured(long this_arg);
3017+
// void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
3018+
public static native void PeerManager_timer_tick_occurred(long this_arg);
30103019
// struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx);
30113020
public static native byte[] build_commitment_secret(byte[] commitment_seed, long idx);
30123021
// struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]);
@@ -3255,12 +3264,16 @@ public interface LDKSocketDescriptor {
32553264
public static native long NodeFeatures_clone(long orig);
32563265
// struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig);
32573266
public static native long ChannelFeatures_clone(long orig);
3267+
// struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig);
3268+
public static native long InvoiceFeatures_clone(long orig);
32583269
// void InitFeatures_free(struct LDKInitFeatures this_obj);
32593270
public static native void InitFeatures_free(long this_obj);
32603271
// void NodeFeatures_free(struct LDKNodeFeatures this_obj);
32613272
public static native void NodeFeatures_free(long this_obj);
32623273
// void ChannelFeatures_free(struct LDKChannelFeatures this_obj);
32633274
public static native void ChannelFeatures_free(long this_obj);
3275+
// void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj);
3276+
public static native void InvoiceFeatures_free(long this_obj);
32643277
// MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void);
32653278
public static native long InitFeatures_empty();
32663279
// MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void);
@@ -3273,18 +3286,26 @@ public interface LDKSocketDescriptor {
32733286
public static native long ChannelFeatures_empty();
32743287
// MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void);
32753288
public static native long ChannelFeatures_known();
3289+
// MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void);
3290+
public static native long InvoiceFeatures_empty();
3291+
// MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void);
3292+
public static native long InvoiceFeatures_known();
32763293
// struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj);
32773294
public static native byte[] InitFeatures_write(long obj);
32783295
// struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj);
32793296
public static native byte[] NodeFeatures_write(long obj);
32803297
// struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj);
32813298
public static native byte[] ChannelFeatures_write(long obj);
3299+
// struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj);
3300+
public static native byte[] InvoiceFeatures_write(long obj);
32823301
// struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser);
32833302
public static native long InitFeatures_read(byte[] ser);
32843303
// struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser);
32853304
public static native long NodeFeatures_read(byte[] ser);
32863305
// struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser);
32873306
public static native long ChannelFeatures_read(byte[] ser);
3307+
// struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser);
3308+
public static native long InvoiceFeatures_read(byte[] ser);
32883309
// void RouteHop_free(struct LDKRouteHop this_obj);
32893310
public static native void RouteHop_free(long this_obj);
32903311
// struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr);
@@ -3347,8 +3368,8 @@ public interface LDKSocketDescriptor {
33473368
public static native void RouteHint_set_cltv_expiry_delta(long this_ptr, short val);
33483369
// struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig);
33493370
public static native long RouteHint_clone(long orig);
3350-
// struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger);
3351-
public static native long get_route(byte[] our_node_id, long network, byte[] payee, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger);
3371+
// struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger);
3372+
public static native long get_route(byte[] our_node_id, long network, byte[] payee, long payee_features, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger);
33523373
// void NetworkGraph_free(struct LDKNetworkGraph this_obj);
33533374
public static native void NetworkGraph_free(long this_obj);
33543375
// struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public ChannelConfig clone() {
133133
}
134134

135135
/**
136-
* Creates a "default" ChannelConfig. See other documentaiton for details on what this implies.
136+
* Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
137137
*/
138138
public static ChannelConfig constructor_default() {
139139
long ret = bindings.ChannelConfig_default();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public ChannelHandshakeConfig clone() {
128128
}
129129

130130
/**
131-
* Creates a "default" ChannelHandshakeConfig. See other documentaiton for details on what this implies.
131+
* Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
132132
*/
133133
public static ChannelHandshakeConfig constructor_default() {
134134
long ret = bindings.ChannelHandshakeConfig_default();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ public void set_force_announced_channel_preference(boolean val) {
243243
* Not checking this value would be a security issue, as our peer would be able to set it to
244244
* max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
245245
*
246-
* Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
247-
* so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
246+
* Default value: 2016, which we also enforce as a maximum value so you can tweak config to
247+
* reduce the loss of having useless locked funds (if your peer accepts)
248248
*/
249249
public short get_their_to_self_delay() {
250250
short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
@@ -257,8 +257,8 @@ public short get_their_to_self_delay() {
257257
* Not checking this value would be a security issue, as our peer would be able to set it to
258258
* max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
259259
*
260-
* Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value
261-
* so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
260+
* Default value: 2016, which we also enforce as a maximum value so you can tweak config to
261+
* reduce the loss of having useless locked funds (if your peer accepts)
262262
*/
263263
public void set_their_to_self_delay(short val) {
264264
bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
@@ -285,7 +285,7 @@ public ChannelHandshakeLimits clone() {
285285
}
286286

287287
/**
288-
* Creates a "default" ChannelHandshakeLimits. See other documentaiton for details on what this implies.
288+
* Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
289289
*/
290290
public static ChannelHandshakeLimits constructor_default() {
291291
long ret = bindings.ChannelHandshakeLimits_default();

0 commit comments

Comments
 (0)