Skip to content

Commit

Permalink
Merge pull request #1457 from CounterpartyXCP/hotfix
Browse files Browse the repository at this point in the history
Hotfixes
  • Loading branch information
adamkrellenstein authored Feb 27, 2024
2 parents e65172a + 98171e3 commit af78ad5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Library Versions ##
* v9.61.2 (2024-02-28)
* Fix integer overflow in dispensers.
* Invalidate broadcast with malformed text.
* Fix Logging for Destructions with Invalid Asset.
* v9.60.0 (2022-08-29)
* Removed `callable`,`call_date`, and `call_price` from issuances
* Added support for CIP24 (Oracled Dispensers)
Expand Down
2 changes: 1 addition & 1 deletion counterpartylib/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Versions
VERSION_MAJOR = 9
VERSION_MINOR = 61
VERSION_REVISION = 1
VERSION_REVISION = 2
VERSION_STRING = str(VERSION_MAJOR) + '.' + str(VERSION_MINOR) + '.' + str(VERSION_REVISION)


Expand Down
11 changes: 7 additions & 4 deletions counterpartylib/lib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,13 @@ def output (quantity, asset):
logger.info('Expired RPS Match: {}'.format(bindings['rps_match_id']))

elif category == 'destructions':
asset_info = get_asset_info(cursor, bindings['asset'])
quantity = bindings['quantity']
if asset_info['divisible']:
quantity = "{:.8f}".format(quantity/config.UNIT)
try:
asset_info = get_asset_info(cursor, bindings['asset'])
quantity = bindings['quantity']
if asset_info['divisible']:
quantity = "{:.8f}".format(quantity/config.UNIT)
except IndexError as e:
quantity = '?'

logger.info('Destruction: {} destroyed {} {} with tag ‘{}’({}) [{}]'.format(bindings['source'], quantity, bindings['asset'], bindings['tag'], bindings['tx_hash'], bindings['status']))

Expand Down
5 changes: 4 additions & 1 deletion counterpartylib/lib/messages/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ def parse (db, tx, message):
except (struct.error) as e:
timestamp, value, fee_fraction_int, text = 0, None, 0, None
status = 'invalid: could not unpack'

except AssertionError:
timestamp, value, fee_fraction_int, text = 0, None, 0, None
status = "invalid: could not unpack text"

if status == 'valid':
# For SQLite3
timestamp = min(timestamp, config.MAX_INT)
Expand Down
11 changes: 7 additions & 4 deletions counterpartylib/lib/messages/dispenser.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,18 @@ def validate (db, source, asset, give_quantity, escrow_quantity, mainchainrate,
problems.append('cannot dispense %s' % asset) # How can we test this on a test vector?
else:
problems.append('address has already a dispenser about to close, no action can be taken until it closes')

cursor.close()

if oracle_address is not None and util.enabled('oracle_dispensers', block_index):
last_price, last_fee, last_label, last_updated = util.get_oracle_last_price(db, oracle_address, block_index)

if last_price is None:
problems.append('The oracle address %s has not broadcasted any price yet' % oracle_address)


if give_quantity > config.MAX_INT or escrow_quantity > config.MAX_INT or mainchainrate > config.MAX_INT:
problems.append('integer overflow')

if len(problems) > 0:
return None, problems
else:
Expand Down

0 comments on commit af78ad5

Please sign in to comment.