MCPcopy
hub / github.com/petertodd/python-bitcoinlib / listunspent

Method listunspent

bitcoin/rpc.py:663–693  ·  view source on GitHub ↗

Return unspent transaction outputs in wallet Outputs will have between minconf and maxconf (inclusive) confirmations, optionally filtered to only include txouts paid to addresses in addrs.

(self, minconf=0, maxconf=9999999, addrs=None)

Source from the content-addressed store, hash-verified

661 return r
662
663 def listunspent(self, minconf=0, maxconf=9999999, addrs=None):
664 """Return unspent transaction outputs in wallet
665
666 Outputs will have between minconf and maxconf (inclusive)
667 confirmations, optionally filtered to only include txouts paid to
668 addresses in addrs.
669 """
670 r = None
671 if addrs is None:
672 r = self._call('listunspent', minconf, maxconf)
673 else:
674 addrs = [str(addr) for addr in addrs]
675 r = self._call('listunspent', minconf, maxconf, addrs)
676
677 r2 = []
678 for unspent in r:
679 unspent['outpoint'] = COutPoint(lx(unspent['txid']), unspent['vout'])
680 del unspent['txid']
681 del unspent['vout']
682
683 # address isn't always available as Bitcoin Core allows scripts w/o
684 # an address type to be imported into the wallet, e.g. non-p2sh
685 # segwit
686 try:
687 unspent['address'] = CBitcoinAddress(unspent['address'])
688 except KeyError:
689 pass
690 unspent['scriptPubKey'] = CScript(unhexlify_str(unspent['scriptPubKey']))
691 unspent['amount'] = int(unspent['amount'] * COIN)
692 r2.append(unspent)
693 return r2
694
695 def lockunspent(self, unlock, outpoints):
696 """Lock or unlock outpoints"""

Callers 1

Calls 6

COutPointClass · 0.90
lxFunction · 0.90
CBitcoinAddressClass · 0.90
CScriptClass · 0.90
unhexlify_strFunction · 0.85
_callMethod · 0.45

Tested by

no test coverage detected