Skip to content

Commit d9c3f39

Browse files
committed
Add method to use Vss with FixedHeader Auth.
1 parent abee187 commit d9c3f39

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/builder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ use std::sync::atomic::AtomicBool;
7777
use std::sync::{Arc, Mutex, RwLock};
7878
use std::time::SystemTime;
7979
#[cfg(any(vss, vss_test))]
80-
use vss_client::headers::{LnurlAuthToJwtProvider, VssHeaderProvider};
80+
use vss_client::headers::{FixedHeaders, LnurlAuthToJwtProvider, VssHeaderProvider};
8181

8282
#[derive(Debug, Clone)]
8383
enum ChainDataSourceConfig {
@@ -401,6 +401,17 @@ impl NodeBuilder {
401401
self.build_with_vss_store_and_header_provider(vss_url, store_id, header_provider)
402402
}
403403

404+
/// Builds a [`Node`] instance with a [`VssStore`] backend and according to the options
405+
/// previously configured. Uses only FixedHeaders as default method for authentication/authorization.
406+
#[cfg(any(vss, vss_test))]
407+
pub fn build_with_vss_store_with_fixed_headers(
408+
&self, vss_url: String, store_id: String, fixed_headers: HashMap<String, String>,
409+
) -> Result<Node, BuildError> {
410+
let header_provider = Arc::new(FixedHeaders::new(fixed_headers));
411+
412+
self.build_with_vss_store_and_header_provider(vss_url, store_id, header_provider)
413+
}
414+
404415
/// Builds a [`Node`] instance with a [`VssStore`] backend and according to the options
405416
/// previously configured. Give `header_provider` is used to attach headers to every request made
406417
/// to [VSS](https://github.com/lightningdevkit/vss-server/blob/main/README.md) backend.

tests/integration_tests_vss.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ mod common;
1111

1212
use ldk_node::Builder;
1313
use std::collections::HashMap;
14-
use std::sync::Arc;
15-
use vss_client::headers::FixedHeaders;
1614

1715
#[test]
1816
fn channel_full_cycle_with_vss_store() {
@@ -24,10 +22,10 @@ fn channel_full_cycle_with_vss_store() {
2422
builder_a.set_chain_source_esplora(esplora_url.clone(), None);
2523
let vss_base_url = std::env::var("TEST_VSS_BASE_URL").unwrap();
2624
let node_a = builder_a
27-
.build_with_vss_store_and_header_provider(
25+
.build_with_vss_store_with_fixed_headers(
2826
vss_base_url.clone(),
2927
"node_1_store".to_string(),
30-
Arc::new(FixedHeaders::new(HashMap::new())),
28+
HashMap::new(),
3129
)
3230
.unwrap();
3331
node_a.start().unwrap();
@@ -37,10 +35,10 @@ fn channel_full_cycle_with_vss_store() {
3735
let mut builder_b = Builder::from_config(config_b);
3836
builder_b.set_chain_source_esplora(esplora_url.clone(), None);
3937
let node_b = builder_b
40-
.build_with_vss_store_and_header_provider(
38+
.build_with_vss_store_with_fixed_headers(
4139
vss_base_url,
4240
"node_2_store".to_string(),
43-
Arc::new(FixedHeaders::new(HashMap::new())),
41+
HashMap::new(),
4442
)
4543
.unwrap();
4644
node_b.start().unwrap();

0 commit comments

Comments
 (0)