Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
target/debug/build
key: test-cache-${{ github.run_id }}-${{ github.run_number }}
- id: set-matrix
run: cargo test --no-run --all-features && echo "matrix=$(testconfig/scripts/get_test_list.sh manager_execution manager_tests contract_updater)" >> "$GITHUB_OUTPUT"
run: cargo test --no-run --all-features && echo "matrix=$(testconfig/scripts/get_test_list.sh manager_execution manager_tests contract_updater stateless_execution)" >> "$GITHUB_OUTPUT"
integration_tests:
name: integration tests
needs: integration_tests_prepare
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

11 changes: 8 additions & 3 deletions ddk-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ version.workspace = true
edition.workspace = true

[features]
default = ["std"]
default = ["std", "manager"]
std = ["ddk-dlc/std", "ddk-messages/std", "ddk-trie/std", "bitcoin/std", "lightning/std"]
# The async DLC application layer: the `Manager` and channel updater. This pulls
# tokio (`sync`). Turn it OFF (`default-features = false`) for FFI/mobile
# consumers that only need the pure protocol core — the `contract` types, the
# `ContractSigner`/`ContractSignerProvider`/`Wallet` traits, and `error::Error`.
manager = ["std", "dep:tokio"]
fuzztarget = ["rand_chacha"]
parallel = ["ddk-trie/parallel"]
use-serde = ["serde", "ddk-dlc/use-serde", "ddk-messages/use-serde", "ddk-trie/use-serde"]
Expand All @@ -30,11 +35,11 @@ once_cell = "1.21.3"
rand_chacha = { version = "0.3.1", optional = true }
secp256k1-zkp = { workspace = true }
serde = { workspace = true, optional = true }
tokio = { workspace = true, features = ["sync"] }
tokio = { workspace = true, features = ["sync"], optional = true }
tracing = { workspace = true }

[dev-dependencies]
ddk = { workspace = true }
ddk = { workspace = true, features = ["manager"] }
ddk-testenv = { workspace = true }
bitcoincore-rpc = { workspace = true }
bitcoincore-rpc-json = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion ddk-manager/src/channel/offered_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl OfferedChannel {
refund_locktime: offered_contract.refund_locktime,
fee_rate_per_vb: offered_contract.fee_rate_per_vb,
fund_output_serial_id: offered_contract.fund_output_serial_id,
cet_nsequence: crate::manager::CET_NSEQUENCE,
cet_nsequence: crate::CET_NSEQUENCE,
}
}

Expand Down
8 changes: 8 additions & 0 deletions ddk-manager/src/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ pub mod ser;
pub mod signed_contract;
pub(crate) mod utils;

/// Converts wire-level contract information into the execution information
/// required to construct CETs and adaptor signatures.
pub fn execution_contract_infos(
contract_info: &ddk_messages::contract_msgs::ContractInfo,
) -> Result<Vec<contract_info::ContractInfo>, Error> {
Ok(crate::conversion_utils::get_contract_info_and_announcements(contract_info)?)
}

#[derive(Clone)]
/// Enum representing the possible states of a DLC.
pub enum Contract {
Expand Down
13 changes: 13 additions & 0 deletions ddk-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,28 @@
#![deny(dead_code)]
#![deny(unused_imports)]
#![deny(missing_docs)]
// Without the `manager` feature the async application layer (`manager` /
// `channel_updater`) is compiled out, leaving some protocol helpers with no
// callers in this subset build. The default build compiles the superset and
// keeps `deny`, so genuinely-dead code is still caught there.
#![cfg_attr(
not(feature = "manager"),
allow(dead_code, unused_imports, unused_macros)
)]

#[macro_use]
extern crate ddk_messages;

pub mod chain_monitor;
pub mod channel;
#[cfg(feature = "manager")]
pub mod channel_updater;
pub mod contract;
pub mod contract_updater;
mod conversion_utils;
mod dlc_input;
pub mod error;
#[cfg(feature = "manager")]
pub mod manager;
pub mod payout_curve;
mod utils;
Expand Down Expand Up @@ -56,6 +66,9 @@ pub type KeysId = [u8; 32];
/// Type alias for a channel id.
pub type ChannelId = [u8; 32];

/// The nSequence value used for CETs in DLC channels.
pub const CET_NSEQUENCE: u32 = 288;

