MCPcopy Create free account
hub / github.com/ElementsProject/elements / CommandLineRawTx

Function CommandLineRawTx

src/bitcoin-tx.cpp:835–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833}
834
835static int CommandLineRawTx(int argc, char* argv[])
836{
837 std::string strPrint;
838 int nRet = 0;
839 try {
840 // Skip switches; Permit common stdin convention "-"
841 while (argc > 1 && IsSwitchChar(argv[1][0]) &&
842 (argv[1][1] != 0)) {
843 argc--;
844 argv++;
845 }
846
847 CMutableTransaction tx;
848 int startArg;
849
850 if (!fCreateBlank) {
851 // require at least one param
852 if (argc < 2)
853 throw std::runtime_error("too few parameters");
854
855 // param: hex-encoded bitcoin transaction
856 std::string strHexTx(argv[1]);
857 if (strHexTx == "-") // "-" implies standard input
858 strHexTx = readStdin();
859
860 if (!DecodeHexTx(tx, strHexTx, true))
861 throw std::runtime_error("invalid transaction encoding");
862
863 startArg = 2;
864 } else
865 startArg = 1;
866
867 for (int i = startArg; i < argc; i++) {
868 std::string arg = argv[i];
869 std::string key, value;
870 size_t eqpos = arg.find('=');
871 if (eqpos == std::string::npos)
872 key = arg;
873 else {
874 key = arg.substr(0, eqpos);
875 value = arg.substr(eqpos + 1);
876 }
877
878 std::string serialization = gArgs.GetArg("-serialization", "ELEMENTS");
879 if (serialization == "ELEMENTS") {
880 g_con_elementsmode = true;
881 } else if (serialization == "BITCOIN") {
882 g_con_elementsmode = false;
883 } else {
884 PrintExceptionContinue(nullptr, "Invalid serialization argument");
885 throw;
886 }
887
888 MutateTx(tx, key, value);
889 }
890
891 OutputTx(CTransaction(tx));
892 }

Callers 1

mainFunction · 0.85

Calls 10

IsSwitchCharFunction · 0.85
readStdinFunction · 0.85
DecodeHexTxFunction · 0.85
PrintExceptionContinueFunction · 0.85
MutateTxFunction · 0.85
OutputTxFunction · 0.85
findMethod · 0.80
GetArgMethod · 0.80
CTransactionClass · 0.70
formatFunction · 0.70

Tested by

no test coverage detected