def get_unspent_testnet(cls, address): endpoint = cls.TEST_UNSPENT_API + "&limit=100" unspents = [] r = requests.get(endpoint.format(address), timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError response = r.json() while len(response) > 0: unspents.extend( Unspent( currency_to_satoshi(tx['value'], 'satoshi'), tx['confirmations'], tx['script'], tx['mintTxid'], tx['mintIndex'], ) for tx in response ) response = requests.get( endpoint.format(address) + "&since={}".format(response[-1]['_id']), timeout=DEFAULT_TIMEOUT ).json() return unspents
def get_unspent_testnet(cls, address): r = requests.get(cls.TEST_UNSPENT_API + address, timeout=DEFAULT_TIMEOUT) return [ Unspent(currency_to_satoshi(tx['amount'], 'btc'), tx['confirmations'], tx['script'], tx['tx'], tx['n']) for tx in r.json()['data']['unspent'] ]
def get_unspent_testnet(cls, address): r = requests.get(cls.TEST_UNSPENT_API.format(address), timeout=DEFAULT_TIMEOUT) return [ Unspent(currency_to_satoshi(tx['amount'], 'btc'), tx['confirmations'], tx['scriptPubKey'], tx['txid'], tx['vout']) for tx in r.json() ]
def get_unspent_testnet(cls, address): r = requests.get(cls.TEST_UNSPENT_API.format(address) + '?limit=1000', timeout=DEFAULT_TIMEOUT) return [ Unspent(currency_to_satoshi(tx['value'], 'btc'), tx['confirmations'], tx['script_pub_key']['hex'], tx['txid'], tx['n']) for tx in r.json()['unspent'] ]
def get_balance_testnet(cls, address: str) -> int: r = requests.get(cls.TEST_BALANCE_API.format(address), timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError try: return currency_to_satoshi(r.json() / 10**8, "ppc") except: return 0
def get_unspent_testnet(cls, address): r = requests.get(cls.TEST_UNSPENT_API + address, timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError return [ Unspent(currency_to_satoshi(tx['amount'], 'btc'), tx['confirmations'], tx['script'], tx['tx'], tx['n']) for tx in r.json()['data']['unspent'] ]
def get_unspent_testnet(cls, address): txs_per_page = 1000 payload = {'limit': str(txs_per_page)} r = requests.get(cls.TEST_UNSPENT_API.format(address), params=payload, timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError response = r.json() unspents = [] next_link = None if 'unspent' in response: unspents.extend( Unspent( currency_to_satoshi(tx['value'], 'btc'), tx['confirmations'], tx['script_pub_key']['hex'], tx['txid'], tx['n'], ) for tx in response['unspent'] ) next_link = response['paging']['next_link'] while next_link: r = requests.get(next_link, params=payload, timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError response = r.json() unspents.extend( Unspent( currency_to_satoshi(tx['value'], 'btc'), tx['confirmations'], tx['script_pub_key']['hex'], tx['txid'], tx['n'], ) for tx in response['unspent'] ) next_link = response['paging']['next_link'] return unspents
def get_unspent(cls, address): r = requests.get(cls.MAIN_UNSPENT_API.format(address), timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError return [ Unspent(currency_to_satoshi(tx['amount'], 'btc'), tx['confirmations'], tx['scriptPubKey'], tx['txid'], tx['vout']) for tx in r.json() ]
def get_unspent(cls, address): r = requests.get(cls.MAIN_UNSPENT_API.format(address) + '?limit=1000', timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError return [ Unspent(currency_to_satoshi(tx['value'], 'btc'), tx['confirmations'], tx['script_pub_key']['hex'], tx['txid'], tx['n']) for tx in r.json()['unspent'] ]
def get_unspent(self, address): r = self.listunspent(0, 9999999, [address]) return [ Unspent( currency_to_satoshi(tx["amount"], "btc"), tx["confirmations"], tx["scriptPubKey"], tx["txid"], tx["vout"], ) for tx in r ]
def get_unspent_testnet(cls, address): r = requests.get(cls.TEST_UNSPENT_API.format(address), timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError return [ Unspent( currency_to_satoshi(tx["amount"], "btc"), tx["confirmations"], tx["scriptPubKey"], tx["txid"], tx["vout"], ) for tx in r.json() ]
def _get_unspent(cls, network, address): url = "{endpoint}{network}/{address}".format( endpoint=cls.MAIN_TRANSACTIONS_UNSPENT, network=network, address=address) r = requests.get(url, timeout=DEFAULT_TIMEOUT) if r.status_code != 200: raise ConnectionError return [ Unspent(currency_to_satoshi(tx['value'], 'ltc'), tx['confirmations'], tx['script_hex'], tx['txid'], tx['output_no']) for tx in r.json()['data']["txs"] ]
def get_unspent_testnet(cls, address): r = requests.get( cls.TEST_UNSPENT_API.format(address) + "?limit=1000", timeout=DEFAULT_TIMEOUT, ) if r.status_code != 200: # pragma: no cover raise ConnectionError return [ Unspent( currency_to_satoshi(tx["value"], "btc"), tx["confirmations"], tx["script_pub_key"]["hex"], tx["txid"], tx["n"], ) for tx in r.json()["unspent"] ]
def get_unspent(cls, address: str) -> list: r = requests.get(cls.MAIN_UNSPENT_API.format(address), timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError try: return [ Unspent( # divide by 10**8 because explorer handles the decimals wrong (extra 2 zeros) currency_to_satoshi(tx["value"] / 10**8, "ppc"), 1, # presume 1 confirmation tx["script"], tx["tx_hash"], tx["tx_ouput_n"], ) for tx in r.json()['unspent_outputs'] ] except KeyError: return []
def get_balance_testnet(cls, address): r = requests.get(cls.TEST_BALANCE_API + address, timeout=DEFAULT_TIMEOUT) if r.status_code != 200: # pragma: no cover raise ConnectionError return currency_to_satoshi(r.json()['data']['balance'], 'btc')
def get_balance_testnet(cls, address): r = requests.get(cls.TEST_BALANCE_API + address, timeout=DEFAULT_TIMEOUT) return currency_to_satoshi(r.json()['data']['balance'], 'btc')