import ConfigParser
import StringIO
import argparse
+import base64
import os
import random
import sys
# connect to bitcoind over JSON-RPC and do initial getmemorypool
url = 'http://%s:%i/' % (args.bitcoind_address, args.bitcoind_rpc_port)
print '''Testing bitcoind RPC connection to '%s' with username '%s'...''' % (url, args.bitcoind_rpc_username)
- bitcoind = jsonrpc.Proxy(url, (args.bitcoind_rpc_username, args.bitcoind_rpc_password))
+ bitcoind = jsonrpc.Proxy(url, dict(Authorization='Basic ' + base64.b64encode(args.bitcoind_rpc_username + ':' + args.bitcoind_rpc_password)))
good = yield deferral.retry('Error while checking bitcoind identity:', 1)(net.PARENT.RPC_CHECK)(bitcoind)
if not good:
print >>sys.stderr, " Check failed! Make sure that you're connected to the right bitcoind with --bitcoind-rpc-port!"
@defer.inlineCallbacks
def set_merged_work(merged_url, merged_userpass):
- merged_proxy = jsonrpc.Proxy(merged_url, (merged_userpass,))
+ merged_proxy = jsonrpc.Proxy(merged_url, dict(Authorization='Basic ' + base64.b64encode(merged_userpass)))
while True:
auxblock = yield deferral.retry('Error while calling merged getauxblock:', 1)(merged_proxy.rpc_getauxblock)()
pre_merged_work.set(dict(pre_merged_work.value, **{auxblock['chainid']: dict(
from __future__ import division
-import base64
import json
from twisted.internet import defer
}
class Proxy(object):
- def __init__(self, url, auth=None, timeout=5):
+ def __init__(self, url, headers={}, timeout=5):
self._url = url
- self._auth = auth
+ self._headers = headers
self._timeout = timeout
@defer.inlineCallbacks
def callRemote(self, method, *params):
id_ = 0
- headers = {
- 'Content-Type': 'application/json',
- }
- if self._auth is not None:
- headers['Authorization'] = 'Basic ' + base64.b64encode(':'.join(self._auth))
try:
data = yield client.getPage(
url=self._url,
method='POST',
- headers=headers,
+ headers=dict(self._headers, **{'Content-Type': 'application/json'}),
postdata=json.dumps({
'jsonrpc': '2.0',
'method': method,