X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=patch%2Fpatch;h=774363a851a3404d37005d1399c5315435fbb5f5;hb=1a1352e1178310c4ff5859e2553b1aeb436779a9;hp=f0b8f539d45136dcb304f644d65ffa4b1c0b17e7;hpb=6a45c209518d75ff8d5e8e61ad532142020f1323;p=electrum-server.git diff --git a/patch/patch b/patch/patch index f0b8f53..774363a 100644 --- a/patch/patch +++ b/patch/patch @@ -1,3 +1,23 @@ +diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp +index 21e37c7..1ce91c9 100644 +--- a/src/bitcoinrpc.cpp ++++ b/src/bitcoinrpc.cpp +@@ -1147,6 +1147,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 1) ConvertTo(params[1]); + if (strMethod == "getbalance" && n > 1) ConvertTo(params[1]); + if (strMethod == "getblockhash" && n > 0) ConvertTo(params[0]); ++ if (strMethod == "getblock" && n > 1) ConvertTo(params[1]); + if (strMethod == "move" && n > 2) ConvertTo(params[2]); + if (strMethod == "move" && n > 3) ConvertTo(params[3]); + if (strMethod == "sendfrom" && n > 2) ConvertTo(params[2]); +@@ -1167,6 +1168,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 1) ConvertTo(params[1]); + if (strMethod == "listunspent" && n > 2) ConvertTo(params[2]); + if (strMethod == "getrawtransaction" && n > 1) ConvertTo(params[1]); ++ if (strMethod == "getrawtransaction" && n > 2) ConvertTo(params[2]); + if (strMethod == "createrawtransaction" && n > 0) ConvertTo(params[0]); + if (strMethod == "createrawtransaction" && n > 1) ConvertTo(params[1]); + if (strMethod == "signrawtransaction" && n > 1) ConvertTo(params[1], true); diff --git a/src/main.cpp b/src/main.cpp index 43bd5dd..b38ce88 100644 --- a/src/main.cpp @@ -23,18 +43,79 @@ index 43bd5dd..b38ce88 100644 CCoins coins; if (view.GetCoins(hash, coins)) diff --git a/src/main.h b/src/main.h -index d810bff..fba793c 100644 +index 8327141..fa27788 100644 --- a/src/main.h +++ b/src/main.h -@@ -115,7 +115,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime); - int GetNumBlocksOfPeers(); - bool IsInitialBlockDownload(); +@@ -156,7 +156,7 @@ bool IsInitialBlockDownload(); + /** Format a string that describes several potential problems detected by the core */ std::string GetWarnings(std::string strFor); + /** Retrieve a transaction (from memory pool, or from disk, if possible) */ -bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false); +bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false, int height = -1); + /** Connect/disconnect blocks until pindexNew is the new tip of the active block chain */ bool SetBestChain(CBlockIndex* pindexNew); - bool ConnectBestBlock(); - CBlockIndex * InsertBlockIndex(uint256 hash); + /** Find the best known block, and make it the tip of the block chain */ +diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp +index 3fde463..e60b71e 100644 +--- a/src/rpcblockchain.cpp ++++ b/src/rpcblockchain.cpp +@@ -41,7 +41,7 @@ double GetDifficulty(const CBlockIndex* blockindex) + } + + +-Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex) ++Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool is_raw=false) + { + Object result; + result.push_back(Pair("hash", block.GetHash().GetHex())); +@@ -53,8 +53,16 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex) + result.push_back(Pair("version", block.nVersion)); + result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); + Array txs; +- BOOST_FOREACH(const CTransaction&tx, block.vtx) +- txs.push_back(tx.GetHash().GetHex()); ++ BOOST_FOREACH(const CTransaction&tx, block.vtx) { ++ if(is_raw){ ++ CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ++ ssTx << tx; ++ string strHex = HexStr(ssTx.begin(), ssTx.end()); ++ txs.push_back(strHex); ++ } ++ else txs.push_back(tx.GetHash().GetHex()); ++ } ++ + result.push_back(Pair("tx", txs)); + result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime())); + result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce)); +@@ -141,7 +149,7 @@ Value getblockhash(const Array& params, bool fHelp) + + Value getblock(const Array& params, bool fHelp) + { +- if (fHelp || params.size() != 1) ++ if (fHelp || params.size() < 1) + throw runtime_error( + "getblock \n" + "Returns details of a block with given block-hash."); +@@ -149,6 +157,10 @@ Value getblock(const Array& params, bool fHelp) + std::string strHash = params[0].get_str(); + uint256 hash(strHash); + ++ bool is_raw = false; ++ if (params.size() == 2) ++ is_raw = params[1].get_int() != 0; ++ + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + +@@ -156,7 +168,7 @@ Value getblock(const Array& params, bool fHelp) + CBlockIndex* pblockindex = mapBlockIndex[hash]; + block.ReadFromDisk(pblockindex, true); + +- return blockToJSON(block, pblockindex); ++ return blockToJSON(block, pblockindex, is_raw); + } + + Value gettxoutsetinfo(const Array& params, bool fHelp) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index e82f4ad..624675f 100644 --- a/src/rpcrawtransaction.cpp