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
use raiden_primitives::{
	deserializers::u256_from_u64,
	types::{
		Address,
		BlockNumber,
		BlockTimeout,
		ChainID,
		TokenAmount,
		TokenNetworkRegistryAddress,
	},
};
use serde::{
	Deserialize,
	Serialize,
};

use crate::types::RoutingMode;

/// The PFS's confirmed block.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ConfirmedBlockInfo {
	pub number: BlockNumber,
}

/// The network info as provided by the PFS.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NetworkInfo {
	pub chain_id: ChainID,
	pub token_network_registry_address: TokenNetworkRegistryAddress,
	pub user_deposit_address: Address,
	pub service_token_address: Address,
	pub confirmed_block: ConfirmedBlockInfo,
}

/// Pathfinding service information.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PFSInfo {
	#[serde(deserialize_with = "u256_from_u64", rename(deserialize = "price_info"))]
	pub price: TokenAmount,
	#[serde(rename(deserialize = "network_info"))]
	pub network: NetworkInfo,
	pub payment_address: Address,
	pub message: String,
	pub operator: String,
	pub version: String,
	pub matrix_server: String,
}

/// Pathfinding service configuration
#[derive(Clone, Debug)]
pub struct PFSConfig {
	pub url: String,
	pub info: PFSInfo,
	pub maximum_fee: TokenAmount,
	pub iou_timeout: BlockTimeout,
	pub max_paths: usize,
}

/// Service configs
#[derive(Clone)]
pub struct ServicesConfig {
	pub routing_mode: RoutingMode,
	pub pathfinding_service_random_address: bool,
	pub pathfinding_service_address: String,
	pub pathfinding_max_paths: usize,
	pub pathfinding_max_fee: TokenAmount,
	pub pathfinding_iou_timeout: BlockTimeout,
	pub monitoring_enabled: bool,
}