Skip to content
Permalink
Browse files

Removed configuration of decoder, using lbrycrd conf from .lbrycrd.

Removed configuration of decoder, using lbrycrd conf from .lbrycrd.
Fixes #21
  • Loading branch information...
filipnyquist committed Sep 26, 2017
1 parent 66cb6b0 commit c4b57300ddbfe077d308c70fff8c362dc4164fdd
Showing with 21 additions and 14 deletions.
  1. +0 −1 decoder/config.json
  2. +21 −13 decoder/decoder.py

This file was deleted.

Oops, something went wrong.
@@ -6,17 +6,25 @@
from flask import Flask, url_for
app = Flask(__name__)


def get_lbrycrdd_connection_details():
with open(os.path.dirname(os.path.realpath(__file__))+'/config.json', 'r') as f:
config = json.load(f)
rpc_user = config['rpc_user']
rpc_pass = config['rpc_password']
rpc_port = config['rpc_port']
rpc_url = config['rpc_url']
return 'http://%s:%s@%s:%i' % (rpc_user, rpc_pass, rpc_url,
rpc_port)

def get_lbrycrdd_connection_details(wallet_conf):
settings = {"username": "lbry",
"password": "lbry",
"rpc_port": 9245}
if wallet_conf and os.path.exists(wallet_conf):
with open(wallet_conf, "r") as conf:
conf_lines = conf.readlines()
for l in conf_lines:
if l.startswith("rpcuser="):
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)
def internal_error(error):
@@ -26,7 +34,7 @@ def internal_error(error):

@app.route('/claim_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)
result = rpc.getclaimsfortx(txid)
claim = None
@@ -43,7 +51,7 @@ def api_decode(txid, nout):

@app.route('/claim_decodeinv/<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)
claim = rpc.getvalueforname(claimid)
if claim:

0 comments on commit c4b5730

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.