Removed configuration of decoder, using lbrycrd conf from .lbrycrd.
Removed configuration of decoder, using lbrycrd conf from .lbrycrd. Fixes #21
This commit is contained in:
parent
66cb6b080e
commit
c4b57300dd
2 changed files with 21 additions and 14 deletions
|
@ -1 +0,0 @@
|
||||||
{"rpc_user": "lbry", "rpc_password": "lbry", "rpc_port": 9245, "rpc_url": "127.0.0.1"}
|
|
|
@ -6,17 +6,25 @@ from lbryschema.decode import smart_decode
|
||||||
from flask import Flask, url_for
|
from flask import Flask, url_for
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
def get_lbrycrdd_connection_details(wallet_conf):
|
||||||
def get_lbrycrdd_connection_details():
|
settings = {"username": "lbry",
|
||||||
with open(os.path.dirname(os.path.realpath(__file__))+'/config.json', 'r') as f:
|
"password": "lbry",
|
||||||
config = json.load(f)
|
"rpc_port": 9245}
|
||||||
rpc_user = config['rpc_user']
|
if wallet_conf and os.path.exists(wallet_conf):
|
||||||
rpc_pass = config['rpc_password']
|
with open(wallet_conf, "r") as conf:
|
||||||
rpc_port = config['rpc_port']
|
conf_lines = conf.readlines()
|
||||||
rpc_url = config['rpc_url']
|
for l in conf_lines:
|
||||||
return 'http://%s:%s@%s:%i' % (rpc_user, rpc_pass, rpc_url,
|
if l.startswith("rpcuser="):
|
||||||
rpc_port)
|
settings["username"] = l[8:].rstrip('\n')
|
||||||
|
if l.startswith("rpcpassword="):
|
||||||
|
settings["password"] = l[12:].rstrip('\n')
|
||||||
|
if l.startswith("rpcport="):
|
||||||
|
settings["rpc_port"] = int(l[8:].rstrip('\n'))
|
||||||
|
rpc_user = settings["username"]
|
||||||
|
rpc_pass = settings["password"]
|
||||||
|
rpc_port = settings["rpc_port"]
|
||||||
|
rpc_url = "127.0.0.1"
|
||||||
|
return "http://%s:%s@%s:%i" % (rpc_user, rpc_pass, rpc_url, rpc_port)
|
||||||
|
|
||||||
@app.errorhandler(500)
|
@app.errorhandler(500)
|
||||||
def internal_error(error):
|
def internal_error(error):
|
||||||
|
@ -26,7 +34,7 @@ def internal_error(error):
|
||||||
|
|
||||||
@app.route('/claim_decode/<txid>/<nout>')
|
@app.route('/claim_decode/<txid>/<nout>')
|
||||||
def api_decode(txid, nout):
|
def api_decode(txid, nout):
|
||||||
connection_string = get_lbrycrdd_connection_details()
|
connection_string = get_lbrycrdd_connection_details(os.path.expanduser("~")+"/.lbrycrd/lbrycrd.conf")
|
||||||
rpc = AuthServiceProxy(connection_string)
|
rpc = AuthServiceProxy(connection_string)
|
||||||
result = rpc.getclaimsfortx(txid)
|
result = rpc.getclaimsfortx(txid)
|
||||||
claim = None
|
claim = None
|
||||||
|
@ -43,7 +51,7 @@ def api_decode(txid, nout):
|
||||||
|
|
||||||
@app.route('/claim_decodeinv/<claimid>')
|
@app.route('/claim_decodeinv/<claimid>')
|
||||||
def api_decodebyclaim(claimid):
|
def api_decodebyclaim(claimid):
|
||||||
connection_string = get_lbrycrdd_connection_details()
|
connection_string = get_lbrycrdd_connection_details(os.path.expanduser("~")+"/.lbrycrd/lbrycrd.conf")
|
||||||
rpc = AuthServiceProxy(connection_string)
|
rpc = AuthServiceProxy(connection_string)
|
||||||
claim = rpc.getvalueforname(claimid)
|
claim = rpc.getvalueforname(claimid)
|
||||||
if claim:
|
if claim:
|
||||||
|
|
Loading…
Reference in a new issue