diff --git a/counterpartylib/lib/blocks.py b/counterpartylib/lib/blocks.py index 20903d3003..df3a4d857a 100644 --- a/counterpartylib/lib/blocks.py +++ b/counterpartylib/lib/blocks.py @@ -104,9 +104,9 @@ def parse_tx(db, tx): order.parse(db, tx, message) elif message_type_id == btcpay.ID: btcpay.parse(db, tx, message) - elif message_type_id == issuance.ID: + elif message_type_id == issuance.ID or (util.enabled("issuance_backwards_compatibility", block_index=tx['block_index']) and message_type_id == issuance.LR_ISSUANCE_ID): issuance.parse(db, tx, message, message_type_id) - elif message_type_id == issuance.SUBASSET_ID and util.enabled('subassets', block_index=tx['block_index']): + elif (message_type_id == issuance.SUBASSET_ID and util.enabled('subassets', block_index=tx['block_index'])) or (util.enabled("issuance_backwards_compatibility", block_index=tx['block_index']) and message_type_id == issuance.LR_SUBASSET_ID): issuance.parse(db, tx, message, message_type_id) elif message_type_id == broadcast.ID: broadcast.parse(db, tx, message) diff --git a/counterpartylib/lib/messages/issuance.py b/counterpartylib/lib/messages/issuance.py index 2698c6a1b0..8032d05657 100644 --- a/counterpartylib/lib/messages/issuance.py +++ b/counterpartylib/lib/messages/issuance.py @@ -23,6 +23,11 @@ SUBASSET_ID = 21 # NOTE: Pascal strings are used for storing descriptions for backwards‐compatibility. +#Lock Reset issuances. Default composed message +LR_ISSUANCE_ID = 22 +LR_SUBASSET_ID = 23 + + def initialise(db): cursor = db.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS issuances( @@ -342,7 +347,11 @@ def compose (db, source, transfer_destination, asset, quantity, divisible, lock, # Type 20 standard issuance FORMAT_2 >QQ??If # used for standard issuances and all reissuances - data = message_type.pack(ID) + if util.enabled("issuance_backwards_compatibility"): + data = message_type.pack(LR_ISSUANCE_ID) + else: + data = message_type.pack(ID) + if (len(description) <= 42) and not util.enabled('pascal_string_removed'): curr_format = FORMAT_2 + '{}p'.format(len(description) + 1) else: @@ -368,7 +377,11 @@ def compose (db, source, transfer_destination, asset, quantity, divisible, lock, # compacts a subasset name to save space compacted_subasset_longname = util.compact_subasset_longname(subasset_longname) compacted_subasset_length = len(compacted_subasset_longname) - data = message_type.pack(SUBASSET_ID) + if util.enabled("issuance_backwards_compatibility"): + data = message_type.pack(LR_SUBASSET_ID) + else: + data = message_type.pack(SUBASSET_ID) + curr_format = subasset_format + '{}s'.format(compacted_subasset_length) + '{}s'.format(len(description)) if subasset_format_length <= 18: @@ -394,7 +407,7 @@ def parse (db, tx, message, message_type_id): # Unpack message. try: subasset_longname = None - if message_type_id == SUBASSET_ID: + if message_type_id == LR_SUBASSET_ID or message_type_id == SUBASSET_ID: if not util.enabled('subassets', block_index=tx['block_index']): logger.warn("subassets are not enabled at block %s" % tx['block_index']) raise exceptions.UnpackError diff --git a/counterpartylib/protocol_changes.json b/counterpartylib/protocol_changes.json index 6a252fc9a6..cea0e28f0d 100644 --- a/counterpartylib/protocol_changes.json +++ b/counterpartylib/protocol_changes.json @@ -419,5 +419,12 @@ "minimum_version_revision": 2, "block_index": 825000, "testnet_block_index": 2412394 + }, + "issuance_backwards_compatibility": { + "minimum_version_major": 9, + "minimum_version_minor": 60, + "minimum_version_revision": 2, + "block_index": 825000, + "testnet_block_index": 2422000 } }