From 9b44ba7c846545307b71d89f852ca49af2ba4d19 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 13 Mar 2018 17:32:29 -0400 Subject: [PATCH] only call get_max_usable_balance when the bid might be too high --- lbrynet/daemon/Daemon.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 02703b8ef..8107668af 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -2037,16 +2037,18 @@ class Daemon(AuthJSONRPCServer): if bid <= 0.0: raise ValueError("Bid value must be greater than 0.0") - balance = yield self.session.wallet.get_max_usable_balance_for_claim(name) - max_bid_amount = balance - MAX_UPDATE_FEE_ESTIMATE - if balance <= MAX_UPDATE_FEE_ESTIMATE: - raise InsufficientFundsError( - "Insufficient funds, please deposit additional LBC. Minimum additional LBC needed {}" - .format(MAX_UPDATE_FEE_ESTIMATE - balance)) - elif bid > max_bid_amount: - raise InsufficientFundsError( - "Please lower the bid. After accounting for the estimated fee, you only have {} left." - .format(max_bid_amount)) + yield self.session.wallet.update_balance() + if bid >= self.session.wallet.get_balance(): + balance = yield self.session.wallet.get_max_usable_balance_for_claim(name) + max_bid_amount = balance - MAX_UPDATE_FEE_ESTIMATE + if balance <= MAX_UPDATE_FEE_ESTIMATE: + raise InsufficientFundsError( + "Insufficient funds, please deposit additional LBC. Minimum additional LBC needed {}" + .format(MAX_UPDATE_FEE_ESTIMATE - balance)) + elif bid > max_bid_amount: + raise InsufficientFundsError( + "Please lower the bid. After accounting for the estimated fee, you only have {} left." + .format(max_bid_amount)) metadata = metadata or {} if fee is not None: