Skip to content

Commit d711f69

Browse files
committed
open virtual channel
1 parent cdf1a98 commit d711f69

11 files changed

Lines changed: 1319 additions & 43 deletions

openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,9 @@ components:
14251425
- integer
14261426
- 'null'
14271427
example: 0
1428+
virtual_open_mode:
1429+
type: string
1430+
example: trusted_no_broadcast
14281431
ChannelStatus:
14291432
type: string
14301433
enum:
@@ -2296,6 +2299,9 @@ components:
22962299
- string
22972300
- 'null'
22982301
example: a8b60c8ce3067b5fc881d4831323e24751daec3b64353c8df3205ec5d838f1c5
2302+
virtual_open_mode:
2303+
type: string
2304+
example: trusted_no_broadcast
22992305
OpenChannelResponse:
23002306
type: object
23012307
required:

src/args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct Args {
3535
/// Disable authentication
3636
#[arg(long, default_value_t = false)]
3737
disable_authentication: bool,
38+
39+
#[arg(long, default_value_t = false)]
40+
enable_virtual_channels_v0: bool,
3841
}
3942

4043
pub(crate) struct UserArgs {
@@ -44,6 +47,7 @@ pub(crate) struct UserArgs {
4447
pub(crate) network: BitcoinNetwork,
4548
pub(crate) max_media_upload_size_mb: u16,
4649
pub(crate) root_public_key: Option<biscuit_auth::PublicKey>,
50+
pub(crate) enable_virtual_channels_v0: bool,
4751
}
4852

4953
pub(crate) fn parse_startup_args() -> Result<UserArgs, AppError> {
@@ -65,5 +69,6 @@ pub(crate) fn parse_startup_args() -> Result<UserArgs, AppError> {
6569
network,
6670
max_media_upload_size_mb: args.max_media_upload_size_mb,
6771
root_public_key,
72+
enable_virtual_channels_v0: args.enable_virtual_channels_v0,
6873
})
6974
}

src/disk.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::sync::Arc;
1616
use crate::error::APIError;
1717
use crate::ldk::{
1818
ChannelIdsMap, InboundPaymentInfoStorage, NetworkGraph, OutboundPaymentInfoStorage,
19-
OutputSpenderTxes, SwapMap,
19+
OutputSpenderTxes, SwapMap, VirtualChannelDraftStore, VirtualChannelSessionStore,
2020
};
2121
use crate::utils::{parse_peer_info, LOGS_DIR};
2222

@@ -30,6 +30,8 @@ pub(crate) const CHANNEL_PEER_DATA: &str = "channel_peer_data";
3030
pub(crate) const OUTPUT_SPENDER_TXES: &str = "output_spender_txes";
3131

3232
pub(crate) const CHANNEL_IDS_FNAME: &str = "channel_ids";
33+
pub(crate) const VIRTUAL_CHANNEL_DRAFT_STORE_FNAME: &str = "virtual_channel_drafts";
34+
pub(crate) const VIRTUAL_CHANNEL_SESSION_STORE_FNAME: &str = "virtual_channel_sessions";
3335

3436
pub(crate) const MAKER_SWAPS_FNAME: &str = "maker_swaps";
3537
pub(crate) const TAKER_SWAPS_FNAME: &str = "taker_swaps";
@@ -223,3 +225,25 @@ pub(crate) fn read_channel_ids_info(path: &Path) -> ChannelIdsMap {
223225
channel_ids: new_hash_map(),
224226
}
225227
}
228+
229+
pub(crate) fn read_virtual_channel_draft_store(path: &Path) -> VirtualChannelDraftStore {
230+
if let Ok(file) = File::open(path) {
231+
if let Ok(info) = VirtualChannelDraftStore::read(&mut BufReader::new(file)) {
232+
return info;
233+
}
234+
}
235+
VirtualChannelDraftStore {
236+
entries: new_hash_map(),
237+
}
238+
}
239+
240+
pub(crate) fn read_virtual_channel_session_store(path: &Path) -> VirtualChannelSessionStore {
241+
if let Ok(file) = File::open(path) {
242+
if let Ok(info) = VirtualChannelSessionStore::read(&mut BufReader::new(file)) {
243+
return info;
244+
}
245+
}
246+
VirtualChannelSessionStore {
247+
entries: new_hash_map(),
248+
}
249+
}

0 commit comments

Comments
 (0)