#include "base58.h"
#include "clientversion.h"
-#include "primitives/block.h" // for MAX_BLOCK_SIZE
-#include "primitives/transaction.h"
-#include "core_io.h"
#include "coins.h"
+#include "consensus/consensus.h"
+#include "core_io.h"
#include "keystore.h"
+#include "primitives/transaction.h"
#include "script/script.h"
#include "script/sign.h"
-#include "ui_interface.h" // for _(...)
-#include "univalue/univalue.h"
+#include <univalue.h>
#include "util.h"
-#include "utilstrencodings.h"
#include "utilmoneystr.h"
+#include "utilstrencodings.h"
#include <stdio.h>
static bool fCreateBlank;
static map<string,UniValue> registers;
-CClientUIInterface uiInterface;
static bool AppInitRawTx(int argc, char* argv[])
{
fCreateBlank = GetBoolArg("-create", false);
- if (argc<2 || mapArgs.count("-?") || mapArgs.count("-help"))
+ if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help"))
{
// First part of help message is specific to this utility
- std::string strUsage = _("Bitcoin Core bitcoin-tx utility version") + " " + FormatFullVersion() + "\n\n" +
+ std::string strUsage = _("Zcash zcash-tx utility version") + " " + FormatFullVersion() + "\n\n" +
_("Usage:") + "\n" +
- " bitcoin-tx [options] <hex-tx> [commands] " + _("Update hex-encoded bitcoin transaction") + "\n" +
- " bitcoin-tx [options] -create [commands] " + _("Create hex-encoded bitcoin transaction") + "\n" +
+ " zcash-tx [options] <hex-tx> [commands] " + _("Update hex-encoded zcash transaction") + "\n" +
+ " zcash-tx [options] -create [commands] " + _("Create hex-encoded zcash transaction") + "\n" +
"\n";
fprintf(stdout, "%s", strUsage.c_str());
valStr.insert(valStr.size(), buf, bread);
}
- if (ferror(f)) {
+ int error = ferror(f);
+ fclose(f);
+
+ if (error) {
string strErr = "Error reading file " + filename;
throw runtime_error(strErr);
}
- fclose(f);
-
// evaluate as JSON buffer register
RegisterSetJson(key, valStr);
}
static void MutateTxVersion(CMutableTransaction& tx, const string& cmdVal)
{
int64_t newVersion = atoi64(cmdVal);
- if (newVersion < 1 || newVersion > CTransaction::CURRENT_VERSION)
+ if (newVersion < CTransaction::MIN_CURRENT_VERSION || newVersion > CTransaction::MAX_CURRENT_VERSION)
throw runtime_error("Invalid TX version requested");
tx.nVersion = (int) newVersion;
UniValue keysObj = registers["privatekeys"];
fGivenKeys = true;
- for (unsigned int kidx = 0; kidx < keysObj.count(); kidx++) {
+ for (size_t kidx = 0; kidx < keysObj.size(); kidx++) {
if (!keysObj[kidx].isStr())
throw runtime_error("privatekey not a string");
CBitcoinSecret vchSecret;
throw runtime_error("prevtxs register variable must be set.");
UniValue prevtxsObj = registers["prevtxs"];
{
- for (unsigned int previdx = 0; previdx < prevtxsObj.count(); previdx++) {
+ for (size_t previdx = 0; previdx < prevtxsObj.size(); previdx++) {
UniValue prevOut = prevtxsObj[previdx];
if (!prevOut.isObject())
throw runtime_error("expected prevtxs internal object");
tx = mergedTx;
}
+class Secp256k1Init
+{
+ ECCVerifyHandle globalVerifyHandle;
+
+public:
+ Secp256k1Init() {
+ ECC_Start();
+ }
+ ~Secp256k1Init() {
+ ECC_Stop();
+ }
+};
+
static void MutateTx(CMutableTransaction& tx, const string& command,
const string& commandVal)
{
+ boost::scoped_ptr<Secp256k1Init> ecc;
+
if (command == "nversion")
MutateTxVersion(tx, commandVal);
else if (command == "locktime")
else if (command == "outscript")
MutateTxAddOutScript(tx, commandVal);
- else if (command == "sign")
+ else if (command == "sign") {
+ if (!ecc) { ecc.reset(new Secp256k1Init()); }
MutateTxSign(tx, commandVal);
+ }
else if (command == "load")
RegisterLoad(commandVal);