* Update server HOWTO to Bitcoin 0.5.2
[electrum-server.git] / patches / bitcoin-0.5.2.diff
1 diff -ur bitcoin-0.5.2/src/bitcoinrpc.cpp bitcoin-0.5.2-electrum/src/bitcoinrpc.cpp
2 --- bitcoin-0.5.2/src/bitcoinrpc.cpp    2012-01-06 01:19:29.000000000 +0200
3 +++ bitcoin-0.5.2-electrum/src/bitcoinrpc.cpp   2012-02-16 12:59:03.000000000 +0200
4 @@ -1362,7 +1362,43 @@
5      return entry;
6  }
7  
8 +Value importtransaction(const Array& params, bool fHelp)
9 +{
10 +  string hexdump;
11 +  if (fHelp || params.size() != 1 || (hexdump=params[0].get_str()).size()&1)
12 +    throw runtime_error(
13 +            "importtransaction <hexdata>\n"
14 +            "Import an offline transaction to announce it into the network");
15 +
16 +  std::vector<unsigned char> rawtx;
17 +  for (int i=0; i<hexdump.size(); i+=2)
18 +    {
19 +      int v;
20 +      if (sscanf(hexdump.substr(i,2).c_str(), "%x", &v)!=1)
21 +       throw JSONRPCError(-4, "Error in hex data.");
22 +      rawtx.push_back((unsigned char)v);
23 +    }
24 +try
25 +  {
26 +    CDataStream ss(rawtx);
27 +    CTransaction tx;
28 +    ss >> tx;
29 +    CInv inv(MSG_TX, tx.GetHash());
30 +    if(! tx.AcceptToMemoryPool(true)) throw JSONRPCError(-4, "Transaction not accepted to memory pool.");
31 +    CDataStream msg(rawtx);
32 +    RelayMessage(inv, msg);
33 +    return tx.GetHash().GetHex();
34 +  }
35 + catch (std::exception& e)
36 +   {
37 +     throw JSONRPCError(-4, "Exception while parsing the transaction data.");
38 +   }
39 +
40 +}
41 +
42 +
43  
44 +  
45  Value backupwallet(const Array& params, bool fHelp)
46  {
47      if (fHelp || params.size() != 1)
48 @@ -1846,6 +1882,7 @@
49      make_pair("settxfee",               &settxfee),
50      make_pair("getmemorypool",          &getmemorypool),
51      make_pair("listsinceblock",        &listsinceblock),
52 +    make_pair("importtransaction",      &importtransaction),
53  };
54  map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
55  
56 diff -ur bitcoin-0.5.2/src/main.cpp bitcoin-0.5.2-electrum/src/main.cpp
57 --- bitcoin-0.5.2/src/main.cpp  2012-01-06 01:19:29.000000000 +0200
58 +++ bitcoin-0.5.2-electrum/src/main.cpp 2012-02-16 13:02:55.000000000 +0200
59 @@ -2819,16 +2819,19 @@
60  
61              // Size limits
62              unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);
63 -            if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
64 -                continue;
65 +            //if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
66 +            //    continue;
67              int nTxSigOps = tx.GetSigOpCount();
68 -            if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
69 -                continue;
70 +            //if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
71 +            //    continue;
72  
73              // Transaction fee required depends on block size
74              bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
75              int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree);
76  
77 +           // Electrum server: do not check fees
78 +           nMinFee = 0;
79 +
80              // Connecting shouldn't fail due to dependency on other memory pool transactions
81              // because we're already processing them in order of dependency
82              map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);