mirror of
https://github.com/stakwork/sphinx-key.git
synced 2026-02-08 17:25:37 +01:00
make_factory
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use crate::policy::Policy;
|
||||
use crate::policy::{make_factory, Policy};
|
||||
|
||||
use lightning_signer::node::{Node, NodeConfig};
|
||||
use lightning_signer::persist::Persist;
|
||||
use lightning_signer::policy::simple_validator::SimpleValidatorFactory;
|
||||
use lightning_signer::signer::derive::KeyDerivationStyle;
|
||||
use std::sync::Arc;
|
||||
use vls_protocol_signer::handler::RootHandler;
|
||||
@@ -27,7 +26,7 @@ pub fn new_root_handler_with_policy(
|
||||
// [permissive mode]
|
||||
// policy.filter = PolicyFilter::new_permissive();
|
||||
|
||||
let validator_factory = Arc::new(SimpleValidatorFactory::new_with_policy(policy.into()));
|
||||
let validator_factory = Arc::new(make_factory(policy, network));
|
||||
let node = if nodes.is_empty() {
|
||||
let node = Arc::new(Node::new(
|
||||
config,
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
use lightning_signer::policy::filter::PolicyFilter;
|
||||
use lightning_signer::policy::simple_validator::SimplePolicy;
|
||||
use std::convert::From;
|
||||
use lightning_signer::policy::simple_validator::SimpleValidatorFactory;
|
||||
use vls_protocol_signer::lightning_signer;
|
||||
use vls_protocol_signer::lightning_signer::bitcoin::Network;
|
||||
|
||||
pub struct Policy {
|
||||
pub max_htlc_value_sat: u64,
|
||||
}
|
||||
|
||||
impl From<Policy> for SimplePolicy {
|
||||
fn from(p: Policy) -> Self {
|
||||
pub fn make_factory(policy: Policy, network: Network) -> SimpleValidatorFactory {
|
||||
SimpleValidatorFactory::new_with_policy(make_policy(policy, network))
|
||||
}
|
||||
|
||||
pub fn make_policy(p: Policy, network: Network) -> SimplePolicy {
|
||||
if network == Network::Bitcoin {
|
||||
SimplePolicy {
|
||||
min_delay: 144, // LDK min
|
||||
max_delay: 2016, // LDK max
|
||||
@@ -25,5 +30,23 @@ impl From<Policy> for SimplePolicy {
|
||||
dev_flags: None,
|
||||
filter: PolicyFilter::default(),
|
||||
}
|
||||
} else {
|
||||
SimplePolicy {
|
||||
min_delay: 4,
|
||||
max_delay: 2016, // Match LDK maximum and default
|
||||
max_channel_size_sat: 1_000_000_001, // lnd itest: wumbu default + 1
|
||||
// lnd itest: async_bidirectional_payments (large amount of dust HTLCs) 1_600_000
|
||||
epsilon_sat: 10_000, // c-lightning
|
||||
max_htlcs: 1000,
|
||||
max_htlc_value_sat: p.max_htlc_value_sat,
|
||||
use_chain_state: false,
|
||||
min_feerate_per_kw: 253, // testnet/regtest observed
|
||||
max_feerate_per_kw: 100_000,
|
||||
require_invoices: false,
|
||||
enforce_balance: false,
|
||||
max_routing_fee_msat: 10000,
|
||||
dev_flags: None,
|
||||
filter: PolicyFilter::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user