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

Function CommandLineRawTx

src/bitcoin-tx.cpp:776–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774}
775
776static int CommandLineRawTx(int argc, char* argv[])
777{
778 std::string strPrint;
779 int nRet = 0;
780 try {
781 // Skip switches; Permit common stdin convention "-"
782 while (argc > 1 && IsSwitchChar(argv[1][0]) &&
783 (argv[1][1] != 0)) {
784 argc--;
785 argv++;
786 }
787
788 CMutableTransaction tx;
789 int startArg;
790
791 if (!fCreateBlank) {
792 // require at least one param
793 if (argc < 2)
794 throw std::runtime_error("too few parameters");
795
796 // param: hex-encoded bitcoin transaction
797 std::string strHexTx(argv[1]);
798 if (strHexTx == "-") // "-" implies standard input
799 strHexTx = readStdin();
800
801 if (!DecodeHexTx(tx, strHexTx, true))
802 throw std::runtime_error("invalid transaction encoding");
803
804 startArg = 2;
805 } else
806 startArg = 1;
807
808 for (int i = startArg; i < argc; i++) {
809 std::string arg = argv[i];
810 std::string key, value;
811 size_t eqpos = arg.find('=');
812 if (eqpos == std::string::npos)
813 key = arg;
814 else {
815 key = arg.substr(0, eqpos);
816 value = arg.substr(eqpos + 1);
817 }
818
819 MutateTx(tx, key, value);
820 }
821
822 OutputTx(tx);
823 }
824
825 catch (const boost::thread_interrupted&) {
826 throw;
827 }
828 catch (const std::exception& e) {
829 strPrint = std::string("error: ") + e.what();
830 nRet = EXIT_FAILURE;
831 }
832 catch (...) {
833 PrintExceptionContinue(nullptr, "CommandLineRawTx()");

Callers 1

mainFunction · 0.85

Calls 8

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

Tested by

no test coverage detected