diff --git a/app/background/node/service.js b/app/background/node/service.js index e5091a487..27e439576 100644 --- a/app/background/node/service.js +++ b/app/background/node/service.js @@ -307,20 +307,17 @@ export class NodeService extends EventEmitter { apiKey, } = rpc; - const portString = port ? `:${port}` : ''; - const pathString = (!pathname || pathname === '/') ? '' : pathname; - const protoString = protocol || 'http'; - - const url = `${protoString}://${host}${portString}${pathString}`; - // Not really used after this point, // but overwrite the local getAPIKey() just in case. this.apiKey = apiKey; return new NodeClient({ - network: this.network, apiKey, - url, + ssl: protocol === 'https', + host, + port: parseInt(port, 10), + path: pathname, + timeout: 30000, }); } diff --git a/app/background/wallet/service.js b/app/background/wallet/service.js index a68c55a6d..200a2a583 100644 --- a/app/background/wallet/service.js +++ b/app/background/wallet/service.js @@ -155,15 +155,28 @@ class WalletService { payload: this.walletApiKey, }); + // This is an unfortunate work-around for the fact that + // WalletNode doesn't accept a `nodePath` option to + // pass to NodeClient which gets passed to bcurl/client. + const nodeURL = + this.conn.pathname + ? + this.conn.protocol + '://' + + 'username_is_ignored:' + this.conn.apiKey + '@' + + this.conn.host + ':' + this.conn.port + this.conn.pathname + : + null; + this.node = new WalletNode({ network: this.networkName, nodeHost: this.conn.host, - nodePort: this.conn.port || undefined, + nodePort: parseInt(this.conn.port, 10), nodeApiKey: this.conn.apiKey, + nodeSSL: this.conn.protocol === 'https', + nodeURL, apiKey: this.walletApiKey, memory: false, prefix: HSD_DATA_DIR, - migrate: 0, logFile: true, logConsole: false, logLevel: 'debug', diff --git a/app/pages/Settings/CustomRPCConfigModal.js b/app/pages/Settings/CustomRPCConfigModal.js index 7f4a44475..f67fe797f 100644 --- a/app/pages/Settings/CustomRPCConfigModal.js +++ b/app/pages/Settings/CustomRPCConfigModal.js @@ -40,7 +40,6 @@ export default class CustomRPCConfigModal extends Component { protocol: 'http', host: '', pathname: '', - networkType: 'main', port: '', apiKey: '', errorMessage: '', @@ -55,12 +54,13 @@ export default class CustomRPCConfigModal extends Component { async fetchCustomRPC() { const conn = await connClient.getCustomRPC(); + const {rpcPort} = Network.get(this.props.walletNetwork); + this.setState({ - networkType: conn.networkType || 'main', protocol: conn.protocol || 'http', apiKey: conn.apiKey, - port: conn.port, - host: conn.host, + port: conn.port || rpcPort, + host: conn.host || '127.0.0.1', pathname: conn.pathname, }); } @@ -72,15 +72,7 @@ export default class CustomRPCConfigModal extends Component { return; } - if (!this.state.confirming && this.isDangerousURL()) { - this.setState({ - confirming: true, - }); - return; - } - const { - networkType, apiKey, host, port, @@ -187,13 +179,16 @@ export default class CustomRPCConfigModal extends Component { const { host, pathname, - networkType, apiKey, port, protocol, - errorMessage, } = this.state; + let {errorMessage} = this.state; + if (!errorMessage && this.isDangerousURL()) + errorMessage = 'Remote connection over HTTP is prohibited.'; + + return ( this.setState({ @@ -222,7 +217,6 @@ export default class CustomRPCConfigModal extends Component { type="text" className="settings__input" value={host} - placeholder={`127.0.0.1`} onChange={e => this.setState({ host: e.target.value, errorMessage: '', @@ -236,7 +230,6 @@ export default class CustomRPCConfigModal extends Component { type="text" className="settings__input" value={pathname} - placeholder={`/`} onChange={e => this.setState({ pathname: e.target.value, errorMessage: '', @@ -244,25 +237,12 @@ export default class CustomRPCConfigModal extends Component { /> -
-
Network Type
- this.setState({ - networkType: net, - port: Network.get(net).rpcPort, - errorMessage: '', - })} - /> -
-
Port
this.setState({ port: e.target.value, errorMessage: '', @@ -273,6 +253,7 @@ export default class CustomRPCConfigModal extends Component {
API Key
- { - !errorMessage && this.state.confirming && ( -
- Remote connection over HTTP is not recommended. Are you sure you want to continue? -
- ) - } - { errorMessage && (
@@ -305,13 +278,11 @@ export default class CustomRPCConfigModal extends Component { Cancel