/// Time trait to provide current unix time. Mainly defined to facilitate testing.
pub trait Time {
/// Must return the unix epoch corresponding to the current time.
Expand Down
4 changes: 1 addition & 3 deletions ddk-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::contract::{
use crate::contract_updater::{accept_contract, verify_accepted_and_sign_contract};
use crate::error::Error;
use crate::utils::get_object_in_state;
use crate::{ChannelId, ContractId, ContractSignerProvider};
use crate::{ChannelId, ContractId, ContractSignerProvider, CET_NSEQUENCE};
use bitcoin::absolute::Height;
use bitcoin::consensus::encode::serialize_hex;
use bitcoin::consensus::Decodable;
Expand Down Expand Up @@ -70,8 +70,6 @@ static AUTOMATIC_REFUND: Lazy<bool> = Lazy::new(|| match std::env::var("AUTOMATI

/// The delay to set the refund value to.
pub const REFUND_DELAY: u32 = 86400 * 7;
/// The nSequence value used for CETs in DLC channels
pub const CET_NSEQUENCE: u32 = 288;
/// Timeout in seconds when waiting for a peer's reply, after which a DLC channel
/// is forced closed.
pub const PEER_TIMEOUT: u64 = 3600;
Expand Down
53 changes: 37 additions & 16 deletions ddk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,60 @@ version.workspace = true
edition.workspace = true

[features]
default = ["manager"]

# The full DLC manager application: builder, chain sync, wallet, storage,
# oracle, and transport services. This pulls the async/networked stack
# (tokio, zeromq, bdk_esplora, ...). Turn it OFF (`default-features = false`)
# for FFI/mobile consumers that only need the stateless `contract` module and
# `ContractKeyProvider`, which depend on nothing heavier than `ddk-manager`.
manager = [
"ddk-manager/manager",
"dep:kormir",
"dep:bdk_esplora",
"dep:tokio",
"dep:zeromq",
"dep:uuid",
"dep:chrono",
"dep:serde_json",
"dep:async-trait",
"dep:hmac",
"dep:sha2",
]

# transport features
nostr = ["dep:nostr-rs", "dep:nostr-sdk", "dep:base64"]
lightning = ["dep:lightning-net-tokio"]
nostr = ["manager", "dep:nostr-rs", "dep:nostr-sdk", "dep:base64"]
lightning = ["manager", "dep:lightning-net-tokio"]

# oracle features
kormir = ["dep:reqwest"]
p2pderivatives = ["dep:reqwest"]
kormir = ["manager", "dep:reqwest"]
p2pderivatives = ["manager", "dep:reqwest"]
nostr-oracle = ["dep:nostr-database", "nostr", "kormir", "kormir/nostr"]

# storage features
sled = ["dep:sled"]
postgres = ["dep:sqlx", "sqlx/postgres"]
sled = ["manager", "dep:sled"]
postgres = ["manager", "dep:sqlx", "sqlx/postgres"]

[dependencies]
ddk-manager = { workspace = true, features = ["std", "use-serde"] }
ddk-dlc = { workspace = true, features = ["std", "use-serde"] }
ddk-messages = { workspace = true, features = ["std", "use-serde"] }
ddk-trie = { workspace = true, features = ["std", "use-serde"] }
kormir = { workspace = true }
kormir = { workspace = true, optional = true }

bitcoin = { workspace = true, features = ["std", "rand", "serde"] }
bdk_esplora = { version = "0.22.2", default-features = false, features = ["std", "async-https", "tokio"] }
bdk_esplora = { version = "0.22.2", default-features = false, features = ["std", "async-https", "tokio"], optional = true }
bdk_wallet = "3.0.0"
bdk_chain = "0.23.3"
lightning = { workspace = true, features = ["std", "grind_signatures"] }
serde = { workspace = true, features = ["std", "derive"] }
serde_json = { workspace = true }
serde_json = { workspace = true, optional = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tokio = { workspace = true, features = ["full"], optional = true }
tracing = { workspace = true }
uuid = { version = "1.8.0", features = ["v4"] }
chrono = { workspace = true, features = ["serde"] }
async-trait = { workspace = true }
uuid = { version = "1.8.0", features = ["v4"], optional = true }
chrono = { workspace = true, features = ["serde"], optional = true }
async-trait = { workspace = true, optional = true }
hex = { workspace = true }

# storage features
Expand All @@ -59,13 +80,13 @@ lightning-net-tokio = { version = "0.2.0", optional = true }

# oracle feature
reqwest = { version = "0.13.3", features = ["json"], optional = true }
hmac = "0.13.0"
sha2 = "0.11.0"
hmac = { version = "0.13.0", optional = true }
sha2 = { version = "0.11.0", optional = true }
nostr-database = { version = "0.44.0", optional = true }
bip39 = "2.2.0"

# zmq feature
zeromq = "0.6.0"
zeromq = { version = "0.6.0", optional = true }

[dev-dependencies]
test-log = { version = "0.2.16", features = ["trace"] }
Expand Down
Loading
Loading