Skip to content

Commit

Permalink
Merge pull request #1094 from get10101/feat/wumbo-trade
Browse files Browse the repository at this point in the history
Wumbo trade: aka configurable channel size
  • Loading branch information
bonomat authored Aug 17, 2023
2 parents a92bb4c + 7c34d80 commit 7982b85
Show file tree
Hide file tree
Showing 22 changed files with 771 additions and 509 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

- Add support for push notifications
- Added new setting to coordinator to configure max channel size to traders

## [1.2.0] - 2023-08-04

Expand Down
123 changes: 106 additions & 17 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion coordinator/src/bin/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ async fn main() -> Result<()> {
opts.get_oracle_info().into(),
)?);

let event_handler = CoordinatorEventHandler::new(node.clone(), Some(node_event_sender));
let event_handler = CoordinatorEventHandler::new(
node.clone(),
Some(node_event_sender),
settings.ln_dlc.max_app_channel_size_sats,
);
let running = node.start(event_handler)?;
let node = Node::new(node, running, pool.clone(), settings.to_node_settings());

Expand Down
11 changes: 11 additions & 0 deletions coordinator/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use axum::Json;
use axum::Router;
use bitcoin::secp256k1::PublicKey;
use bitcoin::Network;
use coordinator_commons::LspConfig;
use coordinator_commons::RegisterParams;
use coordinator_commons::TradeParams;
use diesel::r2d2::ConnectionManager;
Expand Down Expand Up @@ -115,6 +116,7 @@ pub fn router(
.route("/api/admin/balance", get(get_balance))
.route("/api/admin/channels", get(list_channels).post(open_channel))
.route("/api/channels", post(channel_faucet))
.route("/api/lsp/config", get(get_lsp_channel_config))
.route("/api/admin/channels/:channel_id", delete(close_channel))
.route("/api/admin/peers", get(list_peers))
.route("/api/admin/send_payment/:invoice", post(send_payment))
Expand Down Expand Up @@ -313,6 +315,15 @@ pub async fn post_register(
Ok(())
}

pub async fn get_lsp_channel_config(
State(state): State<Arc<AppState>>,
) -> Result<Json<LspConfig>, AppError> {
let settings = state.settings.read().await;
Ok(Json(LspConfig {
max_channel_value_satoshi: settings.ln_dlc.max_app_channel_size_sats,
}))
}

/// Open a channel directly between the coordinator and the target
/// specified in [`ChannelParams`].
///
Expand Down
7 changes: 7 additions & 0 deletions crates/coordinator-commons/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ impl RegisterParams {
self.email.is_some() || self.nostr.is_some()
}
}

/// LSP channel details
#[derive(Serialize, Deserialize)]
pub struct LspConfig {
/// The maximum size a new channel may have
pub max_channel_value_satoshi: u64,
}
1 change: 1 addition & 0 deletions crates/ln-dlc-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ reqwest = { version = "0.11", default-features = false, features = ["json"] }
rust-bitcoin-coin-selection = { version = "0.1.0", features = ["rand"] }
secp256k1-zkp = { version = "0.7.0", features = ["global-context"] }
serde = "1.0.147"
serde_with = "3.1.0"
sha2 = "0.10"
simple-wallet = "0.1.0"
time = "0.3"
Expand Down
12 changes: 0 additions & 12 deletions crates/ln-dlc-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ use lightning::util::config::ChannelHandshakeLimits;
use lightning::util::config::UserConfig;
use std::time::Duration;

/// When handling the [`Event::HTLCIntercepted`], we may need to
/// create a new channel with the recipient of the HTLC. If the
/// payment is small enough (< 1000 sats), opening the channel will
/// fail unless we provide more outbound liquidity.
///
/// This value defines the maximum channel amount between the coordinator and a user that opens a
/// channel through an interceptable invoice. Channels that exceed this amount will be rejected.
/// This value is completely arbitrary.
///
/// This constant only applies to the coordinator.
pub const JUST_IN_TIME_CHANNEL_OUTBOUND_LIQUIDITY_SAT_MAX: u64 = 200_000;

/// The multiplier to be used by the coordinator to define the just in time channel liquidity
///
/// The liquidity provided by the trader will be multiplied with this value to defined the channel
Expand Down
1 change: 0 additions & 1 deletion crates/ln-dlc-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub mod util;

pub use config::CONFIRMATION_TARGET;
pub use config::CONTRACT_TX_FEE_RATE;
pub use config::JUST_IN_TIME_CHANNEL_OUTBOUND_LIQUIDITY_SAT_MAX;
pub use config::LIQUIDITY_MULTIPLIER;
pub use ldk_node_wallet::WalletSettings;
pub use ln::AppEventHandler;
Expand Down
19 changes: 2 additions & 17 deletions crates/ln-dlc-node/src/ln/app_event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,8 @@ where
amount_msat,
)?;
}
Event::HTLCIntercepted {
intercept_id,
requested_next_hop_scid,
payment_hash,
inbound_amount_msat,
expected_outbound_amount_msat,
} => {
common_handlers::handle_intercepted_htlc(
&self.node,
&self.pending_intercepted_htlcs,
intercept_id,
payment_hash,
requested_next_hop_scid,
inbound_amount_msat,
expected_outbound_amount_msat,
)
.await?;
Event::HTLCIntercepted { .. } => {
unimplemented!("App should not intercept htlcs")
}
};

Expand Down
Loading

0 comments on commit 7982b85

Please sign in to comment.