This commit is contained in:
@@ -78,7 +78,8 @@ int AccountUpdate::ProcessUrl(std::string date, std::string signature, std::stri
|
|||||||
data = Replace(data, string("{{URLS}}"), urlout);
|
data = Replace(data, string("{{URLS}}"), urlout);
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
if (result.length() == 0) return NoResponse("");
|
if (result.length() == 0)
|
||||||
|
return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@@ -100,14 +101,15 @@ int AccountUpdate::ProcessPgp(std::string date, std::string signature, std::stri
|
|||||||
data += ReadFile(ACCOUNT_UPDATE_PGP);
|
data += ReadFile(ACCOUNT_UPDATE_PGP);
|
||||||
string bt("");
|
string bt("");
|
||||||
bt = parser.getLast();
|
bt = parser.getLast();
|
||||||
|
string pgpencoded = ReplaceAll(pgp, "\n", "\\n");
|
||||||
data = Replace(data, string("{{ADDRESS}}"), address);
|
data = Replace(data, string("{{ADDRESS}}"), address);
|
||||||
data = Replace(data, string("{{BT}}"), bt);
|
data = Replace(data, string("{{BT}}"), bt);
|
||||||
data = Replace(data, string("{{DATE}}"), date);
|
data = Replace(data, string("{{DATE}}"), date);
|
||||||
data = Replace(data, string("{{SIGN}}"), signature);
|
data = Replace(data, string("{{SIGN}}"), signature);
|
||||||
data = Replace(data, string("{{PGP}}"), pgp);
|
data = Replace(data, string("{{PGP}}"), pgpencoded);
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
if (result.length() == 0) return NoResponse("");
|
if (result.length() == 0)
|
||||||
|
return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@@ -136,7 +138,8 @@ int AccountUpdate::ProcessBitmessage(std::string date, std::string signature, st
|
|||||||
data = Replace(data, string("{{BTM}}"), btmsg);
|
data = Replace(data, string("{{BTM}}"), btmsg);
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
if (result.length() == 0) return NoResponse("");
|
if (result.length() == 0)
|
||||||
|
return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ int Deals::Create()
|
|||||||
string pay;
|
string pay;
|
||||||
|
|
||||||
at = GetVal("-a", "--at");
|
at = GetVal("-a", "--at");
|
||||||
|
if (at.length() == 0)
|
||||||
|
at = "https://testnet-dm2.bitdeals.org";
|
||||||
seller = GetVal("-s", "--seller");
|
seller = GetVal("-s", "--seller");
|
||||||
customer = GetVal("-c", "--customer");
|
customer = GetVal("-c", "--customer");
|
||||||
type = GetVal("-t", "--type");
|
type = GetVal("-t", "--type");
|
||||||
@@ -170,14 +172,16 @@ int Deals::Create()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
string Deals::GetDate(const string date) {
|
string Deals::GetDate(const string date)
|
||||||
|
{
|
||||||
string buffer = date;
|
string buffer = date;
|
||||||
/*
|
/*
|
||||||
-p|--pay { <yyyy-mm-dd> [hh:mm:ss UTC] | <time>[smhd] }
|
-p|--pay { <yyyy-mm-dd> [hh:mm:ss UTC] | <time>[smhd] }
|
||||||
Time for make payment; default: 1d
|
Time for make payment; default: 1d
|
||||||
*/
|
*/
|
||||||
std::transform(buffer.begin(), buffer.end(), buffer.begin(), ::toupper);
|
std::transform(buffer.begin(), buffer.end(), buffer.begin(), ::toupper);
|
||||||
if (buffer.length() < 23) {
|
if (buffer.length() < 23)
|
||||||
|
{
|
||||||
char letter = buffer[buffer.length() - 1];
|
char letter = buffer[buffer.length() - 1];
|
||||||
int append = 0;
|
int append = 0;
|
||||||
string numval = buffer.substr(0, buffer.length() - 1);
|
string numval = buffer.substr(0, buffer.length() - 1);
|
||||||
@@ -202,19 +206,20 @@ string Deals::GetDate(const string date) {
|
|||||||
std::time_t utcTimeInSeconds = std::time(nullptr);
|
std::time_t utcTimeInSeconds = std::time(nullptr);
|
||||||
utcTimeInSeconds += append;
|
utcTimeInSeconds += append;
|
||||||
|
|
||||||
|
|
||||||
tm *tmm = gmtime(&utcTimeInSeconds);
|
tm *tmm = gmtime(&utcTimeInSeconds);
|
||||||
char buff[70];
|
char buff[70];
|
||||||
strftime(buff, sizeof buff, "%Y-%m-%d %H:%M:%S UTC", tmm);
|
strftime(buff, sizeof buff, "%Y-%m-%d %H:%M:%S UTC", tmm);
|
||||||
string result = buff;
|
string result = buff;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string Deals::CommonStatus() {
|
string Deals::CommonStatus()
|
||||||
|
{
|
||||||
string payaddress = parser.getLast();
|
string payaddress = parser.getLast();
|
||||||
string data("curl -s -X POST \"");
|
string data("curl -s -X POST \"");
|
||||||
data.append(address);
|
data.append(address);
|
||||||
@@ -243,7 +248,6 @@ int Deals::Status()
|
|||||||
isPayment = true;
|
isPayment = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string decoded = stream.str();
|
string decoded = stream.str();
|
||||||
cout << decoded << endl;
|
cout << decoded << endl;
|
||||||
|
|
||||||
@@ -255,7 +259,8 @@ int Deals::Status()
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int Deals::Complite() {
|
int Deals::Complite()
|
||||||
|
{
|
||||||
|
|
||||||
string data = CommonStatus();
|
string data = CommonStatus();
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
@@ -296,15 +301,10 @@ int Deals::Complite() {
|
|||||||
if (result.length() == 0)
|
if (result.length() == 0)
|
||||||
return NoResponse("");
|
return NoResponse("");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "success: " << jsonData["result"]["success"] << endl;
|
stream << "success: " << jsonData["result"]["success"] << endl;
|
||||||
stream << "message: " << jsonData["result"]["message"] << endl;
|
stream << "message: " << jsonData["result"]["message"] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string decoded = stream.str();
|
string decoded = stream.str();
|
||||||
std::cout << decoded << endl;
|
std::cout << decoded << endl;
|
||||||
|
|
||||||
@@ -312,7 +312,8 @@ int Deals::Complite() {
|
|||||||
ShowDebug(data, decoded, 0, result);
|
ShowDebug(data, decoded, 0, result);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int Deals::Cancel() {
|
int Deals::Cancel()
|
||||||
|
{
|
||||||
string data = CommonStatus();
|
string data = CommonStatus();
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
if (result.length() == 0)
|
if (result.length() == 0)
|
||||||
@@ -351,17 +352,15 @@ int Deals::Cancel() {
|
|||||||
stream << "success: " << jsonData["result"]["success"] << endl;
|
stream << "success: " << jsonData["result"]["success"] << endl;
|
||||||
stream << "message: " << jsonData["result"]["message"] << endl;
|
stream << "message: " << jsonData["result"]["message"] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string decoded = stream.str();
|
string decoded = stream.str();
|
||||||
std::cout << decoded << endl;
|
std::cout << decoded << endl;
|
||||||
|
|
||||||
if (isDebug)
|
if (isDebug)
|
||||||
ShowDebug(data, decoded, 0, result);
|
ShowDebug(data, decoded, 0, result);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
int Deals::Negative() {
|
int Deals::Negative()
|
||||||
|
{
|
||||||
string data = CommonStatus();
|
string data = CommonStatus();
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
if (result.length() == 0)
|
if (result.length() == 0)
|
||||||
@@ -400,15 +399,12 @@ int Deals::Negative() {
|
|||||||
stream << "success: " << jsonData["result"]["success"] << endl;
|
stream << "success: " << jsonData["result"]["success"] << endl;
|
||||||
stream << "message: " << jsonData["result"]["message"] << endl;
|
stream << "message: " << jsonData["result"]["message"] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string decoded = stream.str();
|
string decoded = stream.str();
|
||||||
std::cout << decoded << endl;
|
std::cout << decoded << endl;
|
||||||
|
|
||||||
if (isDebug)
|
if (isDebug)
|
||||||
ShowDebug(data, decoded, 0, result);
|
ShowDebug(data, decoded, 0, result);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Deals::GetVal(const string first, const string second)
|
string Deals::GetVal(const string first, const string second)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
curl -X POST "{{ADDRESS}}/api/v1/deal/create" \
|
curl -s -X POST "{{ADDRESS}}/api/v1/deal/create" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"at":"{{AT}}","type":"{{TYPE}}","seller":{"address": "{{SELLER}}"},"customer":{"address":"{{CUSTOMER}}"},"payment":{"sum":"{{SUM}}" {{UNTIL}} } {{FEETBACK}} }'
|
-d '{"at":"{{AT}}","type":"{{TYPE}}","seller":{"address": "{{SELLER}}"},"customer":{"address":"{{CUSTOMER}}"},"payment":{"sum":"{{SUM}}" {{UNTIL}} } {{FEETBACK}} }'
|
||||||
Reference in New Issue
Block a user