mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Merge pull request #841 from sipa/getalltransactions
gettransaction RPC for non-wallet transactions
This commit is contained in:
26
src/main.cpp
26
src/main.cpp
@@ -740,7 +740,31 @@ int CTxIndex::GetDepthInMainChain() const
|
||||
return 1 + nBestHeight - pindex->nHeight;
|
||||
}
|
||||
|
||||
|
||||
// Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock)
|
||||
{
|
||||
{
|
||||
LOCK(cs_main);
|
||||
{
|
||||
LOCK(mempool.cs);
|
||||
if (mempool.exists(hash))
|
||||
{
|
||||
tx = mempool.lookup(hash);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
CTxDB txdb("r");
|
||||
CTxIndex txindex;
|
||||
if (tx.ReadFromDisk(txdb, COutPoint(hash, 0), txindex))
|
||||
{
|
||||
CBlock block;
|
||||
if (block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
|
||||
hashBlock = block.GetHash();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user