def is_divisible(db, asset): """Check if the asset is divisible.""" if asset in (config.BTC, config.XCP): return True else: cursor = db.cursor() cursor.execute('''SELECT * FROM issuances \ WHERE (status = ? AND asset = ?)''', ('valid', asset)) issuances = cursor.fetchall() if not issuances: raise exceptions.AssetError('No such asset: {}'.format(asset)) return issuances[0]['divisible']
def get_asset_id (db, asset_name, block_index): """Return asset_id from asset_name.""" if not enabled('hotfix_numeric_assets'): return generate_asset_id(asset_name, block_index) cursor = db.cursor() cursor.execute('''SELECT * FROM assets WHERE asset_name = ?''', (asset_name,)) assets = list(cursor) if len(assets) == 1: return int(assets[0]['asset_id']) else: raise exceptions.AssetError('No such asset: {}'.format(asset_name))