Skip to content

Commit

Permalink
Merge branch 'master' of github.com:CounterpartyXCP/counterparty-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jdogresorg committed Aug 25, 2022
2 parents eb22c3e + dec2136 commit d648bbd
Show file tree
Hide file tree
Showing 4 changed files with 383 additions and 109 deletions.
42 changes: 33 additions & 9 deletions counterpartylib/lib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,26 +262,32 @@ def output (quantity, asset):
logger.info('{} Payment: {} paid {} to {} for order match {} ({}) [{}]'.format(config.BTC, bindings['source'], output(bindings['btc_amount'], config.BTC), bindings['destination'], bindings['order_match_id'], bindings['tx_hash'], bindings['status']))

elif category == 'issuances':
if bindings['transfer']:
logger.info('Issuance: {} transfered asset {} to {} ({}) [{}]'.format(bindings['source'], bindings['asset'], bindings['issuer'], bindings['tx_hash'], bindings['status']))
elif bindings['locked']:
logger.info('Issuance: {} locked asset {} ({}) [{}]'.format(bindings['issuer'], bindings['asset'], bindings['tx_hash'], bindings['status']))
else:
if (get_asset_issuances_quantity(cursor, bindings["asset"]) == 0) or (bindings['quantity'] > 0): #This is the first issuance or the creation of more supply, so we have to log the creation of the token
if bindings['divisible']:
divisibility = 'divisible'
unit = config.UNIT
else:
divisibility = 'indivisible'
unit = 1
try:
quantity = util.value_out(db, bindings['quantity'], None, divisible=bindings['divisible'])
quantity = util.value_out(cursor, bindings['quantity'], None, divisible=bindings['divisible'])
except Exception as e:
quantity = '?'

if 'asset_longname' in bindings and bindings['asset_longname'] is not None:
logger.info('Subasset Issuance: {} created {} of {} subasset {} as numeric asset {} ({}) [{}]'.format(bindings['issuer'], quantity, divisibility, bindings['asset_longname'], bindings['asset'], bindings['tx_hash'], bindings['status']))
logger.info('Subasset Issuance: {} created {} of {} subasset {} as numeric asset {} ({}) [{}]'.format(bindings['source'], quantity, divisibility, bindings['asset_longname'], bindings['asset'], bindings['tx_hash'], bindings['status']))
else:
logger.info('Issuance: {} created {} of {} asset {} ({}) [{}]'.format(bindings['issuer'], quantity, divisibility, bindings['asset'], bindings['tx_hash'], bindings['status']))

logger.info('Issuance: {} created {} of {} asset {} ({}) [{}]'.format(bindings['source'], quantity, divisibility, bindings['asset'], bindings['tx_hash'], bindings['status']))

if bindings['locked']:
lock_issuance = get_lock_issuance(cursor, bindings["asset"])

if (lock_issuance == None) or (lock_issuance['tx_hash'] == bindings['tx_hash']):
logger.info('Issuance: {} locked asset {} ({}) [{}]'.format(bindings['source'], bindings['asset'], bindings['tx_hash'], bindings['status']))

if bindings['transfer']:
logger.info('Issuance: {} transfered asset {} to {} ({}) [{}]'.format(bindings['source'], bindings['asset'], bindings['issuer'], bindings['tx_hash'], bindings['status']))

elif category == 'broadcasts':
if bindings['locked']:
logger.info('Broadcast: {} locked his feed ({}) [{}]'.format(bindings['source'], bindings['tx_hash'], bindings['status']))
Expand Down Expand Up @@ -407,6 +413,24 @@ def output (quantity, asset):

cursor.close()

def get_lock_issuance(cursor, asset):
cursor.execute('''SELECT * FROM issuances \
WHERE (status = ? AND asset = ? AND locked = ?)
ORDER BY tx_index ASC''', ('valid', asset, True))
issuances = cursor.fetchall()

if len(issuances) > 0:
return issuances[0]

return None

def get_asset_issuances_quantity(cursor, asset):
cursor.execute('''SELECT COUNT(*) AS issuances_count FROM issuances \
WHERE (status = ? AND asset = ?)
ORDER BY tx_index DESC''', ('valid', asset))
issuances = cursor.fetchall()
return issuances[0]['issuances_count']

def get_asset_info(cursor, asset):
if asset == config.BTC or asset == config.XCP:
return True
Expand Down
Loading

0 comments on commit d648bbd

Please sign in to comment.