forked from LBRYCommunity/lbry-sdk
integration tests for jsonrpc_transaction_show fixed
This commit is contained in:
parent
048aa07e80
commit
587f0b2ea8
3 changed files with 6 additions and 6 deletions
|
@ -197,10 +197,12 @@ class LbryWalletManager(BaseWalletManager):
|
||||||
tx = await self.db.get_transaction(txid=txid)
|
tx = await self.db.get_transaction(txid=txid)
|
||||||
if not tx:
|
if not tx:
|
||||||
try:
|
try:
|
||||||
_raw = await self.ledger.network.get_transaction(txid)
|
raw = await self.ledger.network.get_transaction(txid)
|
||||||
|
height = await self.ledger.network.get_transaction_height(txid)
|
||||||
except CodeMessageError as e:
|
except CodeMessageError as e:
|
||||||
return {'success': False, 'code': e.code, 'message': e.message}
|
return {'success': False, 'code': e.code, 'message': e.message}
|
||||||
tx = self.ledger.transaction_class(unhexlify(_raw))
|
tx = self.ledger.transaction_class(unhexlify(raw))
|
||||||
|
await self.ledger.maybe_verify_transaction(tx, height)
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -61,9 +61,7 @@ class LBRYElectrumX(ElectrumX):
|
||||||
transaction_info = await self.daemon.getrawtransaction(tx_hash, True)
|
transaction_info = await self.daemon.getrawtransaction(tx_hash, True)
|
||||||
if transaction_info and 'hex' in transaction_info and 'confirmations' in transaction_info:
|
if transaction_info and 'hex' in transaction_info and 'confirmations' in transaction_info:
|
||||||
# an unconfirmed transaction from lbrycrdd will not have a 'confirmations' field
|
# an unconfirmed transaction from lbrycrdd will not have a 'confirmations' field
|
||||||
height = self.db.db_height
|
return (self.db.db_height - transaction_info['confirmations']) + 1
|
||||||
height = height - transaction_info['confirmations']
|
|
||||||
return height
|
|
||||||
elif transaction_info and 'hex' in transaction_info:
|
elif transaction_info and 'hex' in transaction_info:
|
||||||
return -1
|
return -1
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TransactionCommandsTestCase(CommandTestCase):
|
||||||
sendtxid = await self.blockchain.send_to_address(change_address, 10)
|
sendtxid = await self.blockchain.send_to_address(change_address, 10)
|
||||||
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
|
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
|
||||||
self.assertEqual(tx.id, sendtxid)
|
self.assertEqual(tx.id, sendtxid)
|
||||||
self.assertEqual(tx.height, -2)
|
self.assertEqual(tx.height, -1)
|
||||||
await self.generate(1)
|
await self.generate(1)
|
||||||
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
|
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
|
||||||
self.assertEqual(tx.height, self.ledger.headers.height)
|
self.assertEqual(tx.height, self.ledger.headers.height)
|
||||||
|
|
Loading…
Add table
Reference in a new issue