diff --git a/lbrynet/core/StreamDescriptor.py b/lbrynet/core/StreamDescriptor.py index 96e66f9bb..08f55b607 100644 --- a/lbrynet/core/StreamDescriptor.py +++ b/lbrynet/core/StreamDescriptor.py @@ -1,4 +1,3 @@ -import six import binascii from collections import defaultdict import json diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 488bbaffc..b72867a6b 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -979,6 +979,35 @@ class Daemon(AuthJSONRPCServer): return self._render_response(sorted([command for command in self.callable_methods.keys()])) @requires(WALLET_COMPONENT) + @defer.inlineCallbacks + def jsonrpc_account_balance(self, account_name=None, confirmations=6): + """ + Return the balance of an individual account or all of the accounts. + + Usage: + account_balance [ | --account=] [--confirmations=] + + Options: + --account= : (str) If provided only the balance for this + account will be given + --confirmations= : (int) required confirmations (default: 6) + + Returns: + (map) amount of lbry credits in wallet + """ + balances = yield self.wallet.get_balances(confirmations) + lbc_accounts = balances[self.ledger.get_id()] + if account_name is not None: + for account in lbc_accounts: + if account['account'] == account_name: + defer.returnValue(account) + raise Exception( + "No account found with name '{}', available accounts: {}." + .format(account_name, str([a['account'] for a in lbc_accounts])) + ) + defer.returnValue(lbc_accounts) + + @AuthJSONRPCServer.requires("wallet") def jsonrpc_wallet_balance(self, address=None, include_unconfirmed=False): """ Return the balance of the wallet diff --git a/lbrynet/wallet/account.py b/lbrynet/wallet/account.py index 6e9444aff..ba0765cf9 100644 --- a/lbrynet/wallet/account.py +++ b/lbrynet/wallet/account.py @@ -20,7 +20,7 @@ def generate_certificate(): def get_certificate_lookup(tx_or_hash, nout): if isinstance(tx_or_hash, Transaction): - return '{}:{}'.format(tx_or_hash.hex_id.decode(), nout) + return '{}:{}'.format(tx_or_hash.id, nout) else: return '{}:{}'.format(hexlify(tx_or_hash[::-1]).decode(), nout) @@ -58,17 +58,17 @@ class Account(BaseAccount): self.certificates[tx_nout] = self.certificates[maybe_claim_id] del self.certificates[maybe_claim_id] log.info( - "Migrated certificate with claim_id '{}' ('{}') to a new look up key {}." - .format(maybe_claim_id, txo.script.values['claim_name'], tx_nout) + "Migrated certificate with claim_id '%s' ('%s') to a new look up key %s.", + maybe_claim_id, txo.script.values['claim_name'], tx_nout ) succeded += 1 else: log.warning( - "Failed to migrate claim '{}', it's not associated with any of your addresses." - .format(maybe_claim_id) + "Failed to migrate claim '%s', it's not associated with any of your addresses.", + maybe_claim_id ) failed += 1 - log.info('Checked: {}, Converted: {}, Failed: {}'.format(total, succeded, failed)) + log.info('Checked: %s, Converted: %s, Failed: %s', total, succeded, failed) def get_balance(self, confirmations=6, include_claims=False): if include_claims: diff --git a/lbrynet/wallet/claim_proofs.py b/lbrynet/wallet/claim_proofs.py index 3fcd225cd..d950b5abe 100644 --- a/lbrynet/wallet/claim_proofs.py +++ b/lbrynet/wallet/claim_proofs.py @@ -4,7 +4,8 @@ import binascii from lbryschema.hashing import sha256 -class InvalidProofError(Exception): pass +class InvalidProofError(Exception): + pass def height_to_vch(n): diff --git a/lbrynet/wallet/database.py b/lbrynet/wallet/database.py index 9476f6bd3..b10b2a8fa 100644 --- a/lbrynet/wallet/database.py +++ b/lbrynet/wallet/database.py @@ -1,4 +1,3 @@ -import sqlite3 from binascii import hexlify from twisted.internet import defer from torba.basedatabase import BaseDatabase diff --git a/lbrynet/wallet/manager.py b/lbrynet/wallet/manager.py index 508a5f9d2..d568dda21 100644 --- a/lbrynet/wallet/manager.py +++ b/lbrynet/wallet/manager.py @@ -5,7 +5,6 @@ from binascii import hexlify from twisted.internet import defer from torba.manager import WalletManager as BaseWalletManager -from torba.wallet import WalletStorage from lbryschema.uri import parse_lbry_uri from lbryschema.error import URIParseError diff --git a/lbrynet/wallet/resolve.py b/lbrynet/wallet/resolve.py index 45c006be5..bc76ccfc0 100644 --- a/lbrynet/wallet/resolve.py +++ b/lbrynet/wallet/resolve.py @@ -16,7 +16,7 @@ from .claim_proofs import verify_proof, InvalidProofError log = logging.getLogger(__name__) -class Resolver: +class Resolver(object): def __init__(self, claim_trie_root, height, transaction_class, hash160_to_address, network): self.claim_trie_root = claim_trie_root