From d2ebbf5db64243c124c8946595e71f356893ee57 Mon Sep 17 00:00:00 2001 From: vertbyqb Date: Sun, 2 Jan 2022 00:51:34 -0600 Subject: [PATCH 1/2] jsonrpc_channel_sign - Convert hexdata to a string before signing Fixes #3533 --- lbry/extras/daemon/daemon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index bac6c3e6e..646519a0f 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2908,6 +2908,7 @@ class Daemon(metaclass=JSONRPCServerType): "signing_ts": (str) The timestamp used to sign the comment, } """ + hexdata = str(hexdata) wallet = self.wallet_manager.get_wallet_or_default(wallet_id) assert not wallet.is_locked, "Cannot spend funds with locked wallet, unlock first." signing_channel = await self.get_channel_or_error( From aaa11c02bf18b01f4923a532c4156aac2a2a2f0d Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 10 Jan 2022 08:44:28 -0500 Subject: [PATCH 2/2] added integration test --- lbry/extras/daemon/daemon.py | 3 +-- tests/integration/claims/test_claim_commands.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index 646519a0f..c67a5b7e4 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2908,14 +2908,13 @@ class Daemon(metaclass=JSONRPCServerType): "signing_ts": (str) The timestamp used to sign the comment, } """ - hexdata = str(hexdata) wallet = self.wallet_manager.get_wallet_or_default(wallet_id) assert not wallet.is_locked, "Cannot spend funds with locked wallet, unlock first." signing_channel = await self.get_channel_or_error( wallet, channel_account_id, channel_id, channel_name, for_signing=True ) timestamp = str(int(time.time())) - signature = signing_channel.sign_data(unhexlify(hexdata), timestamp) + signature = signing_channel.sign_data(unhexlify(str(hexdata)), timestamp) return { 'signature': signature, 'signing_ts': timestamp diff --git a/tests/integration/claims/test_claim_commands.py b/tests/integration/claims/test_claim_commands.py index e8b1e0d3f..b5aeefdd0 100644 --- a/tests/integration/claims/test_claim_commands.py +++ b/tests/integration/claims/test_claim_commands.py @@ -1233,6 +1233,8 @@ class ChannelCommands(CommandTestCase): signature2 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=data_to_sign)) self.assertTrue(verify(channel, unhexlify(data_to_sign), signature1)) self.assertTrue(verify(channel, unhexlify(data_to_sign), signature2)) + signature3 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=99)) + self.assertTrue(verify(channel, unhexlify('99'), signature3)) async def test_channel_export_import_before_sending_channel(self): # export