Example #1
0
 def get_supply(asset):
     if asset == 'BTC':
         return  backend.get_btc_supply(normalize=False)
     elif asset == 'XCP':
         return util.xcp_supply(db)
     else:
         return util.asset_supply(db, asset)
Example #2
0
 def get_supply(asset):
     if asset == 'BTC':
         return backend.get_btc_supply(normalize=False)
     elif asset == 'XCP':
         return util.xcp_supply(db)
     else:
         return util.asset_supply(db, asset)
Example #3
0
 def get_supply(asset):
     if asset == config.BTC:
         return backend.get_btc_supply(normalize=False)
     elif asset == config.XCP:
         return util.xcp_supply(self.db)
     else:
         asset = util.resolve_subasset_longname(self.db, asset)
         return util.asset_supply(self.db, asset)
Example #4
0
 def get_supply(asset):
     if asset == 'BTC':
         return backend.get_btc_supply(normalize=False)
     elif asset == 'XCP':
         return util.xcp_supply(db)
     else:
         asset = util.resolve_subasset_longname(db, asset)
         return util.asset_supply(db, asset)
Example #5
0
        def get_asset_info(assets):
            logger.warning("Deprecated method: `get_asset_info`")
            if not isinstance(assets, list):
                raise APIError("assets must be a list of asset names, even if it just contains one entry")
            assetsInfo = []
            for asset in assets:
                asset = util.resolve_subasset_longname(self.db, asset)

                # BTC and XCP.
                if asset in [config.BTC, config.XCP]:
                    if asset == config.BTC:
                        supply = backend.get_btc_supply(normalize=False)
                    else:
                        supply = util.xcp_supply(self.db)

                    assetsInfo.append({
                        'asset': asset,
                        'asset_longname': None,
                        'owner': None,
                        'divisible': True,
                        'listed': True,
                        'reassignable': True,
                        'vendable': False if asset == config.BTC else True,
                        'locked': False,
                        'supply': supply,
                        'description': '',
                        'issuer': None
                    })
                    continue

                # User‐created asset.
                cursor = self.db.cursor()
                issuances = list(cursor.execute('''SELECT * FROM issuances WHERE (status = ? AND asset = ?) ORDER BY block_index ASC''', ('valid', asset)))
                if not issuances:
                    continue #asset not found, most likely
                else:
                    last_issuance = issuances[-1]
                locked = False
                for e in issuances:
                    if e['locked']: locked = True
                assetsInfo.append({
                    'asset': asset,
                    'asset_longname': last_issuance['asset_longname'],
                    'owner': last_issuance['issuer'],
                    'divisible': bool(last_issuance['divisible']),
                    'listed': bool(last_issuance['listed']),
                    'reassignable': bool(last_issuance['reassignable']),
                    'vendable': bool(last_issuance['vendable']),
                    'locked': locked,
                    'supply': util.asset_supply(self.db, asset),
                    'description': last_issuance['description'],
                    'issuer': last_issuance['issuer']})
            return assetsInfo
Example #6
0
        def get_asset_info(assets):
            logger.warning("Deprecated method: `get_asset_info`")
            if not isinstance(assets, list):
                raise APIError("assets must be a list of asset names, even if it just contains one entry")
            assetsInfo = []
            for asset in assets:

                # BTC and XCP.
                if asset in [config.BTC, config.XCP]:
                    if asset == config.BTC:
                        supply = backend.get_btc_supply(normalize=False)
                    else:
                        supply = util.xcp_supply(db)

                    assetsInfo.append({
                        'asset': asset,
                        'owner': None,
                        'divisible': True,
                        'locked': False,
                        'supply': supply,
                        'description': '',
                        'issuer': None
                    })
                    continue

                # User‐created asset.
                cursor = db.cursor()
                issuances = list(cursor.execute('''SELECT * FROM issuances WHERE (status = ? AND asset = ?) ORDER BY block_index ASC''', ('valid', asset)))
                cursor.close()
                if not issuances:
                    continue #asset not found, most likely
                else:
                    last_issuance = issuances[-1]
                locked = False
                for e in issuances:
                    if e['locked']: locked = True
                assetsInfo.append({
                    'asset': asset,
                    'owner': last_issuance['issuer'],
                    'divisible': bool(last_issuance['divisible']),
                    'locked': locked,
                    'supply': util.asset_supply(db, asset),
                    'description': last_issuance['description'],
                    'issuer': last_issuance['issuer']})
            return assetsInfo