Skip to content

Commit

Permalink
Use correct witness_type for tx input in Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed Jul 12, 2024
1 parent 88020c3 commit ff5ae18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bitcoinlib/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,14 @@ def _parse_db_transaction(db_tx):
fee=db_tx.fee, txid=db_tx.txid.hex(), date=db_tx.date, confirmations=db_tx.confirmations,
block_height=db_tx.block_height, status='confirmed', witness_type=db_tx.witness_type.value,
index=db_tx.index)
if t.date and not t.date.tzinfo:
t.date = t.date.replace(tzinfo=timezone.utc)
for n in db_tx.nodes:
if n.is_input:
if n.ref_txid == b'\00' * 32:
t.coinbase = True
t.add_input(n.ref_txid.hex(), n.ref_index_n, unlocking_script=n.script, address=n.address,
sequence=n.sequence, value=n.value, index_n=n.index_n, witnesses=n.witnesses, strict=False,
witness_type=db_tx.witness_type.value)
sequence=n.sequence, value=n.value, index_n=n.index_n, witnesses=n.witnesses, strict=False)
else:
t.add_output(n.value, n.address, lock_script=n.script, spent=n.spent, output_n=n.index_n,
spending_txid=None if not n.ref_txid else n.ref_txid.hex(),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ def test_service_cache_transactions_after_txid(self):
self.assertGreaterEqual(srv.results_cache_n, 1)

def test_service_cache_transaction_coinbase(self):
srv = ServiceTest(cache_uri=DATABASE_CACHE_UNITTESTS2, exclude_providers=['bitaps', 'bitgo'])
srv = ServiceTest(cache_uri=DATABASE_CACHE_UNITTESTS2, exclude_providers=['bitaps', 'bitgo'], providers=[
'bcoin'])
t = srv.gettransaction('68104dbd6819375e7bdf96562f89290b41598df7b002089ecdd3c8d999025b13')
if t:
self.assertGreaterEqual(srv.results_cache_n, 0)
Expand Down

0 comments on commit ff5ae18

Please sign in to comment.