Skip to content

Commit bc61bae

Browse files
committed
1 parent e1e11e5 commit bc61bae

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tronapi/trx.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,9 @@ def sign(self, transaction: Any, use_tron: bool = True, multisig: bool = False):
561561
header = TRX_MESSAGE_HEADER if use_tron else ETH_MESSAGE_HEADER
562562
header += str(len(transaction))
563563

564-
message_hash = self.tron.keccak(text=header + transaction)
565-
566-
signed_message = Account.sign_hash(
567-
message_hash, self.tron.private_key
568-
)
564+
message_hash = self.tron.keccak(text=header+transaction)
569565

566+
signed_message = Account.sign_hash(self.tron.toHex(message_hash), self.tron.private_key)
570567
return signed_message
571568

572569
if not multisig and 'signature' in transaction:
@@ -652,8 +649,8 @@ def verify_message(self, message, signed_message=None, address=None, use_tron: b
652649
# before encrypting or decrypting
653650
header = TRX_MESSAGE_HEADER if use_tron else ETH_MESSAGE_HEADER
654651

655-
message_hash = self.tron.keccak(text=header + message)
656-
recovered = Account.recover_hash(message_hash, signed_message.signature)
652+
message_hash = self.tron.keccak(text=header+message)
653+
recovered = Account.recover_hash(self.tron.toHex(message_hash), signed_message.signature)
657654

658655
tron_address = '41' + recovered[2:]
659656
base58address = self.tron.address.from_hex(tron_address).decode()

0 commit comments

Comments
 (0)