2018-08-02 10:02:33 +01:00
|
|
|
import com.google.common.hash.HashCode;
|
|
|
|
|
|
|
|
import data.transaction.TransactionData;
|
|
|
|
import qora.block.BlockChain;
|
|
|
|
import repository.DataException;
|
|
|
|
import repository.Repository;
|
2018-12-04 16:34:55 +00:00
|
|
|
import repository.RepositoryFactory;
|
2018-08-02 10:02:33 +01:00
|
|
|
import repository.RepositoryManager;
|
2018-12-04 16:34:55 +00:00
|
|
|
import repository.hsqldb.HSQLDBRepositoryFactory;
|
2018-08-02 10:02:33 +01:00
|
|
|
import transform.TransformationException;
|
|
|
|
import transform.transaction.TransactionTransformer;
|
|
|
|
import utils.Base58;
|
|
|
|
|
|
|
|
public class txhex {
|
|
|
|
|
2018-12-04 16:34:55 +00:00
|
|
|
public static final String connectionUrl = "jdbc:hsqldb:file:db/test;create=true";
|
|
|
|
|
2018-08-02 10:02:33 +01:00
|
|
|
public static void main(String[] args) {
|
|
|
|
if (args.length == 0) {
|
|
|
|
System.err.println("usage: txhex <base58-tx-signature>");
|
|
|
|
System.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
byte[] signature = Base58.decode(args[0]);
|
|
|
|
|
|
|
|
try {
|
2018-12-04 16:34:55 +00:00
|
|
|
RepositoryFactory repositoryFactory = new HSQLDBRepositoryFactory(connectionUrl);
|
|
|
|
RepositoryManager.setRepositoryFactory(repositoryFactory);
|
2018-08-02 10:02:33 +01:00
|
|
|
} catch (DataException e) {
|
|
|
|
System.err.println("Couldn't connect to repository: " + e.getMessage());
|
|
|
|
System.exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
BlockChain.validate();
|
|
|
|
} catch (DataException e) {
|
|
|
|
System.err.println("Couldn't validate repository: " + e.getMessage());
|
|
|
|
System.exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
|
|
|
TransactionData transactionData = repository.getTransactionRepository().fromSignature(signature);
|
|
|
|
byte[] bytes = TransactionTransformer.toBytes(transactionData);
|
|
|
|
System.out.println(HashCode.fromBytes(bytes).toString());
|
|
|
|
} catch (DataException | TransformationException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2018-12-04 16:34:55 +00:00
|
|
|
RepositoryManager.closeRepositoryFactory();
|
2018-08-02 10:02:33 +01:00
|
|
|
} catch (DataException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|