commit 2787a6d0d8b75ae6c576f5ce0d86d2df979013ee
parent c5a18b67def9de93021404b603e4317d8c573d80
Author: chris-belcher <chris-belcher@users.noreply.github.com>
Date: Mon, 26 Mar 2018 23:05:38 +0100
added support for core's multi-wallet feature
Diffstat:
3 files changed, 13 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 =
+#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
+wallet_filename =
# how often in seconds to poll for new transactions when electrum not connected
poll_interval_listening = 30
diff --git a/jsonrpc.py b/jsonrpc.py
@@ -13,10 +13,14 @@ class JsonRpcError(Exception):
class JsonRpcConnectionError(JsonRpcError): pass
class JsonRpc(object):
- def __init__(self, host, port, user, password):
+ def __init__(self, host, port, user, password, wallet_filename=""):
self.host = host
self.port = port
self.authstr = "%s:%s" % (user, password)
+ if len(wallet_filename) > 0:
+ self.url = "/wallet/" + wallet_filename
+ else:
+ self.url = ""
self.queryId = 1
def queryHTTP(self, obj):
@@ -28,7 +32,7 @@ class JsonRpc(object):
body = json.dumps(obj)
try:
conn = http.client.HTTPConnection(self.host, self.port)
- conn.request("POST", "", body, headers)
+ conn.request("POST", self.url, body, headers)
response = conn.getresponse()
if response.status == 401:
conn.close()
diff --git a/server.py b/server.py
@@ -399,8 +399,9 @@ def main():
if rpc_u == None:
return
rpc = JsonRpc(host = config.get("bitcoin-rpc", "host"),
- port = int(config.get("bitcoin-rpc", "port")),
- user = rpc_u, password = rpc_p)
+ port = int(config.get("bitcoin-rpc", "port")),
+ user = rpc_u, password = rpc_p,
+ wallet_filename=config.get("bitcoin-rpc", "wallet_filename").strip())
#TODO somewhere here loop until rpc works and fully sync'd, to allow
# people to run this script without waiting for their node to fully