diff options
author | Gregory Maxwell <gmaxwell@gmail.com> | 2012-05-08 13:19:11 -0700 |
---|---|---|
committer | Gregory Maxwell <gmaxwell@gmail.com> | 2012-05-08 13:19:11 -0700 |
commit | 2f1dca645bece3a8422659a0bc0b1481242b8f3a (patch) | |
tree | b35ac857200ae439745c6811f041ef946ac520a2 /src/main.cpp | |
parent | f1ae31d8af8e03acbd224d486542b4409acf01ff (diff) | |
parent | c73ba23eb51e8cc8704645486f9ca5b50490b0c9 (diff) | |
download | bitcoin-2f1dca645bece3a8422659a0bc0b1481242b8f3a.tar.xz |
Merge pull request #841 from sipa/getalltransactions
gettransaction RPC for non-wallet transactions
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 238f7c69e4..0e0fd28c40 100644 --- a/src/main.cpp +++ b/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; +} |