Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
run: |
cargo update -p syn --precise "2.0.106" --verbose
cargo update -p quote --precise "1.0.41" --verbose
cargo update -p libc --precise 0.2.183 --verbose
cargo update -p serde_json --precise "1.0.145" --verbose
cargo update -p proc-macro2 --precise "1.0.103" --verbose
cargo update -p itoa --precise 1.0.15
cargo update -p unicode-ident --precise 1.0.22
cargo update -p ryu --precise "1.0.20"
- name: Sanity test bindings against Cargo.toml RL
working-directory: lightning-c-bindings
run: |
Expand All @@ -54,13 +60,20 @@ jobs:
git checkout 0.1-bindings
cargo update -p syn --precise "2.0.106" --verbose
cargo update -p quote --precise "1.0.41" --verbose
cargo update -p libc --precise 0.2.183 --verbose
cargo update -p serde_json --precise "1.0.145" --verbose
cargo update -p proc-macro2 --precise "1.0.103" --verbose
cargo update -p itoa --precise 1.0.15
cargo update -p unicode-ident --precise 1.0.22
cargo update -p ryu --precise "1.0.20"
- name: Fix Github Actions to not be broken
run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings
- name: Pin proc-macro and quote to meet MSRV
run: |
cd c-bindings-gen
cargo update -p quote --precise "1.0.30" --verbose
cargo update -p proc-macro2 --precise "1.0.65" --verbose
cargo update -p unicode-ident --precise 1.0.22
- name: Rebuild bindings without std, and check the sample app builds + links
run: ./genbindings.sh ./rust-lightning false
- name: Rebuild bindings, and check the sample app builds + links
Expand Down Expand Up @@ -101,6 +114,12 @@ jobs:
run: |
cargo update -p syn --precise "2.0.106" --verbose
cargo update -p quote --precise "1.0.41" --verbose
cargo update -p libc --precise 0.2.183 --verbose
cargo update -p serde_json --precise "1.0.145" --verbose
cargo update -p proc-macro2 --precise "1.0.103" --verbose
cargo update -p itoa --precise 1.0.15
cargo update -p unicode-ident --precise 1.0.22
cargo update -p ryu --precise "1.0.20"
- name: Sanity test bindings against Cargo.toml RL
working-directory: lightning-c-bindings
run: |
Expand All @@ -121,13 +140,20 @@ jobs:
git checkout 0.1-bindings
cargo update -p syn --precise "2.0.106" --verbose
cargo update -p quote --precise "1.0.41" --verbose
cargo update -p libc --precise 0.2.183 --verbose
cargo update -p serde_json --precise "1.0.145" --verbose
cargo update -p proc-macro2 --precise "1.0.103" --verbose
cargo update -p itoa --precise 1.0.15
cargo update -p unicode-ident --precise 1.0.22
cargo update -p ryu --precise "1.0.20"
- name: Fix Github Actions to not be broken
run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings
- name: Pin proc-macro and quote to meet MSRV
run: |
cd c-bindings-gen
cargo update -p quote --precise "1.0.30" --verbose
cargo update -p proc-macro2 --precise "1.0.65" --verbose
cargo update -p unicode-ident --precise 1.0.22
- name: Fetch MacOS SDK
run: |
wget https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
Expand Down
28 changes: 24 additions & 4 deletions lightning-c-bindings/include/lightning.h
Original file line number Diff line number Diff line change
Expand Up @@ -21065,7 +21065,8 @@ typedef struct LDKEvent_LDKPaymentSent_Body {
* If the recipient or an intermediate node misbehaves and gives us free money, this may
* overstate the amount paid, though this is unlikely.
*
* This is only `None` for payments initiated on LDK versions prior to 0.0.103.
* This is only `None` for payments abandoned but ultimately claimed when using LDK versions
* prior to 0.3, 0.2.3, or 0.1.10.
*
* [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
*/
Expand Down Expand Up @@ -29825,6 +29826,10 @@ extern const uintptr_t PAYER_NOTE_LIMIT;

extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT;

extern const uintptr_t CHAN_COUNT_ESTIMATE;

extern const uintptr_t NODE_COUNT_ESTIMATE;

extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA;

extern const uint8_t DEFAULT_MAX_PATH_COUNT;
Expand Down Expand Up @@ -65271,13 +65276,16 @@ MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt11Invoice_payment_metadata(const st
MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11Invoice_features(const struct LDKBolt11Invoice *NONNULL_PTR this_arg);

/**
* Recover the payee's public key (only to be used if none was included in the invoice)
* Get the invoice's payee public key.
*
* This uses the explicitly included payee public key, if present, otherwise it recovers the
* payee public key from the signature. Prefer [`Self::get_payee_pub_key`] for clarity.
*/
MUST_USE_RES struct LDKPublicKey Bolt11Invoice_recover_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg);

/**
* Recover the payee's public key if one was included in the invoice, otherwise return the
* recovered public key from the signature
* Get the invoice's payee public key, preferring an explicitly included payee public key and
* falling back to recovering the key from the signature.
*/
MUST_USE_RES struct LDKPublicKey Bolt11Invoice_get_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg);

Expand Down Expand Up @@ -65625,6 +65633,10 @@ MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetwo
* Sync gossip data from a file.
* Returns the last sync timestamp to be used the next time rapid sync data is queried.
*
* You should consider the gossip data source as semi-trusted. It is generally the case that it
* can DoS the client either by omitting data which leads to pathfinding failure or by bloating
* the graph such that it leads to eventual OOM on the client.
*
* `network_graph`: The network graph to apply the updates to
*
* `sync_path`: Path to the file where the gossip update data is located
Expand All @@ -65636,6 +65648,10 @@ MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_sync_network_g
* Update network graph from binary data.
* Returns the last sync timestamp to be used the next time rapid sync data is queried.
*
* You should consider the gossip data source as semi-trusted. It is generally the case that it
* can DoS the client either by omitting data which leads to pathfinding failure or by bloating
* the graph such that it leads to eventual OOM on the client.
*
* `update_data`: `&[u8]` binary stream that comprises the update data
*/
MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data);
Expand All @@ -65644,6 +65660,10 @@ MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network
* Update network graph from binary data.
* Returns the last sync timestamp to be used the next time rapid sync data is queried.
*
* You should consider the gossip data source as semi-trusted. It is generally the case that it
* can DoS the client either by omitting data which leads to pathfinding failure or by bloating
* the graph such that it leads to eventual OOM on the client.
*
* `update_data`: `&[u8]` binary stream that comprises the update data
* `current_time_unix`: `Option<u64>` optional current timestamp to verify data age
*/
Expand Down
3 changes: 2 additions & 1 deletion lightning-c-bindings/src/lightning/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,8 @@ pub enum Event {
/// If the recipient or an intermediate node misbehaves and gives us free money, this may
/// overstate the amount paid, though this is unlikely.
///
/// This is only `None` for payments initiated on LDK versions prior to 0.0.103.
/// This is only `None` for payments abandoned but ultimately claimed when using LDK versions
/// prior to 0.3, 0.2.3, or 0.1.10.
///
/// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
fee_paid_msat: crate::c_types::derived::COption_u64Z,
Expand Down
14 changes: 14 additions & 0 deletions lightning-c-bindings/src/lightning/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,20 @@ pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice, arg: crate::li
pub extern "C" fn NetworkGraph_to_str(o: &crate::lightning::routing::gossip::NetworkGraph) -> Str {
alloc::format!("{}", o.get_native_ref()).into()
}
/// In Jan, 2025 there were about 49K channels.
///
/// We over-allocate by a bit because 20% more is better than the double we get if we're slightly
/// too low.

#[no_mangle]
pub static CHAN_COUNT_ESTIMATE: usize = lightning::routing::gossip::CHAN_COUNT_ESTIMATE;
/// In Jan, 2025 there were about 15K nodes
///
/// We over-allocate by a bit because 33% more is better than the double we get if we're slightly
/// too low.

#[no_mangle]
pub static NODE_COUNT_ESTIMATE: usize = lightning::routing::gossip::NODE_COUNT_ESTIMATE;
/// Creates a new, empty, network graph.
#[must_use]
#[no_mangle]
Expand Down
9 changes: 6 additions & 3 deletions lightning-c-bindings/src/lightning_invoice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2607,16 +2607,19 @@ pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bo
local_ret
}

/// Recover the payee's public key (only to be used if none was included in the invoice)
/// Get the invoice's payee public key.
///
/// This uses the explicitly included payee public key, if present, otherwise it recovers the
/// payee public key from the signature. Prefer [`Self::get_payee_pub_key`] for clarity.
#[must_use]
#[no_mangle]
pub extern "C" fn Bolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key();
crate::c_types::PublicKey::from_rust(&ret)
}

/// Recover the payee's public key if one was included in the invoice, otherwise return the
/// recovered public key from the signature
/// Get the invoice's payee public key, preferring an explicitly included payee public key and
/// falling back to recovering the key from the signature.
#[must_use]
#[no_mangle]
pub extern "C" fn Bolt11Invoice_get_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey {
Expand Down
12 changes: 12 additions & 0 deletions lightning-c-bindings/src/lightning_rapid_gossip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ pub extern "C" fn RapidGossipSync_new(network_graph: &crate::lightning::routing:
/// Sync gossip data from a file.
/// Returns the last sync timestamp to be used the next time rapid sync data is queried.
///
/// You should consider the gossip data source as semi-trusted. It is generally the case that it
/// can DoS the client either by omitting data which leads to pathfinding failure or by bloating
/// the graph such that it leads to eventual OOM on the client.
///
/// `network_graph`: The network graph to apply the updates to
///
/// `sync_path`: Path to the file where the gossip update data is located
Expand All @@ -283,6 +287,10 @@ pub extern "C" fn RapidGossipSync_sync_network_graph_with_file_path(this_arg: &c
/// Update network graph from binary data.
/// Returns the last sync timestamp to be used the next time rapid sync data is queried.
///
/// You should consider the gossip data source as semi-trusted. It is generally the case that it
/// can DoS the client either by omitting data which leads to pathfinding failure or by bloating
/// the graph such that it leads to eventual OOM on the client.
///
/// `update_data`: `&[u8]` binary stream that comprises the update data
#[must_use]
#[no_mangle]
Expand All @@ -295,6 +303,10 @@ pub extern "C" fn RapidGossipSync_update_network_graph(this_arg: &crate::lightni
/// Update network graph from binary data.
/// Returns the last sync timestamp to be used the next time rapid sync data is queried.
///
/// You should consider the gossip data source as semi-trusted. It is generally the case that it
/// can DoS the client either by omitting data which leads to pathfinding failure or by bloating
/// the graph such that it leads to eventual OOM on the client.
///
/// `update_data`: `&[u8]` binary stream that comprises the update data
/// `current_time_unix`: `Option<u64>` optional current timestamp to verify data age
#[must_use]
Expand Down
12 changes: 12 additions & 0 deletions lightning-c-bindings/src/lightning_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ pub mod features;
pub mod payment;
pub mod routing;
pub mod string;
mod unicode {

use alloc::str::FromStr;
use alloc::string::String;
use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
#[cfg(feature="no-std")]
use alloc::{vec::Vec, boxed::Box};

}
Loading