diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-02-15 17:49:04 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-18 23:42:07 +0200 |
commit | c73ba23eb51e8cc8704645486f9ca5b50490b0c9 (patch) | |
tree | 67dec29650d85fb32949de19a901911b121f0f56 /src/main.cpp | |
parent | ac4161e25df2a9475abb0f62d32a7d86d6baff0f (diff) |
gettransaction RPC for non-wallet transactions
Works for wallet transactions, memory-pool transaction and block chain
transactions.
Available for all:
* txid
* version
* locktime
* size
* coinbase/inputs/outputs
* confirmations
Available only for wallet transactions:
* amount
* fee
* details
* blockindex
Available for wallet transactions and block chain transactions:
* blockhash
* time
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 78d84d9064..de54606714 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -733,7 +733,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; +} |