コード例 #1
0
ファイル: services.py プロジェクト: ngoctrantl/bitcash
 def get_unspent(cls, address):
     r = requests.get(cls.MAIN_UNSPENT_API.format(address),
                      timeout=DEFAULT_TIMEOUT)
     r.raise_for_status()  # pragma: no cover
     return [
         Unspent(currency_to_satoshi(tx['amount'],
                                     'bch'), tx['confirmations'],
                 tx['scriptPubKey'], tx['txid'], tx['vout'])
         for tx in r.json()
     ]
コード例 #2
0
ファイル: services.py プロジェクト: joemarct/bitcash
 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'],
                                     'bch'), tx['confirmations'],
                 tx['scriptPubKey'], tx['txid'], tx['vout'])
         for tx in r.json()
     ]
コード例 #3
0
ファイル: services.py プロジェクト: ngoctrantl/bitcash
 def get_unspent(cls, address):
     address = address.replace('bitcoincash:', '')
     r = requests.get(cls.MAIN_UNSPENT_API.format(address),
                      timeout=DEFAULT_TIMEOUT)
     r.raise_for_status()  # pragma: no cover
     return [
         Unspent(currency_to_satoshi(tx['value'],
                                     'satoshi'), tx['confirmations'],
                 tx['script'], tx['mintTxid'], tx['mintIndex'])
         for tx in r.json()
     ]
コード例 #4
0
ファイル: services.py プロジェクト: vinayhosahalli/bitcash
 def get_unspent(cls, address, network):
     API = cls.network_endpoint(network) + cls.UNSPENT_PATH
     r = requests.get(API.format(address), timeout=DEFAULT_TIMEOUT)
     r.raise_for_status()
     return [
         Unspent(
             currency_to_satoshi(tx["amount"], "bch"),
             tx["confirmations"],
             r.json()["scriptPubKey"],
             tx["txid"],
             tx["vout"],
         ) for tx in r.json()["utxos"]
     ]
コード例 #5
0
ファイル: services.py プロジェクト: jackmaninov/bitcash
 def get_unspent(cls, address):
     # As of 2018-05-16, cashexplorer.bitcoin.com only supports legacy addresses.
     address = cashaddress.to_legacy_address(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'],
                                     'bch'), tx['confirmations'],
                 tx['scriptPubKey'], tx['txid'], tx['vout'])
         for tx in r.json()
     ]
コード例 #6
0
ファイル: services.py プロジェクト: remem9527/bchmemo
 def get_unspent(cls, address):
     if not cls.NEW_ADDRESS_SUPPORTED:
         address = cashaddress.to_legacy_address(address)
     r = requests.get((cls.MAIN_ENDPOINT+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'], 'bch'),
                 tx['confirmations'],
                 tx['scriptPubKey'],
                 tx['txid'],
                 tx['vout'])
         for tx in r.json()
     ]
コード例 #7
0
ファイル: services.py プロジェクト: jackmaninov/bitcash
    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
        unspents = []
        for tx in r.json():
            # In weird conditions, the API will send back unspents without a scriptPubKey.
            if 'scriptPubKey' in tx:
                unspents.append(
                    Unspent(currency_to_satoshi(tx['amount'],
                                                'bch'), tx['confirmations'],
                            tx['scriptPubKey'], tx['txid'], tx['vout']))
            else:
                logging.warning('Unspent without scriptPubKey.')

        return unspents
コード例 #8
0
ファイル: services.py プロジェクト: ngoctrantl/bitcash
    def get_unspent_testnet(cls, address):
        address = address.replace('bchtest:', '')
        r = requests.get(cls.TEST_UNSPENT_API.format(address),
                         timeout=DEFAULT_TIMEOUT)
        r.raise_for_status()  # pragma: no cover
        unspents = []
        for tx in r.json():
            # In weird conditions, the API will send back unspents
            # without a scriptPubKey.
            if 'script' in tx:
                unspents.append(
                    Unspent(currency_to_satoshi(tx['value'], 'satoshi'),
                            tx['confirmations'], tx['script'], tx['mintTxid'],
                            tx['mintIndex']))
            else:
                logging.warning('Unspent without scriptPubKey.')

        return unspents
コード例 #9
0
ファイル: services.py プロジェクト: vinayhosahalli/bitcash
    def get_unspent(cls, address, network):
        address = cls.remove_prefix(address)
        API = cls.network_endpoint(network) + cls.UNSPENT_API
        r = requests.get(API.format(address), timeout=DEFAULT_TIMEOUT)
        r.raise_for_status()
        unspents = []
        for tx in r.json():
            # In weird conditions, the API will send back unspents
            # without a scriptPubKey.
            if "script" in tx:
                unspents.append(
                    Unspent(
                        currency_to_satoshi(tx["value"], "satoshi"),
                        tx["confirmations"],
                        tx["script"],
                        tx["mintTxid"],
                        tx["mintIndex"],
                    ))
            else:
                logging.warning("Unspent without scriptPubKey.")

        return unspents
コード例 #10
0
 def to_satoshi(coins):
     return currency_to_satoshi(coins, 'bch')
コード例 #11
0
 def from_bits(coins):
     return currency_to_satoshi(coins, 'mbch')