patch for bitcoind
[electrum-server.git] / patch / patch
1 diff --git a/src/main.cpp b/src/main.cpp
2 index 43bd5dd..b38ce88 100644
3 --- a/src/main.cpp
4 +++ b/src/main.cpp
5 @@ -925,7 +925,7 @@ bool CWalletTx::AcceptWalletTransaction(bool fCheckInputs)
6  
7  
8  // Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
9 -bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
10 +bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow, int height)
11  {
12      CBlockIndex *pindexSlow = NULL;
13      {
14 @@ -940,8 +940,8 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
15          }
16  
17          if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it
18 -            int nHeight = -1;
19 -            {
20 +           int nHeight = height;
21 +           if(nHeight == -1) {
22                  CCoinsViewCache &view = *pcoinsTip;
23                  CCoins coins;
24                  if (view.GetCoins(hash, coins))
25 diff --git a/src/main.h b/src/main.h
26 index d810bff..fba793c 100644
27 --- a/src/main.h
28 +++ b/src/main.h
29 @@ -115,7 +115,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
30  int GetNumBlocksOfPeers();
31  bool IsInitialBlockDownload();
32  std::string GetWarnings(std::string strFor);
33 -bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false);
34 +bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false, int height = -1);
35  bool SetBestChain(CBlockIndex* pindexNew);
36  bool ConnectBestBlock();
37  CBlockIndex * InsertBlockIndex(uint256 hash);
38 diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
39 index e82f4ad..624675f 100644
40 --- a/src/rpcrawtransaction.cpp
41 +++ b/src/rpcrawtransaction.cpp
42 @@ -134,7 +134,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
43  
44  Value getrawtransaction(const Array& params, bool fHelp)
45  {
46 -    if (fHelp || params.size() < 1 || params.size() > 2)
47 +    if (fHelp || params.size() < 1 || params.size() > 3)
48          throw runtime_error(
49              "getrawtransaction <txid> [verbose=0]\n"
50              "If verbose=0, returns a string that is\n"
51 @@ -148,9 +148,13 @@ Value getrawtransaction(const Array& params, bool fHelp)
52      if (params.size() > 1)
53          fVerbose = (params[1].get_int() != 0);
54  
55 +    int height = -1;
56 +    if (params.size() > 2)
57 +        height = params[2].get_int();
58 +
59      CTransaction tx;
60      uint256 hashBlock = 0;
61 -    if (!GetTransaction(hash, tx, hashBlock, true))
62 +    if (!GetTransaction(hash, tx, hashBlock, true, height))
63          throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
64  
65      CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);