Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes transaction signing bug when tx had no change outputs #3213

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lbry/extras/daemon/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,6 @@ async def jsonrpc_channel_create(
)
txo = tx.outputs[0]
await txo.generate_channel_private_key()
tx._reset()

await tx.sign(funding_accounts)

Expand Down Expand Up @@ -2774,7 +2773,6 @@ async def jsonrpc_channel_update(
new_txo.private_key = old_txo.private_key

new_txo.script.generate()
tx._reset()

await tx.sign(funding_accounts)

Expand Down Expand Up @@ -3345,7 +3343,6 @@ async def jsonrpc_stream_create(
file_stream = await self.file_manager.create_stream(file_path)
claim.stream.source.sd_hash = file_stream.sd_hash
new_txo.script.generate()
tx._reset()

if channel:
new_txo.sign(channel)
Expand Down Expand Up @@ -3565,7 +3562,6 @@ async def jsonrpc_stream_update(
file_stream = await self.file_manager.create_stream(file_path)
new_txo.claim.stream.source.sd_hash = file_stream.sd_hash
new_txo.script.generate()
tx._reset()
stream_hash = file_stream.stream_hash
elif old_stream:
stream_hash = old_stream.stream_hash
Expand Down Expand Up @@ -3960,9 +3956,6 @@ async def jsonrpc_collection_update(
)
new_txo = tx.outputs[0]

new_txo.script.generate()
tx._reset()

if channel:
new_txo.sign(channel)
await tx.sign(funding_accounts)
Expand Down
1 change: 1 addition & 0 deletions lbry/wallet/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ def signature_hash_type(hash_type):
return hash_type

async def sign(self, funding_accounts: Iterable['Account']):
self._reset()
ledger, wallet = self.ensure_all_have_same_ledger_and_wallet(funding_accounts)
for i, txi in enumerate(self._inputs):
assert txi.script is not None
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/blockchain/test_claim_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1976,10 +1976,14 @@ async def test_regular_supports_and_tip_supports(self):
self.assertTrue(txs[1]['support_info'][0]['is_tip'])
self.assertTrue(txs[1]['support_info'][0]['is_spent'])

async def test_signed_supports(self):
async def test_signed_supports_with_no_change_txo_regression(self):
# reproduces a bug where transactions did not get properly signed
# if there was no change and just a single output
# lbrycrd returned 'the transaction was rejected by network rules.'
channel_id = self.get_claim_id(await self.channel_create())
stream_id = self.get_claim_id(await self.stream_create())
tx = await self.support_create(stream_id, '0.3', channel_id=channel_id)
tx = await self.support_create(stream_id, '7.967598', channel_id=channel_id)
self.assertEqual(len(tx['outputs']), 1) # must be one to reproduce bug
self.assertTrue(tx['outputs'][0]['is_channel_signature_valid'])


Expand Down