Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thr
esplora-client = { version = "0.12", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.24.0", default-features = false, features = ["proxy", "use-rustls-ring"] }
libc = "0.2"
uniffi = { version = "0.28.3", features = ["build"], optional = true }
uniffi = { version = "0.29.5", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
serde_json = { version = "1.0.128", default-features = false, features = ["std"] }
log = { version = "0.4.22", default-features = false, features = ["std"]}

async-trait = { version = "0.1", default-features = false }
vss-client = { package = "vss-client-ng", version = "0.5" }
prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.6" }
Expand Down Expand Up @@ -106,7 +107,7 @@ lnd_grpc_rust = { version = "2.10.0", default-features = false }
tokio = { version = "1.37", features = ["fs"] }

[build-dependencies]
uniffi = { version = "0.28.3", features = ["build"], optional = true }
uniffi = { version = "0.29.5", features = ["build"], optional = true }

[profile.release]
panic = "abort"
Expand Down
66 changes: 24 additions & 42 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ enum WordCount {
"Words24",
};

[Remote]
enum LogLevel {
"Gossip",
"Trace",
Expand Down Expand Up @@ -281,6 +282,7 @@ interface OnchainPayment {
Txid bump_fee_rbf(PaymentId payment_id, FeeRate? fee_rate);
};

[Remote]
interface FeeRate {
[Name=from_sat_per_kwu]
constructor(u64 sat_kwu);
Expand Down Expand Up @@ -377,6 +379,7 @@ dictionary NodeStatus {
u64? latest_node_announcement_broadcast_timestamp;
};

[Remote]
dictionary BestBlock {
BlockHash block_hash;
u32 height;
Expand All @@ -400,35 +403,21 @@ enum BuildError {
"AsyncPaymentsConfigMismatch",
};

[Trait]
[Trait, WithForeign]
interface VssHeaderProvider {
[Async, Throws=VssHeaderProviderError]
record<string, string> get_headers([ByRef]sequence<u8> request);
record<string, string> get_headers(sequence<u8> request);
};

[Error]
enum VssHeaderProviderError {
"InvalidData",
"RequestError",
"AuthorizationError",
"InternalError",
};

[Enum]
interface Event {
PaymentSuccessful(PaymentId? payment_id, PaymentHash payment_hash, PaymentPreimage? payment_preimage, u64? fee_paid_msat);
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, OutPoint? funding_txo);
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
SplicePending(ChannelId channel_id, UserChannelId user_channel_id, PublicKey counterparty_node_id, OutPoint new_funding_txo);
SpliceFailed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey counterparty_node_id, OutPoint? abandoned_funding_txo);
interface VssHeaderProviderError {
InvalidData(string error);
RequestError(string error);
AuthorizationError(string error);
InternalError(string error);
};

[Remote]
enum PaymentFailureReason {
"RecipientRejected",
"UserAbandoned",
Expand All @@ -442,25 +431,6 @@ enum PaymentFailureReason {
"BlindedPathCreationFailed",
};

[Enum]
interface ClosureReason {
CounterpartyForceClosed(UntrustedString peer_msg);
HolderForceClosed(boolean? broadcasted_latest_txn, string message);
LegacyCooperativeClosure();
CounterpartyInitiatedCooperativeClosure();
LocallyInitiatedCooperativeClosure();
CommitmentTxConfirmed();
FundingTimedOut();
ProcessingError(string err);
DisconnectedPeer();
OutdatedChannelManager();
CounterpartyCoopClosedUnfundedChannel();
LocallyCoopClosedUnfundedChannel();
FundingBatchClosure();
HTLCsTimedOut( PaymentHash? payment_hash );
PeerFeerateTooLow(u32 peer_feerate_sat_per_kw, u32 required_feerate_sat_per_kw);
};

[Enum]
interface PaymentKind {
Onchain(Txid txid, ConfirmationStatus status);
Expand Down Expand Up @@ -510,6 +480,7 @@ dictionary PaymentDetails {
u64 latest_update_timestamp;
};

[Remote]
dictionary RouteParametersConfig {
u64? max_total_routing_fee_msat;
u32 max_total_cltv_expiry_delta;
Expand All @@ -522,13 +493,15 @@ dictionary CustomTlvRecord {
sequence<u8> value;
};

[Remote]
dictionary LSPS1OrderStatus {
LSPS1OrderId order_id;
LSPS1OrderParams order_params;
LSPS1PaymentInfo payment_options;
LSPS1ChannelInfo? channel_state;
};

[Remote]
dictionary LSPS1OrderParams {
u64 lsp_balance_sat;
u64 client_balance_sat;
Expand Down Expand Up @@ -563,26 +536,29 @@ dictionary LSPS1OnchainPaymentInfo {
Address? refund_onchain_address;
};

[Remote]
dictionary LSPS1ChannelInfo {
LSPSDateTime funded_at;
OutPoint funding_outpoint;
LSPSDateTime expires_at;
};

[Remote]
enum LSPS1PaymentState {
"ExpectPayment",
"Paid",
"Refunded",
};

[NonExhaustive]
[Remote, NonExhaustive]
enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};

[Remote]
dictionary OutPoint {
Txid txid;
u32 vout;
Expand Down Expand Up @@ -679,6 +655,7 @@ interface LightningBalance {
);
};

[Remote]
enum BalanceSource {
"HolderForceClosed",
"CounterpartyForceClosed",
Expand Down Expand Up @@ -741,6 +718,7 @@ dictionary ChannelUpdateInfo {
RoutingFees fees;
};

[Remote]
dictionary RoutingFees {
u32 base_msat;
u32 proportional_millionths;
Expand All @@ -757,6 +735,7 @@ dictionary NodeAnnouncementInfo {
sequence<SocketAddress> addresses;
};

[Remote]
enum Currency {
"Bitcoin",
"BitcoinTestnet",
Expand Down Expand Up @@ -929,3 +908,6 @@ typedef string LSPSDateTime;

[Custom]
typedef string ScriptBuf;

typedef enum ClosureReason;
typedef enum Event;
2 changes: 1 addition & 1 deletion bindings/uniffi-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
uniffi = { version = "0.28.3", features = ["cli"] }
uniffi = { version = "0.29.5", features = ["cli"] }
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_kotlin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ else
fi

mkdir -p "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR" || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language kotlin -o "$TARGET_DIR" || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --lib-file "$DYNAMIC_LIB_PATH" --language kotlin -o "$TARGET_DIR" || exit 1

cp "$TARGET_DIR"/"$PACKAGE_DIR"/ldk_node.kt "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR"/ || exit 1
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_kotlin_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-android
RUSTFLAGS="-C link-args=-Wl,-z,max-page-size=16384,-z,common-page-size=16384" CFLAGS="-D__ANDROID_MIN_SDK_VERSION__=21" AR=llvm-ar CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="x86_64-linux-android21-clang" CC="x86_64-linux-android21-clang" cargo build --profile release-smaller --features uniffi --target x86_64-linux-android || exit 1
RUSTFLAGS="-C link-args=-Wl,-z,max-page-size=16384,-z,common-page-size=16384" CFLAGS="-D__ANDROID_MIN_SDK_VERSION__=21" AR=llvm-ar CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="armv7a-linux-androideabi21-clang" CC="armv7a-linux-androideabi21-clang" cargo build --profile release-smaller --features uniffi --target armv7-linux-androideabi || exit 1
RUSTFLAGS="-C link-args=-Wl,-z,max-page-size=16384,-z,common-page-size=16384" CFLAGS="-D__ANDROID_MIN_SDK_VERSION__=21" AR=llvm-ar CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android21-clang" CC="aarch64-linux-android21-clang" cargo build --profile release-smaller --features uniffi --target aarch64-linux-android || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language kotlin --config uniffi-android.toml -o "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --lib-file "$TARGET_DIR"/x86_64-linux-android/release-smaller/libldk_node.so --language kotlin --config uniffi-android.toml -o "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin || exit 1

JNI_LIB_DIR="$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/jniLibs/
mkdir -p $JNI_LIB_DIR/x86_64 || exit 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ else
fi

cargo build --profile release-smaller --features uniffi || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language python -o "$BINDINGS_DIR" || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --lib-file "$DYNAMIC_LIB_PATH" --language python -o "$BINDINGS_DIR" || exit 1

mkdir -p $BINDINGS_DIR
cp "$DYNAMIC_LIB_PATH" "$BINDINGS_DIR" || exit 1
5 changes: 1 addition & 4 deletions scripts/uniffi_bindgen_generate_swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ set -eox pipefail
BINDINGS_DIR="./bindings/swift"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"

cargo build --release || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR" || exit 1

mkdir -p $BINDINGS_DIR

# Install rust target toolchains
Expand All @@ -30,7 +27,7 @@ lipo target/aarch64-apple-ios-sim/release/libldk_node.a target/x86_64-apple-ios/
mkdir -p target/lipo-macos/release-smaller || exit 1
lipo target/aarch64-apple-darwin/release-smaller/libldk_node.a target/x86_64-apple-darwin/release-smaller/libldk_node.a -create -output target/lipo-macos/release-smaller/libldk_node.a || exit 1

$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR" || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --lib-file target/release-smaller/libldk_node.a --language swift -o "$BINDINGS_DIR" || exit 1

swiftc -module-name LDKNode -emit-library -o "$BINDINGS_DIR"/libldk_node.dylib -emit-module -emit-module-path "$BINDINGS_DIR" -parse-as-library -L ./target/release-smaller -lldk_node -Xcc -fmodule-map-file="$BINDINGS_DIR"/LDKNodeFFI.modulemap "$BINDINGS_DIR"/LDKNode.swift -v || exit 1

Expand Down
10 changes: 3 additions & 7 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,17 +1026,13 @@ impl ArcedNodeBuilder {
/// [VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md
pub fn build_with_vss_store_and_header_provider(
&self, node_entropy: Arc<NodeEntropy>, vss_url: String, store_id: String,
header_provider: Arc<dyn VssHeaderProvider>,
header_provider: Arc<dyn crate::ffi::VssHeaderProvider>,
) -> Result<Arc<Node>, BuildError> {
let adapter = Arc::new(crate::ffi::VssHeaderProviderAdapter::new(header_provider));
self.inner
.read()
.unwrap()
.build_with_vss_store_and_header_provider(
*node_entropy,
vss_url,
store_id,
header_provider,
)
.build_with_vss_store_and_header_provider(*node_entropy, vss_url, store_id, adapter)
.map(Arc::new)
}

Expand Down
1 change: 1 addition & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use crate::{
///
/// [`Node`]: [`crate::Node`]
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
pub enum Event {
/// A sent payment was successful.
PaymentSuccessful {
Expand Down
Loading