|
|
@ -13,6 +13,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <boost/assign/list_of.hpp> |
|
|
|
#include <boost/assign/list_of.hpp> |
|
|
|
|
|
|
|
#include <boost/algorithm/string.hpp> |
|
|
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
using namespace boost::assign; |
|
|
|
using namespace boost::assign; |
|
|
@ -501,13 +502,34 @@ static void OutputTx(const CTransaction& tx) |
|
|
|
OutputTxHex(tx); |
|
|
|
OutputTxHex(tx); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static string readStdin() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char buf[4096]; |
|
|
|
|
|
|
|
string ret; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!feof(stdin)) { |
|
|
|
|
|
|
|
size_t bread = fread(buf, 1, sizeof(buf), stdin); |
|
|
|
|
|
|
|
ret.append(buf, bread); |
|
|
|
|
|
|
|
if (bread < sizeof(buf)) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ferror(stdin)) |
|
|
|
|
|
|
|
throw runtime_error("error reading stdin"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boost::algorithm::trim_right(ret); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int CommandLineRawTx(int argc, char* argv[]) |
|
|
|
static int CommandLineRawTx(int argc, char* argv[]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string strPrint; |
|
|
|
string strPrint; |
|
|
|
int nRet = 0; |
|
|
|
int nRet = 0; |
|
|
|
try { |
|
|
|
try { |
|
|
|
// Skip switches
|
|
|
|
// Skip switches; Permit common stdin convention "-"
|
|
|
|
while (argc > 1 && IsSwitchChar(argv[1][0])) { |
|
|
|
while (argc > 1 && IsSwitchChar(argv[1][0]) && |
|
|
|
|
|
|
|
(argv[1][1] != 0)) { |
|
|
|
argc--; |
|
|
|
argc--; |
|
|
|
argv++; |
|
|
|
argv++; |
|
|
|
} |
|
|
|
} |
|
|
@ -522,6 +544,8 @@ static int CommandLineRawTx(int argc, char* argv[]) |
|
|
|
|
|
|
|
|
|
|
|
// param: hex-encoded bitcoin transaction
|
|
|
|
// param: hex-encoded bitcoin transaction
|
|
|
|
string strHexTx(argv[1]); |
|
|
|
string strHexTx(argv[1]); |
|
|
|
|
|
|
|
if (strHexTx == "-") // "-" implies standard input
|
|
|
|
|
|
|
|
strHexTx = readStdin(); |
|
|
|
|
|
|
|
|
|
|
|
if (!DecodeHexTx(txDecodeTmp, strHexTx)) |
|
|
|
if (!DecodeHexTx(txDecodeTmp, strHexTx)) |
|
|
|
throw runtime_error("invalid transaction encoding"); |
|
|
|
throw runtime_error("invalid transaction encoding"); |
|
|
|