1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//! application tooling for DLCs 🌊
// #![doc = include_str!("../README.md")]
/// Build a DDK application.
/// Working with the bitcoin chain.
/// DDK error types
/// JSON structs
/// Logging infrastructure
/// Nostr related functions.
/// Oracle clients.
/// Storage implementations.
/// Transport services.
/// DLC utilities.
/// The internal [`bdk_wallet::PersistedWallet`].
/// DDK object with all services
pub use DlcDevKit;
pub use DlcManagerMessage;
pub use ddk_manager;
use async_trait;
use ChangeSet;
use ;
use Amount;
use DlcDevKitDlcManager;
use Message;
use TransportError;
use WalletError;
use Arc;
use watch;
/// Transport layer for DLC message communication.
///
/// This trait defines the interface for sending and receiving DLC protocol messages
/// between peers. Implementations of this trait (found in the transport module) handle
/// the actual communication layer, such as:
/// - Lightning Network transport
/// - Nostr protocol messaging
/// - Direct TCP/IP connections
/// - In-memory transport (for testing)
///
/// # Implementation Requirements
/// - Must be Send + Sync for thread safety
/// - Must handle connection management
/// - Must support message serialization/deserialization
/// - Must maintain peer connections
///
/// # Usage
/// Implementations are used by the DLC manager to:
/// 1. Establish connections with counterparties
/// 2. Send protocol messages (offers, accepts, signs, etc.)
/// 3. Receive and process incoming messages
/// 4. Maintain connection state
/// Storage interface for DLC contracts and wallet data.
///
/// This trait extends the Rust-DLC storage trait (`ddk_manager::Storage`) with
/// additional functionality for BDK wallet integration. Implementations must be
/// thread-safe and handle interior mutability due to BDK's requirements.
///
/// # Implementation Notes
/// - Must be wrapped in synchronization primitives (Arc, Mutex, etc.)
/// - Must handle concurrent access to wallet data
/// - Should implement efficient caching where appropriate
/// - Must maintain consistency between DLC and wallet states
///
/// # Common Implementations
/// - PostgreSQL storage (persistent)
/// - Sled storage (persistent, embedded)
/// - In-memory storage (temporary, testing)
/// Interface for secure key material storage and retrieval.
///
/// NOTE: This trait is currently a placeholder for future key management functionality.
/// It will be expanded to handle more sophisticated key storage and derivation patterns.
///
/// # Future Enhancements
/// - Hardware wallet integration
/// - Key derivation paths
/// - Multi-signature support
/// - Key rotation policies
/// Interface for DLC oracle implementations.
///
/// This trait extends the Rust-DLC oracle trait (`ddk_manager::Oracle`) and provides
/// a way to identify different oracle implementations. Oracles are responsible for:
/// - Providing event announcements
/// - Publishing attestations
/// - Maintaining cryptographic proofs
///
/// # Common Implementations
/// - Nostr-based oracles
/// - API-based oracles
/// - Local testing oracles
/// Represents the complete balance state of a DLC wallet.
///
/// This struct tracks various categories of funds in the wallet, including:
/// - Regular bitcoin balances (confirmed/unconfirmed)
/// - Funds locked in active DLC contracts
/// - Historical profit/loss from closed contracts
///
/// The separation of different balance types allows for:
/// - Accurate available balance calculation
/// - Contract fund tracking
/// - Performance monitoring
/// - Risk assessment