rpcrawtransaction.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. // ECOin - Copyright (c) - 2014/2022 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. #include <boost/assign/list_of.hpp>
  3. #include "base58.h"
  4. #include "ecoinrpc.h"
  5. #include "txdb.h"
  6. #include "init.h"
  7. #include "main.h"
  8. #include "net.h"
  9. #include "wallet.h"
  10. using namespace std;
  11. using namespace boost;
  12. using namespace boost::assign;
  13. using namespace json_spirit;
  14. void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex)
  15. {
  16. txnouttype type;
  17. vector<CTxDestination> addresses;
  18. int nRequired;
  19. out.push_back(Pair("asm", scriptPubKey.ToString()));
  20. if (fIncludeHex)
  21. out.push_back(Pair("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
  22. if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired))
  23. {
  24. out.push_back(Pair("type", GetTxnOutputType(TX_NONSTANDARD)));
  25. return;
  26. }
  27. out.push_back(Pair("reqSigs", nRequired));
  28. out.push_back(Pair("type", GetTxnOutputType(type)));
  29. Array a;
  30. BOOST_FOREACH(const CTxDestination& addr, addresses)
  31. a.push_back(CEcoinAddress(addr).ToString());
  32. out.push_back(Pair("addresses", a));
  33. }
  34. void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
  35. {
  36. entry.push_back(Pair("txid", tx.GetHash().GetHex()));
  37. entry.push_back(Pair("version", tx.nVersion));
  38. entry.push_back(Pair("time", (boost::int64_t)tx.nTime));
  39. entry.push_back(Pair("locktime", (boost::int64_t)tx.nLockTime));
  40. Array vin;
  41. BOOST_FOREACH(const CTxIn& txin, tx.vin)
  42. {
  43. Object in;
  44. if (tx.IsCoinBase())
  45. in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
  46. else
  47. {
  48. in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
  49. in.push_back(Pair("vout", (boost::int64_t)txin.prevout.n));
  50. Object o;
  51. o.push_back(Pair("asm", txin.scriptSig.ToString()));
  52. o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
  53. in.push_back(Pair("scriptSig", o));
  54. }
  55. in.push_back(Pair("sequence", (boost::int64_t)txin.nSequence));
  56. vin.push_back(in);
  57. }
  58. entry.push_back(Pair("vin", vin));
  59. Array vout;
  60. for (unsigned int i = 0; i < tx.vout.size(); i++)
  61. {
  62. const CTxOut& txout = tx.vout[i];
  63. Object out;
  64. out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
  65. out.push_back(Pair("n", (boost::int64_t)i));
  66. Object o;
  67. ScriptPubKeyToJSON(txout.scriptPubKey, o, false);
  68. out.push_back(Pair("scriptPubKey", o));
  69. vout.push_back(out);
  70. }
  71. entry.push_back(Pair("vout", vout));
  72. if (hashBlock != 0)
  73. {
  74. entry.push_back(Pair("blockhash", hashBlock.GetHex()));
  75. map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
  76. if (mi != mapBlockIndex.end() && (*mi).second)
  77. {
  78. CBlockIndex* pindex = (*mi).second;
  79. if (pindex->IsInMainChain())
  80. {
  81. entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight));
  82. entry.push_back(Pair("time", (boost::int64_t)pindex->nTime));
  83. entry.push_back(Pair("blocktime", (boost::int64_t)pindex->nTime));
  84. }
  85. else
  86. entry.push_back(Pair("confirmations", 0));
  87. }
  88. }
  89. }
  90. Value getrawtransaction(const Array& params, bool fHelp)
  91. {
  92. if (fHelp || params.size() < 1 || params.size() > 2)
  93. throw runtime_error(
  94. "getrawtransaction <txid> [verbose=0]\n"
  95. "If verbose=0, returns a string that is\n"
  96. "serialized, hex-encoded data for <txid>.\n"
  97. "If verbose is non-zero, returns an Object\n"
  98. "with information about <txid>.");
  99. uint256 hash;
  100. hash.SetHex(params[0].get_str());
  101. bool fVerbose = false;
  102. if (params.size() > 1)
  103. fVerbose = (params[1].get_int() != 0);
  104. CTransaction tx;
  105. uint256 hashBlock = 0;
  106. if (!GetTransaction(hash, tx, hashBlock))
  107. throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
  108. CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
  109. ssTx << tx;
  110. string strHex = HexStr(ssTx.begin(), ssTx.end());
  111. if (!fVerbose)
  112. return strHex;
  113. Object result;
  114. result.push_back(Pair("hex", strHex));
  115. TxToJSON(tx, hashBlock, result);
  116. return result;
  117. }
  118. Value listunspent(const Array& params, bool fHelp)
  119. {
  120. if (fHelp || params.size() > 3)
  121. throw runtime_error(
  122. "listunspent [minconf=1] [maxconf=9999999] [\"address\",...]\n"
  123. "Returns array of unspent transaction outputs\n"
  124. "with between minconf and maxconf (inclusive) confirmations.\n"
  125. "Optionally filtered to only include txouts paid to specified addresses.\n"
  126. "Results are an array of Objects, each of which has:\n"
  127. "{txid, vout, scriptPubKey, amount, confirmations}");
  128. RPCTypeCheck(params, list_of(int_type)(int_type)(array_type));
  129. int nMinDepth = 1;
  130. if (params.size() > 0)
  131. nMinDepth = params[0].get_int();
  132. int nMaxDepth = 9999999;
  133. if (params.size() > 1)
  134. nMaxDepth = params[1].get_int();
  135. set<CEcoinAddress> setAddress;
  136. if (params.size() > 2)
  137. {
  138. Array inputs = params[2].get_array();
  139. BOOST_FOREACH(Value& input, inputs)
  140. {
  141. CEcoinAddress address(input.get_str());
  142. if (!address.IsValid())
  143. throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Ecoin address: ")+input.get_str());
  144. if (setAddress.count(address))
  145. throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+input.get_str());
  146. setAddress.insert(address);
  147. }
  148. }
  149. Array results;
  150. vector<COutput> vecOutputs;
  151. pwalletMain->AvailableCoins(vecOutputs, false);
  152. BOOST_FOREACH(const COutput& out, vecOutputs)
  153. {
  154. if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
  155. continue;
  156. if(setAddress.size())
  157. {
  158. CTxDestination address;
  159. if(!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
  160. continue;
  161. if (!setAddress.count(address))
  162. continue;
  163. }
  164. int64 nValue = out.tx->vout[out.i].nValue;
  165. const CScript& pk = out.tx->vout[out.i].scriptPubKey;
  166. Object entry;
  167. entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
  168. entry.push_back(Pair("vout", out.i));
  169. CTxDestination address;
  170. if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
  171. {
  172. entry.push_back(Pair("address", CEcoinAddress(address).ToString()));
  173. if (pwalletMain->mapAddressBook.count(address))
  174. entry.push_back(Pair("account", pwalletMain->mapAddressBook[address]));
  175. }
  176. entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end())));
  177. entry.push_back(Pair("amount",ValueFromAmount(nValue)));
  178. entry.push_back(Pair("confirmations",out.nDepth));
  179. results.push_back(entry);
  180. }
  181. return results;
  182. }
  183. Value createrawtransaction(const Array& params, bool fHelp)
  184. {
  185. if (fHelp || params.size() != 2)
  186. throw runtime_error(
  187. "createrawtransaction [{\"txid\":txid,\"vout\":n},...] {address:amount,...}\n"
  188. "Create a transaction spending given inputs\n"
  189. "(array of objects containing transaction id and output number),\n"
  190. "sending to given address(es).\n"
  191. "Returns hex-encoded raw transaction.\n"
  192. "Note that the transaction's inputs are not signed, and\n"
  193. "it is not stored in the wallet or transmitted to the network.");
  194. RPCTypeCheck(params, list_of(array_type)(obj_type));
  195. Array inputs = params[0].get_array();
  196. Object sendTo = params[1].get_obj();
  197. CTransaction rawTx;
  198. BOOST_FOREACH(Value& input, inputs)
  199. {
  200. const Object& o = input.get_obj();
  201. const Value& txid_v = find_value(o, "txid");
  202. if (txid_v.type() != str_type)
  203. throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing txid key");
  204. string txid = txid_v.get_str();
  205. if (!IsHex(txid))
  206. throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid");
  207. const Value& vout_v = find_value(o, "vout");
  208. if (vout_v.type() != int_type)
  209. throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
  210. int nOutput = vout_v.get_int();
  211. if (nOutput < 0)
  212. throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
  213. CTxIn in(COutPoint(uint256(txid), nOutput));
  214. rawTx.vin.push_back(in);
  215. }
  216. set<CEcoinAddress> setAddress;
  217. BOOST_FOREACH(const Pair& s, sendTo)
  218. {
  219. CEcoinAddress address(s.name_);
  220. if (!address.IsValid())
  221. throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Ecoin address: ")+s.name_);
  222. if (setAddress.count(address))
  223. throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
  224. setAddress.insert(address);
  225. CScript scriptPubKey;
  226. scriptPubKey.SetDestination(address.Get());
  227. int64 nAmount = AmountFromValue(s.value_);
  228. CTxOut out(nAmount, scriptPubKey);
  229. rawTx.vout.push_back(out);
  230. }
  231. CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
  232. ss << rawTx;
  233. return HexStr(ss.begin(), ss.end());
  234. }
  235. Value decoderawtransaction(const Array& params, bool fHelp)
  236. {
  237. if (fHelp || params.size() != 1)
  238. throw runtime_error(
  239. "decoderawtransaction <hex string>\n"
  240. "Return a JSON object representing the serialized, hex-encoded transaction.");
  241. RPCTypeCheck(params, list_of(str_type));
  242. vector<unsigned char> txData(ParseHex(params[0].get_str()));
  243. CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
  244. CTransaction tx;
  245. try {
  246. ssData >> tx;
  247. }
  248. catch (std::exception &e) {
  249. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
  250. }
  251. Object result;
  252. TxToJSON(tx, 0, result);
  253. return result;
  254. }
  255. Value decodescript(const Array& params, bool fHelp)
  256. {
  257. if (fHelp || params.size() != 1)
  258. throw runtime_error(
  259. "decodescript <hex string>\n"
  260. "Decode a hex-encoded script.");
  261. // RPCTypeCheck(params, list_of(str_type));
  262. // Object r;
  263. // CScript script;
  264. // if (params[0].get_str().size() > 0){
  265. // vector<unsigned char> scriptData(ParseHex(params[0], "argument"));
  266. // script = CScript(scriptData.begin(), scriptData.end());
  267. // } else {
  268. // // Empty scripts are valid
  269. // }
  270. // ScriptPubKeyToJSON(script, r, false);
  271. // r.push_back(Pair("p2sh", CEcoinAddress(script.GetID()).ToString()));
  272. // return r;
  273. }
  274. Value signrawtransaction(const Array& params, bool fHelp)
  275. {
  276. if (fHelp || params.size() < 1 || params.size() > 4)
  277. throw runtime_error(
  278. "signrawtransaction <hex string> [{\"txid\":txid,\"vout\":n,\"scriptPubKey\":hex},...] [<privatekey1>,...] [sighashtype=\"ALL\"]\n"
  279. "Sign inputs for raw transaction (serialized, hex-encoded).\n"
  280. "Second optional argument (may be null) is an array of previous transaction outputs that\n"
  281. "this transaction depends on but may not yet be in the blockchain.\n"
  282. "Third optional argument (may be null) is an array of base58-encoded private\n"
  283. "keys that, if given, will be the only keys used to sign the transaction.\n"
  284. "Fourth optional argument is a string that is one of six values; ALL, NONE, SINGLE or\n"
  285. "ALL|ANYONECANPAY, NONE|ANYONECANPAY, SINGLE|ANYONECANPAY.\n"
  286. "Returns json object with keys:\n"
  287. " hex : raw transaction with signature(s) (hex-encoded string)\n"
  288. " complete : 1 if transaction has a complete set of signature (0 if not)"
  289. + HelpRequiringPassphrase());
  290. RPCTypeCheck(params, list_of(str_type)(array_type)(array_type)(str_type), true);
  291. vector<unsigned char> txData(ParseHex(params[0].get_str()));
  292. CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
  293. vector<CTransaction> txVariants;
  294. while (!ssData.empty())
  295. {
  296. try {
  297. CTransaction tx;
  298. ssData >> tx;
  299. txVariants.push_back(tx);
  300. }
  301. catch (std::exception &e) {
  302. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
  303. }
  304. }
  305. if (txVariants.empty())
  306. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Missing transaction");
  307. // mergedTx will end up with all the signatures; it
  308. // starts as a clone of the rawtx:
  309. CTransaction mergedTx(txVariants[0]);
  310. bool fComplete = true;
  311. // Fetch previous transactions (inputs):
  312. map<COutPoint, CScript> mapPrevOut;
  313. for (unsigned int i = 0; i < mergedTx.vin.size(); i++)
  314. {
  315. CTransaction tempTx;
  316. MapPrevTx mapPrevTx;
  317. CTxDB txdb("r");
  318. map<uint256, CTxIndex> unused;
  319. bool fInvalid;
  320. // FetchInputs aborts on failure, so we go one at a time.
  321. tempTx.vin.push_back(mergedTx.vin[i]);
  322. tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);
  323. // Copy results into mapPrevOut:
  324. BOOST_FOREACH(const CTxIn& txin, tempTx.vin)
  325. {
  326. const uint256& prevHash = txin.prevout.hash;
  327. if (mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size()>txin.prevout.n)
  328. mapPrevOut[txin.prevout] = mapPrevTx[prevHash].second.vout[txin.prevout.n].scriptPubKey;
  329. }
  330. }
  331. // Add previous txouts given in the RPC call:
  332. if (params.size() > 1 && params[1].type() != null_type)
  333. {
  334. Array prevTxs = params[1].get_array();
  335. BOOST_FOREACH(Value& p, prevTxs)
  336. {
  337. if (p.type() != obj_type)
  338. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
  339. Object prevOut = p.get_obj();
  340. RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type));
  341. string txidHex = find_value(prevOut, "txid").get_str();
  342. if (!IsHex(txidHex))
  343. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "txid must be hexadecimal");
  344. uint256 txid;
  345. txid.SetHex(txidHex);
  346. int nOut = find_value(prevOut, "vout").get_int();
  347. if (nOut < 0)
  348. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive");
  349. string pkHex = find_value(prevOut, "scriptPubKey").get_str();
  350. if (!IsHex(pkHex))
  351. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "scriptPubKey must be hexadecimal");
  352. vector<unsigned char> pkData(ParseHex(pkHex));
  353. CScript scriptPubKey(pkData.begin(), pkData.end());
  354. COutPoint outpoint(txid, nOut);
  355. if (mapPrevOut.count(outpoint))
  356. {
  357. // Complain if scriptPubKey doesn't match
  358. if (mapPrevOut[outpoint] != scriptPubKey)
  359. {
  360. string err("Previous output scriptPubKey mismatch:\n");
  361. err = err + mapPrevOut[outpoint].ToString() + "\nvs:\n"+
  362. scriptPubKey.ToString();
  363. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, err);
  364. }
  365. }
  366. else
  367. mapPrevOut[outpoint] = scriptPubKey;
  368. }
  369. }
  370. bool fGivenKeys = false;
  371. CBasicKeyStore tempKeystore;
  372. if (params.size() > 2 && params[2].type() != null_type)
  373. {
  374. fGivenKeys = true;
  375. Array keys = params[2].get_array();
  376. BOOST_FOREACH(Value k, keys)
  377. {
  378. CEcoinSecret vchSecret;
  379. bool fGood = vchSecret.SetString(k.get_str());
  380. if (!fGood)
  381. throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY,"Invalid private key");
  382. CKey key;
  383. bool fCompressed;
  384. CSecret secret = vchSecret.GetSecret(fCompressed);
  385. key.SetSecret(secret, fCompressed);
  386. tempKeystore.AddKey(key);
  387. }
  388. }
  389. else
  390. EnsureWalletIsUnlocked();
  391. const CKeyStore& keystore = (fGivenKeys ? tempKeystore : *pwalletMain);
  392. int nHashType = SIGHASH_ALL;
  393. if (params.size() > 3 && params[3].type() != null_type)
  394. {
  395. static map<string, int> mapSigHashValues =
  396. boost::assign::map_list_of
  397. (string("ALL"), int(SIGHASH_ALL))
  398. (string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
  399. (string("NONE"), int(SIGHASH_NONE))
  400. (string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY))
  401. (string("SINGLE"), int(SIGHASH_SINGLE))
  402. (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY))
  403. ;
  404. string strHashType = params[3].get_str();
  405. if (mapSigHashValues.count(strHashType))
  406. nHashType = mapSigHashValues[strHashType];
  407. else
  408. throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid sighash param");
  409. }
  410. bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
  411. // Sign what we can:
  412. for (unsigned int i = 0; i < mergedTx.vin.size(); i++)
  413. {
  414. CTxIn& txin = mergedTx.vin[i];
  415. if (mapPrevOut.count(txin.prevout) == 0)
  416. {
  417. fComplete = false;
  418. continue;
  419. }
  420. const CScript& prevPubKey = mapPrevOut[txin.prevout];
  421. txin.scriptSig.clear();
  422. // Only sign SIGHASH_SINGLE if there's a corresponding output:
  423. if (!fHashSingle || (i < mergedTx.vout.size()))
  424. SignSignature(keystore, prevPubKey, mergedTx, i, nHashType);
  425. // ... and merge in other signatures:
  426. BOOST_FOREACH(const CTransaction& txv, txVariants)
  427. {
  428. txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
  429. }
  430. if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, true, 0))
  431. fComplete = false;
  432. }
  433. Object result;
  434. CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
  435. ssTx << mergedTx;
  436. result.push_back(Pair("hex", HexStr(ssTx.begin(), ssTx.end())));
  437. result.push_back(Pair("complete", fComplete));
  438. return result;
  439. }
  440. Value sendrawtransaction(const Array& params, bool fHelp)
  441. {
  442. if (fHelp || params.size() < 1 || params.size() > 1)
  443. throw runtime_error(
  444. "sendrawtransaction <hex string>\n"
  445. "Submits raw transaction (serialized, hex-encoded) to local node and network.");
  446. RPCTypeCheck(params, list_of(str_type));
  447. // parse hex string from parameter
  448. vector<unsigned char> txData(ParseHex(params[0].get_str()));
  449. CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
  450. CTransaction tx;
  451. // deserialize binary data stream
  452. try {
  453. ssData >> tx;
  454. }
  455. catch (std::exception &e) {
  456. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
  457. }
  458. uint256 hashTx = tx.GetHash();
  459. // See if the transaction is already in a block or in the memory pool
  460. CTransaction existingTx;
  461. uint256 hashBlock = 0;
  462. if (GetTransaction(hashTx, existingTx, hashBlock))
  463. {
  464. if (hashBlock != 0)
  465. throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("transaction already in block ")+hashBlock.GetHex());
  466. // Not in block, but already in the memory pool; will drop through to re-relay it
  467. }
  468. else
  469. {
  470. // push to local node
  471. CTxDB txdb("r");
  472. if (!tx.AcceptToMemoryPool(txdb))
  473. throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected");
  474. SyncWithWallets(tx, NULL, true);
  475. }
  476. RelayTransaction(tx, hashTx);
  477. return hashTx.GetHex();
  478. }