MCPcopy Create free account
hub / github.com/ElementsProject/elements / count_unspent

Function count_unspent

test/functional/wallet_avoidreuse.py:20–43  ·  view source on GitHub ↗

Count the unspent outputs for the given node and return various statistics

(node)

Source from the content-addressed store, hash-verified

18 node.sendtoaddress(address=discardaddr, amount=balance, subtractfeefromamount=True, avoid_reuse=False)
19
20def count_unspent(node):
21 '''Count the unspent outputs for the given node and return various statistics'''
22 r = {
23 "total": {
24 "count": 0,
25 "sum": 0,
26 },
27 "reused": {
28 "count": 0,
29 "sum": 0,
30 },
31 }
32 supports_reused = True
33 for utxo in node.listunspent(minconf=0):
34 r["total"]["count"] += 1
35 r["total"]["sum"] += utxo["amount"]
36 if supports_reused and "reused" in utxo:
37 if utxo["reused"]:
38 r["reused"]["count"] += 1
39 r["reused"]["sum"] += utxo["amount"]
40 else:
41 supports_reused = False
42 r["reused"]["supported"] = supports_reused
43 return r
44
45def assert_unspent(node, total_count=None, total_sum=None, reused_supported=None, reused_count=None, reused_sum=None, margin=0.001):
46 '''Make assertions about a node's unspent output statistics'''

Callers 1

assert_unspentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected