Skip to content

Commit 8a70904

Browse files
authored
Merge pull request #90 from TheBlueMatt/main
Expose ProbabilisticScorer
2 parents 54be51e + 0c666a9 commit 8a70904

File tree

346 files changed

+4187
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+4187
-526
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
export HOME=/root/ # Github actions is apparently broken
6262
export PATH=$(pwd)/$(echo node-*/bin):$PATH
6363
# npx playwright install-deps is broken so we do it manually, see https://github.com/microsoft/playwright/issues/11165
64-
apt-get install -y --no-install-recommends fonts-liberation libenchant-2-2 libicu67 libjpeg62-turbo libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 libegl1 libgbm1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxshmfence1 xvfb fonts-noto-color-emoji fonts-unifont libfontconfig libfreetype6 xfonts-scalable fonts-ipafont-gothic fonts-wqy-zenhei fonts-tlwg-loma-otf ffmpeg libcairo-gobject2 libdbus-glib-1-2 libfontconfig1 libgdk-pixbuf2.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libxcb-shm0 libxcursor1 libxi6 libxrender1 libxt6 gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good libepoxy0 libevdev2 libgl1 libgles2 libgstreamer-gl1.0-0 libgstreamer1.0-0 libharfbuzz-icu0 libharfbuzz0b libhyphen0 libnotify4 libopenjp2-7 libopus0 libpng16-16 libsecret-1-0 libsoup2.4-1 libwayland-client0 libwayland-egl1 libwayland-server0 libwebp6 libwebpdemux2 libwoff1 libxkbcommon0 libxml2 libxslt1.1
64+
apt-get install -y --no-install-recommends fonts-liberation libenchant-2-2 libicu67 libjpeg62-turbo libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 libegl1 libgbm1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxshmfence1 xvfb fonts-noto-color-emoji fonts-unifont libfontconfig libfreetype6 xfonts-scalable fonts-ipafont-gothic fonts-wqy-zenhei fonts-tlwg-loma-otf ffmpeg libcairo-gobject2 libdbus-glib-1-2 libfontconfig1 libgdk-pixbuf2.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libxcb-shm0 libxcursor1 libxi6 libxrender1 libxt6 gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good libepoxy0 libevdev2 libgl1 libgles2 libgstreamer-gl1.0-0 libgstreamer1.0-0 libharfbuzz-icu0 libharfbuzz0b libhyphen0 libnotify4 libopenjp2-7 libopus0 libpng16-16 libsecret-1-0 libsoup2.4-1 libwayland-client0 libwayland-egl1 libwayland-server0 libwebp7 libwebpdemux2 libwoff1 libxkbcommon0 libxml2 libxslt1.1
6565
mkdir -p $HOME/.cache/ms-playwright # `playwright install` is too dumb to create this for us
6666
chmod -R 777 $HOME/
6767
npm i -D playwright

gen_type_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
309309
opaque_ret_conv_suf += "if ((uintptr_t)" + ty_info.var_name + "_var.inner > 4096) {\n"
310310
indent = "\t"
311311
if not holds_ref and ty_info.is_ptr and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns: # is_ptr, not holds_ref implies passing a pointed-to value to java, which needs copied
312-
opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");\n"
312+
opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&" + ty_info.var_name + "_var);\n"
313313
elif not holds_ref and ty_info.is_ptr:
314314
opaque_ret_conv_suf += indent + "// WARNING: we may need a move here but no clone is available for " + ty_info.rust_obj + "\n"
315315

genbindings.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ if [ "$2" != "wasm" ]; then
158158
popd
159159
LDK_LIB="tmp/libldk.bc tmp/libldk.a"
160160
fi
161-
$COMPILE -o liblightningjni_release$LDK_TARGET_SUFFIX.so -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c $LDK_LIB
161+
$COMPILE -o liblightningjni_release$LDK_TARGET_SUFFIX.so -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c $LDK_LIB -lm
162162
if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
163163
GLIBC_SYMBS="$(objdump -T liblightningjni_release$LDK_TARGET_SUFFIX.so | grep GLIBC_ | grep -v "GLIBC_2\.2\." | grep -v "GLIBC_2\.3\(\.\| \)" | grep -v "GLIBC_2.\(14\|17\) " || echo)"
164164
if [ "$GLIBC_SYMBS" != "" ]; then
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.ldk.enums;
2+
3+
/**
4+
* Specifies the recipient of an invoice, to indicate to [`KeysInterface::sign_invoice`] what node
5+
* secret key should be used to sign the invoice.
6+
*/
7+
public enum Recipient {
8+
/**
9+
* The invoice should be signed with the local node secret key.
10+
*/
11+
LDKRecipient_Node,
12+
/**
13+
* The invoice should be signed with the phantom node secret key. This secret key must be the
14+
* same for all nodes participating in the [phantom node payment].
15+
*
16+
* [phantom node payment]: PhantomKeysManager
17+
*/
18+
LDKRecipient_PhantomNode,
19+
; static native void init();
20+
static { init(); }
21+
}

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

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ public final static class None extends LDKCOption_u32Z {
144144
public static native long CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(long owner);
145145
// struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner);
146146
public static native long CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(long owner);
147-
// struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner);
147+
// struct LDKTrustedClosingTransaction *NONNULL_PTR CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner);
148148
public static native long CResult_TrustedClosingTransactionNoneZ_get_ok(long owner);
149149
// void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner);
150150
public static native void CResult_TrustedClosingTransactionNoneZ_get_err(long owner);
151151
// struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner);
152152
public static native long CResult_CommitmentTransactionDecodeErrorZ_get_ok(long owner);
153153
// struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner);
154154
public static native long CResult_CommitmentTransactionDecodeErrorZ_get_err(long owner);
155-
// struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner);
155+
// struct LDKTrustedCommitmentTransaction *NONNULL_PTR CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner);
156156
public static native long CResult_TrustedCommitmentTransactionNoneZ_get_ok(long owner);
157157
// void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner);
158158
public static native void CResult_TrustedCommitmentTransactionNoneZ_get_err(long owner);
@@ -609,14 +609,22 @@ public final static class SendReplyChannelRange extends LDKMessageSendEvent {
609609
public static native long CResult_ScoringParametersDecodeErrorZ_get_ok(long owner);
610610
// struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner);
611611
public static native long CResult_ScoringParametersDecodeErrorZ_get_err(long owner);
612-
// struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner);
612+
// struct LDKScorer *NONNULL_PTR CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner);
613613
public static native long CResult_ScorerDecodeErrorZ_get_ok(long owner);
614614
// struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner);
615615
public static native long CResult_ScorerDecodeErrorZ_get_err(long owner);
616616
// struct LDKProbabilisticScoringParameters CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner);
617617
public static native long CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(long owner);
618618
// struct LDKDecodeError CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner);
619619
public static native long CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(long owner);
620+
// struct LDKProbabilisticScoringParameters C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner);
621+
public static native long C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(long owner);
622+
// struct LDKNetworkGraph C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner);
623+
public static native long C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(long owner);
624+
// struct LDKProbabilisticScorer *NONNULL_PTR CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner);
625+
public static native long CResult_ProbabilisticScorerDecodeErrorZ_get_ok(long owner);
626+
// struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner);
627+
public static native long CResult_ProbabilisticScorerDecodeErrorZ_get_err(long owner);
620628
// struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner);
621629
public static native long CResult_InitFeaturesDecodeErrorZ_get_ok(long owner);
622630
// struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner);
@@ -967,9 +975,9 @@ public interface LDKLogger {
967975
public static native long LDKLogger_new(LDKLogger impl);
968976
// struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner);
969977
public static native byte[] C2Tuple_BlockHashChannelManagerZ_get_a(long owner);
970-
// struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner);
978+
// struct LDKChannelManager *NONNULL_PTR C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner);
971979
public static native long C2Tuple_BlockHashChannelManagerZ_get_b(long owner);
972-
// struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner);
980+
// struct LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner);
973981
public static native long CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(long owner);
974982
// struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner);
975983
public static native long CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(long owner);
@@ -1421,7 +1429,7 @@ public final static class None extends LDKCOption_FilterZ {
14211429
}
14221430
static { LDKCOption_FilterZ.init(); }
14231431
public static native LDKCOption_FilterZ LDKCOption_FilterZ_ref_from_ptr(long ptr);
1424-
// struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner);
1432+
// struct LDKLockedChannelMonitor *NONNULL_PTR CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner);
14251433
public static native long CResult_LockedChannelMonitorNoneZ_get_ok(long owner);
14261434
// void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner);
14271435
public static native void CResult_LockedChannelMonitorNoneZ_get_err(long owner);
@@ -2208,6 +2216,22 @@ public interface LDKRouter {
22082216
public static native long CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(long arg);
22092217
// struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR orig);
22102218
public static native long CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(long orig);
2219+
// uintptr_t C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR arg);
2220+
public static native long C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(long arg);
2221+
// struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(const struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR orig);
2222+
public static native long C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(long orig);
2223+
// struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(struct LDKProbabilisticScoringParameters a, const struct LDKNetworkGraph *NONNULL_PTR b);
2224+
public static native long C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(long a, long b);
2225+
// void C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ _res);
2226+
public static native void C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(long _res);
2227+
// struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o);
2228+
public static native long CResult_ProbabilisticScorerDecodeErrorZ_ok(long o);
2229+
// struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e);
2230+
public static native long CResult_ProbabilisticScorerDecodeErrorZ_err(long e);
2231+
// bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o);
2232+
public static native boolean CResult_ProbabilisticScorerDecodeErrorZ_is_ok(long o);
2233+
// void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res);
2234+
public static native void CResult_ProbabilisticScorerDecodeErrorZ_free(long _res);
22112235
// struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o);
22122236
public static native long CResult_InitFeaturesDecodeErrorZ_ok(long o);
22132237
// struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
@@ -6696,6 +6720,8 @@ public interface LDKRouter {
66966720
public static native byte[] Scorer_write(long obj);
66976721
// struct LDKCResult_ScorerDecodeErrorZ Scorer_read(struct LDKu8slice ser);
66986722
public static native long Scorer_read(byte[] ser);
6723+
// void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj);
6724+
public static native void ProbabilisticScorer_free(long this_obj);
66996725
// void ProbabilisticScoringParameters_free(struct LDKProbabilisticScoringParameters this_obj);
67006726
public static native void ProbabilisticScoringParameters_free(long this_obj);
67016727
// uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr);
@@ -6716,8 +6742,16 @@ public interface LDKRouter {
67166742
public static native byte[] ProbabilisticScoringParameters_write(long obj);
67176743
// struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ ProbabilisticScoringParameters_read(struct LDKu8slice ser);
67186744
public static native long ProbabilisticScoringParameters_read(byte[] ser);
6745+
// MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringParameters params, const struct LDKNetworkGraph *NONNULL_PTR network_graph);
6746+
public static native long ProbabilisticScorer_new(long params, long network_graph);
67196747
// MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_default(void);
67206748
public static native long ProbabilisticScoringParameters_default();
6749+
// struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg);
6750+
public static native long ProbabilisticScorer_as_Score(long this_arg);
6751+
// struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj);
6752+
public static native byte[] ProbabilisticScorer_write(long obj);
6753+
// struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ arg);
6754+
public static native long ProbabilisticScorer_read(byte[] ser, long arg);
67216755
// void FilesystemPersister_free(struct LDKFilesystemPersister this_obj);
67226756
public static native void FilesystemPersister_free(long this_obj);
67236757
// MUST_USE_RES struct LDKFilesystemPersister FilesystemPersister_new(struct LDKStr path_to_channel_data);

0 commit comments

Comments
 (0)