diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 806b76f40..aa4681c76 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -3125,7 +3125,7 @@ class Daemon(AuthJSONRPCServer): response = yield self._render_response(out) defer.returnValue(response) - @AuthJSONRPCServer.requires("wallet") + @requires("wallet") def jsonrpc_account_balance(self, account_name=None, confirmations=6, include_reserved=False, include_claims=False): """ @@ -3168,6 +3168,28 @@ class Daemon(AuthJSONRPCServer): raise Exception("'--include-claims' requires specifying an LBC account.") return self.wallet.get_balances(confirmations) + @requires("wallet") + def jsonrpc_account_max_gap(self, account_name): + """ + Finds ranges of consecutive addresses that are unused and returns the length + of the longest such range: for change and receiving address chains. This is + useful to figure out ideal values to set for 'receiving_gap' and 'change_gap' + account settings. + + Usage: + account_max_gap + + Options: + --account= : (str) account for which to get max gaps + + Returns: + (map) maximum gap for change and receiving addresses + """ + for account in self.wallet.accounts: + if account.name == account_name: + return account.get_max_gap() + raise Exception("Couldn't find an account named: '{}'.".format(account_name)) + def loggly_time_string(dt): formatted_dt = dt.strftime("%Y-%m-%dT%H:%M:%S") diff --git a/lbrynet/wallet/manager.py b/lbrynet/wallet/manager.py index f8d5a7668..434a341b1 100644 --- a/lbrynet/wallet/manager.py +++ b/lbrynet/wallet/manager.py @@ -1,5 +1,4 @@ import os -import six import json from binascii import hexlify from twisted.internet import defer @@ -16,16 +15,14 @@ from .transaction import Transaction from .database import WalletDatabase # pylint: disable=unused-import -if six.PY3: - buffer = memoryview - - class BackwardsCompatibleNetwork: def __init__(self, manager): self.manager = manager def get_local_height(self): - return len(self.manager.ledgers.values()[0].headers) + for ledger in self.manager.ledgers.values(): + assert isinstance(ledger, MainNetLedger) + return ledger.headers.height def get_server_height(self): return self.get_local_height() @@ -173,7 +170,7 @@ class LbryWalletManager(BaseWalletManager): defer.returnValue(tx) def _old_get_temp_claim_info(self, tx, txo, address, claim_dict, name, bid): - if isinstance(address, buffer): + if isinstance(address, memoryview): address = str(address) return { "claim_id": hexlify(tx.get_claim_id(txo.position)).decode(),