MyCrypto/common/libs/nodes/custom/index.ts

19 lines
543 B
TypeScript
Raw Normal View History

import RPCNode from '../rpc';
import RPCClient from '../rpc/client';
2018-01-20 20:06:28 +00:00
import { CustomNodeConfig } from 'config';
export default class CustomNode extends RPCNode {
constructor(config: CustomNodeConfig) {
const endpoint = `${config.url}:${config.port}`;
super(endpoint);
const headers: { [key: string]: string } = {};
if (config.auth) {
const { username, password } = config.auth;
headers.Authorization = `Basic ${btoa(`${username}:${password}`)}`;
}
this.client = new RPCClient(endpoint, headers);
}
}