MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CommandLineRawTx

Function CommandLineRawTx

src/bitcoin-tx.cpp:795–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

793}
794
795static int CommandLineRawTx(int argc, char* argv[])
796{
797 std::string strPrint;
798 int nRet = 0;
799 try {
800 // Skip switches; Permit common stdin convention "-"
801 while (argc > 1 && IsSwitchChar(argv[1][0]) &&
802 (argv[1][1] != 0)) {
803 argc--;
804 argv++;
805 }
806
807 CMutableTransaction tx;
808 int startArg;
809
810 if (!fCreateBlank) {
811 // require at least one param
812 if (argc < 2)
813 throw std::runtime_error("too few parameters");
814
815 // param: hex-encoded bitcoin transaction
816 std::string strHexTx(argv[1]);
817 if (strHexTx == "-") // "-" implies standard input
818 strHexTx = readStdin();
819
820 if (!DecodeHexTx(tx, strHexTx, true))
821 throw std::runtime_error("invalid transaction encoding");
822
823 startArg = 2;
824 } else
825 startArg = 1;
826
827 for (int i = startArg; i < argc; i++) {
828 std::string arg = argv[i];
829 std::string key, value;
830 size_t eqpos = arg.find('=');
831 if (eqpos == std::string::npos)
832 key = arg;
833 else {
834 key = arg.substr(0, eqpos);
835 value = arg.substr(eqpos + 1);
836 }
837
838 MutateTx(tx, key, value);
839 }
840
841 OutputTx(CTransaction(tx));
842 }
843 catch (const std::exception& e) {
844 strPrint = std::string("error: ") + e.what();
845 nRet = EXIT_FAILURE;
846 }
847 catch (...) {
848 PrintExceptionContinue(nullptr, "CommandLineRawTx()");
849 throw;
850 }
851
852 if (strPrint != "") {

Callers 1

bitcoin-tx.cppFile · 0.85

Calls 10

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

Tested by

no test coverage detected