fix download link to bitcoind
[electrum-server.git] / patch / patch
1 diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
2 index 21e37c7..1ce91c9 100644
3 --- a/src/bitcoinrpc.cpp
4 +++ b/src/bitcoinrpc.cpp
5 @@ -1147,6 +1147,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
6      if (strMethod == "listreceivedbyaccount"  && n > 1) ConvertTo<bool>(params[1]);
7      if (strMethod == "getbalance"             && n > 1) ConvertTo<boost::int64_t>(params[1]);
8      if (strMethod == "getblockhash"           && n > 0) ConvertTo<boost::int64_t>(params[0]);
9 +    if (strMethod == "getblock"               && n > 1) ConvertTo<boost::int64_t>(params[1]);
10      if (strMethod == "move"                   && n > 2) ConvertTo<double>(params[2]);
11      if (strMethod == "move"                   && n > 3) ConvertTo<boost::int64_t>(params[3]);
12      if (strMethod == "sendfrom"               && n > 2) ConvertTo<double>(params[2]);
13 @@ -1167,6 +1168,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
14      if (strMethod == "listunspent"            && n > 1) ConvertTo<boost::int64_t>(params[1]);
15      if (strMethod == "listunspent"            && n > 2) ConvertTo<Array>(params[2]);
16      if (strMethod == "getrawtransaction"      && n > 1) ConvertTo<boost::int64_t>(params[1]);
17 +    if (strMethod == "getrawtransaction"      && n > 2) ConvertTo<boost::int64_t>(params[2]);
18      if (strMethod == "createrawtransaction"   && n > 0) ConvertTo<Array>(params[0]);
19      if (strMethod == "createrawtransaction"   && n > 1) ConvertTo<Object>(params[1]);
20      if (strMethod == "signrawtransaction"     && n > 1) ConvertTo<Array>(params[1], true);
21 diff --git a/src/main.cpp b/src/main.cpp
22 index 43bd5dd..b38ce88 100644
23 --- a/src/main.cpp
24 +++ b/src/main.cpp
25 @@ -925,7 +925,7 @@ bool CWalletTx::AcceptWalletTransaction(bool fCheckInputs)
26  
27  
28  // Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
29 -bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
30 +bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow, int height)
31  {
32      CBlockIndex *pindexSlow = NULL;
33      {
34 @@ -940,8 +940,8 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
35          }
36  
37          if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it
38 -            int nHeight = -1;
39 -            {
40 +           int nHeight = height;
41 +           if(nHeight == -1) {
42                  CCoinsViewCache &view = *pcoinsTip;
43                  CCoins coins;
44                  if (view.GetCoins(hash, coins))
45 diff --git a/src/main.h b/src/main.h
46 index 8327141..fa27788 100644
47 --- a/src/main.h
48 +++ b/src/main.h
49 @@ -156,7 +156,7 @@ bool IsInitialBlockDownload();
50  /** Format a string that describes several potential problems detected by the core */
51  std::string GetWarnings(std::string strFor);
52  /** Retrieve a transaction (from memory pool, or from disk, if possible) */
53 -bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false);
54 +bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false, int height = -1);
55  /** Connect/disconnect blocks until pindexNew is the new tip of the active block chain */
56  bool SetBestChain(CBlockIndex* pindexNew);
57  /** Find the best known block, and make it the tip of the block chain */
58 diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
59 index 3fde463..e60b71e 100644
60 --- a/src/rpcblockchain.cpp
61 +++ b/src/rpcblockchain.cpp
62 @@ -41,7 +41,7 @@ double GetDifficulty(const CBlockIndex* blockindex)
63  }
64  
65  
66 -Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
67 +Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool is_raw=false)
68  {
69      Object result;
70      result.push_back(Pair("hash", block.GetHash().GetHex()));
71 @@ -53,8 +53,16 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
72      result.push_back(Pair("version", block.nVersion));
73      result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
74      Array txs;
75 -    BOOST_FOREACH(const CTransaction&tx, block.vtx)
76 -        txs.push_back(tx.GetHash().GetHex());
77 +    BOOST_FOREACH(const CTransaction&tx, block.vtx) {
78 +      if(is_raw){
79 +       CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
80 +        ssTx << tx;
81 +        string strHex = HexStr(ssTx.begin(), ssTx.end());
82 +        txs.push_back(strHex);
83 +      }
84 +      else txs.push_back(tx.GetHash().GetHex());
85 +    }
86 +
87      result.push_back(Pair("tx", txs));
88      result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime()));
89      result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
90 @@ -141,7 +149,7 @@ Value getblockhash(const Array& params, bool fHelp)
91  
92  Value getblock(const Array& params, bool fHelp)
93  {
94 -    if (fHelp || params.size() != 1)
95 +    if (fHelp || params.size() < 1)
96          throw runtime_error(
97              "getblock <hash>\n"
98              "Returns details of a block with given block-hash.");
99 @@ -149,6 +157,10 @@ Value getblock(const Array& params, bool fHelp)
100      std::string strHash = params[0].get_str();
101      uint256 hash(strHash);
102  
103 +    bool is_raw = false;
104 +    if (params.size() == 2)
105 +        is_raw = params[1].get_int() != 0;
106 +
107      if (mapBlockIndex.count(hash) == 0)
108          throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
109  
110 @@ -156,7 +168,7 @@ Value getblock(const Array& params, bool fHelp)
111      CBlockIndex* pblockindex = mapBlockIndex[hash];
112      block.ReadFromDisk(pblockindex, true);
113  
114 -    return blockToJSON(block, pblockindex);
115 +    return blockToJSON(block, pblockindex, is_raw);
116  }
117  
118  Value gettxoutsetinfo(const Array& params, bool fHelp)
119 diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
120 index e82f4ad..624675f 100644
121 --- a/src/rpcrawtransaction.cpp
122 +++ b/src/rpcrawtransaction.cpp
123 @@ -134,7 +134,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
124  
125  Value getrawtransaction(const Array& params, bool fHelp)
126  {
127 -    if (fHelp || params.size() < 1 || params.size() > 2)
128 +    if (fHelp || params.size() < 1 || params.size() > 3)
129          throw runtime_error(
130              "getrawtransaction <txid> [verbose=0]\n"
131              "If verbose=0, returns a string that is\n"
132 @@ -148,9 +148,13 @@ Value getrawtransaction(const Array& params, bool fHelp)
133      if (params.size() > 1)
134          fVerbose = (params[1].get_int() != 0);
135  
136 +    int height = -1;
137 +    if (params.size() > 2)
138 +        height = params[2].get_int();
139 +
140      CTransaction tx;
141      uint256 hashBlock = 0;
142 -    if (!GetTransaction(hash, tx, hashBlock, true))
143 +    if (!GetTransaction(hash, tx, hashBlock, true, height))
144          throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
145  
146      CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);