Import backend using backend name.
[electrum-server.git] / patches / bitcoin-0.6.0.diff
1 diff -ur bitcoin-0.6.0/src/bitcoinrpc.cpp bitcoin-0.6.0-electrum/src/bitcoinrpc.cpp
2 --- bitcoin-0.6.0/src/bitcoinrpc.cpp    2012-03-29 22:11:04.000000000 +0300
3 +++ bitcoin-0.6.0-electrum/src/bitcoinrpc.cpp   2012-03-31 12:30:50.631339067 +0300
4 @@ -1486,7 +1486,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 @@ -2047,7 +2083,8 @@
49      make_pair("getmemorypool",          &getmemorypool),
50      make_pair("listsinceblock",         &listsinceblock),
51      make_pair("dumpprivkey",            &dumpprivkey),
52 -    make_pair("importprivkey",          &importprivkey)
53 +    make_pair("importprivkey",          &importprivkey),
54 +    make_pair("importtransaction",      &importtransaction)
55  };
56  map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
57  
58 diff -ur bitcoin-0.6.0/src/main.cpp bitcoin-0.6.0-electrum/src/main.cpp
59 --- bitcoin-0.6.0/src/main.cpp  2012-03-29 22:11:04.000000000 +0300
60 +++ bitcoin-0.6.0-electrum/src/main.cpp 2012-03-31 12:36:41.711339168 +0300
61 @@ -3164,18 +3164,21 @@
62  
63              // Size limits
64              unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);
65 -            if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
66 -                continue;
67 +            //if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
68 +            //    continue;
69  
70              // Legacy limits on sigOps:
71              int nTxSigOps = tx.GetLegacySigOpCount();
72 -            if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
73 -                continue;
74 +            //if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
75 +            //    continue;
76  
77              // Transaction fee required depends on block size
78              bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
79              int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, GMF_BLOCK);
80  
81 +            // Electrum server: do not check fees
82 +            nMinFee = 0;
83 +
84              // Connecting shouldn't fail due to dependency on other memory pool transactions
85              // because we're already processing them in order of dependency
86              map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);