Merge branch 'master' of git.bitdeals.org:private/apostol-dm
This commit is contained in:
@@ -546,23 +546,23 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CString CCustomModule::GetAddress(const CHTTPRequest &Request) {
|
CString CCustomModule::GetParam(const CHTTPRequest &Request, const CString &Key) {
|
||||||
CString Result;
|
CString Result;
|
||||||
|
|
||||||
Result = Request.Params["address"];
|
Result = Request.Params[Key];
|
||||||
|
|
||||||
if (Result.IsEmpty() && !Request.Content.IsEmpty()) {
|
if (Result.IsEmpty() && !Request.Content.IsEmpty()) {
|
||||||
const auto &contentType = Request.Headers.Values(_T("content-type"));
|
const auto &contentType = Request.Headers.Values(_T("content-type"));
|
||||||
if (contentType.Find("application/x-www-form-urlencoded") == 0) {
|
if (contentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||||
const CStringList &FormData = Request.FormData;
|
const CStringList &FormData = Request.FormData;
|
||||||
Result = FormData["address"];
|
Result = FormData[Key];
|
||||||
} else if (contentType.Find("multipart/form-data") == 0) {
|
} else if (contentType.Find("multipart/form-data") == 0) {
|
||||||
CFormData FormData;
|
CFormData FormData;
|
||||||
CHTTPRequestParser::ParseFormData(Request, FormData);
|
CHTTPRequestParser::ParseFormData(Request, FormData);
|
||||||
Result = FormData.Data("address");
|
Result = FormData.Data(Key);
|
||||||
} else if (contentType.Find("application/json") == 0) {
|
} else if (contentType.Find("application/json") == 0) {
|
||||||
const CJSON contextJson(Request.Content);
|
const CJSON contextJson(Request.Content);
|
||||||
Result = contextJson["address"].AsString();
|
Result = contextJson[Key].AsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +634,7 @@ namespace Apostol {
|
|||||||
try {
|
try {
|
||||||
if (caCommand == "account" && (caAction == "status" || caAction == "new" || caAction == "add" || caAction == "update" || caAction == "delete")) {
|
if (caCommand == "account" && (caAction == "status" || caAction == "new" || caAction == "add" || caAction == "update" || caAction == "delete")) {
|
||||||
DoAccount(AConnection, "POST", sRoute);
|
DoAccount(AConnection, "POST", sRoute);
|
||||||
} else if (caCommand == "deal" && (caAction.IsEmpty() || caAction == "status" || caAction == "create" || caAction == "pay" || caAction == "complete" || caAction == "cancel" || caAction == "feedback")) {
|
} else if (caCommand == "deal" && slRouts.Count() == 4 && (caAction.IsEmpty() || caAction == "status" || caAction == "create" || caAction == "pay" || caAction == "complete" || caAction == "cancel" || caAction == "feedback")) {
|
||||||
DoDeal(AConnection, "POST", sRoute, caAction);
|
DoDeal(AConnection, "POST", sRoute, caAction);
|
||||||
} else if (caCommand == "signature") {
|
} else if (caCommand == "signature") {
|
||||||
DoSignature(AConnection);
|
DoSignature(AConnection);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace Apostol {
|
|||||||
void ModuleNew(CContext &Context);
|
void ModuleNew(CContext &Context);
|
||||||
void ModuleAuthorize(CContext &Context);
|
void ModuleAuthorize(CContext &Context);
|
||||||
|
|
||||||
static CString GetAddress(const CHTTPRequest &Request);
|
static CString GetParam(const CHTTPRequest &Request, const CString &Key);
|
||||||
|
|
||||||
void DoGet(CHTTPServerConnection *AConnection) override;
|
void DoGet(CHTTPServerConnection *AConnection) override;
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,14 @@ namespace Apostol {
|
|||||||
return doCreate;
|
return doCreate;
|
||||||
} else if (S == "created") {
|
} else if (S == "created") {
|
||||||
return doCreated;
|
return doCreated;
|
||||||
|
} else if (S == "submit") {
|
||||||
|
return doSubmit;
|
||||||
|
} else if (S == "submitted") {
|
||||||
|
return doSubmitted;
|
||||||
|
} else if (S == "confirm") {
|
||||||
|
return doConfirm;
|
||||||
|
} else if (S == "confirmed") {
|
||||||
|
return doConfirmed;
|
||||||
} else if (S == "pay") {
|
} else if (S == "pay") {
|
||||||
return doPay;
|
return doPay;
|
||||||
} else if (S == "paid") {
|
} else if (S == "paid") {
|
||||||
@@ -192,6 +200,14 @@ namespace Apostol {
|
|||||||
return "Create";
|
return "Create";
|
||||||
case doCreated:
|
case doCreated:
|
||||||
return "Created";
|
return "Created";
|
||||||
|
case doSubmit:
|
||||||
|
return "Submit";
|
||||||
|
case doSubmitted:
|
||||||
|
return "Submitted";
|
||||||
|
case doConfirm:
|
||||||
|
return "Confirm";
|
||||||
|
case doConfirmed:
|
||||||
|
return "Confirmed";
|
||||||
case doPay:
|
case doPay:
|
||||||
return "Pay";
|
return "Pay";
|
||||||
case doPaid:
|
case doPaid:
|
||||||
@@ -291,15 +307,16 @@ namespace Apostol {
|
|||||||
|
|
||||||
CString DealData::GetStringData() const {
|
CString DealData::GetStringData() const {
|
||||||
CString Data;
|
CString Data;
|
||||||
|
CString S;
|
||||||
|
|
||||||
Data.Format("Type: %d;", (int) Type);
|
Data = S.Format("Type: %d;", (int) Type);
|
||||||
Data.Format("URL: %s;", At.c_str());
|
Data += S.Format("URL: %s;", At.c_str());
|
||||||
Data.Format("Date: %s;", Date.c_str());
|
Data += S.Format("Date: %s;", Date.c_str());
|
||||||
Data.Format("Seller: %s;", Seller.Address.c_str());
|
Data += S.Format("Seller: %s;", Seller.Address.c_str());
|
||||||
Data.Format("Customer: %s;", Customer.Address.c_str());
|
Data += S.Format("Customer: %s;", Customer.Address.c_str());
|
||||||
Data.Format("Until: %s;", Payment.Until.c_str());
|
Data += S.Format("Until: %s;", Payment.Until.c_str());
|
||||||
Data.Format("Sum: %s;", Payment.Sum.c_str());
|
Data += S.Format("Sum: %s;", Payment.Sum.c_str());
|
||||||
Data.Format("LeaveBefore: %s", FeedBack.LeaveBefore.c_str());
|
Data += S.Format("LeaveBefore: %s", FeedBack.LeaveBefore.c_str());
|
||||||
|
|
||||||
return Data;
|
return Data;
|
||||||
}
|
}
|
||||||
@@ -422,7 +439,7 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
std::string CDeal::get_payment_ek(const std::string &key1, const std::string &key2, std::string &key3,
|
std::string CDeal::get_payment_ek(const std::string &key1, const std::string &key2, std::string &key3,
|
||||||
uint8_t version_key, uint8_t version_script) {
|
uint8_t version_key, uint8_t version_script) {
|
||||||
|
|
||||||
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_ek(version_key) : ec_public(key3));
|
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_ek(version_key) : ec_public(key3));
|
||||||
|
|
||||||
@@ -436,7 +453,7 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
std::string CDeal::get_payment_hd(const std::string &key1, const std::string &key2, std::string &key3,
|
std::string CDeal::get_payment_hd(const std::string &key1, const std::string &key2, std::string &key3,
|
||||||
uint64_t prefixes, uint8_t version_script) {
|
uint64_t prefixes, uint8_t version_script) {
|
||||||
|
|
||||||
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(prefixes) : ec_public(key3));
|
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(prefixes) : ec_public(key3));
|
||||||
|
|
||||||
@@ -450,7 +467,7 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
std::string CDeal::get_payment_witness(const std::string &key1, const std::string &key2, std::string &key3,
|
std::string CDeal::get_payment_witness(const std::string &key1, const std::string &key2, std::string &key3,
|
||||||
uint64_t prefixes) {
|
uint64_t prefixes) {
|
||||||
|
|
||||||
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(prefixes) : ec_public(key3));
|
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(prefixes) : ec_public(key3));
|
||||||
|
|
||||||
@@ -462,7 +479,7 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CString CDeal::GetPaymentEK(const CString &Key1, const CString &Key2, CString &Key3,
|
CString CDeal::GetPaymentEK(const CString &Key1, const CString &Key2, CString &Key3,
|
||||||
uint8_t version_key, uint8_t version_script) {
|
uint8_t version_key, uint8_t version_script) {
|
||||||
|
|
||||||
std::string key3(Key3);
|
std::string key3(Key3);
|
||||||
|
|
||||||
@@ -475,7 +492,7 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CString CDeal::GetPaymentHD(const CString &Key1, const CString &Key2, CString &Key3,
|
CString CDeal::GetPaymentHD(const CString &Key1, const CString &Key2, CString &Key3,
|
||||||
uint64_t prefixes, uint8_t version_script) {
|
uint64_t prefixes, uint8_t version_script) {
|
||||||
|
|
||||||
std::string key3(Key3);
|
std::string key3(Key3);
|
||||||
|
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ namespace Apostol {
|
|||||||
enum CFeedBackStatus { fsNegative = -1, fsNeutral = 0, fsPositive = 1 };
|
enum CFeedBackStatus { fsNegative = -1, fsNeutral = 0, fsPositive = 1 };
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
enum CDealOrder { doCreate = 0, doCreated, doPay, doPaid, doComplete, doCompleted, doCancel, doCanceled,
|
enum CDealOrder { doCreate = 0, doCreated, doSubmit, doSubmitted, doConfirm, doConfirmed, doPay, doPaid, doComplete, doCompleted, doCancel, doCanceled,
|
||||||
doExecute, doExecuted, doDelete, doDeleted, doFail, doFailed, doFeedback };
|
doExecute, doExecuted, doDelete, doDeleted, doFail, doFailed, doFeedback };
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
typedef struct DealData {
|
typedef struct DealData {
|
||||||
@@ -319,7 +319,7 @@ namespace Apostol {
|
|||||||
uint8_t version_script = payment_address::mainnet_p2sh);
|
uint8_t version_script = payment_address::mainnet_p2sh);
|
||||||
|
|
||||||
std::string get_payment_witness(const std::string &key1, const std::string &key2, std::string &key3,
|
std::string get_payment_witness(const std::string &key1, const std::string &key2, std::string &key3,
|
||||||
uint64_t prefixes = hd_private::mainnet);
|
uint64_t prefixes = hd_private::mainnet);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
int exitcode;
|
int exitcode;
|
||||||
|
|
||||||
DefaultLocale.SetLocale("");
|
DefaultLocale.SetLocale("en-US");
|
||||||
|
|
||||||
CDealModule dm(argc, argv);
|
CDealModule dm(argc, argv);
|
||||||
|
|
||||||
@@ -272,6 +272,6 @@ int main(int argc, char *argv[]) {
|
|||||||
exit_failure("Unknown error...");
|
exit_failure("Unknown error...");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(exitcode);
|
return exitcode;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -253,10 +253,10 @@ namespace Apostol {
|
|||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caHost = caServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caUserAddress = GetAddress(caServerRequest);
|
|
||||||
|
|
||||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
const auto &caUserAddress = GetParam(caServerRequest, "address");
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
@@ -491,15 +491,14 @@ namespace Apostol {
|
|||||||
const auto &caHost = caServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
|
|
||||||
const auto &address = GetAddress(caServerRequest);
|
const auto &code = GetParam(caServerRequest, "code");
|
||||||
const auto &code = caServerRequest.Params["code"];
|
const auto &address = GetParam(caServerRequest, "address");
|
||||||
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||||
|
|
||||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||||
@@ -861,12 +860,13 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Json.Object().AddPair("module", Module);
|
Json.Object().AddPair("module", Module);
|
||||||
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
|
||||||
|
|
||||||
if (!caDealCode.IsEmpty()) {
|
if (!caDealCode.IsEmpty()) {
|
||||||
CJSONValue Deal(jvtObject);
|
CJSONValue Deal(jvtObject);
|
||||||
Deal.Object().AddPair("code", caDealCode);
|
Deal.Object().AddPair("code", caDealCode);
|
||||||
Json.Object().AddPair("deal", Deal);
|
Json.Object().AddPair("deal", Deal);
|
||||||
|
} else {
|
||||||
|
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sPayload.IsEmpty())
|
if (!sPayload.IsEmpty())
|
||||||
@@ -927,14 +927,7 @@ namespace Apostol {
|
|||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
||||||
|
|
||||||
const auto &address = GetAddress(caServerRequest);
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
const auto &code = caServerRequest.Params["code"];
|
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
|
||||||
|
|
||||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
@@ -1131,7 +1124,9 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Delphi::Exception::Exception &e) {
|
} catch (Delphi::Exception::Exception &e) {
|
||||||
|
Context.SetFixedDate(Context.FixedDate() + (CDateTime) 5 / MinsPerDay); // 5 min
|
||||||
Context.SetStatus(Context::csAuthorized);
|
Context.SetStatus(Context::csAuthorized);
|
||||||
|
|
||||||
Log()->Error(APP_LOG_INFO, 0, "[FetchPGP] %s", e.what());
|
Log()->Error(APP_LOG_INFO, 0, "[FetchPGP] %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -357,26 +357,26 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &ServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
|
|
||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caHost = ServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caUserAddress = GetAddress(ServerRequest);
|
|
||||||
|
|
||||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
const auto &caUserAddress = GetParam(caServerRequest, "address");
|
||||||
const auto &caServerParam = ServerRequest.Params["server"];
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
CStringList caClearText;
|
CStringList caClearText;
|
||||||
CString sPayload;
|
CString sPayload;
|
||||||
|
|
||||||
if (!ServerRequest.Content.IsEmpty()) {
|
if (!caServerRequest.Content.IsEmpty()) {
|
||||||
|
|
||||||
const auto &ContentType = ServerRequest.Headers.Values(_T("content-type"));
|
const auto &ContentType = caServerRequest.Headers.Values(_T("content-type"));
|
||||||
|
|
||||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||||
|
|
||||||
const CStringList &FormData = ServerRequest.FormData;
|
const CStringList &FormData = caServerRequest.FormData;
|
||||||
|
|
||||||
const auto &formDate = FormData["date"];
|
const auto &formDate = FormData["date"];
|
||||||
const auto &formAddress = FormData["address"];
|
const auto &formAddress = FormData["address"];
|
||||||
@@ -422,7 +422,7 @@ namespace Apostol {
|
|||||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||||
|
|
||||||
CFormData FormData;
|
CFormData FormData;
|
||||||
CHTTPRequestParser::ParseFormData(ServerRequest, FormData);
|
CHTTPRequestParser::ParseFormData(caServerRequest, FormData);
|
||||||
|
|
||||||
const auto &formDate = FormData.Data("date");
|
const auto &formDate = FormData.Data("date");
|
||||||
const auto &formAddress = FormData.Data("address");
|
const auto &formAddress = FormData.Data("address");
|
||||||
@@ -467,7 +467,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
} else if (ContentType.Find("application/json") == 0) {
|
} else if (ContentType.Find("application/json") == 0) {
|
||||||
|
|
||||||
const CJSON contextJson(ServerRequest.Content);
|
const CJSON contextJson(caServerRequest.Content);
|
||||||
|
|
||||||
const auto &jsonDate = contextJson["date"].AsString();
|
const auto &jsonDate = contextJson["date"].AsString();
|
||||||
const auto &jsonAddress = contextJson["address"].AsString();
|
const auto &jsonAddress = contextJson["address"].AsString();
|
||||||
@@ -514,7 +514,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
caClearText = ServerRequest.Content;
|
caClearText = caServerRequest.Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pgpValue == "off" || pgpValue == "false") {
|
if (pgpValue == "off" || pgpValue == "false") {
|
||||||
@@ -571,7 +571,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &ServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
|
|
||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caModuleFee = m_Module["fee"];
|
const auto &caModuleFee = m_Module["fee"];
|
||||||
@@ -580,18 +580,17 @@ namespace Apostol {
|
|||||||
if (checkFee == -1)
|
if (checkFee == -1)
|
||||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||||
|
|
||||||
const auto &caHost = ServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
|
|
||||||
|
const auto &code = GetParam(caServerRequest, "code");
|
||||||
|
const auto &address = GetParam(caServerRequest, "address");
|
||||||
|
const auto &pgpValue = GetParam(caServerRequest, "pgp");
|
||||||
|
const auto &caServerParam = GetParam(caServerRequest, "server");
|
||||||
|
|
||||||
const auto &address = GetAddress(ServerRequest);
|
|
||||||
const auto &code = ServerRequest.Params["code"];
|
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||||
|
|
||||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
|
||||||
const auto &caServerParam = ServerRequest.Params["server"];
|
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||||
@@ -603,14 +602,14 @@ namespace Apostol {
|
|||||||
|
|
||||||
CString sPayload;
|
CString sPayload;
|
||||||
|
|
||||||
if (!ServerRequest.Content.IsEmpty() && Action != "status") {
|
if (!caServerRequest.Content.IsEmpty() && Action != "status") {
|
||||||
|
|
||||||
const auto utc = UTC();
|
const auto utc = UTC();
|
||||||
const auto &ContentType = ServerRequest.Headers.Values(_T("content-type"));
|
const auto &ContentType = caServerRequest.Headers.Values(_T("content-type"));
|
||||||
|
|
||||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||||
|
|
||||||
const CStringList &FormData = ServerRequest.FormData;
|
const CStringList &FormData = caServerRequest.FormData;
|
||||||
|
|
||||||
const auto &formType = FormData["type"];
|
const auto &formType = FormData["type"];
|
||||||
const auto &formAt = FormData["at"];
|
const auto &formAt = FormData["at"];
|
||||||
@@ -697,7 +696,7 @@ namespace Apostol {
|
|||||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||||
|
|
||||||
CFormData FormData;
|
CFormData FormData;
|
||||||
CHTTPRequestParser::ParseFormData(ServerRequest, FormData);
|
CHTTPRequestParser::ParseFormData(caServerRequest, FormData);
|
||||||
|
|
||||||
const auto &formType = FormData.Data("type");
|
const auto &formType = FormData.Data("type");
|
||||||
const auto &formAt = FormData.Data("at");
|
const auto &formAt = FormData.Data("at");
|
||||||
@@ -783,7 +782,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
} else if (ContentType.Find("application/json") == 0) {
|
} else if (ContentType.Find("application/json") == 0) {
|
||||||
|
|
||||||
const CJSON jsonData(ServerRequest.Content);
|
const CJSON jsonData(caServerRequest.Content);
|
||||||
|
|
||||||
const auto &formOrder = jsonData["order"].AsString().Lower();
|
const auto &formOrder = jsonData["order"].AsString().Lower();
|
||||||
const auto &formType = jsonData["type"].AsString();
|
const auto &formType = jsonData["type"].AsString();
|
||||||
@@ -878,7 +877,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Node = YAML::Load(ServerRequest.Content.c_str());
|
Node = YAML::Load(caServerRequest.Content.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &BTCKeys = caContext.BTCKeys();
|
const auto &BTCKeys = caContext.BTCKeys();
|
||||||
@@ -944,12 +943,13 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Json.Object().AddPair("module", Module);
|
Json.Object().AddPair("module", Module);
|
||||||
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
|
||||||
|
|
||||||
if (!caDealCode.IsEmpty()) {
|
if (!caDealCode.IsEmpty()) {
|
||||||
CJSONValue Deal(jvtObject);
|
CJSONValue Deal(jvtObject);
|
||||||
Deal.Object().AddPair("code", caDealCode);
|
Deal.Object().AddPair("code", caDealCode);
|
||||||
Json.Object().AddPair("deal", Deal);
|
Json.Object().AddPair("deal", Deal);
|
||||||
|
} else {
|
||||||
|
Json.Object().AddPair("address", caUserAddress.IsEmpty() ? caModuleAddress : caUserAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sPayload.IsEmpty())
|
if (!sPayload.IsEmpty())
|
||||||
@@ -979,7 +979,7 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &ServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
|
|
||||||
const auto &caModuleAddress = m_Module["address"];
|
const auto &caModuleAddress = m_Module["address"];
|
||||||
const auto &caModuleFee = m_Module["fee"];
|
const auto &caModuleFee = m_Module["fee"];
|
||||||
@@ -988,17 +988,17 @@ namespace Apostol {
|
|||||||
if (checkFee == -1)
|
if (checkFee == -1)
|
||||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||||
|
|
||||||
const auto &caHost = ServerRequest.Headers["host"];
|
const auto &caHost = caServerRequest.Headers["host"];
|
||||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
|
|
||||||
const auto &address = ServerRequest.Params["address"];
|
const auto &address = caServerRequest.Params["address"];
|
||||||
const auto &code = ServerRequest.Params["code"];
|
const auto &code = caServerRequest.Params["code"];
|
||||||
|
|
||||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||||
|
|
||||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
const auto &pgpValue = caServerRequest.Params["pgp"];
|
||||||
const auto &caServerParam = ServerRequest.Params["server"];
|
const auto &caServerParam = caServerRequest.Params["server"];
|
||||||
|
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
@@ -1013,7 +1013,7 @@ namespace Apostol {
|
|||||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CJSON Json(ServerRequest.Content);
|
const CJSON Json(caServerRequest.Content);
|
||||||
|
|
||||||
pClient->Send(URI, Json, OnRequest);
|
pClient->Send(URI, Json, OnRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user