fixed output public_keys order bug

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2022-04-19 23:32:56 +02:00
parent b7c4acd830
commit 90fca9c4e1
2 changed files with 8 additions and 3 deletions

View File

@ -57,7 +57,7 @@ outputs:create_index('unique_search' ,{type='hash', parts={'output_id'}})
outputs:create_index('id_search' ,{type='tree', unique=false, parts={'transaction_id'}}) outputs:create_index('id_search' ,{type='tree', unique=false, parts={'transaction_id'}})
keys = box.schema.space.create('keys') keys = box.schema.space.create('keys')
keys:format({{name = 'id', type='string'}, {name = 'transaction_id', type = 'string'} ,{name = 'output_id', type = 'string'}, {name = 'public_key', type = 'string'}}) keys:format({{name = 'id', type='string'}, {name = 'transaction_id', type = 'string'} ,{name = 'output_id', type = 'string'}, {name = 'public_key', type = 'string'}, {name = 'key_index', type = 'integer'}})
keys:create_index('id_search', {type = 'hash', parts={'id'}}) keys:create_index('id_search', {type = 'hash', parts={'id'}})
keys:create_index('keys_search', {type = 'tree', unique=false, parts={'public_key'}}) keys:create_index('keys_search', {type = 'tree', unique=false, parts={'public_key'}})
keys:create_index('txid_search', {type = 'tree', unique=false, parts={'transaction_id'}}) keys:create_index('txid_search', {type = 'tree', unique=false, parts={'transaction_id'}})

View File

@ -106,9 +106,11 @@ class TransactionDecompose:
print(f"\noutput: {tmp_output}") print(f"\noutput: {tmp_output}")
_outputs.append(tmp_output) _outputs.append(tmp_output)
output_index = output_index + 1 output_index = output_index + 1
key_index = 0
for _key in _output["public_keys"]: for _key in _output["public_keys"]:
key_id = self.__create_hash(7) key_id = self.__create_hash(7)
_keys.append((key_id, self._transaction["id"], output_id, _key)) _keys.append((key_id, self._transaction["id"], output_id, _key, key_index))
key_index = key_index + 1
return _keys, _outputs return _keys, _outputs
def __prepare_transaction(self): def __prepare_transaction(self):
@ -171,7 +173,10 @@ class TransactionCompose:
print (f"\noutput : {_output}") print (f"\noutput : {_output}")
_out = self._map["outputs"].copy() _out = self._map["outputs"].copy()
_out["amount"] = _output[1] _out["amount"] = _output[1]
_out["public_keys"] = [_key[3] for _key in self.db_results["keys"] if _key[2] == _output[5]] _tmp_keys = [(_key[3], _key[4]) for _key in self.db_results["keys"] if _key[2] == _output[5]]
_sorted_keys = sorted(_tmp_keys, key=lambda tup: (tup[1]) )
_out["public_keys"] = [_key[0] for _key in _sorted_keys]
_out["condition"]["uri"] = _output[2] _out["condition"]["uri"] = _output[2]
if self.db_results["outputs"][0][7] is None: if self.db_results["outputs"][0][7] is None:
_out["condition"]["details"]["type"] = _output[3] _out["condition"]["details"]["type"] = _output[3]