utxo_list, transaction_show

This commit is contained in:
Lex Berezhny 2018-09-19 09:58:50 -04:00
parent ce4d734250
commit 0adcaa6a5d
3 changed files with 23 additions and 19 deletions

View file

@ -2765,22 +2765,18 @@ class Daemon(AuthJSONRPCServer):
Returns:
(dict) JSON formatted transaction
"""
d = self.wallet_manager.get_transaction(txid)
d.addCallback(lambda r: self._render_response(r))
return d
return self.wallet_manager.get_transaction(txid)
@requires(WALLET_COMPONENT)
@defer.inlineCallbacks
def jsonrpc_utxo_list(self):
def jsonrpc_utxo_list(self, account_id=None):
"""
List unspent transaction outputs
Usage:
utxo_list
utxo_list [<account_id>]
Options:
None
--account=<account_id> : (str) id of the account to query
Returns:
(list) List of unspent transaction outputs (UTXOs)
@ -2799,16 +2795,9 @@ class Daemon(AuthJSONRPCServer):
...
]
"""
unspent = yield self.wallet_manager.list_unspent()
for i, utxo in enumerate(unspent):
utxo['txid'] = utxo.pop('prevout_hash')
utxo['nout'] = utxo.pop('prevout_n')
utxo['amount'] = utxo.pop('value')
utxo['is_coinbase'] = utxo.pop('coinbase')
unspent[i] = utxo
defer.returnValue(unspent)
return self.wallet_manager.get_utxos(
self.get_account_or_default('account', account_id)
)
@requires(WALLET_COMPONENT)
def jsonrpc_block_show(self, blockhash=None, height=None):
@ -3355,6 +3344,11 @@ class Daemon(AuthJSONRPCServer):
return certificates[0]
raise ValueError("Couldn't find channel because a channel name or channel_id was not provided.")
def get_account_or_default(self, argument: str, account_id: str, lbc_only=True):
if account_id is None:
return self.default_account
return self.get_account_or_error(argument, account_id, lbc_only)
def get_account_or_error(self, argument: str, account_id: str, lbc_only=True):
for account in self.default_wallet.accounts:
if account.id == account_id:

View file

@ -37,9 +37,13 @@ class JSONResponseEncoder(JSONEncoder):
def encode_output(self, txo):
return {
'txid': txo.tx_ref.id,
'nout': txo.position,
'amount': txo.amount,
'address': txo.get_address(self.ledger)
'address': txo.get_address(self.ledger),
'is_claim': txo.script.is_claim_name,
'is_support': txo.script.is_support_claim,
'is_update': txo.script.is_update_claim
}
def encode_input(self, txi):

View file

@ -204,9 +204,15 @@ class LbryWalletManager(BaseWalletManager):
def address_is_mine(self, address):
return defer.succeed(True)
def get_transaction(self, txid):
return self.default_account.ledger.get_transaction(txid)
def get_history(self):
return defer.succeed([])
def get_utxos(self, account):
return account.get_unspent_outputs()
@defer.inlineCallbacks
def claim_name(self, name, amount, claim_dict, certificate=None, claim_address=None):
account = self.default_account