diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index 8ce3b1e0a2..5d16812bff 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2943,19 +2943,21 @@ async def jsonrpc_channel_update( @requires(WALLET_COMPONENT) async def jsonrpc_channel_sign( - self, channel_name=None, channel_id=None, hexdata=None, channel_account_id=None, wallet_id=None): + self, channel_name=None, channel_id=None, hexdata=None, salt=None, + channel_account_id=None, wallet_id=None): """ Signs data using the specified channel signing key. Usage: - channel_sign [ | --channel_name=] - [ | --channel_id=] [ | --hexdata=] + channel_sign [ | --channel_name=] [ | --channel_id=] + [ | --hexdata=] [ | --salt=] [--channel_account_id=...] [--wallet_id=] Options: --channel_name= : (str) name of channel used to sign (or use channel id) --channel_id= : (str) claim id of channel used to sign (or use channel name) --hexdata= : (str) data to sign, encoded as hexadecimal + --salt= : (str) salt to use for signing, default is to use timestamp --channel_account_id=: (str) one or more account ids for accounts to look in for channel certificates, defaults to all accounts. --wallet_id= : (str) restrict operation to specific wallet @@ -2972,11 +2974,13 @@ async def jsonrpc_channel_sign( 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(str(hexdata)), timestamp) + if salt is None: + salt = str(int(time.time())) + signature = signing_channel.sign_data(unhexlify(str(hexdata)), salt) return { 'signature': signature, - 'signing_ts': timestamp + 'signing_ts': salt, # DEPRECATED + 'salt': salt, } @requires(WALLET_COMPONENT) diff --git a/tests/integration/claims/test_claim_commands.py b/tests/integration/claims/test_claim_commands.py index 9b475950fa..d3fbda0436 100644 --- a/tests/integration/claims/test_claim_commands.py +++ b/tests/integration/claims/test_claim_commands.py @@ -31,7 +31,7 @@ def verify(channel, data, signature, channel_hash=None): pieces = [ - signature['signing_ts'].encode(), + signature['salt'].encode(), channel_hash or channel.claim_hash, data ] @@ -1239,8 +1239,13 @@ async def test_sign_hex_encoded_data(self): channel = channel_tx.outputs[0] signature1 = await self.out(self.daemon.jsonrpc_channel_sign(channel_name='@signer', hexdata=data_to_sign)) signature2 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=data_to_sign)) + signature3 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=data_to_sign, salt='beef')) + signature4 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=data_to_sign, salt='beef')) + self.assertNotEqual(signature2, signature3) + self.assertEqual(signature3, signature4) self.assertTrue(verify(channel, unhexlify(data_to_sign), signature1)) self.assertTrue(verify(channel, unhexlify(data_to_sign), signature2)) + self.assertTrue(verify(channel, unhexlify(data_to_sign), signature3)) signature3 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=99)) self.assertTrue(verify(channel, unhexlify('99'), signature3))