From 3152ecfd71a8102734e143a6846dcdf399e3338f Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 1 Nov 2017 17:17:38 -0400 Subject: [PATCH] add wallet_list_unspent --- CHANGELOG.md | 2 +- lbrynet/core/Wallet.py | 3 +++ lbrynet/daemon/Daemon.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90024ba39..ce7cdba49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ at anytime. * ### Added - * + * Added `wallet_list_unspent` command * ### Removed diff --git a/lbrynet/core/Wallet.py b/lbrynet/core/Wallet.py index 5ebb60d93..a535a8af6 100644 --- a/lbrynet/core/Wallet.py +++ b/lbrynet/core/Wallet.py @@ -1488,6 +1488,9 @@ class LBRYumWallet(Wallet): def list_addresses(self): return self._run_cmd_as_defer_succeed('listaddresses') + def list_unspent(self): + return self._run_cmd_as_defer_succeed('listunspent') + def send_claim_to_address(self, claim_id, destination, amount): return self._run_cmd_as_defer_succeed('sendclaimtoaddress', claim_id, destination, amount) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index fe7912075..439763d7a 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -2404,6 +2404,42 @@ class Daemon(AuthJSONRPCServer): tx['broadcast'] = broadcast defer.returnValue(tx) + @defer.inlineCallbacks + def jsonrpc_wallet_list_unspent(self): + """ + List unspent transaction outputs + + Usage: + wallet_prefill_addresses + + Returns: + (list) List of UTXOs + [ + { + "address": (str) the output address + "amount": (float) unspent amount + "height": (int) block height + "is_claim": (bool) is the tx a claim + "is_coinbase": (bool) is the tx a coinbase tx + "is_support": (bool) is the tx a support + "is_update": (bool) is the tx an update + "nout": (int) nout of the output + "txid": (str) txid of the output + }, + ... + ] + """ + + unspent = yield self.session.wallet.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) + def jsonrpc_block_show(self, blockhash=None, height=None): """ Get contents of a block