Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BdkActor #750

Closed
wants to merge 2 commits into from
Closed
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
41 changes: 40 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ lightning-transaction-sync = { git = "https://github.com/get10101/rust-lightning
lightning-net-tokio = { git = "https://github.com/get10101/rust-lightning/", rev = "5aa1449c" }
lightning-persister = { git = "https://github.com/get10101/rust-lightning/", rev = "5aa1449c" }
rust-bitcoin-coin-selection = { git = "https://github.com/p2pderivatives/rust-bitcoin-coin-selection" }
xtra = { git = "https://github.com/Restioson/xtra", rev = "d98393a" }
29 changes: 15 additions & 14 deletions coordinator/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ pub struct Balance {

#[autometrics]
pub async fn get_balance(State(state): State<Arc<AppState>>) -> Result<Json<Balance>, AppError> {
spawn_blocking(move || {
let offchain = state.node.inner.get_ldk_balance();
let onchain =
state.node.inner.get_on_chain_balance().map_err(|e| {
AppError::InternalServerError(format!("Failed to get balance: {e:#}"))
})?;

Ok(Json(Balance {
offchain: offchain.available,
onchain: onchain.confirmed,
}))
})
.await
.map_err(|e| AppError::InternalServerError(format!("Failed to get balance: {e:#}")))?
let onchain = state
.node
.inner
.get_on_chain_balance()
.await
.map_err(|e| AppError::InternalServerError(format!("Failed to get balance: {e:#}")))?;

let offchain = spawn_blocking(move || state.node.inner.get_ldk_balance())
.await
.map_err(|e| AppError::InternalServerError(format!("Failed to get balance: {e:#}")))?;

Ok(Json(Balance {
offchain: offchain.available,
onchain: onchain.confirmed,
}))
}

#[autometrics]
Expand Down
5 changes: 3 additions & 2 deletions coordinator/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub async fn get_new_address(
State(app_state): State<Arc<AppState>>,
) -> Result<Json<String>, AppError> {
let address =
app_state.node.inner.get_new_address().map_err(|e| {
app_state.node.inner.get_new_address().await.map_err(|e| {
AppError::InternalServerError(format!("Failed to get new address: {e:#}"))
})?;
Ok(Json(address.to_string()))
Expand Down Expand Up @@ -359,7 +359,8 @@ async fn update_settings(
.node
.inner
.update_settings(updated_settings.ln_dlc)
.await;
.await
.map_err(|e| AppError::InternalServerError(format!("Could not write settings: {e:#}")))?;

Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions crates/ln-dlc-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = "A common interface for using Lightning and DLC channels side-by-s

[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
async-trait = "0.1.68"
autometrics = "0.5"
bdk = { version = "0.27.0", default-features = false, features = ["key-value-db", "use-esplora-blocking"] }
bip39 = { version = "2", features = ["rand_core"] }
Expand Down Expand Up @@ -42,6 +43,7 @@ tokio = { version = "1", default-features = false, features = ["io-util", "macro
tracing = "0.1.37"
tracing-log = "0.1.3"
ureq = "2.5.0"
xtra = { version = "0.6", features = ["instrumentation", "sink"] }

[dev-dependencies]
clap = { version = "4", features = ["derive"] }
Expand Down
Loading