forked from LBRYCommunity/lbry-sdk
update channel balance checking to match claim
Simple balance check before calling get_max_usable_balance_for_claim - matches what happens on the claim. Also provide clearer error message about maximum amount
This commit is contained in:
parent
80fcb760b7
commit
b218e84d29
1 changed files with 14 additions and 12 deletions
|
@ -1851,17 +1851,19 @@ class Daemon(AuthJSONRPCServer):
|
||||||
raise Exception("Invalid channel name")
|
raise Exception("Invalid channel name")
|
||||||
if amount <= 0:
|
if amount <= 0:
|
||||||
raise Exception("Invalid amount")
|
raise Exception("Invalid amount")
|
||||||
|
|
||||||
balance = yield self.session.wallet.get_max_usable_balance_for_claim(channel_name)
|
yield self.session.wallet.update_balance()
|
||||||
max_bid_amount = balance - MAX_UPDATE_FEE_ESTIMATE
|
if amount >= self.session.wallet.get_balance():
|
||||||
if balance <= MAX_UPDATE_FEE_ESTIMATE:
|
balance = yield self.session.wallet.get_max_usable_balance_for_claim(channel_name)
|
||||||
raise InsufficientFundsError(
|
max_bid_amount = balance - MAX_UPDATE_FEE_ESTIMATE
|
||||||
"Insufficient funds, please deposit additional LBC. Minimum additional LBC needed {}"
|
if balance <= MAX_UPDATE_FEE_ESTIMATE:
|
||||||
.format(MAX_UPDATE_FEE_ESTIMATE - balance))
|
raise InsufficientFundsError(
|
||||||
elif amount > max_bid_amount:
|
"Insufficient funds, please deposit additional LBC. Minimum additional LBC needed {}"
|
||||||
raise InsufficientFundsError(
|
. format(MAX_UPDATE_FEE_ESTIMATE - balance))
|
||||||
"Please lower the bid value, the maximum amount you can specify for this claim is {}"
|
elif amount > max_bid_amount:
|
||||||
.format(max_bid_amount))
|
raise InsufficientFundsError(
|
||||||
|
"Please lower the bid value, the maximum amount you can specify for this channel is {}"
|
||||||
|
.format(max_bid_amount))
|
||||||
|
|
||||||
result = yield self.session.wallet.claim_new_channel(channel_name, amount)
|
result = yield self.session.wallet.claim_new_channel(channel_name, amount)
|
||||||
self.analytics_manager.send_new_channel()
|
self.analytics_manager.send_new_channel()
|
||||||
|
@ -2047,7 +2049,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
.format(MAX_UPDATE_FEE_ESTIMATE - balance))
|
.format(MAX_UPDATE_FEE_ESTIMATE - balance))
|
||||||
elif bid > max_bid_amount:
|
elif bid > max_bid_amount:
|
||||||
raise InsufficientFundsError(
|
raise InsufficientFundsError(
|
||||||
"Please lower the bid. After accounting for the estimated fee, you only have {} left."
|
"Please lower the bid value, the maximum amount you can specify for this claim is {}."
|
||||||
.format(max_bid_amount))
|
.format(max_bid_amount))
|
||||||
|
|
||||||
metadata = metadata or {}
|
metadata = metadata or {}
|
||||||
|
|
Loading…
Reference in a new issue