electrum-bitcoinprivate/server/patches/bitcoinrpc.cpp.diff

53 lines
1.8 KiB
Diff

diff -u -r bitcoin/src/bitcoinrpc.cpp bitcoin-electrum/src/bitcoinrpc.cpp
--- bitcoin/src/bitcoinrpc.cpp 2011-12-28 21:23:40.844812872 +0200
+++ bitcoin-electrum/src/bitcoinrpc.cpp 2011-12-28 17:31:24.000000000 +0200
@@ -1437,6 +1437,38 @@
return entry;
}
+Value importtransaction(const Array& params, bool fHelp)
+{
+ string hexdump;
+ if (fHelp || params.size() != 1 || (hexdump=params[0].get_str()).size()&1)
+ throw runtime_error(
+ "importtransaction <hexdata>\n"
+ "Import an offline transaction to announce it into the network");
+
+ std::vector<unsigned char> rawtx;
+ for (int i=0; i<hexdump.size(); i+=2)
+ {
+ int v;
+ if (sscanf(hexdump.substr(i,2).c_str(), "%x", &v)!=1)
+ throw JSONRPCError(-4, "Error in hex data.");
+ rawtx.push_back((unsigned char)v);
+ }
+try
+ {
+ CDataStream ss(rawtx);
+ CTransaction tx;
+ ss >> tx;
+ CInv inv(MSG_TX, tx.GetHash());
+ if(! tx.AcceptToMemoryPool(true)) throw JSONRPCError(-4, "Transaction not accepted to memory pool.");
+ CDataStream msg(rawtx);
+ RelayMessage(inv, msg);
+ return tx.GetHash().GetHex();
+ }
+ catch (std::exception& e)
+ {
+ throw JSONRPCError(-4, "Exception while parsing the transaction data.");
+ }
+}
Value backupwallet(const Array& params, bool fHelp)
{
@@ -1950,7 +1982,8 @@
make_pair("getmemorypool", &getmemorypool),
make_pair("listsinceblock", &listsinceblock),
make_pair("dumpprivkey", &dumpprivkey),
- make_pair("importprivkey", &importprivkey)
+ make_pair("importprivkey", &importprivkey),
+ make_pair("importtransaction", &importtransaction)
};
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));