forked from LBRYCommunity/lbry-sdk
utxo_list, transaction_show
This commit is contained in:
parent
ce4d734250
commit
0adcaa6a5d
3 changed files with 23 additions and 19 deletions
|
@ -2765,22 +2765,18 @@ class Daemon(AuthJSONRPCServer):
|
||||||
Returns:
|
Returns:
|
||||||
(dict) JSON formatted transaction
|
(dict) JSON formatted transaction
|
||||||
"""
|
"""
|
||||||
|
return self.wallet_manager.get_transaction(txid)
|
||||||
d = self.wallet_manager.get_transaction(txid)
|
|
||||||
d.addCallback(lambda r: self._render_response(r))
|
|
||||||
return d
|
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
@requires(WALLET_COMPONENT)
|
||||||
@defer.inlineCallbacks
|
def jsonrpc_utxo_list(self, account_id=None):
|
||||||
def jsonrpc_utxo_list(self):
|
|
||||||
"""
|
"""
|
||||||
List unspent transaction outputs
|
List unspent transaction outputs
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
utxo_list
|
utxo_list [<account_id>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
None
|
--account=<account_id> : (str) id of the account to query
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(list) List of unspent transaction outputs (UTXOs)
|
(list) List of unspent transaction outputs (UTXOs)
|
||||||
|
@ -2799,16 +2795,9 @@ class Daemon(AuthJSONRPCServer):
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
|
return self.wallet_manager.get_utxos(
|
||||||
unspent = yield self.wallet_manager.list_unspent()
|
self.get_account_or_default('account', account_id)
|
||||||
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)
|
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
@requires(WALLET_COMPONENT)
|
||||||
def jsonrpc_block_show(self, blockhash=None, height=None):
|
def jsonrpc_block_show(self, blockhash=None, height=None):
|
||||||
|
@ -3355,6 +3344,11 @@ class Daemon(AuthJSONRPCServer):
|
||||||
return certificates[0]
|
return certificates[0]
|
||||||
raise ValueError("Couldn't find channel because a channel name or channel_id was not provided.")
|
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):
|
def get_account_or_error(self, argument: str, account_id: str, lbc_only=True):
|
||||||
for account in self.default_wallet.accounts:
|
for account in self.default_wallet.accounts:
|
||||||
if account.id == account_id:
|
if account.id == account_id:
|
||||||
|
|
|
@ -37,9 +37,13 @@ class JSONResponseEncoder(JSONEncoder):
|
||||||
|
|
||||||
def encode_output(self, txo):
|
def encode_output(self, txo):
|
||||||
return {
|
return {
|
||||||
|
'txid': txo.tx_ref.id,
|
||||||
'nout': txo.position,
|
'nout': txo.position,
|
||||||
'amount': txo.amount,
|
'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):
|
def encode_input(self, txi):
|
||||||
|
|
|
@ -204,9 +204,15 @@ class LbryWalletManager(BaseWalletManager):
|
||||||
def address_is_mine(self, address):
|
def address_is_mine(self, address):
|
||||||
return defer.succeed(True)
|
return defer.succeed(True)
|
||||||
|
|
||||||
|
def get_transaction(self, txid):
|
||||||
|
return self.default_account.ledger.get_transaction(txid)
|
||||||
|
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
return defer.succeed([])
|
return defer.succeed([])
|
||||||
|
|
||||||
|
def get_utxos(self, account):
|
||||||
|
return account.get_unspent_outputs()
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def claim_name(self, name, amount, claim_dict, certificate=None, claim_address=None):
|
def claim_name(self, name, amount, claim_dict, certificate=None, claim_address=None):
|
||||||
account = self.default_account
|
account = self.default_account
|
||||||
|
|
Loading…
Reference in a new issue