commit 478fc02820696bdbbf5af9e7ca9b1a6c4a6f954a
parent 4154e827f9bf71b052ce445b4d561774c4b95558
Author: chris-belcher <chris-belcher@users.noreply.github.com>
Date: Thu, 29 Mar 2018 17:39:45 +0100
added option to manually configure rpc_user/password instead of using .cookie file
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/config.cfg_sample b/config.cfg_sample
@@ -24,6 +24,10 @@ host = localhost
port = 8332
#empty means look in the default location
datadir =
+#if you dont want to use the .cookie method, uncomment to config u/p here
+#rpc_user =
+#rpc_password =
+
#to be used with the multi-wallet feature
# see https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.15.0.md#multi-wallet-support
# empty means default file, for when using a single wallet file
diff --git a/server.py b/server.py
@@ -1,7 +1,7 @@
#! /usr/bin/python3
import socket, time, json, datetime, struct, binascii, ssl, os.path, platform
-from configparser import ConfigParser, NoSectionError
+from configparser import ConfigParser, NoSectionError, NoOptionError
from electrumpersonalserver.jsonrpc import JsonRpc, JsonRpcError
import electrumpersonalserver.hashes as hashes
@@ -403,8 +403,15 @@ def main():
except NoSectionError:
log("Non-existant configuration file `config.cfg`")
return
- rpc_u, rpc_p = obtain_rpc_username_password(config.get(
- "bitcoin-rpc", "datadir"))
+ debug_fd = open("debug.log", "w")
+ try:
+ rpc_u = config.get("bitcoin-rpc", "rpc_user")
+ rpc_p = config.get("bitcoin-rpc", "rpc_password")
+ debug("obtaining auth from rpc_user/pass")
+ except NoOptionError:
+ rpc_u, rpc_p = obtain_rpc_username_password(config.get(
+ "bitcoin-rpc", "datadir"))
+ debug("obtaining auth from .cookie")
if rpc_u == None:
return
rpc = JsonRpc(host = config.get("bitcoin-rpc", "host"),
@@ -426,7 +433,6 @@ def main():
printed_error_msg = True
time.sleep(5)
- debug_fd = open("debug.log", "w")
import_needed, relevant_spks_addrs, deterministic_wallets = \
get_scriptpubkeys_to_monitor(rpc, config)
if import_needed: