Skip to content

Commit 1c42b23

Browse files
authored
Merge pull request #84 from TheBlueMatt/main
0.0.109 Support
2 parents 5768b0e + 1eda66a commit 1c42b23

File tree

18 files changed

+1418
-353
lines changed

18 files changed

+1418
-353
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
git clone https://github.com/rust-bitcoin/rust-lightning
3939
cd rust-lightning
40-
git checkout 0.0.108-bindings
40+
git checkout 0.0.109-bindings
4141
- name: Rebuild bindings without std, and check the sample app builds + links
4242
run: ./genbindings.sh ./rust-lightning false
4343
- name: Rebuild bindings, and check the sample app builds + links
@@ -88,7 +88,7 @@ jobs:
8888
run: |
8989
git clone https://github.com/rust-bitcoin/rust-lightning
9090
cd rust-lightning
91-
git checkout 0.0.108-bindings
91+
git checkout 0.0.109-bindings
9292
- name: Rebuild bindings using Apple clang, and check the sample app builds + links
9393
run: ./genbindings.sh ./rust-lightning true
9494
- name: Rebuild bindings using upstream clang, and check the sample app builds + links

c-bindings-gen/src/types.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,12 +1477,18 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14771477
}
14781478
if let Some(t) = single_contained {
14791479
if let syn::Type::Tuple(syn::TypeTuple { elems, .. }) = t {
1480-
assert!(elems.is_empty());
14811480
let inner_name = self.get_c_mangled_container_type(vec![single_contained.unwrap()], generics, "Option").unwrap();
1482-
return Some(("if ", vec![
1483-
(format!(".is_none() {{ {}::None }} else {{ {}::Some /*",
1484-
inner_name, inner_name), format!(""))
1485-
], " */}", ContainerPrefixLocation::PerConv));
1481+
if elems.is_empty() {
1482+
return Some(("if ", vec![
1483+
(format!(".is_none() {{ {}::None }} else {{ {}::Some /* ",
1484+
inner_name, inner_name), format!(""))
1485+
], " */ }", ContainerPrefixLocation::PerConv));
1486+
} else {
1487+
return Some(("if ", vec![
1488+
(format!(".is_none() {{ {}::None }} else {{ {}::Some(",
1489+
inner_name, inner_name), format!("({}.unwrap())", var_access))
1490+
], ") }", ContainerPrefixLocation::PerConv));
1491+
}
14861492
}
14871493
if let syn::Type::Reference(syn::TypeReference { elem, .. }) = t {
14881494
if let syn::Type::Slice(_) = &**elem {
@@ -2039,6 +2045,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
20392045
write!(w, "{}", sliceconv(false, None)).unwrap();
20402046
}
20412047
}
2048+
} else if let syn::Type::Array(_) = &*s.elem {
2049+
write!(w, "{}", sliceconv(false, Some(".map(|a| *a)"))).unwrap();
20422050
} else { unimplemented!(); }
20432051
},
20442052
syn::Type::Tuple(t) => {
@@ -2391,6 +2399,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
23912399
ptr_for_ref = true;
23922400
convert_container!("Slice", 1, || ty.iter());
23932401
unimplemented!("convert_container should return true as container_lookup should succeed for slices");
2402+
} else if let syn::Type::Array(_) = &*s.elem {
2403+
is_ref = false;
2404+
ptr_for_ref = true;
2405+
let arr_elem = [(*s.elem).clone()];
2406+
convert_container!("Slice", 1, || arr_elem.iter());
2407+
unimplemented!("convert_container should return true as container_lookup should succeed for slices");
23942408
} else { unimplemented!() }
23952409
},
23962410
syn::Type::Tuple(t) => {
@@ -2901,6 +2915,22 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
29012915
let mut segments = syn::punctuated::Punctuated::new();
29022916
segments.push(parse_quote!(Vec<#args>));
29032917
self.write_c_type_intern(w, &syn::Type::Path(syn::TypePath { qself: None, path: syn::Path { leading_colon: None, segments } }), generics, false, is_mut, ptr_for_ref, with_ref_lifetime, c_ty)
2918+
} else if let syn::Type::Array(a) = &*s.elem {
2919+
if let syn::Expr::Lit(l) = &a.len {
2920+
if let syn::Lit::Int(i) = &l.lit {
2921+
let mut buf = Vec::new();
2922+
self.write_rust_type(&mut buf, generics, &*a.elem, false);
2923+
let arr_ty = String::from_utf8(buf).unwrap();
2924+
2925+
let arr_str = format!("[{}; {}]", arr_ty, i.base10_digits());
2926+
let ty = self.c_type_from_path(&arr_str, false, ptr_for_ref).unwrap()
2927+
.rsplitn(2, "::").next().unwrap();
2928+
2929+
let mangled_container = format!("CVec_{}Z", ty);
2930+
write!(w, "{}::{}", Self::generated_container_path(), mangled_container).unwrap();
2931+
self.check_create_container(mangled_container, "Vec", vec![&*s.elem], generics, false)
2932+
} else { false }
2933+
} else { false }
29042934
} else { false }
29052935
},
29062936
syn::Type::Tuple(t) => {

lightning-c-bindings/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ std = ["bitcoin/std", "lightning/std", "lightning-invoice/std"]
2222
bitcoin = { version = "0.28", default-features = false }
2323
secp256k1 = { version = "0.22", features = ["global-context", "recovery"] }
2424
# Note that the following line is matched by genbindings to update the path
25-
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.108-bindings", default-features = false }
26-
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.108-bindings", default-features = false }
27-
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.108-bindings", default-features = false }
28-
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.108-bindings", default-features = false }
29-
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.108-bindings", default-features = false }
25+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.109-bindings", default-features = false }
26+
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.109-bindings", default-features = false }
27+
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.109-bindings", default-features = false }
28+
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.109-bindings", default-features = false }
29+
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.109-bindings", default-features = false }
3030

3131
core2 = { version = "0.3.0", optional = true, default-features = false }
3232

lightning-c-bindings/demo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ int main() {
555555
LDK::ChannelHandshakeConfig handshake_config2 = ChannelHandshakeConfig_default();
556556
ChannelHandshakeConfig_set_minimum_depth(&handshake_config2, 2);
557557
LDK::UserConfig config2 = UserConfig_default();
558-
UserConfig_set_own_channel_config(&config2, std::move(handshake_config2));
558+
UserConfig_set_channel_handshake_config(&config2, std::move(handshake_config2));
559559

560560
LDK::ChannelManager cm2 = ChannelManager_new(fee_est, mon2, broadcast, logger2, KeysManager_as_KeysInterface(&keys2), std::move(config2), ChainParameters_new(network, BestBlock_new(chain_tip, 0)));
561561

@@ -711,7 +711,7 @@ int main() {
711711
LDK::RouteParameters route_params = RouteParameters_new(PaymentParameters_new(
712712
ChannelManager_get_our_node_id(&cm2), LDKInvoiceFeatures {
713713
.inner = NULL, .is_owned = false
714-
}, Invoice_route_hints(invoice->contents.result), COption_u64Z_none(), 0xffffffff),
714+
}, Invoice_route_hints(invoice->contents.result), COption_u64Z_none(), 0xffffffff, 1),
715715
5000, Invoice_min_final_cltv_expiry(invoice->contents.result));
716716
random_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg);
717717

lightning-c-bindings/include/ldk_rust_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ struct nativeRoutingFeesOpaque;
9696
typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees;
9797
struct nativeNodeAnnouncementInfoOpaque;
9898
typedef struct nativeNodeAnnouncementInfoOpaque LDKnativeNodeAnnouncementInfo;
99+
struct nativeNodeAliasOpaque;
100+
typedef struct nativeNodeAliasOpaque LDKnativeNodeAlias;
99101
struct nativeNodeInfoOpaque;
100102
typedef struct nativeNodeInfoOpaque LDKnativeNodeInfo;
101103
struct nativeDelayedPaymentOutputDescriptorOpaque;

0 commit comments

Comments
 (0)