--- a/bitcoin/manifest.txt +++ b/bitcoin/manifest.txt @@ -28,3 +28,5 @@ 542413 asciilifeform_aggressive_pushgetblocks asciilifeform Issue PushGetBlocks command to any peer that issues 'version' command 542413 mod6_excise_hash_truncation mod6 Regrind of ben_vulpes original; removes truncation of hashes printed to TRB log file 543661 asciilifeform_whogaveblox asciilifeform Record the origin of every incoming candidate block (whether accepted or rejected) +606789 mod6_phexdigit_fix mod6 Fix decoding LUT which wrongly accepted certain invalid characters as hex +606789 bitcoin_getrawtransaction jfw Add RPC to get transactions from memory pool or database (hex only) --- a/bitcoin/src/bitcoinrpc.cpp +++ b/bitcoin/src/bitcoinrpc.cpp @@ -1351,7 +1351,31 @@ return entry; } +Value getrawtransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getrawtransaction \n" + "Get hex serialization of from memory pool or database."); + uint256 hash; + map::iterator it; + CTransaction tx; + CDataStream ssTx; + + hash.SetHex(params[0].get_str()); + it = mapTransactions.find(hash); + if (it != mapTransactions.end()) + tx = it->second; + else { + CTxDB txdb("r"); + if (!txdb.ReadDiskTx(hash, tx)) + throw JSONRPCError(-5, "Transaction not found in memory pool or database."); + } + ssTx << tx; + return HexStr(ssTx.begin(), ssTx.end()); +} + Value backupwallet(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1865,6 +1889,7 @@ make_pair("getreceivedbyaccount", &getreceivedbyaccount), make_pair("listreceivedbyaddress", &listreceivedbyaddress), make_pair("listreceivedbyaccount", &listreceivedbyaccount), + make_pair("getrawtransaction", &getrawtransaction), make_pair("backupwallet", &backupwallet), make_pair("keypoolrefill", &keypoolrefill), make_pair("walletpassphrase", &walletpassphrase), --- a/bitcoin/src/main.cpp +++ b/bitcoin/src/main.cpp @@ -26,7 +26,7 @@ CCriticalSection cs_main; -static map mapTransactions; +map mapTransactions; CCriticalSection cs_mapTransactions; unsigned int nTransactionsUpdated = 0; map mapNextTx; --- a/bitcoin/src/main.h +++ b/bitcoin/src/main.h @@ -46,6 +46,7 @@ extern CCriticalSection cs_main; +extern std::map mapTransactions; extern std::map mapBlockIndex; extern uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock;