Committing updates.
This commit is contained in:
@@ -226,10 +226,10 @@ namespace Apostol {
|
||||
CDealType CDeal::StringToType(const CString &Value) {
|
||||
const auto &status = Value.Lower();
|
||||
|
||||
if (status.Find("prepayment") != CString::npos || status.Find("prepaid") != CString::npos) {
|
||||
return dtPrepaid;
|
||||
} else if (status.Find("postpayment") != CString::npos || status.Find("postpaid") != CString::npos) {
|
||||
return dtPostpaid;
|
||||
if (status.Find("prepayment") != CString::npos) {
|
||||
return dtPrepayment;
|
||||
} else if (status.Find("postpayment") != CString::npos) {
|
||||
return dtPostpayment;
|
||||
} else {
|
||||
throw ExceptionFrm(R"(Invalid order type value: "%s".)", status.c_str());
|
||||
}
|
||||
@@ -238,9 +238,9 @@ namespace Apostol {
|
||||
|
||||
CString CDeal::TypeToString(CDealType Type) {
|
||||
switch (Type) {
|
||||
case dtPrepaid:
|
||||
case dtPrepayment:
|
||||
return "Prepayment";
|
||||
case dtPostpaid:
|
||||
case dtPostpayment:
|
||||
return "Postpayment";
|
||||
default:
|
||||
return "Unknown";
|
||||
@@ -249,9 +249,9 @@ namespace Apostol {
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
CString CDeal::TypeCodeToString(const CString &Code) {
|
||||
if (Code == "prepaid.deal") {
|
||||
if (Code == "prepayment.deal") {
|
||||
return {"Prepayment"};
|
||||
} else if (Code == "postpaid.deal") {
|
||||
} else if (Code == "postpayment.deal") {
|
||||
return {"Postpayment"};
|
||||
} else {
|
||||
throw ExceptionFrm(R"(Invalid type code value: "%s".)", Code.c_str());
|
||||
@@ -366,9 +366,9 @@ namespace Apostol {
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
std::string CDeal::get_payment_hd(const std::string &key1, const std::string &key2, std::string &key3,
|
||||
uint64_t version_key, uint8_t version_script) {
|
||||
uint64_t prefixes, uint8_t version_script) {
|
||||
|
||||
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(version_key) : ec_public(key3));
|
||||
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(prefixes) : ec_public(key3));
|
||||
|
||||
if (key3.empty())
|
||||
key3 = Witness.keys()[2].encoded();
|
||||
@@ -379,6 +379,18 @@ namespace Apostol {
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
std::string CDeal::get_payment_witness(const std::string &key1, const std::string &key2, std::string &key3,
|
||||
uint64_t prefixes) {
|
||||
|
||||
CWitness Witness(ec_public(key1), ec_public(key2), key3.empty() ? to_public_hd(prefixes) : ec_public(key3));
|
||||
|
||||
if (key3.empty())
|
||||
key3 = Witness.keys()[2].encoded();
|
||||
|
||||
return Witness.to_witness(prefixes == hd_private::mainnet ? "bc" : "tb");
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
CString CDeal::GetPaymentEK(const CString &Key1, const CString &Key2, CString &Key3,
|
||||
uint8_t version_key, uint8_t version_script) {
|
||||
|
||||
@@ -392,12 +404,24 @@ namespace Apostol {
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
CString CDeal::GetPaymentHD(const CString &Key1, const CString &Key2, CString &Key3, uint64_t version_key,
|
||||
uint8_t version_script) {
|
||||
CString CDeal::GetPaymentHD(const CString &Key1, const CString &Key2, CString &Key3,
|
||||
uint64_t prefixes, uint8_t version_script) {
|
||||
|
||||
std::string key3(Key3);
|
||||
|
||||
const auto& payment = get_payment_hd(Key1.c_str(), Key2.c_str(), key3, version_key, version_script);
|
||||
const auto& payment = get_payment_hd(Key1.c_str(), Key2.c_str(), key3, prefixes, version_script);
|
||||
|
||||
Key3 = key3;
|
||||
|
||||
return payment;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
CString CDeal::GetPaymentSW(const CString &Key1, const CString &Key2, CString &Key3, uint64_t prefixes) {
|
||||
|
||||
std::string key3(Key3);
|
||||
|
||||
const auto& payment = get_payment_witness(Key1.c_str(), Key2.c_str(), key3, prefixes);
|
||||
|
||||
Key3 = key3;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user