1 diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
2 index 6e2eac5..8b60ebf 100644
3 --- a/src/bitcoinrpc.cpp
4 +++ b/src/bitcoinrpc.cpp
5 @@ -1355,7 +1355,43 @@ Value gettransaction(const Array& params, bool fHelp)
9 +Value importtransaction(const Array& params, bool fHelp)
12 + if (fHelp || params.size() != 1 || (hexdump=params[0].get_str()).size()&1)
13 + throw runtime_error(
14 + "importtransaction <hexdata>\n"
15 + "Import an offline transaction to announce it into the network");
17 + std::vector<unsigned char> rawtx;
18 + for (int i=0; i<hexdump.size(); i+=2)
21 + if (sscanf(hexdump.substr(i,2).c_str(), "%x", &v)!=1)
22 + throw JSONRPCError(-4, "Error in hex data.");
23 + rawtx.push_back((unsigned char)v);
27 + CDataStream ss(rawtx);
30 + CInv inv(MSG_TX, tx.GetHash());
31 + if(! tx.AcceptToMemoryPool(true)) throw JSONRPCError(-4, "Transaction not accepted to memory pool.");
32 + CDataStream msg(rawtx);
33 + RelayMessage(inv, msg);
34 + return tx.GetHash().GetHex();
36 + catch (std::exception& e)
38 + throw JSONRPCError(-4, "Exception while parsing the transaction data.");
46 Value backupwallet(const Array& params, bool fHelp)
48 if (fHelp || params.size() != 1)
49 @@ -1850,6 +1886,7 @@ pair<string, rpcfn_type> pCallTable[] =
50 make_pair("settxfee", &settxfee),
51 make_pair("getmemorypool", &getmemorypool),
52 make_pair("listsinceblock", &listsinceblock),
53 + make_pair("importtransaction", &importtransaction),
55 map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));