mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Improved contract loading validation.
This commit is contained in:
33
src/main.cpp
33
src/main.cpp
@@ -8,34 +8,40 @@
|
||||
#include "conf.h"
|
||||
#include "crypto.h"
|
||||
#include "usr/usr.h"
|
||||
#include "proc.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace shared;
|
||||
|
||||
int parse_cmd(int argc, char **argv);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (!parse_cmd(argc, argv))
|
||||
if (parse_cmd(argc, argv) != 0)
|
||||
return -1;
|
||||
|
||||
if (conf::ctx.command == "version")
|
||||
{
|
||||
cout << _HP_VERSION_ << endl;
|
||||
}
|
||||
else if (conf::ctx.command == "new")
|
||||
{
|
||||
if (conf::create_contract() != 0 || crypto::init() != 0)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool initSuccess = conf::init(argc, argv) && crypto::init();
|
||||
if (!initSuccess)
|
||||
{
|
||||
cerr << "Init error\n";
|
||||
if (conf::init() != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (conf::ctx.command == "run")
|
||||
if (conf::ctx.command == "rekey")
|
||||
{
|
||||
usr::init();
|
||||
//Clear the keys. crpyto::init will init the keys.
|
||||
if (conf::clear_keys() != 0 || crypto::init() != 0)
|
||||
return -1;
|
||||
}
|
||||
else if (conf::ctx.command == "run")
|
||||
{
|
||||
if (crypto::init() != 0 || usr::init() != 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,13 +64,14 @@ int parse_cmd(int argc, char **argv)
|
||||
else
|
||||
{
|
||||
conf::set_contract_dir_paths(argv[2]);
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (command == "version")
|
||||
{
|
||||
if (argc == 2)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,5 +81,5 @@ int parse_cmd(int argc, char **argv)
|
||||
cout << "hpcore <command> <contract dir> (command = run | new | rekey)\n";
|
||||
cout << "Example: hpcore run ~/mycontract\n";
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user