forked from LBRYCommunity/lbry-sdk
fix
This commit is contained in:
parent
dd68fb077b
commit
cba9c16a06
2 changed files with 6 additions and 7 deletions
|
@ -818,10 +818,10 @@ class Transaction:
|
||||||
)
|
)
|
||||||
if payment > cost:
|
if payment > cost:
|
||||||
change = payment - cost
|
change = payment - cost
|
||||||
if change > cost_of_change and change > DUST:
|
change_amount = change - cost_of_change
|
||||||
|
if change_amount > DUST:
|
||||||
change_address = await change_account.change.get_or_create_usable_address()
|
change_address = await change_account.change.get_or_create_usable_address()
|
||||||
change_hash160 = change_account.ledger.address_to_hash160(change_address)
|
change_hash160 = change_account.ledger.address_to_hash160(change_address)
|
||||||
change_amount = change - cost_of_change
|
|
||||||
change_output = Output.pay_pubkey_hash(change_amount, change_hash160)
|
change_output = Output.pay_pubkey_hash(change_amount, change_hash160)
|
||||||
change_output.is_internal_transfer = True
|
change_output.is_internal_transfer = True
|
||||||
tx.add_outputs([Output.pay_pubkey_hash(change_amount, change_hash160)])
|
tx.add_outputs([Output.pay_pubkey_hash(change_amount, change_hash160)])
|
||||||
|
|
|
@ -5,15 +5,14 @@ class TransactionCommandsTestCase(CommandTestCase):
|
||||||
|
|
||||||
async def test_txo_dust_prevention(self):
|
async def test_txo_dust_prevention(self):
|
||||||
address = await self.daemon.jsonrpc_address_unused(self.account.id)
|
address = await self.daemon.jsonrpc_address_unused(self.account.id)
|
||||||
tx = await self.account_send('9.9998758', address)
|
tx = await self.account_send('9.9997758', address)
|
||||||
# dust prevention threshold not reached, small txo created
|
# dust prevention threshold not reached, small txo created
|
||||||
self.assertEqual(2, len(tx['outputs']))
|
self.assertEqual(2, len(tx['outputs']))
|
||||||
self.assertEqual(tx['outputs'][1]['amount'], '0.0000002')
|
self.assertEqual(tx['outputs'][1]['amount'], '0.0001002')
|
||||||
tx = await self.account_send('8.9998759', address)
|
tx = await self.account_send('9.999706', address)
|
||||||
# prior to dust prevention this produced a '0.0000001' change txo
|
|
||||||
# dust prevention prevented dust
|
# dust prevention prevented dust
|
||||||
self.assertEqual(1, len(tx['outputs']))
|
self.assertEqual(1, len(tx['outputs']))
|
||||||
self.assertEqual(tx['outputs'][0]['amount'], '8.9998759')
|
self.assertEqual(tx['outputs'][0]['amount'], '9.999706')
|
||||||
|
|
||||||
async def test_transaction_show(self):
|
async def test_transaction_show(self):
|
||||||
# local tx
|
# local tx
|
||||||
|
|
Loading…
Reference in a new issue