Skip to content

Commit 3e33cfd

Browse files
authored
Merge pull request #135 from TheBlueMatt/main
0.0.116
2 parents 40764e2 + 8d497f0 commit 3e33cfd

File tree

751 files changed

+364975
-203861
lines changed

Some content is hidden

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

751 files changed

+364975
-203861
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ jobs:
4040
# Note this is a different endpoint, as we need one non-upstream commit!
4141
git clone https://git.bitcoin.ninja/rust-lightning
4242
cd rust-lightning
43-
git checkout origin/2023-04-0.0.115-java-bindings
43+
git checkout origin/2023-07-0.0.116-java-bindings
4444
cd ..
4545
git clone https://github.com/lightningdevkit/ldk-c-bindings
4646
cd ldk-c-bindings
47-
git checkout 0.0.115
47+
git checkout 0.0.116
4848
- name: Rebuild C bindings without STD
4949
run: |
5050
cd ldk-c-bindings
@@ -71,8 +71,8 @@ jobs:
7171
apt-get install -y --no-install-recommends fonts-liberation libenchant-2-2 libicu72 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
7272
mkdir -p $HOME/.cache/ms-playwright # `playwright install` is too dumb to create this for us
7373
chmod -R 777 $HOME/
74-
npm i -D playwright
75-
npx playwright install
74+
npm i -D playwright@1.37.0-alpha-jul-31-2023
75+
npx playwright@1.37.0-alpha-jul-31-2023 install
7676
- name: Build and Test TS Debug Bindings for Web
7777
run: |
7878
export HOME=/root/ # Github actions is apparently broken
@@ -134,11 +134,16 @@ jobs:
134134
# Note this is a different endpoint, as we need one non-upstream commit!
135135
git clone https://git.bitcoin.ninja/rust-lightning
136136
cd rust-lightning
137-
git checkout origin/2023-04-0.0.115-java-bindings
137+
git checkout origin/2023-07-0.0.116-java-bindings
138138
cd ..
139139
git clone https://github.com/lightningdevkit/ldk-c-bindings
140140
cd ldk-c-bindings
141-
git checkout 0.0.115
141+
git checkout 0.0.116
142+
- name: Pin proc-macro and quote to meet MSRV
143+
run: |
144+
cd ldk-c-bindings/c-bindings-gen
145+
cargo update -p quote --precise "1.0.30" --verbose
146+
cargo update -p proc-macro2 --precise "1.0.65" --verbose
142147
- name: Rebuild C bindings, and check the sample app builds + links
143148
run: |
144149
cd ldk-c-bindings
@@ -190,11 +195,16 @@ jobs:
190195
# Note this is a different endpoint, as we need one non-upstream commit!
191196
git clone https://git.bitcoin.ninja/rust-lightning
192197
cd rust-lightning
193-
git checkout origin/2023-04-0.0.115-java-bindings
198+
git checkout origin/2023-07-0.0.116-java-bindings
194199
cd ..
195200
git clone https://github.com/lightningdevkit/ldk-c-bindings
196201
cd ldk-c-bindings
197-
git checkout 0.0.115
202+
git checkout 0.0.116
203+
- name: Pin proc-macro and quote to meet MSRV
204+
run: |
205+
cd ldk-c-bindings/c-bindings-gen
206+
cargo update -p quote --precise "1.0.30" --verbose
207+
cargo update -p proc-macro2 --precise "1.0.65" --verbose
198208
- name: Rebuild C bindings, and check the sample app builds + links
199209
run: |
200210
cd ldk-c-bindings
@@ -300,11 +310,11 @@ jobs:
300310
# Note this is a different endpoint, as we need one non-upstream commit!
301311
git clone https://git.bitcoin.ninja/rust-lightning
302312
cd rust-lightning
303-
git checkout origin/2023-04-0.0.115-java-bindings
313+
git checkout origin/2023-07-0.0.116-java-bindings
304314
cd ..
305315
git clone https://github.com/lightningdevkit/ldk-c-bindings
306316
cd ldk-c-bindings
307-
git checkout 0.0.115
317+
git checkout 0.0.116
308318
- name: Fetch MacOS SDK
309319
run: |
310320
curl -o Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
@@ -437,11 +447,11 @@ jobs:
437447
# Note this is a different endpoint, as we need one non-upstream commit!
438448
git clone https://git.bitcoin.ninja/rust-lightning
439449
cd rust-lightning
440-
git checkout origin/2023-04-0.0.115-java-bindings
450+
git checkout origin/2023-07-0.0.116-java-bindings
441451
cd ..
442452
git clone https://github.com/lightningdevkit/ldk-c-bindings
443453
cd ldk-c-bindings
444-
git checkout 0.0.115
454+
git checkout 0.0.116
445455
- name: Checkout Android AAR binaries and artifacts
446456
run: |
447457
# Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
@@ -510,11 +520,11 @@ jobs:
510520
# Note this is a different endpoint, as we need one non-upstream commit!
511521
git clone https://git.bitcoin.ninja/rust-lightning
512522
cd rust-lightning
513-
git checkout origin/2023-04-0.0.115-java-bindings
523+
git checkout origin/2023-07-0.0.116-java-bindings
514524
cd ..
515525
git clone https://github.com/lightningdevkit/ldk-c-bindings
516526
cd ldk-c-bindings
517-
git checkout 0.0.115
527+
git checkout 0.0.116
518528
- name: Rebuild C bindings and check the sample app builds + links
519529
run: |
520530
cd ldk-c-bindings

