forked from LBRYCommunity/lbry-sdk
Merge pull request #619 from wallermadev/master
Adding functionality to check the balance of a given wallet.
This commit is contained in:
commit
dc7193bb8f
3 changed files with 31 additions and 10 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -10,18 +10,16 @@ at anytime.
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
* Add `lbryschema_version` to response from `version`
|
* Add `lbryschema_version` to response from `version`
|
||||||
*
|
* Added call to `get_address_balance` when `address` conditional returns true
|
||||||
*
|
* Added `address` conditional to `jsonrpc_wallet_balance`
|
||||||
|
* Added `get_address_balance` method to the `Wallet` class
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
*
|
* Added optional `address` and `include_unconfirmed` params to `jsonrpc_wallet_balance` method
|
||||||
*
|
|
||||||
*
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* fix stream_cost_estimate throwing exception on non decodeable claims
|
* fix stream_cost_estimate throwing exception on non decodeable claims
|
||||||
*
|
*
|
||||||
*
|
|
||||||
|
|
||||||
## [0.10.0rc2] - 2017-04-17
|
## [0.10.0rc2] - 2017-04-17
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -797,6 +797,9 @@ class Wallet(object):
|
||||||
def get_new_address(self):
|
def get_new_address(self):
|
||||||
return defer.fail(NotImplementedError())
|
return defer.fail(NotImplementedError())
|
||||||
|
|
||||||
|
def get_address_balance(self, address):
|
||||||
|
return defer.fail(NotImplementedError())
|
||||||
|
|
||||||
def get_block(self, blockhash):
|
def get_block(self, blockhash):
|
||||||
return defer.fail(NotImplementedError())
|
return defer.fail(NotImplementedError())
|
||||||
|
|
||||||
|
@ -1024,6 +1027,16 @@ class LBRYumWallet(Wallet):
|
||||||
yield self._save_wallet()
|
yield self._save_wallet()
|
||||||
defer.returnValue(addr)
|
defer.returnValue(addr)
|
||||||
|
|
||||||
|
# Get the balance of a given address.
|
||||||
|
|
||||||
|
def get_address_balance(self, address, include_balance=False):
|
||||||
|
c, u, x = self.wallet.get_addr_balance(address)
|
||||||
|
if include_balance is False:
|
||||||
|
return Decimal(float(c) / COIN)
|
||||||
|
else:
|
||||||
|
return Decimal((float(c) + float(u) + float(x)) / COIN)
|
||||||
|
|
||||||
|
|
||||||
# Return an address with no balance in it, if
|
# Return an address with no balance in it, if
|
||||||
# there is none, create a brand new address
|
# there is none, create a brand new address
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -1311,20 +1311,30 @@ class Daemon(AuthJSONRPCServer):
|
||||||
if 'DEPRECATED' not in getattr(self, "jsonrpc_" + command).__doc__]
|
if 'DEPRECATED' not in getattr(self, "jsonrpc_" + command).__doc__]
|
||||||
))
|
))
|
||||||
|
|
||||||
def jsonrpc_get_balance(self):
|
def jsonrpc_get_balance(self, address=None, include_unconfirmed=False):
|
||||||
"""
|
"""
|
||||||
DEPRECATED. Use `wallet_balance` instead.
|
DEPRECATED. Use `wallet_balance` instead.
|
||||||
"""
|
"""
|
||||||
return self.jsonrpc_wallet_balance()
|
return self.jsonrpc_wallet_balance(address, include_unconfirmed)
|
||||||
|
|
||||||
def jsonrpc_wallet_balance(self):
|
def jsonrpc_wallet_balance(self, address=None, include_unconfirmed=False):
|
||||||
"""
|
"""
|
||||||
Return the balance of the wallet
|
Return the balance of the wallet
|
||||||
|
|
||||||
|
Args:
|
||||||
|
'address' (optional): If address is provided only that balance will be given
|
||||||
|
'include_unconfirmed' (optional): If set unconfirmed balance will be included in
|
||||||
|
the only takes effect when address is also provided.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(float) amount of lbry credits in wallet
|
(float) amount of lbry credits in wallet
|
||||||
"""
|
"""
|
||||||
|
if address is None:
|
||||||
return self._render_response(float(self.session.wallet.get_balance()))
|
return self._render_response(float(self.session.wallet.get_balance()))
|
||||||
|
else:
|
||||||
|
return self._render_response(float(
|
||||||
|
self.session.wallet.get_address_balance(address, include_unconfirmed)))
|
||||||
|
|
||||||
|
|
||||||
def jsonrpc_stop(self):
|
def jsonrpc_stop(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue