python-bitcoin-blockchain-parser
python-bitcoin-blockchain-parser copied to clipboard
db parameter in get_transaction
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!
Do you resolve this problem?
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()
...
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.