gen_type_mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
500500
to_hu_conv = self.consts.var_decl_statement(ty_info.java_hu_ty, ty_info.var_name + "_hu_conv", "new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ")") + ";" + to_hu_conv_sfx,
501501
to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = from_hu_conv)
502502

503-
# The manually-defined types - TxOut, BigEndianScalar, U5, and Error
503+
# The manually-defined types - TxIn, TxOut, BigEndianScalar, U5, and Error
504504
if ty_info.rust_obj == "LDKError":
505505
assert from_hu_conv is None
506506
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
@@ -517,7 +517,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
517517
to_hu_conv = self.consts.var_decl_statement(ty_info.java_hu_ty, ty_info.var_name + "_conv", "new " + ty_info.java_hu_ty + "(" + ty_info.var_name + ")") + ";",
518518
to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (ty_info.var_name + ".getVal()", ""))
519519

520-
assert ty_info.rust_obj == "LDKTxOut" or ty_info.rust_obj == "LDKBigEndianScalar"
520+
assert ty_info.rust_obj == "LDKTxOut" or ty_info.rust_obj == "LDKTxIn" or ty_info.rust_obj == "LDKBigEndianScalar"
521521
if not ty_info.is_ptr and not holds_ref:
522522
ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_ref = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_ref = ", ";")
523523
ret_conv_name = "tag_ptr(" + ty_info.var_name + "_ref, true)"

genbindings.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ def java_c_types(fn_arg, ret_arr_len):
231231
assert var_is_arr_regex.match(fn_arg[8:])
232232
arr_access = "data"
233233
elif fn_arg.startswith("LDKWitness ") or fn_arg == "LDKWitness":
234-
fn_arg = "uint8_t (*" + fn_arg[11:] + ")[datalen]"
234+
if len(fn_arg) > 12 and fn_arg[11] == "*":
235+
fn_arg = "uint8_t (" + fn_arg[11:] + ")[datalen]"
236+
else:
237+
fn_arg = "uint8_t (*" + fn_arg[11:] + ")[datalen]"
235238
rust_obj = "LDKWitness"
236239
assert var_is_arr_regex.match(fn_arg[8:])
237240
arr_access = "data"
@@ -323,6 +326,14 @@ def java_c_types(fn_arg, ret_arr_len):
323326
fn_ty_arg = "I"
324327
fn_arg = fn_arg[8:].strip()
325328
is_primitive = True
329+
elif fn_arg.startswith("int64_t"):
330+
mapped_type = consts.c_type_map['int64_t']
331+
java_ty = mapped_type[0]
332+
c_ty = "int64_t"
333+
arr_ty = "int64_t"
334+
fn_ty_arg = "J"
335+
fn_arg = fn_arg[7:].strip()
336+
is_primitive = True
326337
elif fn_arg.startswith("uint64_t") or fn_arg.startswith("uintptr_t"):
327338
# TODO: uintptr_t is arch-dependent :(
328339
mapped_type = consts.c_type_map['uint64_t']
@@ -575,6 +586,9 @@ def map_fn_with_ref_option(line, re_match, ret_arr_len, c_call_string, doc_comme
575586
return_type_info = type_mapping_generator.map_type(method_return_type.strip() + " ret", True, ret_arr_len, False, force_holds_ref)
576587

577588
if method_name.endswith("_clone") and expected_struct not in unitary_enums:
589+
# LDKWitness is mapped as an array, so no need to implement clone
590+
if expected_struct == "LDKWitness":
591+
return
578592
meth_line = "uint64_t " + expected_struct.replace("LDK", "") + "_clone_ptr(" + expected_struct + " *NONNULL_PTR arg)"
579593
write_c("static inline " + meth_line + " {\n")
580594
write_c("\t" + return_type_info.ret_conv[0].replace("\n", "\n\t"))
@@ -641,8 +655,8 @@ def map_fn_with_ref_option(line, re_match, ret_arr_len, c_call_string, doc_comme
641655
expected_struct in complex_enums or expected_struct in complex_enums or
642656
expected_struct in result_types or expected_struct in tuple_types) and not is_free
643657
impl_on_utils = not impl_on_struct and (not is_free and not method_name.endswith("_clone") and
644-
not method_name.startswith("TxOut") and not method_name.startswith("BigEndianScalar") and
645-
not method_name.startswith("_") and
658+
not method_name.startswith("TxOut") and not method_name.startswith("TxIn") and
659+
not method_name.startswith("BigEndianScalar") and not method_name.startswith("_") and
646660
method_name != "check_platform" and method_name != "Result_read" and
647661
not expected_struct in unitary_enums and
648662
((not method_name.startswith("C2Tuple_") and not method_name.startswith("C3Tuple_"))
@@ -1096,6 +1110,36 @@ def map_tuple(struct_name, field_lines):
10961110
write_c("\treturn thing->value;")
10971111
write_c("}")
10981112
map_fn(fn_line + "\n", re.compile("(.*) (TxOut_get_value) \((.*)\)").match(fn_line), None, None, None)
1113+
elif struct_name == "LDKTxIn":
1114+
with open(f"{sys.argv[3]}/structs/TxIn{consts.file_ext}", "w") as out_java_struct:
1115+
out_java_struct.write(consts.hu_struct_file_prefix)
1116+
out_java_struct.write(consts.txin_defn)
1117+
out_java_struct.write(consts.hu_struct_file_suffix)
1118+
fn_line = "struct LDKWitness TxIn_get_witness (struct LDKTxIn* thing)"
1119+
write_c(fn_line + " {")
1120+
write_c("\treturn Witness_clone(&thing->witness);")
1121+
write_c("}")
1122+
map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_witness) \((.*)\)").match(fn_line), None, None, None)
1123+
fn_line = "struct LDKCVec_u8Z TxIn_get_script_sig (struct LDKTxIn* thing)"
1124+
write_c(fn_line + " {")
1125+
write_c("\treturn CVec_u8Z_clone(&thing->script_sig);")
1126+
write_c("}")
1127+
map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_script_sig) \((.*)\)").match(fn_line), None, None, None)
1128+
fn_line = "LDKThirtyTwoBytes TxIn_get_previous_txid (struct LDKTxIn* thing)"
1129+
write_c(fn_line + " {")
1130+
write_c("\treturn thing->previous_txid;")
1131+
write_c("}")
1132+
map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_previous_txid) \((.*)\)").match(fn_line), None, None, None)
1133+
fn_line = "uint32_t TxIn_get_previous_vout (struct LDKTxIn* thing)"
1134+
write_c(fn_line + " {")
1135+
write_c("\treturn thing->previous_vout;")
1136+
write_c("}")
1137+
map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_previous_vout) \((.*)\)").match(fn_line), None, None, None)
1138+
fn_line = "uint32_t TxIn_get_sequence (struct LDKTxIn* thing)"
1139+
write_c(fn_line + " {")
1140+
write_c("\treturn thing->sequence;")
1141+
write_c("}")
1142+
map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_sequence) \((.*)\)").match(fn_line), None, None, None)
10991143
elif struct_name == "LDKBigEndianScalar":
11001144
with open(f"{sys.argv[3]}/structs/BigEndianScalar{consts.file_ext}", "w") as out_java_struct:
11011145
out_java_struct.write(consts.hu_struct_file_prefix)

java_strings.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
1717
uint16_t = ['short'],
1818
uint32_t = ['int'],
1919
uint64_t = ['long'],
20+
int64_t = ['long'],
2021
)
2122
self.java_type_map = dict(
2223
String = "String"
@@ -130,6 +131,38 @@ class CommonBase {
130131
}
131132
}"""
132133

134+
self.txin_defn = """public class TxIn extends CommonBase {
135+
/** The witness in this input, in serialized form */
136+
public final byte[] witness;
137+
/** The script_sig in this input */
138+
public final byte[] script_sig;
139+
/** The transaction output's sequence number */
140+
public final int sequence;
141+
/** The txid this input is spending */
142+
public final byte[] previous_txid;
143+
/** The output index within the spent transaction of the output this input is spending */
144+
public final int previous_vout;
145+
146+
TxIn(java.lang.Object _dummy, long ptr) {
147+
super(ptr);
148+
this.witness = bindings.TxIn_get_witness(ptr);
149+
this.script_sig = bindings.TxIn_get_script_sig(ptr);
150+
this.sequence = bindings.TxIn_get_sequence(ptr);
151+
this.previous_txid = bindings.TxIn_get_previous_txid(ptr);
152+
this.previous_vout = bindings.TxIn_get_previous_vout(ptr);
153+
}
154+
/** Constructs a new TxIn, note that previous_txid must be exactly 32 bytes */
155+
public TxIn(byte[] witness, byte[] script_sig, int sequence, byte[] previous_txid, int previous_vout) {
156+
this(null, bindings.TxIn_new(witness, script_sig, sequence, previous_txid, previous_vout));
157+
}
158+
159+
@Override @SuppressWarnings(\"deprecation\")
160+
protected void finalize() throws Throwable {
161+
super.finalize();
162+
if (ptr != 0) { bindings.TxIn_free(ptr); }
163+
}
164+
}"""
165+
133166
self.scalar_defn = """public class BigEndianScalar extends CommonBase {
134167
/** The bytes of the scalar value, in big endian */
135168
public final byte[] scalar_bytes;

node-net/test/test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const chan_handler = ldk.ErroringMessageHandler.constructor_new().as_ChannelMess
3232
const cust_handler = ldk.IgnoringMessageHandler.constructor_new().as_CustomMessageHandler();
3333
const onion_handler = ldk.IgnoringMessageHandler.constructor_new().as_OnionMessageHandler();
3434

35-
const a_pm = ldk.PeerManager.constructor_new(chan_handler, routing_handler, onion_handler, 0xdeadbeef, rng_seed, logger_a, cust_handler, keys_manager_a.as_NodeSigner());
35+
const a_pm = ldk.PeerManager.constructor_new(chan_handler, routing_handler, onion_handler, cust_handler, 0xdeadbeef, rng_seed, logger_a, keys_manager_a.as_NodeSigner());
3636
const a_net_handler = new node_net.NodeLDKNet(a_pm);
3737
var port = 10000;
3838
for (; port < 11000; port++) {
@@ -43,7 +43,7 @@ for (; port < 11000; port++) {
4343
} catch(_) {}
4444
}
4545

46-
const b_pm = ldk.PeerManager.constructor_new(chan_handler, routing_handler, onion_handler, 0xdeadbeef, rng_seed, logger_b, cust_handler, keys_manager_b.as_NodeSigner());
46+
const b_pm = ldk.PeerManager.constructor_new(chan_handler, routing_handler, onion_handler, cust_handler, 0xdeadbeef, rng_seed, logger_b, keys_manager_b.as_NodeSigner());
4747
const b_net_handler = new node_net.NodeLDKNet(b_pm);
4848
await b_net_handler.connect_peer("127.0.0.1", port, node_a_pk);
4949

0 commit comments

Comments
 (0)