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

db parameter in get_transaction #105

Closed
czanoci opened this issue Jun 10, 2022 · 3 comments
Closed

db parameter in get_transaction #105

czanoci opened this issue Jun 10, 2022 · 3 comments

Comments

@czanoci
Copy link

czanoci commented Jun 10, 2022

What should we pass as the database db in get_transaction(txid, db)? Is there any sample code that showcases the use of this function? Thanks!

@JavierPorron
Copy link

Do you resolve this problem?

@JavierPorron
Copy link

I finally resolve it. Just you have to open the leveldb index tx and pass it as parameter.

db = plyvel.DB(os.path.expanduser('~/.bitcoin/indexes/txindex'), compression=None)

tx = blockchain.get_transaction(txid,index)

db.close()

...

@levushakov
Copy link
Contributor

Is it possible to get the confirmed block number of a transaction? For example if I use

import os
from blockchain_parser.blockchain import Blockchain
import plyvel

blockchain_path = "~/.bitcoin"  # Update this path to your local Bitcoin blockchain data directory
blockchain = Blockchain(os.path.expanduser(blockchain_path + "/blocks"))

txid = "dfcec48bb8491856c353306ab5febeb7e99e4d783eedf3de98f3ee0812b92bad"

plyvel_db = plyvel.DB(
    os.path.expanduser(blockchain_path + "/indexes/txindex"),
    compression=None,
)

result = blockchain.get_transaction(
    txid, plyvel_db
)

I get a transaction object Transaction(48a387570eeffb07e8e84642efe36bc4088285fc04db91743a9850bfd1611af2). I would like to know the block that it was confirmed at.

levushakov added a commit to levushakov/python-bitcoin-blockchain-parser that referenced this issue Mar 5, 2024
alecalve added a commit that referenced this issue Mar 23, 2024
Issue #29 & #105 solved: get_transaction() returns block header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants