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

Enable anchor channels and scid aliases #1166

Merged
merged 2 commits into from
May 7, 2024
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
8 changes: 4 additions & 4 deletions mutiny-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ lnurl-rs = { version = "0.4.0", default-features = false, features = ["async", "
cfg-if = "1.0.0"
bip39 = { version = "2.0.0" }
bitcoin = { version = "0.30.2", default-features = false, features = ["std", "serde", "secp-recovery", "rand"] }
bdk = { version = "1.0.0-alpha.5" }
bdk_esplora = { version = "0.7.0", default-features = false, features = ["std", "async-https"] }
bdk_chain = { version = "0.9.0", features = ["std"] }
bdk = { version = "=1.0.0-alpha.5" }
bdk_esplora = { version = "=0.7.0", default-features = false, features = ["std", "async-https"] }
bdk_chain = { version = "=0.9.0", features = ["std"] }
bdk-macros = "0.6.0"
getrandom = { version = "0.2" }
itertools = "0.11.0"
Expand Down Expand Up @@ -64,7 +64,7 @@ base64 = "0.13.0"
pbkdf2 = "0.11"
aes-gcm = "0.10.1"

log = "=0.4.18"
log = "0.4.18"
futures = "0.3.25"
thiserror = "1.0"
anyhow = "1.0"
Expand Down
6 changes: 6 additions & 0 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ mod test_utils;
pub use crate::gossip::{GOSSIP_SYNC_TIME_KEY, NETWORK_GRAPH_KEY, PROB_SCORER_KEY};
pub use crate::keymanager::generate_seed;
pub use crate::ldkstorage::{CHANNEL_CLOSURE_PREFIX, CHANNEL_MANAGER_KEY, MONITORS_PREFIX_KEY};
pub use bitcoin;
pub use fedimint_core;
pub use lightning;
pub use lightning_invoice;
pub use nostr_sdk;

use crate::utils::spawn;
use crate::{auth::MutinyAuthClient, hermes::HermesClient, logging::MutinyLogger};
use crate::{blindauth::BlindAuthClient, cashu::CashuHttpClient};
Expand Down
21 changes: 3 additions & 18 deletions mutiny-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,15 +1781,7 @@ impl<S: MutinyStorage> Node<S> {
.lsp_client
.as_ref()
.is_some_and(|l| l.accept_underpaying_htlcs());
let mut config = default_user_config(accept_underpaying_htlcs);

// if we are opening channel to LSP, turn off SCID alias until CLN is updated
// LSP protects all invoice information anyways, so no UTXO leakage
if let Some(lsp) = self.lsp_client.clone() {
if pubkey == lsp.get_lsp_pubkey().await {
config.channel_handshake_config.negotiate_scid_privacy = false;
}
}
let config = default_user_config(accept_underpaying_htlcs);

let user_channel_id = user_channel_id.unwrap_or_else(|| {
// generate random user channel id
Expand Down Expand Up @@ -1890,14 +1882,7 @@ impl<S: MutinyStorage> Node<S> {
.lsp_client
.as_ref()
.is_some_and(|l| l.accept_underpaying_htlcs());
let mut config = default_user_config(accept_underpaying_htlcs);
// if we are opening channel to LSP, turn off SCID alias until CLN is updated
// LSP protects all invoice information anyways, so no UTXO leakage
if let Some(lsp) = self.lsp_client.clone() {
if pubkey == lsp.get_lsp_pubkey().await {
config.channel_handshake_config.negotiate_scid_privacy = false;
}
}
let config = default_user_config(accept_underpaying_htlcs);

let user_channel_id = user_chan_id.unwrap_or_else(|| {
// generate random user channel id
Expand Down Expand Up @@ -2364,7 +2349,7 @@ pub(crate) fn default_user_config(accept_underpaying_htlcs: bool) -> UserConfig
announced_channel: false,
negotiate_scid_privacy: true,
commit_upfront_shutdown_pubkey: false,
negotiate_anchors_zero_fee_htlc_tx: false,
negotiate_anchors_zero_fee_htlc_tx: true, // enable anchor channels
max_inbound_htlc_value_in_flight_percent_of_channel: 100,
our_to_self_delay: 6 * 24 * 2, // 2 days
their_channel_reserve_proportional_millionths: 0,
Expand Down
10 changes: 8 additions & 2 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ impl<S: MutinyStorage> NodeManager<S> {
/// Creates a background process that will sync the wallet with the blockchain.
/// This will also update the fee estimates every 10 minutes.
pub fn start_sync(nm: Arc<NodeManager<S>>) {
// sync every second on regtest, this makes testing easier
let sync_interval_secs = match nm.network {
Network::Bitcoin | Network::Testnet | Network::Signet => 60,
Network::Regtest => 1,
net => unreachable!("Unknown network: {net}"),
};
utils::spawn(async move {
let mut synced = false;
loop {
Expand Down Expand Up @@ -617,8 +623,8 @@ impl<S: MutinyStorage> NodeManager<S> {
synced = true;
}

// sleep for 1 minute, checking graceful shutdown check each 1s.
for _ in 0..60 {
// wait for next sync round, checking graceful shutdown check each second.
for _ in 0..sync_interval_secs {
if nm.stop.load(Ordering::Relaxed) {
return;
}
Expand Down
Loading