Bitcoin ABC  0.24.7
P2P Digital Currency
bitcoin-tx.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #if defined(HAVE_CONFIG_H)
6 #include <config/bitcoin-config.h>
7 #endif
8 
9 #include <chainparams.h>
10 #include <clientversion.h>
11 #include <coins.h>
12 #include <consensus/consensus.h>
13 #include <core_io.h>
14 #include <currencyunit.h>
15 #include <key_io.h>
16 #include <primitives/transaction.h>
17 #include <rpc/util.h>
18 #include <script/script.h>
19 #include <script/sign.h>
20 #include <script/signingprovider.h>
21 #include <util/moneystr.h>
22 #include <util/strencodings.h>
23 #include <util/string.h>
24 #include <util/system.h>
25 #include <util/translation.h>
26 
27 #include <univalue.h>
28 
29 #include <boost/algorithm/string.hpp>
30 
31 #include <cstdio>
32 #include <functional>
33 #include <memory>
34 
35 static bool fCreateBlank;
36 static std::map<std::string, UniValue> registers;
37 static const int CONTINUE_EXECUTION = -1;
38 
39 const std::function<std::string(const char *)> G_TRANSLATION_FUN = nullptr;
40 
41 static void SetupBitcoinTxArgs(ArgsManager &argsman) {
42  SetupHelpOptions(argsman);
43 
44  SetupCurrencyUnitOptions(argsman);
45  argsman.AddArg("-create", "Create new, empty TX.", ArgsManager::ALLOW_ANY,
47  argsman.AddArg("-json", "Select JSON output", ArgsManager::ALLOW_ANY,
49  argsman.AddArg(
50  "-txid",
51  "Output only the hex-encoded transaction id of the resultant "
52  "transaction.",
55 
56  argsman.AddArg("delin=N", "Delete input N from TX", ArgsManager::ALLOW_ANY,
58  argsman.AddArg("delout=N", "Delete output N from TX",
60  argsman.AddArg("in=TXID:VOUT(:SEQUENCE_NUMBER)", "Add input to TX",
62  argsman.AddArg("locktime=N", "Set TX lock time to N",
64  argsman.AddArg("nversion=N", "Set TX version to N", ArgsManager::ALLOW_ANY,
66  argsman.AddArg("outaddr=VALUE:ADDRESS", "Add address-based output to TX",
68  argsman.AddArg("outpubkey=VALUE:PUBKEY[:FLAGS]",
69  "Add pay-to-pubkey output to TX. "
70  "Optionally add the \"S\" flag to wrap the output in a "
71  "pay-to-script-hash.",
73  argsman.AddArg("outdata=[VALUE:]DATA", "Add data-based output to TX",
75  argsman.AddArg("outscript=VALUE:SCRIPT[:FLAGS]",
76  "Add raw script output to TX. "
77  "Optionally add the \"S\" flag to wrap the output in a "
78  "pay-to-script-hash.",
80  argsman.AddArg(
81  "outmultisig=VALUE:REQUIRED:PUBKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]",
82  "Add Pay To n-of-m Multi-sig output to TX. n = REQUIRED, m = PUBKEYS. "
83  "Optionally add the \"S\" flag to wrap the output in a "
84  "pay-to-script-hash.",
86  argsman.AddArg("sign=SIGHASH-FLAGS",
87  "Add zero or more signatures to transaction. "
88  "This command requires JSON registers:"
89  "prevtxs=JSON object, "
90  "privatekeys=JSON object. "
91  "See signrawtransactionwithkey docs for format of sighash "
92  "flags, JSON objects.",
94 
95  argsman.AddArg("load=NAME:FILENAME",
96  "Load JSON file FILENAME into register NAME",
98  argsman.AddArg("set=NAME:JSON-STRING",
99  "Set register NAME to given JSON-STRING",
101 }
102 
103 //
104 // This function returns either one of EXIT_ codes when it's expected to stop
105 // the process or CONTINUE_EXECUTION when it's expected to continue further.
106 //
107 static int AppInitRawTx(int argc, char *argv[]) {
108  //
109  // Parameters
110  //
112  std::string error;
113  if (!gArgs.ParseParameters(argc, argv, error)) {
114  tfm::format(std::cerr, "Error parsing command line arguments: %s\n",
115  error);
116  return EXIT_FAILURE;
117  }
118 
119  // Check for -chain, -testnet or -regtest parameter (Params() calls are only
120  // valid after this clause)
121  try {
123  } catch (const std::exception &e) {
124  tfm::format(std::cerr, "Error: %s\n", e.what());
125  return EXIT_FAILURE;
126  }
127 
128  fCreateBlank = gArgs.GetBoolArg("-create", false);
129 
130  if (argc < 2 || HelpRequested(gArgs)) {
131  // First part of help message is specific to this utility
132  std::string strUsage =
133  PACKAGE_NAME " bitcoin-tx utility version " + FormatFullVersion() +
134  "\n\n" +
135  "Usage: bitcoin-tx [options] <hex-tx> [commands] Update "
136  "hex-encoded bitcoin transaction\n" +
137  "or: bitcoin-tx [options] -create [commands] Create "
138  "hex-encoded bitcoin transaction\n" +
139  "\n";
140  strUsage += gArgs.GetHelpMessage();
141 
142  tfm::format(std::cout, "%s", strUsage);
143 
144  if (argc < 2) {
145  tfm::format(std::cerr, "Error: too few parameters\n");
146  return EXIT_FAILURE;
147  }
148 
149  return EXIT_SUCCESS;
150  }
151 
152  return CONTINUE_EXECUTION;
153 }
154 
155 static void RegisterSetJson(const std::string &key,
156  const std::string &rawJson) {
157  UniValue val;
158  if (!val.read(rawJson)) {
159  std::string strErr = "Cannot parse JSON for key " + key;
160  throw std::runtime_error(strErr);
161  }
162 
163  registers[key] = val;
164 }
165 
166 static void RegisterSet(const std::string &strInput) {
167  // separate NAME:VALUE in string
168  size_t pos = strInput.find(':');
169  if ((pos == std::string::npos) || (pos == 0) ||
170  (pos == (strInput.size() - 1))) {
171  throw std::runtime_error("Register input requires NAME:VALUE");
172  }
173 
174  std::string key = strInput.substr(0, pos);
175  std::string valStr = strInput.substr(pos + 1, std::string::npos);
176 
177  RegisterSetJson(key, valStr);
178 }
179 
180 static void RegisterLoad(const std::string &strInput) {
181  // separate NAME:FILENAME in string
182  size_t pos = strInput.find(':');
183  if ((pos == std::string::npos) || (pos == 0) ||
184  (pos == (strInput.size() - 1))) {
185  throw std::runtime_error("Register load requires NAME:FILENAME");
186  }
187 
188  std::string key = strInput.substr(0, pos);
189  std::string filename = strInput.substr(pos + 1, std::string::npos);
190 
191  FILE *f = fopen(filename.c_str(), "r");
192  if (!f) {
193  std::string strErr = "Cannot open file " + filename;
194  throw std::runtime_error(strErr);
195  }
196 
197  // load file chunks into one big buffer
198  std::string valStr;
199  while ((!feof(f)) && (!ferror(f))) {
200  char buf[4096];
201  int bread = fread(buf, 1, sizeof(buf), f);
202  if (bread <= 0) {
203  break;
204  }
205 
206  valStr.insert(valStr.size(), buf, bread);
207  }
208 
209  int error = ferror(f);
210  fclose(f);
211 
212  if (error) {
213  std::string strErr = "Error reading file " + filename;
214  throw std::runtime_error(strErr);
215  }
216 
217  // evaluate as JSON buffer register
218  RegisterSetJson(key, valStr);
219 }
220 
221 static Amount ExtractAndValidateValue(const std::string &strValue) {
222  Amount value;
223  if (!ParseMoney(strValue, value)) {
224  throw std::runtime_error("invalid TX output value");
225  }
226 
227  return value;
228 }
229 
231  const std::string &cmdVal) {
232  int64_t newVersion;
233  if (!ParseInt64(cmdVal, &newVersion) || newVersion < 1 ||
234  newVersion > CTransaction::MAX_STANDARD_VERSION) {
235  throw std::runtime_error("Invalid TX version requested: '" + cmdVal +
236  "'");
237  }
238 
239  tx.nVersion = int(newVersion);
240 }
241 
243  const std::string &cmdVal) {
244  int64_t newLocktime;
245  if (!ParseInt64(cmdVal, &newLocktime) || newLocktime < 0LL ||
246  newLocktime > 0xffffffffLL) {
247  throw std::runtime_error("Invalid TX locktime requested: '" + cmdVal +
248  "'");
249  }
250 
251  tx.nLockTime = (unsigned int)newLocktime;
252 }
253 
255  const std::string &strInput) {
256  std::vector<std::string> vStrInputParts;
257  boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
258 
259  // separate TXID:VOUT in string
260  if (vStrInputParts.size() < 2) {
261  throw std::runtime_error("TX input missing separator");
262  }
263 
264  // extract and validate TXID
265  uint256 hash;
266  if (!ParseHashStr(vStrInputParts[0], hash)) {
267  throw std::runtime_error("invalid TX input txid");
268  }
269 
270  TxId txid(hash);
271 
272  static const unsigned int minTxOutSz = 9;
273  static const unsigned int maxVout = MAX_TX_SIZE / minTxOutSz;
274 
275  // extract and validate vout
276  const std::string &strVout = vStrInputParts[1];
277  int64_t vout;
278  if (!ParseInt64(strVout, &vout) || vout < 0 ||
279  vout > static_cast<int64_t>(maxVout)) {
280  throw std::runtime_error("invalid TX input vout '" + strVout + "'");
281  }
282 
283  // extract the optional sequence number
284  uint32_t nSequenceIn = std::numeric_limits<unsigned int>::max();
285  if (vStrInputParts.size() > 2) {
286  nSequenceIn = std::stoul(vStrInputParts[2]);
287  }
288 
289  // append to transaction input list
290  CTxIn txin(txid, vout, CScript(), nSequenceIn);
291  tx.vin.push_back(txin);
292 }
293 
295  const std::string &strInput,
296  const CChainParams &chainParams) {
297  // Separate into VALUE:ADDRESS
298  std::vector<std::string> vStrInputParts;
299  boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
300 
301  if (vStrInputParts.size() != 2) {
302  throw std::runtime_error("TX output missing or too many separators");
303  }
304 
305  // Extract and validate VALUE
306  Amount value = ExtractAndValidateValue(vStrInputParts[0]);
307 
308  // extract and validate ADDRESS
309  std::string strAddr = vStrInputParts[1];
310  CTxDestination destination = DecodeDestination(strAddr, chainParams);
311  if (!IsValidDestination(destination)) {
312  throw std::runtime_error("invalid TX output address");
313  }
314  CScript scriptPubKey = GetScriptForDestination(destination);
315 
316  // construct TxOut, append to transaction output list
317  CTxOut txout(value, scriptPubKey);
318  tx.vout.push_back(txout);
319 }
320 
322  const std::string &strInput) {
323  // Separate into VALUE:PUBKEY[:FLAGS]
324  std::vector<std::string> vStrInputParts;
325  boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
326 
327  if (vStrInputParts.size() < 2 || vStrInputParts.size() > 3) {
328  throw std::runtime_error("TX output missing or too many separators");
329  }
330 
331  // Extract and validate VALUE
332  Amount value = ExtractAndValidateValue(vStrInputParts[0]);
333 
334  // Extract and validate PUBKEY
335  CPubKey pubkey(ParseHex(vStrInputParts[1]));
336  if (!pubkey.IsFullyValid()) {
337  throw std::runtime_error("invalid TX output pubkey");
338  }
339 
340  CScript scriptPubKey = GetScriptForRawPubKey(pubkey);
341 
342  // Extract and validate FLAGS
343  bool bScriptHash = false;
344  if (vStrInputParts.size() == 3) {
345  std::string flags = vStrInputParts[2];
346  bScriptHash = (flags.find('S') != std::string::npos);
347  }
348 
349  if (bScriptHash) {
350  // Get the ID for the script, and then construct a P2SH destination for
351  // it.
352  scriptPubKey = GetScriptForDestination(ScriptHash(scriptPubKey));
353  }
354 
355  // construct TxOut, append to transaction output list
356  CTxOut txout(value, scriptPubKey);
357  tx.vout.push_back(txout);
358 }
359 
361  const std::string &strInput) {
362  // Separate into VALUE:REQUIRED:NUMKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]
363  std::vector<std::string> vStrInputParts;
364  boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
365 
366  // Check that there are enough parameters
367  if (vStrInputParts.size() < 3) {
368  throw std::runtime_error("Not enough multisig parameters");
369  }
370 
371  // Extract and validate VALUE
372  Amount value = ExtractAndValidateValue(vStrInputParts[0]);
373 
374  // Extract REQUIRED
375  uint32_t required = stoul(vStrInputParts[1]);
376 
377  // Extract NUMKEYS
378  uint32_t numkeys = stoul(vStrInputParts[2]);
379 
380  // Validate there are the correct number of pubkeys
381  if (vStrInputParts.size() < numkeys + 3) {
382  throw std::runtime_error("incorrect number of multisig pubkeys");
383  }
384 
385  if (required < 1 || required > MAX_PUBKEYS_PER_MULTISIG || numkeys < 1 ||
386  numkeys > MAX_PUBKEYS_PER_MULTISIG || numkeys < required) {
387  throw std::runtime_error("multisig parameter mismatch. Required " +
388  ToString(required) + " of " +
389  ToString(numkeys) + "signatures.");
390  }
391 
392  // extract and validate PUBKEYs
393  std::vector<CPubKey> pubkeys;
394  for (int pos = 1; pos <= int(numkeys); pos++) {
395  CPubKey pubkey(ParseHex(vStrInputParts[pos + 2]));
396  if (!pubkey.IsFullyValid()) {
397  throw std::runtime_error("invalid TX output pubkey");
398  }
399 
400  pubkeys.push_back(pubkey);
401  }
402 
403  // Extract FLAGS
404  bool bScriptHash = false;
405  if (vStrInputParts.size() == numkeys + 4) {
406  std::string flags = vStrInputParts.back();
407  bScriptHash = (flags.find('S') != std::string::npos);
408  } else if (vStrInputParts.size() > numkeys + 4) {
409  // Validate that there were no more parameters passed
410  throw std::runtime_error("Too many parameters");
411  }
412 
413  CScript scriptPubKey = GetScriptForMultisig(required, pubkeys);
414 
415  if (bScriptHash) {
416  if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) {
417  throw std::runtime_error(
418  strprintf("redeemScript exceeds size limit: %d > %d",
419  scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
420  }
421  // Get the ID for the script, and then construct a P2SH destination for
422  // it.
423  scriptPubKey = GetScriptForDestination(ScriptHash(scriptPubKey));
424  }
425 
426  // construct TxOut, append to transaction output list
427  CTxOut txout(value, scriptPubKey);
428  tx.vout.push_back(txout);
429 }
430 
432  const std::string &strInput) {
433  Amount value = Amount::zero();
434 
435  // separate [VALUE:]DATA in string
436  size_t pos = strInput.find(':');
437 
438  if (pos == 0) {
439  throw std::runtime_error("TX output value not specified");
440  }
441 
442  if (pos != std::string::npos) {
443  // Extract and validate VALUE
444  value = ExtractAndValidateValue(strInput.substr(0, pos));
445  }
446 
447  // extract and validate DATA
448  std::string strData = strInput.substr(pos + 1, std::string::npos);
449 
450  if (!IsHex(strData)) {
451  throw std::runtime_error("invalid TX output data");
452  }
453 
454  std::vector<uint8_t> data = ParseHex(strData);
455 
456  CTxOut txout(value, CScript() << OP_RETURN << data);
457  tx.vout.push_back(txout);
458 }
459 
461  const std::string &strInput) {
462  // separate VALUE:SCRIPT[:FLAGS]
463  std::vector<std::string> vStrInputParts;
464  boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
465  if (vStrInputParts.size() < 2) {
466  throw std::runtime_error("TX output missing separator");
467  }
468 
469  // Extract and validate VALUE
470  Amount value = ExtractAndValidateValue(vStrInputParts[0]);
471 
472  // extract and validate script
473  std::string strScript = vStrInputParts[1];
474  CScript scriptPubKey = ParseScript(strScript);
475 
476  // Extract FLAGS
477  bool bScriptHash = false;
478  if (vStrInputParts.size() == 3) {
479  std::string flags = vStrInputParts.back();
480  bScriptHash = (flags.find('S') != std::string::npos);
481  }
482 
483  if (scriptPubKey.size() > MAX_SCRIPT_SIZE) {
484  throw std::runtime_error(strprintf("script exceeds size limit: %d > %d",
485  scriptPubKey.size(),
486  MAX_SCRIPT_SIZE));
487  }
488 
489  if (bScriptHash) {
490  if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) {
491  throw std::runtime_error(
492  strprintf("redeemScript exceeds size limit: %d > %d",
493  scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
494  }
495  scriptPubKey = GetScriptForDestination(ScriptHash(scriptPubKey));
496  }
497 
498  // construct TxOut, append to transaction output list
499  CTxOut txout(value, scriptPubKey);
500  tx.vout.push_back(txout);
501 }
502 
504  const std::string &strInIdx) {
505  // parse requested deletion index
506  int64_t inIdx;
507  if (!ParseInt64(strInIdx, &inIdx) || inIdx < 0 ||
508  inIdx >= static_cast<int64_t>(tx.vin.size())) {
509  throw std::runtime_error("Invalid TX input index '" + strInIdx + "'");
510  }
511 
512  // delete input from transaction
513  tx.vin.erase(tx.vin.begin() + inIdx);
514 }
515 
517  const std::string &strOutIdx) {
518  // parse requested deletion index
519  int64_t outIdx;
520  if (!ParseInt64(strOutIdx, &outIdx) || outIdx < 0 ||
521  outIdx >= static_cast<int64_t>(tx.vout.size())) {
522  throw std::runtime_error("Invalid TX output index '" + strOutIdx + "'");
523  }
524 
525  // delete output from transaction
526  tx.vout.erase(tx.vout.begin() + outIdx);
527 }
528 
529 static const unsigned int N_SIGHASH_OPTS = 12;
530 static const struct {
531  const char *flagStr;
532  int flags;
534  {"ALL", SIGHASH_ALL},
535  {"NONE", SIGHASH_NONE},
536  {"SINGLE", SIGHASH_SINGLE},
537  {"ALL|ANYONECANPAY", SIGHASH_ALL | SIGHASH_ANYONECANPAY},
538  {"NONE|ANYONECANPAY", SIGHASH_NONE | SIGHASH_ANYONECANPAY},
539  {"SINGLE|ANYONECANPAY", SIGHASH_SINGLE | SIGHASH_ANYONECANPAY},
540  {"ALL|FORKID", SIGHASH_ALL | SIGHASH_FORKID},
541  {"NONE|FORKID", SIGHASH_NONE | SIGHASH_FORKID},
542  {"SINGLE|FORKID", SIGHASH_SINGLE | SIGHASH_FORKID},
543  {"ALL|FORKID|ANYONECANPAY",
545  {"NONE|FORKID|ANYONECANPAY",
547  {"SINGLE|FORKID|ANYONECANPAY",
549 };
550 
551 static bool findSigHashFlags(SigHashType &sigHashType,
552  const std::string &flagStr) {
553  sigHashType = SigHashType();
554 
555  for (unsigned int i = 0; i < N_SIGHASH_OPTS; i++) {
556  if (flagStr == sigHashOptions[i].flagStr) {
557  sigHashType = SigHashType(sigHashOptions[i].flags);
558  return true;
559  }
560  }
561 
562  return false;
563 }
564 
565 static void MutateTxSign(CMutableTransaction &tx, const std::string &flagStr) {
566  SigHashType sigHashType = SigHashType().withForkId();
567 
568  if ((flagStr.size() > 0) && !findSigHashFlags(sigHashType, flagStr)) {
569  throw std::runtime_error("unknown sighash flag/sign option");
570  }
571 
572  // mergedTx will end up with all the signatures; it
573  // starts as a clone of the raw tx:
574  CMutableTransaction mergedTx{tx};
575  const CMutableTransaction txv{tx};
576 
577  CCoinsView viewDummy;
578  CCoinsViewCache view(&viewDummy);
579 
580  if (!registers.count("privatekeys")) {
581  throw std::runtime_error("privatekeys register variable must be set.");
582  }
583 
584  FillableSigningProvider tempKeystore;
585  UniValue keysObj = registers["privatekeys"];
586 
587  for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
588  if (!keysObj[kidx].isStr()) {
589  throw std::runtime_error("privatekey not a std::string");
590  }
591 
592  CKey key = DecodeSecret(keysObj[kidx].getValStr());
593  if (!key.IsValid()) {
594  throw std::runtime_error("privatekey not valid");
595  }
596  tempKeystore.AddKey(key);
597  }
598 
599  // Add previous txouts given in the RPC call:
600  if (!registers.count("prevtxs")) {
601  throw std::runtime_error("prevtxs register variable must be set.");
602  }
603 
604  UniValue prevtxsObj = registers["prevtxs"];
605 
606  for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
607  UniValue prevOut = prevtxsObj[previdx];
608  if (!prevOut.isObject()) {
609  throw std::runtime_error("expected prevtxs internal object");
610  }
611 
612  std::map<std::string, UniValue::VType> types = {
613  {"txid", UniValue::VSTR},
614  {"vout", UniValue::VNUM},
615  {"scriptPubKey", UniValue::VSTR}};
616  if (!prevOut.checkObject(types)) {
617  throw std::runtime_error("prevtxs internal object typecheck fail");
618  }
619 
620  uint256 hash;
621  if (!ParseHashStr(prevOut["txid"].get_str(), hash)) {
622  throw std::runtime_error("txid must be hexadecimal string (not '" +
623  prevOut["txid"].get_str() + "')");
624  }
625 
626  TxId txid(hash);
627 
628  const int nOut = prevOut["vout"].get_int();
629  if (nOut < 0) {
630  throw std::runtime_error("vout cannot be negative");
631  }
632 
633  COutPoint out(txid, nOut);
634  std::vector<uint8_t> pkData(
635  ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey"));
636  CScript scriptPubKey(pkData.begin(), pkData.end());
637 
638  {
639  const Coin &coin = view.AccessCoin(out);
640  if (!coin.IsSpent() &&
641  coin.GetTxOut().scriptPubKey != scriptPubKey) {
642  std::string err("Previous output scriptPubKey mismatch:\n");
643  err = err + ScriptToAsmStr(coin.GetTxOut().scriptPubKey) +
644  "\nvs:\n" + ScriptToAsmStr(scriptPubKey);
645  throw std::runtime_error(err);
646  }
647 
648  CTxOut txout;
649  txout.scriptPubKey = scriptPubKey;
650  txout.nValue = Amount::zero();
651  if (prevOut.exists("amount")) {
652  txout.nValue = AmountFromValue(prevOut["amount"]);
653  }
654 
655  view.AddCoin(out, Coin(txout, 1, false), true);
656  }
657 
658  // If redeemScript given and private keys given, add redeemScript to the
659  // tempKeystore so it can be signed:
660  if (scriptPubKey.IsPayToScriptHash() &&
661  prevOut.exists("redeemScript")) {
662  UniValue v = prevOut["redeemScript"];
663  std::vector<uint8_t> rsData(ParseHexUV(v, "redeemScript"));
664  CScript redeemScript(rsData.begin(), rsData.end());
665  tempKeystore.AddCScript(redeemScript);
666  }
667  }
668 
669  const FillableSigningProvider &keystore = tempKeystore;
670 
671  // Sign what we can:
672  for (size_t i = 0; i < mergedTx.vin.size(); i++) {
673  CTxIn &txin = mergedTx.vin[i];
674  const Coin &coin = view.AccessCoin(txin.prevout);
675  if (coin.IsSpent()) {
676  continue;
677  }
678 
679  const CScript &prevPubKey = coin.GetTxOut().scriptPubKey;
680  const Amount amount = coin.GetTxOut().nValue;
681 
682  SignatureData sigdata =
683  DataFromTransaction(mergedTx, i, coin.GetTxOut());
684  // Only sign SIGHASH_SINGLE if there's a corresponding output:
685  if ((sigHashType.getBaseType() != BaseSigHashType::SINGLE) ||
686  (i < mergedTx.vout.size())) {
687  ProduceSignature(keystore,
689  &mergedTx, i, amount, sigHashType),
690  prevPubKey, sigdata);
691  }
692 
693  UpdateInput(txin, sigdata);
694  }
695 
696  tx = mergedTx;
697 }
698 
701 
702 public:
705 };
706 
707 static void MutateTx(CMutableTransaction &tx, const std::string &command,
708  const std::string &commandVal,
709  const CChainParams &chainParams) {
710  std::unique_ptr<Secp256k1Init> ecc;
711 
712  if (command == "nversion") {
713  MutateTxVersion(tx, commandVal);
714  } else if (command == "locktime") {
715  MutateTxLocktime(tx, commandVal);
716  } else if (command == "delin") {
717  MutateTxDelInput(tx, commandVal);
718  } else if (command == "in") {
719  MutateTxAddInput(tx, commandVal);
720  } else if (command == "delout") {
721  MutateTxDelOutput(tx, commandVal);
722  } else if (command == "outaddr") {
723  MutateTxAddOutAddr(tx, commandVal, chainParams);
724  } else if (command == "outpubkey") {
725  ecc.reset(new Secp256k1Init());
726  MutateTxAddOutPubKey(tx, commandVal);
727  } else if (command == "outmultisig") {
728  ecc.reset(new Secp256k1Init());
729  MutateTxAddOutMultiSig(tx, commandVal);
730  } else if (command == "outscript") {
731  MutateTxAddOutScript(tx, commandVal);
732  } else if (command == "outdata") {
733  MutateTxAddOutData(tx, commandVal);
734  } else if (command == "sign") {
735  ecc.reset(new Secp256k1Init());
736  MutateTxSign(tx, commandVal);
737  } else if (command == "load") {
738  RegisterLoad(commandVal);
739  } else if (command == "set") {
740  RegisterSet(commandVal);
741  } else {
742  throw std::runtime_error("unknown command");
743  }
744 }
745 
746 static void OutputTxJSON(const CTransaction &tx) {
747  UniValue entry(UniValue::VOBJ);
748  TxToUniv(tx, uint256(), entry);
749 
750  std::string jsonOutput = entry.write(4);
751  tfm::format(std::cout, "%s\n", jsonOutput);
752 }
753 
754 static void OutputTxHash(const CTransaction &tx) {
755  // the hex-encoded transaction id.
756  std::string strHexHash = tx.GetId().GetHex();
757 
758  tfm::format(std::cout, "%s\n", strHexHash);
759 }
760 
761 static void OutputTxHex(const CTransaction &tx) {
762  std::string strHex = EncodeHexTx(tx);
763 
764  tfm::format(std::cout, "%s\n", strHex);
765 }
766 
767 static void OutputTx(const CTransaction &tx) {
768  if (gArgs.GetBoolArg("-json", false)) {
769  OutputTxJSON(tx);
770  } else if (gArgs.GetBoolArg("-txid", false)) {
771  OutputTxHash(tx);
772  } else {
773  OutputTxHex(tx);
774  }
775 }
776 
777 static std::string readStdin() {
778  char buf[4096];
779  std::string ret;
780 
781  while (!feof(stdin)) {
782  size_t bread = fread(buf, 1, sizeof(buf), stdin);
783  ret.append(buf, bread);
784  if (bread < sizeof(buf)) {
785  break;
786  }
787  }
788 
789  if (ferror(stdin)) {
790  throw std::runtime_error("error reading stdin");
791  }
792 
793  boost::algorithm::trim_right(ret);
794 
795  return ret;
796 }
797 
798 static int CommandLineRawTx(int argc, char *argv[],
799  const CChainParams &chainParams) {
800  std::string strPrint;
801  int nRet = 0;
802  try {
803  // Skip switches; Permit common stdin convention "-"
804  while (argc > 1 && IsSwitchChar(argv[1][0]) && (argv[1][1] != 0)) {
805  argc--;
806  argv++;
807  }
808 
810  int startArg;
811 
812  if (!fCreateBlank) {
813  // require at least one param
814  if (argc < 2) {
815  throw std::runtime_error("too few parameters");
816  }
817 
818  // param: hex-encoded bitcoin transaction
819  std::string strHexTx(argv[1]);
820 
821  // "-" implies standard input
822  if (strHexTx == "-") {
823  strHexTx = readStdin();
824  }
825 
826  if (!DecodeHexTx(tx, strHexTx)) {
827  throw std::runtime_error("invalid transaction encoding");
828  }
829 
830  startArg = 2;
831  } else {
832  startArg = 1;
833  }
834 
835  for (int i = startArg; i < argc; i++) {
836  std::string arg = argv[i];
837  std::string key, value;
838  size_t eqpos = arg.find('=');
839  if (eqpos == std::string::npos) {
840  key = arg;
841  } else {
842  key = arg.substr(0, eqpos);
843  value = arg.substr(eqpos + 1);
844  }
845 
846  MutateTx(tx, key, value, chainParams);
847  }
848 
849  OutputTx(CTransaction(tx));
850  } catch (const std::exception &e) {
851  strPrint = std::string("error: ") + e.what();
852  nRet = EXIT_FAILURE;
853  } catch (const UniValue &e) {
854  strPrint = std::string("error code: ") + e["code"].getValStr() +
855  " message: " + e["message"].getValStr();
856  nRet = EXIT_FAILURE;
857  } catch (...) {
858  PrintExceptionContinue(nullptr, "CommandLineRawTx()");
859  throw;
860  }
861 
862  if (strPrint != "") {
863  tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint);
864  }
865 
866  return nRet;
867 }
868 
869 int main(int argc, char *argv[]) {
871 
872  try {
873  int ret = AppInitRawTx(argc, argv);
874  if (ret != CONTINUE_EXECUTION) {
875  return ret;
876  }
877  } catch (const std::exception &e) {
878  PrintExceptionContinue(&e, "AppInitRawTx()");
879  return EXIT_FAILURE;
880  } catch (...) {
881  PrintExceptionContinue(nullptr, "AppInitRawTx()");
882  return EXIT_FAILURE;
883  }
884 
885  int ret = EXIT_FAILURE;
886  try {
887  ret = CommandLineRawTx(argc, argv, Params());
888  } catch (const std::exception &e) {
889  PrintExceptionContinue(&e, "CommandLineRawTx()");
890  } catch (...) {
891  PrintExceptionContinue(nullptr, "CommandLineRawTx()");
892  }
893 
894  return ret;
895 }
SetupBitcoinTxArgs
static void SetupBitcoinTxArgs(ArgsManager &argsman)
Definition: bitcoin-tx.cpp:41
MutateTx
static void MutateTx(CMutableTransaction &tx, const std::string &command, const std::string &commandVal, const CChainParams &chainParams)
Definition: bitcoin-tx.cpp:707
CTxIn
An input of a transaction.
Definition: transaction.h:61
ParseHashStr
bool ParseHashStr(const std::string &strHex, uint256 &result)
Parse a hex string into 256 bits.
Definition: core_read.cpp:242
ParseInt64
bool ParseInt64(const std::string &str, int64_t *out)
Convert string to signed 64-bit integer with strict parse error feedback.
Definition: strencodings.cpp:334
AppInitRawTx
static int AppInitRawTx(int argc, char *argv[])
Definition: bitcoin-tx.cpp:107
CTxOut::nValue
Amount nValue
Definition: transaction.h:132
ArgsManager::GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:517
SIGHASH_SINGLE
@ SIGHASH_SINGLE
Definition: sighashtype.h:17
ToString
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:69
ParseHex
std::vector< uint8_t > ParseHex(const char *psz)
Definition: strencodings.cpp:87
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:27
tinyformat::format
void format(std::ostream &out, const char *fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:1111
fsbridge::fopen
FILE * fopen(const fs::path &p, const char *mode)
Definition: fs.cpp:24
flags
int flags
Definition: bitcoin-tx.cpp:532
key_io.h
SetupHelpOptions
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
Definition: system.cpp:676
ArgsManager::ALLOW_ANY
@ ALLOW_ANY
Definition: system.h:159
moneystr.h
transaction.h
FillableSigningProvider
Fillable signing provider that keeps keys in an address->secret map.
Definition: signingprovider.h:76
ArgsManager::GetHelpMessage
std::string GetHelpMessage() const
Get the help string.
Definition: system.cpp:598
CCoinsViewCache::AddCoin
void AddCoin(const COutPoint &outpoint, Coin coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:103
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:243
string.h
SetupEnvironment
void SetupEnvironment()
Definition: system.cpp:1306
IsHex
bool IsHex(const std::string &str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
Definition: strencodings.cpp:64
SetupChainParamsBaseOptions
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
Definition: chainparamsbase.cpp:17
ArgsManager::GetChainName
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Definition: system.cpp:1033
SIGHASH_ALL
@ SIGHASH_ALL
Definition: sighashtype.h:15
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:47
MutableTransactionSignatureCreator
A signature creator for transactions.
Definition: sign.h:38
clientversion.h
CCoinsViewCache::AccessCoin
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Definition: coins.cpp:180
UniValue::read
bool read(const char *raw, size_t len)
Definition: univalue_read.cpp:259
OutputTx
static void OutputTx(const CTransaction &tx)
Definition: bitcoin-tx.cpp:767
RegisterSet
static void RegisterSet(const std::string &strInput)
Definition: bitcoin-tx.cpp:166
readStdin
static std::string readStdin()
Definition: bitcoin-tx.cpp:777
CScript::IsPayToScriptHash
bool IsPayToScriptHash() const
Definition: script.cpp:373
chainparams.h
UniValue::write
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
Definition: univalue_write.cpp:159
SetupCurrencyUnitOptions
void SetupCurrencyUnitOptions(ArgsManager &argsman)
Definition: currencyunit.cpp:9
core_io.h
MutateTxAddOutPubKey
static void MutateTxAddOutPubKey(CMutableTransaction &tx, const std::string &strInput)
Definition: bitcoin-tx.cpp:321
UniValue::checkObject
bool checkObject(const std::map< std::string, UniValue::VType > &memberTypes) const
Definition: univalue.cpp:179
UniValue
Definition: univalue.h:23
FillableSigningProvider::AddKey
virtual bool AddKey(const CKey &key)
Definition: signingprovider.h:110
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:194
Amount::zero
static constexpr Amount zero()
Definition: amount.h:42
CONTINUE_EXECUTION
static const int CONTINUE_EXECUTION
Definition: bitcoin-tx.cpp:37
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:175
signingprovider.h
MAX_SCRIPT_SIZE
static const int MAX_SCRIPT_SIZE
Definition: script.h:32
HelpRequested
bool HelpRequested(const ArgsManager &args)
Definition: system.cpp:671
strencodings.h
OP_RETURN
@ OP_RETURN
Definition: script.h:83
MAX_TX_SIZE
static const uint64_t MAX_TX_SIZE
The maximum allowed size for a transaction, in bytes.
Definition: consensus.h:14
OutputTxHash
static void OutputTxHash(const CTransaction &tx)
Definition: bitcoin-tx.cpp:754
SignatureData
Definition: sign.h:66
IsValidDestination
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
Definition: standard.cpp:263
ECC_Stop
void ECC_Stop()
Deinitialize the elliptic curve support.
Definition: key.cpp:451
ParseScript
CScript ParseScript(const std::string &s)
Definition: core_read.cpp:27
CTxOut
An output of a transaction.
Definition: transaction.h:130
CTransaction::GetId
const TxId GetId() const
Definition: transaction.h:244
GetScriptForRawPubKey
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
Definition: standard.cpp:247
registers
static std::map< std::string, UniValue > registers
Definition: bitcoin-tx.cpp:36
Coin
A UTXO entry.
Definition: coins.h:27
CMutableTransaction::nVersion
int32_t nVersion
Definition: transaction.h:282
OutputTxJSON
static void OutputTxJSON(const CTransaction &tx)
Definition: bitcoin-tx.cpp:746
GetScriptForMultisig
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: standard.cpp:252
CTxOut::scriptPubKey
CScript scriptPubKey
Definition: transaction.h:133
SIGHASH_NONE
@ SIGHASH_NONE
Definition: sighashtype.h:16
ArgsManager::AddArg
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:565
DecodeHexTx
NODISCARD bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
Definition: core_read.cpp:191
UniValue::exists
bool exists(const std::string &key) const
Definition: univalue.h:87
univalue.h
consensus.h
MutateTxDelOutput
static void MutateTxDelOutput(CMutableTransaction &tx, const std::string &strOutIdx)
Definition: bitcoin-tx.cpp:516
IsSwitchChar
bool IsSwitchChar(char c)
Definition: system.h:116
CKey::IsValid
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:94
sign.h
MutateTxAddOutMultiSig
static void MutateTxAddOutMultiSig(CMutableTransaction &tx, const std::string &strInput)
Definition: bitcoin-tx.cpp:360
OptionsCategory::OPTIONS
@ OPTIONS
base_blob::GetHex
std::string GetHex() const
Definition: uint256.cpp:16
MutateTxAddInput
static void MutateTxAddInput(CMutableTransaction &tx, const std::string &strInput)
Definition: bitcoin-tx.cpp:254
SigHashType
Signature hash type wrapper class.
Definition: sighashtype.h:37
SelectParams
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
Definition: chainparams.cpp:530
main
int main(int argc, char *argv[])
Definition: bitcoin-tx.cpp:869
ArgsManager::ParseParameters
NODISCARD bool ParseParameters(int argc, const char *const argv[], std::string &error)
Definition: system.cpp:317
DecodeSecret
CKey DecodeSecret(const std::string &str)
Definition: key_io.cpp:80
UniValue::VNUM
@ VNUM
Definition: univalue.h:27
uint256
256-bit opaque blob.
Definition: uint256.h:127
Secp256k1Init
Definition: bitcoin-tx.cpp:699
TxId
A TxId is the identifier of a transaction.
Definition: txid.h:14
MutateTxAddOutScript
static void MutateTxAddOutScript(CMutableTransaction &tx, const std::string &strInput)
Definition: bitcoin-tx.cpp:460
MutateTxVersion
static void MutateTxVersion(CMutableTransaction &tx, const std::string &cmdVal)
Definition: bitcoin-tx.cpp:230
Amount
Definition: amount.h:19
G_TRANSLATION_FUN
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate string to current locale using Qt.
Definition: bitcoin-tx.cpp:39
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:430
CTransaction::MAX_STANDARD_VERSION
static const int32_t MAX_STANDARD_VERSION
Definition: transaction.h:203
coins.h
EncodeHexTx
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Definition: core_write.cpp:165
ProduceSignature
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
Definition: sign.cpp:197
system.h
AmountFromValue
Amount AmountFromValue(const UniValue &value)
Definition: util.cpp:81
MutateTxAddOutData
static void MutateTxAddOutData(CMutableTransaction &tx, const std::string &strInput)
Definition: bitcoin-tx.cpp:431
ECC_Start
void ECC_Start()
Initialize the elliptic curve support.
Definition: key.cpp:434
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1201
SIGHASH_FORKID
@ SIGHASH_FORKID
Definition: sighashtype.h:18
UniValue::getValStr
const std::string & getValStr() const
Definition: univalue.h:77
TxToUniv
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
Definition: core_write.cpp:213
CPubKey
An encapsulated public key.
Definition: pubkey.h:31
RegisterLoad
static void RegisterLoad(const std::string &strInput)
Definition: bitcoin-tx.cpp:180
ECCVerifyHandle
Users of this module must hold an ECCVerifyHandle.
Definition: pubkey.h:228
UniValue::get_int
int get_int() const
Definition: univalue_get.cpp:105
CKey
An encapsulated secp256k1 private key.
Definition: key.h:28
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:231
ArgsManager
Definition: system.h:152
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:281
currencyunit.h
translation.h
flagStr
const char * flagStr
Definition: bitcoin-tx.cpp:531
MutateTxLocktime
static void MutateTxLocktime(CMutableTransaction &tx, const std::string &cmdVal)
Definition: bitcoin-tx.cpp:242
gArgs
ArgsManager gArgs
Definition: system.cpp:75
Secp256k1Init::Secp256k1Init
Secp256k1Init()
Definition: bitcoin-tx.cpp:703
RegisterSetJson
static void RegisterSetJson(const std::string &key, const std::string &rawJson)
Definition: bitcoin-tx.cpp:155
CTxIn::prevout
COutPoint prevout
Definition: transaction.h:63
OutputTxHex
static void OutputTxHex(const CTransaction &tx)
Definition: bitcoin-tx.cpp:761
prevector::size
size_type size() const
Definition: prevector.h:386
CMutableTransaction::nLockTime
uint32_t nLockTime
Definition: transaction.h:283
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:508
CPubKey::IsFullyValid
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
Definition: pubkey.cpp:257
findSigHashFlags
static bool findSigHashFlags(SigHashType &sigHashType, const std::string &flagStr)
Definition: bitcoin-tx.cpp:551
CommandLineRawTx
static int CommandLineRawTx(int argc, char *argv[], const CChainParams &chainParams)
Definition: bitcoin-tx.cpp:798
FillableSigningProvider::AddCScript
virtual bool AddCScript(const CScript &redeemScript)
Definition: signingprovider.cpp:125
UniValue::size
size_t size() const
Definition: univalue.h:80
BaseSigHashType::SINGLE
@ SINGLE
MAX_SCRIPT_ELEMENT_SIZE
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
Definition: script.h:23
script.h
sigHashOptions
static const struct @0 sigHashOptions[N_SIGHASH_OPTS]
util.h
SigHashType::getBaseType
BaseSigHashType getBaseType() const
Definition: sighashtype.h:64
OptionsCategory::COMMANDS
@ COMMANDS
UpdateInput
void UpdateInput(CTxIn &input, const SignatureData &data)
Definition: sign.cpp:330
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
OptionsCategory::REGISTER_COMMANDS
@ REGISTER_COMMANDS
FormatFullVersion
std::string FormatFullVersion()
Definition: clientversion.cpp:58
Secp256k1Init::~Secp256k1Init
~Secp256k1Init()
Definition: bitcoin-tx.cpp:704
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
Coin::IsSpent
bool IsSpent() const
Definition: coins.h:46
MutateTxDelInput
static void MutateTxDelInput(CMutableTransaction &tx, const std::string &strInIdx)
Definition: bitcoin-tx.cpp:503
DecodeDestination
CTxDestination DecodeDestination(const std::string &addr, const CChainParams &params)
Definition: key_io.cpp:177
DataFromTransaction
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
Definition: sign.cpp:274
Coin::GetTxOut
CTxOut & GetTxOut()
Definition: coins.h:48
UniValue::VSTR
@ VSTR
Definition: univalue.h:27
ExtractAndValidateValue
static Amount ExtractAndValidateValue(const std::string &strValue)
Definition: bitcoin-tx.cpp:221
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition: transaction.h:280
MutateTxAddOutAddr
static void MutateTxAddOutAddr(CMutableTransaction &tx, const std::string &strInput, const CChainParams &chainParams)
Definition: bitcoin-tx.cpp:294
fCreateBlank
static bool fCreateBlank
Definition: bitcoin-tx.cpp:35
Secp256k1Init::globalVerifyHandle
ECCVerifyHandle globalVerifyHandle
Definition: bitcoin-tx.cpp:700
CTxDestination
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:132
MutateTxSign
static void MutateTxSign(CMutableTransaction &tx, const std::string &flagStr)
Definition: bitcoin-tx.cpp:565
ScriptHash
Definition: standard.h:114
N_SIGHASH_OPTS
static const unsigned int N_SIGHASH_OPTS
Definition: bitcoin-tx.cpp:529
SigHashType::withForkId
SigHashType withForkId(bool forkId=true) const
Definition: sighashtype.h:54
MAX_PUBKEYS_PER_MULTISIG
static const int MAX_PUBKEYS_PER_MULTISIG
Definition: script.h:29
ScriptToAsmStr
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_write.cpp:102
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
Definition: system.cpp:716
ParseHexUV
std::vector< uint8_t > ParseHexUV(const UniValue &v, const std::string &strName)
Definition: core_read.cpp:251
ParseMoney
bool ParseMoney(const std::string &money_string, Amount &nRet)
Parse an amount denoted in full coins.
Definition: moneystr.cpp:36
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:278
SIGHASH_ANYONECANPAY
@ SIGHASH_ANYONECANPAY
Definition: sighashtype.h:19
UniValue::isObject
bool isObject() const
Definition: univalue.h:96