PRCYCoin  2.0.0.7rc1
P2P Digital Currency
prcycoin-tx.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 The Bitcoin developers
2 // Copyright (c) 2015-2018 The PIVX developers
3 // Copyright (c) 2018-2020 The DAPS Project developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #include "base58.h"
8 #include "clientversion.h"
9 #include "coins.h"
10 #include "core_io.h"
11 #include "keystore.h"
12 #include "primitives/block.h" // for MAX_BLOCK_SIZE
13 #include "primitives/transaction.h"
14 #include "script/script.h"
15 #include "script/sign.h"
16 #include "guiinterface.h" // for _(...)
17 #include <univalue.h>
18 #include "util.h"
19 #include "utilmoneystr.h"
20 #include "utilstrencodings.h"
21 
22 #include <stdio.h>
23 
24 #include <boost/algorithm/string.hpp>
25 #include <boost/assign/list_of.hpp>
26 
27 #define MAX_FILE_LENGTH (1024 * 1024) // 1MB
28 
29 
30 static bool fCreateBlank;
31 static std::map<std::string, UniValue> registers;
33 
34 static bool AppInitRawTx(int argc, char* argv[])
35 {
36  //
37  // Parameters
38  //
39  ParseParameters(argc, argv);
40 
41  // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
43  fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
44  return false;
45  }
46 
47  fCreateBlank = GetBoolArg("-create", false);
48 
49  if (argc < 2 || mapArgs.count("-?") || mapArgs.count("-help")) {
50  // First part of help message is specific to this utility
51  std::string strUsage = _("PRCY prcycoin-tx utility version") + " " + FormatFullVersion() + "\n\n" +
52  _("Usage:") + "\n" +
53  " prcycoin-tx [options] <hex-tx> [commands] " + _("Update hex-encoded prcycoin transaction") + "\n" +
54  " prcycoin-tx [options] -create [commands] " + _("Create hex-encoded prcycoin transaction") + "\n" +
55  "\n";
56 
57  fprintf(stdout, "%s", strUsage.c_str());
58 
59  strUsage = HelpMessageGroup(_("Options:"));
60  strUsage += HelpMessageOpt("-?", _("This help message"));
61  strUsage += HelpMessageOpt("-create", _("Create new, empty TX."));
62  strUsage += HelpMessageOpt("-json", _("Select JSON output"));
63  strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction id of the resultant transaction."));
64  strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly."));
65  strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
66 
67  fprintf(stdout, "%s", strUsage.c_str());
68 
69 
70  strUsage = HelpMessageGroup(_("Commands:"));
71  strUsage += HelpMessageOpt("delin=N", _("Delete input N from TX"));
72  strUsage += HelpMessageOpt("delout=N", _("Delete output N from TX"));
73  strUsage += HelpMessageOpt("in=TXID:VOUT", _("Add input to TX"));
74  strUsage += HelpMessageOpt("locktime=N", _("Set TX lock time to N"));
75  strUsage += HelpMessageOpt("nversion=N", _("Set TX version to N"));
76  strUsage += HelpMessageOpt("outaddr=VALUE:ADDRESS", _("Add address-based output to TX"));
77  strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT", _("Add raw script output to TX"));
78  strUsage += HelpMessageOpt("sign=SIGHASH-FLAGS", _("Add zero or more signatures to transaction") + ". " +
79  _("This command requires JSON registers:") +
80  _("prevtxs=JSON object") + ", " +
81  _("privatekeys=JSON object") + ". " +
82  _("See signrawtransaction docs for format of sighash flags, JSON objects."));
83  fprintf(stdout, "%s", strUsage.c_str());
84 
85  strUsage = HelpMessageGroup(_("Register Commands:"));
86  strUsage += HelpMessageOpt("load=NAME:FILENAME", _("Load JSON file FILENAME into register NAME"));
87  strUsage += HelpMessageOpt("set=NAME:JSON-STRING", _("Set register NAME to given JSON-STRING"));
88  fprintf(stdout, "%s", strUsage.c_str());
89 
90  return false;
91  }
92  return true;
93 }
94 
95 static void RegisterSetJson(const std::string& key, const std::string& rawJson)
96 {
97  UniValue val;
98  if (!val.read(rawJson)) {
99  std::string strErr = "Cannot parse JSON for key " + key;
100  throw std::runtime_error(strErr);
101  }
102 
103  registers[key] = val;
104 }
105 
106 static void RegisterSet(const std::string& strInput)
107 {
108  // separate NAME:VALUE in string
109  size_t pos = strInput.find(':');
110  if ((pos == std::string::npos) ||
111  (pos == 0) ||
112  (pos == (strInput.size() - 1)))
113  throw std::runtime_error("Register input requires NAME:VALUE");
114 
115  std::string key = strInput.substr(0, pos);
116  std::string valStr = strInput.substr(pos + 1, std::string::npos);
117 
118  RegisterSetJson(key, valStr);
119 }
120 
121 static void RegisterLoad(const std::string& strInput)
122 {
123  // separate NAME:FILENAME in string
124  size_t pos = strInput.find(':');
125  if ((pos == std::string::npos) ||
126  (pos == 0) ||
127  (pos == (strInput.size() - 1)))
128  throw std::runtime_error("Register load requires NAME:FILENAME");
129 
130  std::string key = strInput.substr(0, pos);
131  std::string filename = strInput.substr(pos + 1, std::string::npos);
132 
133  FILE* f = fsbridge::fopen(filename.c_str(), "r");
134  if (!f) {
135  std::string strErr = "Cannot open file " + filename;
136  throw std::runtime_error(strErr);
137  }
138 
139  // load file chunks into one big buffer
140  std::string valStr;
141  int totalLength = 0;
142  while ((!feof(f)) && (!ferror(f)) && totalLength < MAX_FILE_LENGTH) {
143  char buf[4096];
144  int bread = fread(buf, 1, sizeof(buf), f);
145  if (bread <= 0)
146  break;
147 
148  totalLength += bread;
149  valStr.insert(valStr.size(), buf, bread);
150  }
151 
152  if (ferror(f)) {
153  std::string strErr = "Error reading file " + filename;
154  throw std::runtime_error(strErr);
155  }
156 
157  if (totalLength > MAX_FILE_LENGTH) {
158  std::string strErr = "Error reading big file " + filename;
159  throw std::runtime_error(strErr);
160  }
161 
162  fclose(f);
163 
164  // evaluate as JSON buffer register
165  RegisterSetJson(key, valStr);
166 }
167 
168 static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
169 {
170  int64_t newVersion = atoi64(cmdVal);
171  if (newVersion < 1 || newVersion > CTransaction::CURRENT_VERSION)
172  throw std::runtime_error("Invalid TX version requested");
173 
174  tx.nVersion = (int)newVersion;
175 }
176 
177 static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
178 {
179  int64_t newLocktime = atoi64(cmdVal);
180  if (newLocktime < 0LL || newLocktime > 0xffffffffLL)
181  throw std::runtime_error("Invalid TX locktime requested");
182 
183  tx.nLockTime = (unsigned int)newLocktime;
184 }
185 
186 static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInput)
187 {
188  // separate TXID:VOUT in string
189  size_t pos = strInput.find(':');
190  if ((pos == std::string::npos) ||
191  (pos == 0) ||
192  (pos == (strInput.size() - 1)))
193  throw std::runtime_error("TX input missing separator");
194 
195  // extract and validate TXID
196  std::string strTxid = strInput.substr(0, pos);
197  if ((strTxid.size() != 64) || !IsHex(strTxid))
198  throw std::runtime_error("invalid TX input txid");
199  uint256 txid(strTxid);
200 
201  static const unsigned int minTxOutSz = 9;
202  unsigned int nMaxSize = MAX_BLOCK_SIZE_LEGACY;
203  static const unsigned int maxVout = nMaxSize / minTxOutSz;
204 
205  // extract and validate vout
206  std::string strVout = strInput.substr(pos + 1, std::string::npos);
207  int vout = atoi(strVout);
208  if ((vout < 0) || (vout > (int)maxVout))
209  throw std::runtime_error("invalid TX input vout");
210 
211  // append to transaction input list
212  CTxIn txin(txid, vout);
213  tx.vin.push_back(txin);
214 }
215 
216 static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput)
217 {
218  // separate VALUE:ADDRESS in string
219  size_t pos = strInput.find(':');
220  if ((pos == std::string::npos) ||
221  (pos == 0) ||
222  (pos == (strInput.size() - 1)))
223  throw std::runtime_error("TX output missing separator");
224 
225  // extract and validate VALUE
226  std::string strValue = strInput.substr(0, pos);
227  CAmount value;
228  if (!ParseMoney(strValue, value))
229  throw std::runtime_error("invalid TX output value");
230 
231  // extract and validate ADDRESS
232  std::string strAddr = strInput.substr(pos + 1, std::string::npos);
233  CBitcoinAddress addr(strAddr);
234  if (!addr.IsValid())
235  throw std::runtime_error("invalid TX output address");
236 
237  // build standard output script via GetScriptForDestination()
238  CScript scriptPubKey = GetScriptForDestination(addr.Get());
239 
240  // construct TxOut, append to transaction output list
241  CTxOut txout(value, scriptPubKey);
242  tx.vout.push_back(txout);
243 }
244 
245 static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& strInput)
246 {
247  // separate VALUE:SCRIPT in string
248  size_t pos = strInput.find(':');
249  if ((pos == std::string::npos) ||
250  (pos == 0))
251  throw std::runtime_error("TX output missing separator");
252 
253  // extract and validate VALUE
254  std::string strValue = strInput.substr(0, pos);
255  CAmount value;
256  if (!ParseMoney(strValue, value))
257  throw std::runtime_error("invalid TX output value");
258 
259  // extract and validate script
260  std::string strScript = strInput.substr(pos + 1, std::string::npos);
261  CScript scriptPubKey = ParseScript(strScript); // throws on err
262 
263  // construct TxOut, append to transaction output list
264  CTxOut txout(value, scriptPubKey);
265  tx.vout.push_back(txout);
266 }
267 
268 static void MutateTxDelInput(CMutableTransaction& tx, const std::string& strInIdx)
269 {
270  // parse requested deletion index
271  int inIdx = atoi(strInIdx);
272  if (inIdx < 0 || inIdx >= (int)tx.vin.size()) {
273  std::string strErr = "Invalid TX input index '" + strInIdx + "'";
274  throw std::runtime_error(strErr.c_str());
275  }
276 
277  // delete input from transaction
278  tx.vin.erase(tx.vin.begin() + inIdx);
279 }
280 
281 static void MutateTxDelOutput(CMutableTransaction& tx, const std::string& strOutIdx)
282 {
283  // parse requested deletion index
284  int outIdx = atoi(strOutIdx);
285  if (outIdx < 0 || outIdx >= (int)tx.vout.size()) {
286  std::string strErr = "Invalid TX output index '" + strOutIdx + "'";
287  throw std::runtime_error(strErr.c_str());
288  }
289 
290  // delete output from transaction
291  tx.vout.erase(tx.vout.begin() + outIdx);
292 }
293 
294 static const unsigned int N_SIGHASH_OPTS = 6;
295 static const struct {
296  const char* flagStr;
297  int flags;
298 } sighashOptions[N_SIGHASH_OPTS] = {
299  {"ALL", SIGHASH_ALL},
300  {"NONE", SIGHASH_NONE},
301  {"SINGLE", SIGHASH_SINGLE},
302  {"ALL|ANYONECANPAY", SIGHASH_ALL | SIGHASH_ANYONECANPAY},
303  {"NONE|ANYONECANPAY", SIGHASH_NONE | SIGHASH_ANYONECANPAY},
304  {"SINGLE|ANYONECANPAY", SIGHASH_SINGLE | SIGHASH_ANYONECANPAY},
305 };
306 
307 static bool findSighashFlags(int& flags, const std::string& flagStr)
308 {
309  flags = 0;
310 
311  for (unsigned int i = 0; i < N_SIGHASH_OPTS; i++) {
312  if (flagStr == sighashOptions[i].flagStr) {
313  flags = sighashOptions[i].flags;
314  return true;
315  }
316  }
317 
318  return false;
319 }
320 
321 uint256 ParseHashUO(std::map<std::string, UniValue>& o, std::string strKey)
322 {
323  if (!o.count(strKey))
324  return UINT256_ZERO;
325  return ParseHashUV(o[strKey], strKey);
326 }
327 
328 std::vector<unsigned char> ParseHexUO(std::map<std::string, UniValue>& o, std::string strKey)
329 {
330  if (!o.count(strKey)) {
331  std::vector<unsigned char> emptyVec;
332  return emptyVec;
333  }
334  return ParseHexUV(o[strKey], strKey);
335 }
336 
337 static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
338 {
339  int nHashType = SIGHASH_ALL;
340 
341  if (flagStr.size() > 0)
342  if (!findSighashFlags(nHashType, flagStr))
343  throw std::runtime_error("unknown sighash flag/sign option");
344 
345  std::vector<CTransaction> txVariants;
346  txVariants.push_back(tx);
347 
348  // mergedTx will end up with all the signatures; it
349  // starts as a clone of the raw tx:
350  CMutableTransaction mergedTx(txVariants[0]);
351  bool fComplete = true;
352  CCoinsView viewDummy;
353  CCoinsViewCache view(&viewDummy);
354 
355  if (!registers.count("privatekeys"))
356  throw std::runtime_error("privatekeys register variable must be set.");
357  bool fGivenKeys = false;
358  CBasicKeyStore tempKeystore;
359  UniValue keysObj = registers["privatekeys"];
360  fGivenKeys = true;
361 
362  for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
363  if (!keysObj[kidx].isStr())
364  throw std::runtime_error("privatekey not a string");
365  CBitcoinSecret vchSecret;
366  bool fGood = vchSecret.SetString(keysObj[kidx].getValStr());
367  if (!fGood)
368  throw std::runtime_error("privatekey not valid");
369 
370  CKey key = vchSecret.GetKey();
371  tempKeystore.AddKey(key);
372  }
373 
374  // Add previous txouts given in the RPC call:
375  if (!registers.count("prevtxs"))
376  throw std::runtime_error("prevtxs register variable must be set.");
377  UniValue prevtxsObj = registers["prevtxs"];
378  {
379  for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
380  UniValue prevOut = prevtxsObj[previdx];
381  if (!prevOut.isObject())
382  throw std::runtime_error("expected prevtxs internal object");
383 
384  std::map<std::string, UniValue::VType> types = boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR);
385  if (!prevOut.checkObject(types))
386  throw std::runtime_error("prevtxs internal object typecheck fail");
387 
388  uint256 txid = ParseHashUV(prevOut["txid"], "txid");
389 
390  int nOut = atoi(prevOut["vout"].getValStr());
391  if (nOut < 0)
392  throw std::runtime_error("vout must be positive");
393 
394  std::vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey"));
395  CScript scriptPubKey(pkData.begin(), pkData.end());
396 
397  {
398  CCoinsModifier coins = view.ModifyCoins(txid);
399  if (coins->IsAvailable(nOut) && coins->vout[nOut].scriptPubKey != scriptPubKey) {
400  std::string err("Previous output scriptPubKey mismatch:\n");
401  err = err + coins->vout[nOut].scriptPubKey.ToString() + "\nvs:\n" +
402  scriptPubKey.ToString();
403  throw std::runtime_error(err);
404  }
405  if ((unsigned int)nOut >= coins->vout.size())
406  coins->vout.resize(nOut + 1);
407  coins->vout[nOut].scriptPubKey = scriptPubKey;
408  coins->vout[nOut].nValue = 0; // we don't know the actual output value
409  }
410 
411  // if redeemScript given and private keys given,
412  // add redeemScript to the tempKeystore so it can be signed:
413  if (fGivenKeys && scriptPubKey.IsPayToScriptHash() &&
414  prevOut.exists("redeemScript")) {
415  UniValue v = prevOut["redeemScript"];
416  std::vector<unsigned char> rsData(ParseHexUV(v, "redeemScript"));
417  CScript redeemScript(rsData.begin(), rsData.end());
418  tempKeystore.AddCScript(redeemScript);
419  }
420  }
421  }
422 
423  const CKeyStore& keystore = tempKeystore;
424 
425  bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
426 
427  // Sign what we can:
428  for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
429  CTxIn& txin = mergedTx.vin[i];
430  const CCoins* coins = view.AccessCoins(txin.prevout.hash);
431  if (!coins || !coins->IsAvailable(txin.prevout.n)) {
432  fComplete = false;
433  continue;
434  }
435  const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
436 
437  txin.scriptSig.clear();
438  // Only sign SIGHASH_SINGLE if there's a corresponding output:
439  if (!fHashSingle || (i < mergedTx.vout.size()))
440  SignSignature(keystore, prevPubKey, mergedTx, i, nHashType);
441 
442  // ... and merge in other signatures:
443  for (const CTransaction& txv : txVariants) {
444  txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
445  }
446  if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i)))
447  fComplete = false;
448  }
449 
450  if (fComplete) {
451  // do nothing... for now
452  // perhaps store this for later optional JSON output
453  }
454 
455  tx = mergedTx;
456 }
457 
458 static void MutateTx(CMutableTransaction& tx, const std::string& command, const std::string& commandVal)
459 {
460  if (command == "nversion")
461  MutateTxVersion(tx, commandVal);
462  else if (command == "locktime")
463  MutateTxLocktime(tx, commandVal);
464 
465  else if (command == "delin")
466  MutateTxDelInput(tx, commandVal);
467  else if (command == "in")
468  MutateTxAddInput(tx, commandVal);
469 
470  else if (command == "delout")
471  MutateTxDelOutput(tx, commandVal);
472  else if (command == "outaddr")
473  MutateTxAddOutAddr(tx, commandVal);
474  else if (command == "outscript")
475  MutateTxAddOutScript(tx, commandVal);
476 
477  else if (command == "sign")
478  MutateTxSign(tx, commandVal);
479 
480  else if (command == "load")
481  RegisterLoad(commandVal);
482 
483  else if (command == "set")
484  RegisterSet(commandVal);
485 
486  else
487  throw std::runtime_error("unknown command");
488 }
489 
490 static void OutputTxJSON(const CTransaction& tx)
491 {
492  UniValue entry(UniValue::VOBJ);
493  TxToUniv(tx, UINT256_ZERO, entry);
494 
495  std::string jsonOutput = entry.write(4);
496  fprintf(stdout, "%s\n", jsonOutput.c_str());
497 }
498 
499 static void OutputTxHash(const CTransaction& tx)
500 {
501  std::string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id)
502 
503  fprintf(stdout, "%s\n", strHexHash.c_str());
504 }
505 
506 static void OutputTxHex(const CTransaction& tx)
507 {
508  std::string strHex = EncodeHexTx(tx);
509 
510  fprintf(stdout, "%s\n", strHex.c_str());
511 }
512 
513 static void OutputTx(const CTransaction& tx)
514 {
515  if (GetBoolArg("-json", false))
516  OutputTxJSON(tx);
517  else if (GetBoolArg("-txid", false))
518  OutputTxHash(tx);
519  else
520  OutputTxHex(tx);
521 }
522 
523 static std::string readStdin()
524 {
525  char buf[4096];
526  std::string ret;
527 
528  int totalLength = 0;
529  while (!feof(stdin) && totalLength < MAX_FILE_LENGTH) {
530  size_t bread = fread(buf, 1, sizeof(buf), stdin);
531  ret.append(buf, bread);
532  if (bread < sizeof(buf))
533  break;
534 
535  totalLength += bread;
536  }
537 
538  if (ferror(stdin))
539  throw std::runtime_error("error reading stdin");
540  if (totalLength > MAX_FILE_LENGTH)
541  throw std::runtime_error("error reading stdin max length");
542 
543  boost::algorithm::trim_right(ret);
544 
545  return ret;
546 }
547 
548 static int CommandLineRawTx(int argc, char* argv[])
549 {
550  std::string strPrint;
551  int nRet = 0;
552  try {
553  // Skip switches; Permit common stdin convention "-"
554  while (argc > 1 && IsSwitchChar(argv[1][0]) &&
555  (argv[1][1] != 0)) {
556  argc--;
557  argv++;
558  }
559 
560  CTransaction txDecodeTmp;
561  int startArg;
562 
563  if (!fCreateBlank) {
564  // require at least one param
565  if (argc < 2)
566  throw std::runtime_error("too few parameters");
567 
568  // param: hex-encoded prcycoin transaction
569  std::string strHexTx(argv[1]);
570  if (strHexTx == "-") // "-" implies standard input
571  strHexTx = readStdin();
572 
573  if (!DecodeHexTx(txDecodeTmp, strHexTx))
574  throw std::runtime_error("invalid transaction encoding");
575 
576  startArg = 2;
577  } else
578  startArg = 1;
579 
580  CMutableTransaction tx(txDecodeTmp);
581 
582  for (int i = startArg; i < argc; i++) {
583  std::string arg = argv[i];
584  std::string key, value;
585  size_t eqpos = arg.find('=');
586  if (eqpos == std::string::npos)
587  key = arg;
588  else {
589  key = arg.substr(0, eqpos);
590  value = arg.substr(eqpos + 1);
591  }
592 
593  MutateTx(tx, key, value);
594  }
595 
596  OutputTx(tx);
597  }
598 
599  catch (const boost::thread_interrupted&) {
600  throw;
601  } catch (const std::exception& e) {
602  strPrint = std::string("error: ") + e.what();
603  nRet = EXIT_FAILURE;
604  } catch (...) {
605  PrintExceptionContinue(NULL, "CommandLineRawTx()");
606  throw;
607  }
608 
609  if (strPrint != "") {
610  fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
611  }
612  return nRet;
613 }
614 
615 int main(int argc, char* argv[])
616 {
618 
619  try {
620  if (!AppInitRawTx(argc, argv))
621  return EXIT_FAILURE;
622  } catch (const std::exception& e) {
623  PrintExceptionContinue(&e, "AppInitRawTx()");
624  return EXIT_FAILURE;
625  } catch (...) {
626  PrintExceptionContinue(NULL, "AppInitRawTx()");
627  return EXIT_FAILURE;
628  }
629 
630  int ret = EXIT_FAILURE;
631  try {
632  ret = CommandLineRawTx(argc, argv);
633  } catch (const std::exception& e) {
634  PrintExceptionContinue(&e, "CommandLineRawTx()");
635  } catch (...) {
636  PrintExceptionContinue(NULL, "CommandLineRawTx()");
637  }
638  return ret;
639 }
CTxIn
An input of a transaction.
Definition: transaction.h:83
CKeyStore
A virtual base class for key stores.
Definition: keystore.h:21
block.h
SIGHASH_ANYONECANPAY
@ SIGHASH_ANYONECANPAY
Definition: interpreter.h:27
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition: transaction.h:387
UINT256_ZERO
const uint256 UINT256_ZERO
constant uint256 instances
Definition: uint256.h:129
UniValue::checkObject
bool checkObject(const std::map< std::string, UniValue::VType > &memberTypes)
Definition: univalue.cpp:227
main
int main(int argc, char *argv[])
Definition: prcycoin-tx.cpp:615
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:21
SetupEnvironment
void SetupEnvironment()
Definition: util.cpp:600
CBitcoinSecret::GetKey
CKey GetKey()
Definition: base58.cpp:304
uiInterface
CClientUIInterface uiInterface
Definition: prcycoin-tx.cpp:32
CClientUIInterface
Signals for UI communication.
Definition: guiinterface.h:28
transaction.h
HelpMessageGroup
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
Definition: util.cpp:282
fsbridge::fopen
FILE * fopen(const fs::path &p, const char *mode)
Definition: fs.cpp:13
base_uint::GetHex
std::string GetHex() const
Definition: arith_uint256.cpp:155
COutPoint::hash
uint256 hash
Definition: transaction.h:39
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Definition: standard.cpp:285
CBitcoinAddress
base58-encoded PRCY addresses.
Definition: base58.h:109
CMutableTransaction::nVersion
int32_t nVersion
Definition: transaction.h:386
mapArgs
std::map< std::string, std::string > mapArgs
Definition: util.cpp:111
CCoins::IsAvailable
bool IsAvailable(unsigned int nPos) const
check whether a particular output is still available
Definition: coins.h:275
HelpMessageOpt
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
Definition: util.cpp:286
SelectParamsFromCommandLine
bool SelectParamsFromCommandLine()
Looks for -regtest or -testnet and then calls SelectParams as appropriate.
Definition: chainparams.cpp:490
flags
int flags
Definition: prcycoin-tx.cpp:297
clientversion.h
UniValue::read
bool read(const char *raw, size_t len)
Definition: univalue_read.cpp:253
CScript::IsPayToScriptHash
bool IsPayToScriptHash() const
Definition: script.cpp:235
guiinterface.h
CScript::clear
void clear()
Definition: script.h:634
core_io.h
IsSwitchChar
bool IsSwitchChar(char c)
Definition: util.h:92
TxToUniv
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry)
Definition: core_write.cpp:95
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
Definition: util.cpp:309
MutableTransactionSignatureChecker
Definition: interpreter.h:119
UniValue
Definition: univalue.h:19
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:269
CBitcoinSecret
A base58-encoded secret key.
Definition: base58.h:131
atoi
int atoi(const std::string &str)
Definition: utilstrencodings.cpp:587
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:346
CCoins::vout
std::vector< CTxOut > vout
unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are d...
Definition: coins.h:85
CMutableTransaction::nLockTime
uint32_t nLockTime
Definition: transaction.h:389
IsHex
bool IsHex(const std::string &str)
Definition: utilstrencodings.cpp:68
CTxOut
An output of a transaction.
Definition: transaction.h:164
_
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
Definition: guiinterface.h:119
UniValue::exists
bool exists(const std::string &key) const
Definition: univalue.h:75
univalue.h
GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:255
sign.h
DecodeHexTx
bool DecodeHexTx(CTransaction &tx, const std::string &strHexTx)
Definition: core_read.cpp:63
CCoinsModifier
A reference to a mutable cache entry.
Definition: coins.h:398
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
ParseScript
CScript ParseScript(std::string s)
Definition: core_read.cpp:26
CBitcoinSecret::SetString
bool SetString(const char *pszSecret)
Definition: base58.cpp:319
CBasicKeyStore::AddCScript
virtual bool AddCScript(const CScript &redeemScript)
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
Definition: keystore.cpp:34
keystore.h
UniValue::VNUM
@ VNUM
Definition: univalue.h:21
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
ParseHexUO
std::vector< unsigned char > ParseHexUO(std::map< std::string, UniValue > &o, std::string strKey)
Definition: prcycoin-tx.cpp:328
flagStr
const char * flagStr
Definition: prcycoin-tx.cpp:296
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:363
SIGHASH_NONE
@ SIGHASH_NONE
Definition: interpreter.h:25
ParseHashUO
uint256 ParseHashUO(std::map< std::string, UniValue > &o, std::string strKey)
Definition: prcycoin-tx.cpp:321
coins.h
VerifyScript
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
Definition: interpreter.cpp:1163
CTransaction::CURRENT_VERSION
static const int32_t CURRENT_VERSION
Definition: transaction.h:277
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:388
ParseHashUV
uint256 ParseHashUV(const UniValue &v, const std::string &strName)
Definition: core_read.cpp:95
atoi64
int64_t atoi64(const char *psz)
Definition: utilstrencodings.cpp:569
CKey
An encapsulated private key.
Definition: key.h:39
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:414
CKeyStore::AddKey
virtual bool AddKey(const CKey &key)
Definition: keystore.cpp:22
utilmoneystr.h
COutPoint::n
uint32_t n
Definition: transaction.h:40
key
CKey key
Definition: bip38tooldialog.cpp:173
CScript::ToString
std::string ToString() const
Definition: script.cpp:266
ParseParameters
void ParseParameters(int argc, const char *const argv[])
Definition: util.cpp:208
CTxIn::prevout
COutPoint prevout
Definition: transaction.h:86
SignSignature
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, int nHashType)
Definition: sign.cpp:96
CTxIn::scriptSig
CScript scriptSig
Definition: transaction.h:87
SIGHASH_SINGLE
@ SIGHASH_SINGLE
Definition: interpreter.h:26
base58.h
CCoins
Definition: coins.h:77
UniValue::size
size_t size() const
Definition: univalue.h:69
CBasicKeyStore
Basic key store, that keeps keys in an address->secret map.
Definition: keystore.h:57
script.h
CTransaction::GetHash
const uint256 & GetHash() const
Definition: transaction.h:342
EncodeHexTx
std::string EncodeHexTx(const CTransaction &tx)
Definition: core_write.cpp:55
ParseHexUV
std::vector< unsigned char > ParseHexUV(const UniValue &v, const std::string &strName)
Definition: core_read.cpp:113
utilstrencodings.h
FormatFullVersion
std::string FormatFullVersion()
Definition: clientversion.cpp:80
SIGHASH_ALL
@ SIGHASH_ALL
Definition: interpreter.h:24
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:384
CombineSignatures
CScript CombineSignatures(const CScript &scriptPubKey, const CTransaction &txTo, unsigned int nIn, const CScript &scriptSig1, const CScript &scriptSig2)
Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders, combine them intellig...
Definition: sign.cpp:249
UniValue::VSTR
@ VSTR
Definition: univalue.h:21
util.h
MAX_FILE_LENGTH
#define MAX_FILE_LENGTH
Definition: prcycoin-tx.cpp:27
ParseMoney
bool ParseMoney(const std::string &str, CAmount &nRet)
Definition: utilmoneystr.cpp:37
UniValue::isObject
bool isObject() const
Definition: univalue.h:84