Skip to content

Commit fce05e1

Browse files
authored
Merge pull request #394 from duality-solutions/v2.4.2.0-WIP
V2.4.2.0 wip
2 parents 23b4587 + 688bff2 commit fce05e1

20 files changed

Lines changed: 114 additions & 29 deletions

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
**Dynamic CHANGELOG**
22
-------------------------
33

4+
**Dynamic v2.4.2.0**
5+
6+
* [BDAP] Set maximum months stored in local accounts db
7+
* [BDAP] Limit acount registration to 100 years
8+
* [Mempool] Don't check if standard tx for BDAP txs in accept to mempool
9+
* [BDAP] Remove maximum months for updated accounts
10+
* [BDAP] Fix add months to block and epoch times
11+
* [Util] Fix epoch to ISO date string conversion
12+
* Bump client and block version to v2.4.2.0
13+
* Increase minimum protocol to v2.4 (71000) or greater
14+
* [Wallet] Check txout instead of entire tx for BDAP
15+
16+
417
**Dynamic v2.4.1.0**
518

619
* [Qt] Update/Add Languages

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/duality-solutions/Dynamic.png?branch=master)](https://travis-ci.org/duality-solutions/Dynamic)
44

5-
# **Dynamic (DYN) v2.4.1.0**
5+
# **Dynamic (DYN) v2.4.2.0**
66

77
![DYN logo](https://github.com/duality-solutions/Dynamic/blob/master/src/qt/res/icons/drk/about.png)
88

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
22
AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 2)
44
define(_CLIENT_VERSION_MINOR, 4)
5-
define(_CLIENT_VERSION_REVISION, 1)
5+
define(_CLIENT_VERSION_REVISION, 2)
66
define(_CLIENT_VERSION_BUILD, 0)
77
define(_CLIENT_VERSION_IS_RELEASE, true)
88
define(_COPYRIGHT_YEAR, 2019)

contrib/gitian-descriptors/gitian-arm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: "dynamic-arm-2.4.1.0"
2+
name: "dynamic-arm-2.4.2.0"
33
enable_cache: true
44
suites:
55
- "trusty"

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: "dynamic-linux-2.4.1.0"
2+
name: "dynamic-linux-2.4.2.0"
33
enable_cache: true
44
suites:
55
- "trusty"

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: "dynamic-osx-2.4.1.0"
2+
name: "dynamic-osx-2.4.2.0"
33
enable_cache: true
44
suites:
55
- "trusty"

contrib/gitian-descriptors/gitian-win.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: "dynamic-2.4.1.0"
2+
name: "dynamic-2.4.2.0"
33
enable_cache: true
44
suites:
55
- "trusty"

src/bdap/bdap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static constexpr unsigned int MAX_BDAP_LINK_DATA_SIZE = 1592;
5656
static constexpr uint64_t DEFAULT_LINK_EXPIRE_TIME = 1861920000;
5757
static constexpr int32_t DEFAULT_REGISTRATION_MONTHS = 12; // 1 year
5858
static constexpr bool ENFORCE_BDAP_CREDIT_USE = false; // TODO: Change to true before release
59+
static constexpr uint32_t MAX_REGISTRATION_MONTHS = 1200; // 100 years
5960
static const std::string DEFAULT_PUBLIC_DOMAIN = "bdap.io";
6061
static const std::string DEFAULT_PUBLIC_OU = "public";
6162
static const std::string DEFAULT_ADMIN_OU = "admin";

src/bdap/domainentrydb.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,13 @@ bool CheckDomainEntryTx(const CTransactionRef& tx, const CScript& scriptOp, cons
653653

654654
uint32_t nMonths;
655655
ParseUInt32(strMonths, &nMonths);
656+
if (nMonths > MAX_REGISTRATION_MONTHS)
657+
nMonths = MAX_REGISTRATION_MONTHS;
658+
659+
int64_t nCurrentEpoch = GetTime();
660+
int64_t nEpochAddMonths = AddMonthsToBlockTime(nBlockTime > 0 ? nBlockTime : nCurrentEpoch, nMonths);
661+
if (nEpochAddMonths < nCurrentEpoch)
662+
nMonths = MAX_REGISTRATION_MONTHS;
656663

657664
if (!GetBDAPFees(OP_BDAP_NEW, OP_BDAP_ACCOUNT_ENTRY, entry.ObjectType(), (uint16_t)nMonths, monthlyFee, oneTimeFee, depositFee)) {
658665
errorMessage = "Failed to get fees to add a new BDAP account";
@@ -712,12 +719,19 @@ bool CheckDomainEntryTx(const CTransactionRef& tx, const CScript& scriptOp, cons
712719

713720
uint32_t nMonths;
714721
ParseUInt32(strMonths, &nMonths);
715-
if (nMonths >= 10000)
716-
nMonths = 24;
722+
if (nMonths > MAX_REGISTRATION_MONTHS)
723+
nMonths = MAX_REGISTRATION_MONTHS;
724+
725+
int64_t nCurrentEpoch = GetTime();
726+
int64_t nEpochAddMonths = AddMonthsToBlockTime(nBlockTime > 0 ? nBlockTime : nCurrentEpoch, nMonths);
727+
if (nEpochAddMonths < nCurrentEpoch)
728+
nMonths = MAX_REGISTRATION_MONTHS;
729+
717730
if (!GetBDAPFees(OP_BDAP_MODIFY, OP_BDAP_ACCOUNT_ENTRY, entry.ObjectType(), (uint16_t)nMonths, monthlyFee, oneTimeFee, depositFee)) {
718731
errorMessage = "Failed to get fees to add a new BDAP account";
719732
return false;
720733
}
734+
721735
LogPrint("bdap", "%s -- nMonths %d, monthlyFee %d, oneTimeFee %d, depositFee %d\n", __func__,
722736
nMonths, FormatMoney(monthlyFee), FormatMoney(oneTimeFee), FormatMoney(depositFee));
723737
// extract amounts from tx.

src/bdap/fees.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "util.h" // for LogPrintf
1010

1111
#include <boost/date_time/posix_time/posix_time.hpp>
12+
#include <ctime>
1213
#include <limits>
1314
#include <map>
1415

@@ -174,24 +175,42 @@ bool GetBDAPFees(const opcodetype& opCodeAction, const opcodetype& opCodeObject,
174175

175176
int64_t AddMonthsToCurrentEpoch(const short nMonths)
176177
{
178+
struct std::tm epoch_date;
179+
epoch_date.tm_hour = 0; epoch_date.tm_min = 0; epoch_date.tm_sec = 0;
180+
epoch_date.tm_year = 70; epoch_date.tm_mon = 0; epoch_date.tm_mday = 1;
181+
177182
boost::gregorian::date dt = boost::gregorian::day_clock::universal_day();
178183
short nYear = dt.year() + ((dt.month() + nMonths)/12);
179184
short nMonth = (dt.month() + nMonths) % 12;
180185
short nDay = dt.day();
181-
boost::posix_time::time_duration dur = boost::posix_time::ptime(boost::gregorian::date(nYear, nMonth, nDay)) - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1));
182186
//LogPrintf("%s -- nYear %d, nMonth %d, nDay %d\n", __func__, nYear, nMonth, nDay);
183-
return dur.total_seconds() + SECONDS_PER_DAY;
187+
struct std::tm month_date;
188+
month_date.tm_hour = 0; month_date.tm_min = 0; month_date.tm_sec = 0;
189+
month_date.tm_year = nYear - 1900; month_date.tm_mon = nMonth -1; month_date.tm_mday = nDay;
190+
191+
int64_t seconds = (int64_t)std::difftime(std::mktime(&month_date), std::mktime(&epoch_date));
192+
193+
return seconds + SECONDS_PER_DAY;
184194
}
185195

186196
int64_t AddMonthsToBlockTime(const uint32_t& nBlockTime, const short nMonths)
187197
{
198+
struct std::tm epoch_date;
199+
epoch_date.tm_hour = 0; epoch_date.tm_min = 0; epoch_date.tm_sec = 0;
200+
epoch_date.tm_year = 70; epoch_date.tm_mon = 0; epoch_date.tm_mday = 1;
201+
188202
boost::gregorian::date dt = boost::posix_time::from_time_t(nBlockTime).date();
189203
short nYear = dt.year() + ((dt.month() + nMonths)/12);
190204
short nMonth = (dt.month() + nMonths) % 12;
191205
short nDay = dt.day();
192-
boost::posix_time::time_duration dur = boost::posix_time::ptime(boost::gregorian::date(nYear, nMonth, nDay)) - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1));
193206
//LogPrintf("%s -- nYear %d, nMonth %d, nDay %d\n", __func__, nYear, nMonth, nDay);
194-
return dur.total_seconds() + SECONDS_PER_DAY;
207+
struct std::tm month_date;
208+
month_date.tm_hour = 0; month_date.tm_min = 0; month_date.tm_sec = 0;
209+
month_date.tm_year = nYear - 1900; month_date.tm_mon = nMonth -1; month_date.tm_mday = nDay;
210+
211+
int64_t seconds = (int64_t)std::difftime(std::mktime(&month_date), std::mktime(&epoch_date));
212+
213+
return seconds + SECONDS_PER_DAY;
195214
}
196215

197216
uint16_t MonthsFromBlockToExpire(const uint32_t& nBlockTime, const uint64_t& nExpireTime)

0 commit comments

Comments
 (0)