Skip to content

Commit e335f0b

Browse files
authored
Merge pull request #230 from tnull/2024-01-upgrade-uniffi-to-0.26
Upgrade UniFFI to 0.26.0
2 parents c755eee + 9026795 commit e335f0b

File tree

13 files changed

+28
-75
lines changed

13 files changed

+28
-75
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ futures = "0.3"
6565
tokio = { version = "1", default-features = false, features = [ "rt-multi-thread", "time", "sync" ] }
6666
esplora-client = { version = "0.6", default-features = false }
6767
libc = "0.2"
68-
uniffi = { version = "0.25.1", features = ["build"], optional = true }
68+
uniffi = { version = "0.26.0", features = ["build"], optional = true }
6969

7070
[target.'cfg(vss)'.dependencies]
7171
vss-client = "0.2"
@@ -92,7 +92,7 @@ electrsd = { version = "0.26.0", features = ["legacy"] }
9292
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
9393

9494
[build-dependencies]
95-
uniffi = { version = "0.25.1", features = ["build"], optional = true }
95+
uniffi = { version = "0.26.0", features = ["build"], optional = true }
9696

9797
[profile.release]
9898
panic = "abort"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ LDK Node is a self-custodial Lightning node in library form. Its central goal is
1414
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send_payment`, etc.
1515

1616
```rust
17-
use ldk_node::{Builder, Network};
17+
use ldk_node::Builder;
1818
use ldk_node::lightning_invoice::Bolt11Invoice;
1919
use ldk_node::lightning::ln::msgs::SocketAddress;
2020
use ldk_node::bitcoin::secp256k1::PublicKey;
21+
use ldk_node::bitcoin::Network;
2122
use std::str::FromStr;
2223

2324
fn main() {

bindings/kotlin/ldk-node-android/lib/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616
}
1717

1818
android {
19-
compileSdk = 31
19+
compileSdk = 33
2020

2121
defaultConfig {
2222
minSdk = 21
@@ -41,7 +41,7 @@ android {
4141
}
4242

4343
dependencies {
44-
implementation("net.java.dev.jna:jna:5.8.0@aar")
44+
implementation("net.java.dev.jna:jna:5.12.0@aar")
4545
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7")
4646
implementation("androidx.appcompat:appcompat:1.4.0")
4747
implementation("androidx.core:core-ktx:1.7.0")
@@ -50,7 +50,7 @@ dependencies {
5050
androidTestImplementation("com.github.tony19:logback-android:2.0.0")
5151
androidTestImplementation("androidx.test.ext:junit:1.1.3")
5252
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
53-
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1")
53+
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
5454
androidTestImplementation("org.jetbrains.kotlin:kotlin-test-junit")
5555
}
5656

bindings/kotlin/ldk-node-jvm/lib/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ dependencies {
4747
// Use the Kotlin JDK 8 standard library.
4848
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
4949

50-
implementation("net.java.dev.jna:jna:5.8.0")
50+
implementation("net.java.dev.jna:jna:5.12.0")
5151
}
5252

5353
tasks.named<Test>("test") {

bindings/ldk_node.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ enum PaymentStatus {
165165
"Failed",
166166
};
167167

168+
[NonExhaustive]
168169
enum Network {
169170
"Bitcoin",
170171
"Testnet",

bindings/uniffi-bindgen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
uniffi = { version = "0.25.1", features = ["cli"] }
9+
uniffi = { version = "0.26.0", features = ["cli"] }

scripts/uniffi_bindgen_generate_kotlin_android.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-android
3838
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
3939
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
4040
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
41-
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language kotlin -o "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin || exit 1
41+
$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
4242

4343
JNI_LIB_DIR="$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/jniLibs/
4444
mkdir -p $JNI_LIB_DIR/x86_64 || exit 1

src/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::peer_store::PeerStore;
99
use crate::sweep::OutputSweeper;
1010
use crate::tx_broadcaster::TransactionBroadcaster;
1111
use crate::types::{
12-
ChainMonitor, ChannelManager, FakeMessageRouter, GossipSync, KeysManager, Network,
13-
NetworkGraph, OnionMessenger, PeerManager,
12+
ChainMonitor, ChannelManager, FakeMessageRouter, GossipSync, KeysManager, NetworkGraph,
13+
OnionMessenger, PeerManager,
1414
};
1515
use crate::wallet::Wallet;
1616
use crate::LogLevel;
@@ -49,7 +49,7 @@ use bdk::template::Bip84;
4949

5050
use bip39::Mnemonic;
5151

52-
use bitcoin::BlockHash;
52+
use bitcoin::{BlockHash, Network};
5353

5454
#[cfg(any(vss, vss_test))]
5555
use bitcoin::bip32::ChildNumber;

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
//! [`send_payment`], etc.:
2727
//!
2828
//! ```no_run
29-
//! use ldk_node::{Builder, Network};
29+
//! use ldk_node::Builder;
3030
//! use ldk_node::lightning_invoice::Bolt11Invoice;
3131
//! use ldk_node::lightning::ln::msgs::SocketAddress;
32+
//! use ldk_node::bitcoin::Network;
3233
//! use ldk_node::bitcoin::secp256k1::PublicKey;
3334
//! use std::str::FromStr;
3435
//!
@@ -122,7 +123,7 @@ use types::{
122123
Broadcaster, ChainMonitor, ChannelManager, FeeEstimator, KeysManager, NetworkGraph,
123124
PeerManager, Router, Scorer, Sweeper, Wallet,
124125
};
125-
pub use types::{ChannelDetails, Network, PeerDetails, UserChannelId};
126+
pub use types::{ChannelDetails, PeerDetails, UserChannelId};
126127

127128
use logger::{log_error, log_info, log_trace, FilesystemLogger, Logger};
128129

@@ -148,7 +149,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
148149
use bitcoin::hashes::Hash;
149150
use bitcoin::secp256k1::PublicKey;
150151

151-
use bitcoin::{Address, Txid};
152+
use bitcoin::{Address, Network, Txid};
152153

153154
use rand::Rng;
154155

@@ -1494,7 +1495,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
14941495
fn receive_payment_inner(
14951496
&self, amount_msat: Option<u64>, description: &str, expiry_secs: u32,
14961497
) -> Result<Bolt11Invoice, Error> {
1497-
let currency = Currency::from(bitcoin::Network::from(self.config.network));
1498+
let currency = Currency::from(self.config.network);
14981499
let keys_manager = Arc::clone(&self.keys_manager);
14991500
let invoice = match lightning_invoice::utils::create_invoice_from_channelmanager(
15001501
&self.channel_manager,
@@ -1547,7 +1548,8 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
15471548
///
15481549
/// For example, you could retrieve all stored outbound payments as follows:
15491550
/// ```
1550-
/// # use ldk_node::{Builder, Config, Network, PaymentDirection};
1551+
/// # use ldk_node::{Builder, Config, PaymentDirection};
1552+
/// # use ldk_node::bitcoin::Network;
15511553
/// # let mut config = Config::default();
15521554
/// # config.network = Network::Regtest;
15531555
/// # config.storage_dir_path = "/tmp/ldk_node_test/".to_string();

src/types.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use lightning_transaction_sync::EsploraSyncClient;
2121
use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
2222
use bitcoin::OutPoint;
2323

24-
use std::fmt;
25-
use std::str::FromStr;
2624
use std::sync::{Arc, Mutex, RwLock};
2725

2826
pub(crate) type ChainMonitor<K> = chainmonitor::ChainMonitor<
@@ -139,58 +137,6 @@ pub(crate) type Sweeper<K> = OutputSweeper<
139137
Arc<FilesystemLogger>,
140138
>;
141139

142-
/// The cryptocurrency network to act on.
143-
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Clone, Hash, Debug)]
144-
pub enum Network {
145-
/// Mainnet Bitcoin.
146-
Bitcoin,
147-
/// Bitcoin's testnet network.
148-
Testnet,
149-
/// Bitcoin's signet network.
150-
Signet,
151-
/// Bitcoin's regtest network.
152-
Regtest,
153-
}
154-
155-
impl TryFrom<bitcoin::Network> for Network {
156-
type Error = ();
157-
158-
fn try_from(network: bitcoin::Network) -> Result<Self, Self::Error> {
159-
match network {
160-
bitcoin::Network::Bitcoin => Ok(Self::Bitcoin),
161-
bitcoin::Network::Testnet => Ok(Self::Testnet),
162-
bitcoin::Network::Signet => Ok(Self::Signet),
163-
bitcoin::Network::Regtest => Ok(Self::Regtest),
164-
_ => Err(()),
165-
}
166-
}
167-
}
168-
169-
impl From<Network> for bitcoin::Network {
170-
fn from(network: Network) -> Self {
171-
match network {
172-
Network::Bitcoin => bitcoin::Network::Bitcoin,
173-
Network::Testnet => bitcoin::Network::Testnet,
174-
Network::Signet => bitcoin::Network::Signet,
175-
Network::Regtest => bitcoin::Network::Regtest,
176-
}
177-
}
178-
}
179-
180-
impl fmt::Display for Network {
181-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
182-
bitcoin::Network::from(*self).fmt(f)
183-
}
184-
}
185-
186-
impl FromStr for Network {
187-
type Err = ();
188-
189-
fn from_str(s: &str) -> Result<Self, Self::Err> {
190-
bitcoin::Network::from_str(s).map_err(|_| ())?.try_into()
191-
}
192-
}
193-
194140
/// A local, potentially user-provided, identifier of a channel.
195141
///
196142
/// By default, this will be randomly generated for the user to ensure local uniqueness.

0 commit comments

Comments
 (0)