1 diff -ur bitcoin-0.6.3-orig/src/bitcoinrpc.cpp bitcoin-0.6.3/src/bitcoinrpc.cpp
2 --- bitcoin-0.6.3-orig/src/bitcoinrpc.cpp 2012-06-19 13:44:55.000000000 -0700
3 +++ bitcoin-0.6.3/src/bitcoinrpc.cpp 2012-07-09 11:56:21.329502578 -0700
8 +Value importtransaction(const Array& params, bool fHelp)
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");
16 + std::vector<unsigned char> rawtx;
17 + for (int i=0; i<hexdump.size(); i+=2)
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);
26 + CDataStream ss(rawtx, SER_NETWORK, PROTOCOL_VERSION);
29 + CInv inv(MSG_TX, tx.GetHash());
32 + if(! tx.AcceptToMemoryPool(txdb, true)) throw JSONRPCError(-4, "Transaction not accepted to memory pool.");
33 + CDataStream msg(rawtx, SER_NETWORK, PROTOCOL_VERSION);
34 + RelayMessage(inv, msg);
35 + return tx.GetHash().GetHex();
37 + catch (std::exception& e)
39 + throw JSONRPCError(-4, "Exception while parsing the transaction data.");
45 Value backupwallet(const Array& params, bool fHelp)
47 if (fHelp || params.size() != 1)
49 result.push_back(Pair("version", pblock->nVersion));
50 result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
51 result.push_back(Pair("transactions", transactions));
52 - result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
53 - result.push_back(Pair("coinbaseflags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
54 result.push_back(Pair("time", (int64_t)pblock->nTime));
55 result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
56 result.push_back(Pair("curtime", (int64_t)GetAdjustedTime()));
58 { "listsinceblock", &listsinceblock, false },
59 { "dumpprivkey", &dumpprivkey, false },
60 { "importprivkey", &importprivkey, false },
61 + { "importtransaction", &importtransaction, false },
64 CRPCTable::CRPCTable()
65 diff -ur bitcoin-0.6.3-orig/src/main.cpp bitcoin-0.6.3/src/main.cpp
66 --- bitcoin-0.6.3-orig/src/main.cpp 2012-06-19 13:44:55.000000000 -0700
67 +++ bitcoin-0.6.3/src/main.cpp 2012-07-09 12:00:26.989497203 -0700
68 @@ -3189,156 +3189,28 @@
72 - // Create coinbase tx
74 - txNew.vin.resize(1);
75 - txNew.vin[0].prevout.SetNull();
76 - txNew.vout.resize(1);
77 - txNew.vout[0].scriptPubKey << reservekey.GetReservedKey() << OP_CHECKSIG;
79 - // Add our coinbase tx as first transaction
80 - pblock->vtx.push_back(txNew);
82 // Collect memory pool transactions into the block
85 LOCK2(cs_main, mempool.cs);
88 - // Priority order to process transactions
89 - list<COrphan> vOrphan; // list memory doesn't move
90 - map<uint256, vector<COrphan*> > mapDependers;
91 - multimap<double, CTransaction*> mapPriority;
92 - for (map<uint256, CTransaction>::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi)
94 - CTransaction& tx = (*mi).second;
95 - if (tx.IsCoinBase() || !tx.IsFinal())
98 - COrphan* porphan = NULL;
99 - double dPriority = 0;
100 - BOOST_FOREACH(const CTxIn& txin, tx.vin)
102 - // Read prev transaction
103 - CTransaction txPrev;
105 - if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))
107 - // Has to wait for dependencies
110 - // Use list for automatic deletion
111 - vOrphan.push_back(COrphan(&tx));
112 - porphan = &vOrphan.back();
114 - mapDependers[txin.prevout.hash].push_back(porphan);
115 - porphan->setDependsOn.insert(txin.prevout.hash);
118 - int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
120 - // Read block header
121 - int nConf = txindex.GetDepthInMainChain();
123 - dPriority += (double)nValueIn * nConf;
125 - if (fDebug && GetBoolArg("-printpriority"))
126 - printf("priority nValueIn=%-12"PRI64d" nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);
129 - // Priority is sum(valuein * age) / txsize
130 - dPriority /= ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
133 - porphan->dPriority = dPriority;
135 - mapPriority.insert(make_pair(-dPriority, &(*mi).second));
137 - if (fDebug && GetBoolArg("-printpriority"))
139 - printf("priority %-20.1f %s\n%s", dPriority, tx.GetHash().ToString().substr(0,10).c_str(), tx.ToString().c_str());
146 - // Collect transactions into block
147 - map<uint256, CTxIndex> mapTestPool;
148 - uint64 nBlockSize = 1000;
150 - int nBlockSigOps = 100;
151 - while (!mapPriority.empty())
152 + for (map<uint256, CTransaction>::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi)
154 - // Take highest priority transaction off priority queue
155 - double dPriority = -(*mapPriority.begin()).first;
156 - CTransaction& tx = *(*mapPriority.begin()).second;
157 - mapPriority.erase(mapPriority.begin());
160 - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
161 - if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
164 - // Legacy limits on sigOps:
165 - unsigned int nTxSigOps = tx.GetLegacySigOpCount();
166 - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
169 - // Transaction fee required depends on block size
170 - bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
171 - int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, GMF_BLOCK);
172 + CTransaction& tx = (*mi).second;
173 + if (tx.IsCoinBase() || !tx.IsFinal())
176 - // Connecting shouldn't fail due to dependency on other memory pool transactions
177 - // because we're already processing them in order of dependency
178 - map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);
179 - MapPrevTx mapInputs;
181 - if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid))
184 - int64 nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut();
185 - if (nTxFees < nMinFee)
188 - nTxSigOps += tx.GetP2SHSigOpCount(mapInputs);
189 - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
192 - if (!tx.ConnectInputs(mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true))
194 - mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size());
195 - swap(mapTestPool, mapTestPoolTmp);
198 - pblock->vtx.push_back(tx);
199 - nBlockSize += nTxSize;
201 - nBlockSigOps += nTxSigOps;
204 - // Add transactions that depend on this one to the priority queue
205 - uint256 hash = tx.GetHash();
206 - if (mapDependers.count(hash))
207 + if (!tx.get_electrum_flag())
209 - BOOST_FOREACH(COrphan* porphan, mapDependers[hash])
211 - if (!porphan->setDependsOn.empty())
213 - porphan->setDependsOn.erase(hash);
214 - if (porphan->setDependsOn.empty())
215 - mapPriority.insert(make_pair(-porphan->dPriority, porphan->ptx));
218 + tx.set_electrum_flag(true);
219 + pblock->vtx.push_back(tx);
224 - nLastBlockTx = nBlockTx;
225 - nLastBlockSize = nBlockSize;
226 - printf("CreateNewBlock(): total size %lu\n", nBlockSize);
228 + printf("CreateNewBlock(): transactions: %lu\n", nBlockTx);
230 - pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
233 pblock->hashPrevBlock = pindexPrev->GetBlockHash();
234 diff -ur bitcoin-0.6.3-orig/src/main.h bitcoin-0.6.3/src/main.h
235 --- bitcoin-0.6.3-orig/src/main.h 2012-06-19 13:44:55.000000000 -0700
236 +++ bitcoin-0.6.3/src/main.h 2012-07-09 11:56:21.333502571 -0700
239 bool DoS(int nDoSIn, bool fIn) const { nDoS += nDoSIn; return fIn; }
241 + bool electrum_flag;
243 + void set_electrum_flag(bool x){
247 + bool get_electrum_flag(){
248 + return electrum_flag;
257 nDoS = 0; // Denial-of-service prevention
258 + set_electrum_flag(false);