MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / helloblock_unspent

Function helloblock_unspent

src/lib/pybitcointools/bci.py:160–180  ·  view source on GitHub ↗
(*args)

Source from the content-addressed store, hash-verified

158
159
160def helloblock_unspent(*args):
161 addrs, network = parse_addr_args(*args)
162 if network == 'testnet':
163 url = 'https://testnet.helloblock.io/v1/addresses/%s/unspents?limit=500&offset=%s'
164 elif network == 'btc':
165 url = 'https://mainnet.helloblock.io/v1/addresses/%s/unspents?limit=500&offset=%s'
166 o = []
167 for addr in addrs:
168 for offset in xrange(0, 10**9, 500):
169 res = make_request(url % (addr, offset))
170 data = json.loads(res.decode("utf-8"))["data"]
171 if not len(data["unspents"]):
172 break
173 elif offset:
174 sys.stderr.write("Getting more unspents: %d\n" % offset)
175 for dat in data["unspents"]:
176 o.append({
177 "output": dat["txHash"]+':'+str(dat["index"]),
178 "value": dat["value"],
179 })
180 return o
181
182
183unspent_getters = {

Callers

nothing calls this directly

Calls 3

parse_addr_argsFunction · 0.85
make_requestFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected