You've already forked transactions
2f2cb78741
This now prints the txid from inside the Transaction object directly.
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
/*
|
|
* This file is part of the Bitcoin project
|
|
* Copyright (C) 2014-2016 Tom Zander <tomz@freedommail.ch>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "Transaction.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QCommandLineParser>
|
|
#include <QFileInfo>
|
|
#include <QDebug>
|
|
|
|
int main(int x, char **y) {
|
|
QCoreApplication app(x, y);
|
|
QCoreApplication::setApplicationName("Transactions");
|
|
QCoreApplication::setApplicationVersion("1.1");
|
|
|
|
QCommandLineParser parser;
|
|
parser.setApplicationDescription("Transactions investigations");
|
|
parser.addHelpOption();
|
|
parser.addPositionalArgument("transaction", "Source transaction");
|
|
QCommandLineOption rawtx(QStringList() << "rawtx", "pass a raw hexformatted transaction instead of a filename" );
|
|
parser.addOption(rawtx);
|
|
QCommandLineOption printRaw(QStringList() << "p" << "printRaw", "Print raw hex version");
|
|
parser.addOption(printRaw);
|
|
QCommandLineOption script(QStringList() << "rawscript", "pass raw hexformatted script");
|
|
parser.addOption(script);
|
|
|
|
parser.process(app);
|
|
const QStringList args = parser.positionalArguments();
|
|
if (args.isEmpty())
|
|
parser.showHelp(1);
|
|
|
|
QTextStream out(stdout);
|
|
if (parser.isSet(script)) {
|
|
if (parser.isSet(rawtx)) {
|
|
out << "ERROR: pass only one, either input script or rawtx.\n";
|
|
out << "Bailing out" << Qt::endl;
|
|
return 1;
|
|
}
|
|
QByteArray data = QByteArray::fromHex(args.at(0).toLatin1());
|
|
|
|
Transaction::debugScript(data, 0, out);
|
|
return 0;
|
|
}
|
|
Transaction t;
|
|
bool success;
|
|
if (parser.isSet(rawtx)) {
|
|
QByteArray data = QByteArray::fromHex(args.at(0).toLatin1());
|
|
success = t.read(data);
|
|
} else {
|
|
success = t.read(args.at(0));
|
|
}
|
|
if (parser.isSet(printRaw)) {
|
|
if (parser.isSet(rawtx) || parser.isSet(script)) {
|
|
out << "ERROR: printraw and rawtx both as arguments makes no sense.\n";
|
|
out << "Sorry, not doing it" << Qt::endl;
|
|
return 1;
|
|
}
|
|
|
|
QFile in(args.at(0));
|
|
if (in.open(QIODevice::ReadOnly)) {
|
|
QByteArray all = in.readAll();
|
|
out << "Serialized: " << QString::fromLatin1(all.toHex()) << Qt::endl;
|
|
}
|
|
}
|
|
|
|
if (!success)
|
|
return 1;
|
|
|
|
QByteArray data = QByteArray::fromHex(args.at(0).toLatin1());
|
|
t.debug();
|
|
if (parser.isSet(rawtx))
|
|
out << "size: " << data.length() << Qt::endl;
|
|
out << "\n\n";
|
|
out.flush();
|
|
|
|
return 0;
|
|
}
|