forked from LBRYCommunity/lbry-sdk
commit
79384e7bf8
4 changed files with 36 additions and 30 deletions
|
@ -289,7 +289,7 @@ class LBRYWallet(object):
|
||||||
d = self._do_send_many(payments_to_send)
|
d = self._do_send_many(payments_to_send)
|
||||||
d.addCallback(lambda txid: log.debug("Sent transaction %s", txid))
|
d.addCallback(lambda txid: log.debug("Sent transaction %s", txid))
|
||||||
return d
|
return d
|
||||||
log.info("There were no payments to send")
|
log.debug("There were no payments to send")
|
||||||
return defer.succeed(True)
|
return defer.succeed(True)
|
||||||
|
|
||||||
def get_stream_info_for_name(self, name):
|
def get_stream_info_for_name(self, name):
|
||||||
|
@ -493,6 +493,29 @@ class LBRYWallet(object):
|
||||||
d = self._get_history()
|
d = self._get_history()
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def get_tx_json(self, txid):
|
||||||
|
def _decode(raw_tx):
|
||||||
|
tx = Transaction(raw_tx).deserialize()
|
||||||
|
decoded_tx = {}
|
||||||
|
for txkey in tx.keys():
|
||||||
|
if isinstance(tx[txkey], list):
|
||||||
|
decoded_tx[txkey] = []
|
||||||
|
for i in tx[txkey]:
|
||||||
|
tmp = {}
|
||||||
|
for k in i.keys():
|
||||||
|
if isinstance(i[k], Decimal):
|
||||||
|
tmp[k] = float(i[k] / 1e8)
|
||||||
|
else:
|
||||||
|
tmp[k] = i[k]
|
||||||
|
decoded_tx[txkey].append(tmp)
|
||||||
|
else:
|
||||||
|
decoded_tx[txkey] = tx[txkey]
|
||||||
|
return decoded_tx
|
||||||
|
|
||||||
|
d = self._get_raw_tx(txid)
|
||||||
|
d.addCallback(_decode)
|
||||||
|
return d
|
||||||
|
|
||||||
def get_name_and_validity_for_sd_hash(self, sd_hash):
|
def get_name_and_validity_for_sd_hash(self, sd_hash):
|
||||||
d = self._get_claim_metadata_for_sd_hash(sd_hash)
|
d = self._get_claim_metadata_for_sd_hash(sd_hash)
|
||||||
d.addCallback(lambda name_txid: self._get_status_of_claim(name_txid[1], name_txid[0], sd_hash) if name_txid is not None else None)
|
d.addCallback(lambda name_txid: self._get_status_of_claim(name_txid[1], name_txid[0], sd_hash) if name_txid is not None else None)
|
||||||
|
@ -989,7 +1012,7 @@ class LBRYcrdWallet(LBRYWallet):
|
||||||
@_catch_connection_error
|
@_catch_connection_error
|
||||||
def _update_name_rpc(self, txid, value, amount):
|
def _update_name_rpc(self, txid, value, amount):
|
||||||
rpc_conn = self._get_rpc_conn()
|
rpc_conn = self._get_rpc_conn()
|
||||||
return rpc_conn.updateclaim(txid, value, amount)
|
return rpc_conn.updateclaim(txid, json.dumps(value), amount)
|
||||||
|
|
||||||
@_catch_connection_error
|
@_catch_connection_error
|
||||||
def _send_name_claim_rpc(self, name, value, amount):
|
def _send_name_claim_rpc(self, name, value, amount):
|
||||||
|
@ -1314,29 +1337,6 @@ class LBRYumWallet(LBRYWallet):
|
||||||
func = getattr(self.cmd_runner, cmd.name)
|
func = getattr(self.cmd_runner, cmd.name)
|
||||||
return threads.deferToThread(func)
|
return threads.deferToThread(func)
|
||||||
|
|
||||||
def get_tx_json(self, txid):
|
|
||||||
def _decode(raw_tx):
|
|
||||||
tx = Transaction(raw_tx).deserialize()
|
|
||||||
decoded_tx = {}
|
|
||||||
for txkey in tx.keys():
|
|
||||||
if isinstance(tx[txkey], list):
|
|
||||||
decoded_tx[txkey] = []
|
|
||||||
for i in tx[txkey]:
|
|
||||||
tmp = {}
|
|
||||||
for k in i.keys():
|
|
||||||
if isinstance(i[k], Decimal):
|
|
||||||
tmp[k] = float(i[k] / 1e8)
|
|
||||||
else:
|
|
||||||
tmp[k] = i[k]
|
|
||||||
decoded_tx[txkey].append(tmp)
|
|
||||||
else:
|
|
||||||
decoded_tx[txkey] = tx[txkey]
|
|
||||||
return decoded_tx
|
|
||||||
|
|
||||||
d = self._get_raw_tx(txid)
|
|
||||||
d.addCallback(_decode)
|
|
||||||
return d
|
|
||||||
|
|
||||||
def get_pub_keys(self, wallet):
|
def get_pub_keys(self, wallet):
|
||||||
cmd = known_commands['getpubkeys']
|
cmd = known_commands['getpubkeys']
|
||||||
func = getattr(self.cmd_runner, cmd.name)
|
func = getattr(self.cmd_runner, cmd.name)
|
||||||
|
|
|
@ -172,7 +172,8 @@ class ConnectionManager(object):
|
||||||
def pick_best_peer(peers):
|
def pick_best_peer(peers):
|
||||||
# TODO: Eventually rank them based on past performance/reputation. For now
|
# TODO: Eventually rank them based on past performance/reputation. For now
|
||||||
# TODO: just pick the first to which we don't have an open connection
|
# TODO: just pick the first to which we don't have an open connection
|
||||||
log.debug("Got a list of peers to choose from: %s", str(["%s:%i" % (p.host, p.port) for p in peers]))
|
|
||||||
|
log.debug("Got a list of peers to choose from: %s", str(peers))
|
||||||
if peers is None:
|
if peers is None:
|
||||||
return None
|
return None
|
||||||
for peer in peers:
|
for peer in peers:
|
||||||
|
|
|
@ -76,11 +76,16 @@ def disable_third_party_loggers():
|
||||||
|
|
||||||
|
|
||||||
def disable_noisy_loggers():
|
def disable_noisy_loggers():
|
||||||
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
|
logging.getLogger('BitcoinRPC').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO)
|
||||||
logging.getLogger('lbrynet.core.client.ConnectionManager').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.core.client.ConnectionManager').setLevel(logging.INFO)
|
||||||
logging.getLogger('lbrynet.core.client.BlobRequester').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.core.client.BlobRequester').setLevel(logging.INFO)
|
||||||
logging.getLogger('lbrynet.core.client.ClientProtocol').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.core.client.ClientProtocol').setLevel(logging.INFO)
|
||||||
logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.core.server.ServerRequestHandler').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.core.server.ServerProtocol').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.core.server.BlobAvailabilityHandler').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.lbrynet_daemon.LBRYExchangeRateManager').setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
@_log_decorator
|
@_log_decorator
|
||||||
|
|
|
@ -47,7 +47,7 @@ class MarketFeed(object):
|
||||||
return defer.succeed(from_amount / (1.0 - self.fee))
|
return defer.succeed(from_amount / (1.0 - self.fee))
|
||||||
|
|
||||||
def _save_price(self, price):
|
def _save_price(self, price):
|
||||||
log.info("Saving price update %f for %s" % (price, self.market))
|
log.debug("Saving price update %f for %s" % (price, self.market))
|
||||||
self.rate = ExchangeRate(self.market, price, int(time.time()))
|
self.rate = ExchangeRate(self.market, price, int(time.time()))
|
||||||
|
|
||||||
def _update_price(self):
|
def _update_price(self):
|
||||||
|
@ -191,7 +191,7 @@ class DummyExchangeRateManager(object):
|
||||||
feed.rate = ExchangeRate(feed.market, rates[feed.market]['spot'], rates[feed.market]['ts'])
|
feed.rate = ExchangeRate(feed.market, rates[feed.market]['spot'], rates[feed.market]['ts'])
|
||||||
|
|
||||||
def convert_currency(self, from_currency, to_currency, amount):
|
def convert_currency(self, from_currency, to_currency, amount):
|
||||||
log.info("Converting %f %s to %s" % (amount, from_currency, to_currency))
|
log.debug("Converting %f %s to %s" % (amount, from_currency, to_currency))
|
||||||
for market in self.market_feeds:
|
for market in self.market_feeds:
|
||||||
if market.rate.currency_pair == (from_currency, to_currency):
|
if market.rate.currency_pair == (from_currency, to_currency):
|
||||||
return amount * market.rate.spot
|
return amount * market.rate.spot
|
||||||
|
|
Loading…
Reference in a new issue