1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00

Refactor daemon port and cookie directory

This commit is contained in:
Roman Zeyde 2018-08-14 09:23:45 +03:00
parent 123e0cf23b
commit 56af6170dd
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -8,10 +8,10 @@ import numpy as np
import matplotlib.pyplot as plt
class Daemon:
def __init__(self):
self.sock = socket.create_connection(('localhost', 8332))
def __init__(self, port=8332, cookie_dir='~/.bitcoin'):
self.sock = socket.create_connection(('localhost', port))
self.fd = self.sock.makefile()
path = os.path.expanduser('~/.bitcoin/.cookie')
path = os.path.join(os.path.expanduser(cookie_dir), '.cookie')
cookie = binascii.b2a_base64(open(path, 'rb').read())
self.cookie = cookie.decode('ascii').strip()
self.index = 0