Skip to content

Commit 79edaee

Browse files
committed
[BDAP] Use in account and link RPC commands
1 parent 16eb85c commit 79edaee

File tree

7 files changed

+79
-75
lines changed

7 files changed

+79
-75
lines changed

src/bdap/bdap.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ static constexpr unsigned int DHT_HEX_PUBLIC_KEY_LENGTH = 64; // Ed25519 pubke
5353
static constexpr unsigned int MAX_BDAP_LINK_MESSAGE = 256;
5454
static constexpr unsigned int MAX_BDAP_SIGNATURE_PROOF = 90; // TODO (bdap): Update to 65 or use MAX_SIGNATURE_LENGTH when you start a new chain.
5555
static constexpr unsigned int MAX_BDAP_LINK_DATA_SIZE = 1592;
56-
static constexpr unsigned int DEFAULT_REGISTRATION_DAYS = 731; // 2 years
56+
static constexpr uint64_t DEFAULT_LINK_EXPIRE_TIME = 4102444800;
57+
static constexpr int32_t DEFAULT_REGISTRATION_MONTHS = 12; // 1 year
5758
static const std::string DEFAULT_PUBLIC_DOMAIN = "bdap.io";
5859
static const std::string DEFAULT_PUBLIC_OU = "public";
5960
static const std::string DEFAULT_ADMIN_OU = "admin";

src/bdap/fees.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
#include "bdap/fees.h"
66

7+
#include "bdap/bdap.h" // for SECONDS_PER_DAY
78
#include "bdap/utils.h" // for GetObjectTypeString
89
#include "util.h" // for LogPrintf
910

11+
#include <boost/date_time/posix_time/posix_time.hpp>
12+
1013
// Default BDAP Monthly Fees
1114
std::map<int32_t, CAmount> mapDefaultMonthlyFees = {
1215
{BDAP_MONTHY_USER_FEE, 50 * BDAP_CREDIT},
@@ -105,4 +108,15 @@ bool GetBDAPFees(const opcodetype& opCodeAction, const opcodetype& opCodeObject,
105108
}
106109

107110
return true;
111+
}
112+
113+
int64_t AddMonthsToCurrentEpoch(const short nMonths)
114+
{
115+
boost::gregorian::date dt = boost::gregorian::day_clock::local_day();
116+
short nYear = dt.year() + ((dt.month() + nMonths)/12);
117+
short nMonth = (dt.month() + nMonths) % 12;
118+
short nDay = dt.day();
119+
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));
120+
//LogPrintf("%s -- nYear %d, nMonth %d, nDay %d\n", __func__, nYear, nMonth, nDay);
121+
return dur.total_seconds() + SECONDS_PER_DAY;
108122
}

src/bdap/fees.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ static const int32_t BDAP_NON_REFUNDABLE_CERTIFICATE_DEPOSIT = 7003;
3636
static const int32_t BDAP_NON_REFUNDABLE_SIDECHAIN_DEPOSIT = 7004;
3737

3838
bool GetBDAPFees(const opcodetype& opCodeAction, const opcodetype& opCodeObject, const BDAP::ObjectType objType, const uint16_t nMonths, CAmount& monthlyFee, CAmount& oneTimeFee, CAmount& depositFee);
39+
int64_t AddMonthsToCurrentEpoch(const short nMonths);
3940

4041
#endif // DYNAMIC_BDAP_FEES_H

src/bdap/rpcdomainentry.cpp

+23-27
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include "bdap/domainentry.h"
66
#include "bdap/domainentrydb.h"
7+
#include "bdap/fees.h"
78
#include "bdap/utils.h"
8-
#include "dht/ed25519.h"
99
#include "core_io.h" // needed for ScriptToAsmStr
1010
#include "dynodeman.h"
1111
#include "rpcprotocol.h"
@@ -69,13 +69,12 @@ static UniValue AddDomainEntry(const JSONRPCRequest& request, BDAP::ObjectType b
6969

7070
txDomainEntry.LinkAddress = vchFromString(sxAddr.ToString());
7171

72-
int64_t nDays = DEFAULT_REGISTRATION_DAYS; // default to 2 years.
72+
int32_t nMonths = DEFAULT_REGISTRATION_MONTHS; // default to 2 years.
7373
if (request.params.size() >= 3) {
74-
if (!ParseInt64(request.params[2].get_str(), &nDays))
74+
if (!ParseInt32(request.params[2].get_str(), &nMonths))
7575
throw std::runtime_error("BDAP_ADD_PUBLIC_ENTRY_RPC_ERROR: ERRCODE: 3505 - " + _("Error converting registration days to int"));
7676
}
77-
int64_t nSeconds = nDays * SECONDS_PER_DAY;
78-
txDomainEntry.nExpireTime = chainActive.Tip()->GetMedianTimePast() + nSeconds;
77+
txDomainEntry.nExpireTime = AddMonthsToCurrentEpoch((short)nMonths);
7978

8079
CharString data;
8180
txDomainEntry.Serialize(data);
@@ -94,24 +93,23 @@ static UniValue AddDomainEntry(const JSONRPCRequest& request, BDAP::ObjectType b
9493
CScript scriptData;
9594
scriptData << OP_RETURN << data;
9695

97-
// Send the transaction
98-
CWalletTx wtx;
99-
float fYears = ((float)nDays/365.25);
100-
CAmount nOperationFee = GetBDAPFee(scriptPubKey) * powf(3.1, fYears);
101-
CAmount nDataFee = GetBDAPFee(scriptData) * powf(3.1, fYears);
102-
96+
// Get BDAP fees
97+
CAmount monthlyFee, oneTimeFee, depositFee;
98+
if (!GetBDAPFees(OP_BDAP_NEW, OP_BDAP_ACCOUNT_ENTRY, bdapType, nMonths, monthlyFee, oneTimeFee, depositFee))
99+
throw JSONRPCError(RPC_BDAP_FEE_UNKNOWN, strprintf("Error calculating BDAP fees."));
100+
LogPrintf("%s -- monthlyFee %d, oneTimeFee %d, depositFee %d\n", __func__, monthlyFee, oneTimeFee, depositFee);
103101
// check BDAP values
104102
std::string strMessage;
105103
if (!txDomainEntry.ValidateValues(strMessage))
106104
throw std::runtime_error("BDAP_ADD_PUBLIC_ENTRY_RPC_ERROR: ERRCODE: 3506 - " + strMessage);
107105

108106
bool fUseInstantSend = false;
109107
if (dnodeman.EnoughActiveForInstandSend() && sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) {
110-
// TODO (bdap): calculate cost for instant send.
111-
nOperationFee = nOperationFee * 2;
112108
fUseInstantSend = true;
113109
}
114-
SendBDAPTransaction(scriptData, scriptPubKey, wtx, nOperationFee, nDataFee, fUseInstantSend);
110+
// Send the transaction
111+
CWalletTx wtx;
112+
SendBDAPTransaction(scriptData, scriptPubKey, wtx, monthlyFee, depositFee, fUseInstantSend);
115113
txDomainEntry.txHash = wtx.GetHash();
116114

117115
UniValue oName(UniValue::VOBJ);
@@ -401,13 +399,12 @@ static UniValue UpdateDomainEntry(const JSONRPCRequest& request, BDAP::ObjectTyp
401399
txUpdatedEntry.CommonName = vchCommonName;
402400
txUpdatedEntry.nObjectType = GetObjectTypeInt(bdapType);
403401

404-
int64_t nDays = DEFAULT_REGISTRATION_DAYS; // default to 2 years.
402+
int32_t nMonths = DEFAULT_REGISTRATION_MONTHS; // default to 1 year.
405403
if (request.params.size() >= 3) {
406-
if (!ParseInt64(request.params[2].get_str(), &nDays))
404+
if (!ParseInt32(request.params[2].get_str(), &nMonths))
407405
throw std::runtime_error("BDAP_UPDATE_PUBLIC_ENTRY_RPC_ERROR: ERRCODE: 3702 - " + _("Error converting registration days to int"));
408406
}
409-
int64_t nSeconds = nDays * SECONDS_PER_DAY;
410-
txUpdatedEntry.nExpireTime = chainActive.Tip()->GetMedianTimePast() + nSeconds;
407+
txUpdatedEntry.nExpireTime = AddMonthsToCurrentEpoch((short)nMonths);
411408

412409
CharString data;
413410
txUpdatedEntry.Serialize(data);
@@ -427,24 +424,23 @@ static UniValue UpdateDomainEntry(const JSONRPCRequest& request, BDAP::ObjectTyp
427424
CScript scriptData;
428425
scriptData << OP_RETURN << data;
429426

430-
// Send the transaction
431-
CWalletTx wtx;
432-
float fYears = ((float)nDays/365.25);
433-
CAmount nOperationFee = GetBDAPFee(scriptPubKey) * powf(3.1, fYears);
434-
CAmount nDataFee = GetBDAPFee(scriptData) * powf(3.1, fYears);
435-
427+
// Get BDAP fees
428+
CAmount monthlyFee, oneTimeFee, depositFee;
429+
if (!GetBDAPFees(OP_BDAP_MODIFY, OP_BDAP_ACCOUNT_ENTRY, bdapType, nMonths, monthlyFee, oneTimeFee, depositFee))
430+
throw JSONRPCError(RPC_BDAP_FEE_UNKNOWN, strprintf("Error calculating BDAP fees."));
431+
LogPrintf("%s -- monthlyFee %d, oneTimeFee %d, depositFee %d\n", __func__, monthlyFee, oneTimeFee, depositFee);
436432
// check BDAP values
437433
std::string strMessage;
438434
if (!txUpdatedEntry.ValidateValues(strMessage))
439435
throw std::runtime_error("BDAP_UPDATE_PUBLIC_ENTRY_RPC_ERROR: ERRCODE: 3703 - " + strMessage);
440436

441437
bool fUseInstantSend = false;
442438
if (dnodeman.EnoughActiveForInstandSend() && sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) {
443-
// TODO (bdap): calculate cost for instant send.
444-
nOperationFee = nOperationFee * 2;
445439
fUseInstantSend = true;
446440
}
447-
SendBDAPTransaction(scriptData, scriptPubKey, wtx, nOperationFee, nDataFee, fUseInstantSend);
441+
// Send the transaction
442+
CWalletTx wtx;
443+
SendBDAPTransaction(scriptData, scriptPubKey, wtx, monthlyFee, depositFee, fUseInstantSend);
448444
txUpdatedEntry.txHash = wtx.GetHash();
449445

450446
UniValue oName(UniValue::VOBJ);

src/bdap/rpclinking.cpp

+24-30
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "bdap/bdap.h"
66
#include "bdap/domainentry.h"
77
#include "bdap/domainentrydb.h"
8+
#include "bdap/fees.h"
89
#include "bdap/vgp/include/encryption.h" // for VGP E2E encryption
910
#include "bdap/linking.h"
1011
#include "bdap/linkingdb.h"
@@ -102,7 +103,7 @@ static bool BuildJsonLinkAcceptInfo(const CLinkAccept& link, const CDomainEntry&
102103

103104
static UniValue SendLinkRequest(const JSONRPCRequest& request)
104105
{
105-
if (request.fHelp || request.params.size() < 4 || request.params.size() > 5)
106+
if (request.fHelp || request.params.size() != 4)
106107
throw std::runtime_error(
107108
"link request userid-from userid-to message\n"
108109
"Creates a link request transaction on the blockchain."
@@ -111,7 +112,6 @@ static UniValue SendLinkRequest(const JSONRPCRequest& request)
111112
"1. requestor (string) BDAP account requesting the link\n"
112113
"2. recipient (string) Link recipient's BDAP account.\n"
113114
"3. invite message (string) Message from requestor to recipient.\n"
114-
"4. registration days (int, optional) Number of days to keep the link request on the blockchain before pruning.\n"
115115
"\nResult:\n"
116116
"{(json object)\n"
117117
" \"Requestor FQDN\" (string) Requestor's BDAP full path\n"
@@ -196,14 +196,7 @@ static UniValue SendLinkRequest(const JSONRPCRequest& request)
196196
if (!CreateSignatureProof(key, strRecipientFQDN, txLink.SignatureProof))
197197
throw std::runtime_error("BDAP_SEND_LINK_RPC_ERROR: ERRCODE: 4008 - Error signing " + strRequestorFQDN + _("'s signature proof."));
198198

199-
int64_t nDays = DEFAULT_REGISTRATION_DAYS; //default to 4 years.
200-
if (request.params.size() > 4) {
201-
if (!ParseInt64(request.params[4].get_str(), &nDays))
202-
throw std::runtime_error("BDAP_SEND_LINK_RPC_ERROR: ERRCODE: 4009 - Error parsing registration days parameter = " + request.params[4].get_str());
203-
}
204-
205-
int64_t nSeconds = nDays * SECONDS_PER_DAY;
206-
txLink.nExpireTime = chainActive.Tip()->GetMedianTimePast() + nSeconds;
199+
txLink.nExpireTime = DEFAULT_LINK_EXPIRE_TIME;
207200
CKeyEd25519 dhtKey;
208201
std::vector<unsigned char> vchSharedPubKey = GetLinkSharedPubKey(privReqDHTKey, entryRecipient.DHTPublicKey);
209202
txLink.SharedPubKey = vchSharedPubKey;
@@ -265,14 +258,18 @@ static UniValue SendLinkRequest(const JSONRPCRequest& request)
265258
CScript scriptData;
266259
scriptData << OP_RETURN << dataEncrypted;
267260

261+
// Get BDAP fees
262+
BDAP::ObjectType bdapType = ObjectType::BDAP_LINK_REQUEST;
263+
int32_t nMonths = 0; // Links do not expire
264+
CAmount monthlyFee, oneTimeFee, depositFee;
265+
if (!GetBDAPFees(OP_BDAP_NEW, OP_BDAP_LINK_REQUEST, bdapType, nMonths, monthlyFee, oneTimeFee, depositFee))
266+
throw JSONRPCError(RPC_BDAP_FEE_UNKNOWN, strprintf("Error calculating BDAP fees."));
267+
LogPrintf("%s -- monthlyFee %d, oneTimeFee %d, depositFee %d\n", __func__, monthlyFee, oneTimeFee, depositFee);
268268
// Send the transaction
269269
CWalletTx wtx;
270-
float fYears = ((float)nDays/365.25);
271-
CAmount nOperationFee = GetBDAPFee(scriptPubKey) * powf(3.1, fYears);
272-
CAmount nDataFee = (GetBDAPFee(scriptData) * powf(3.1, fYears)) + (GetBDAPFee(stealthScript) * powf(3.1, fYears));
273-
274270
bool fUseInstantSend = false;
275-
SendLinkingTransaction(scriptData, scriptPubKey, stealthScript, wtx, nOperationFee, nDataFee, fUseInstantSend);
271+
SendLinkingTransaction(scriptData, scriptPubKey, stealthScript, wtx, oneTimeFee, depositFee, fUseInstantSend);
272+
276273
txLink.txHash = wtx.GetHash();
277274

278275
UniValue oLink(UniValue::VOBJ);
@@ -284,15 +281,14 @@ static UniValue SendLinkRequest(const JSONRPCRequest& request)
284281

285282
static UniValue SendLinkAccept(const JSONRPCRequest& request)
286283
{
287-
if (request.fHelp || request.params.size() < 3 || request.params.size() > 4)
284+
if (request.fHelp || request.params.size() != 3)
288285
throw std::runtime_error(
289286
"link accept userid-from userid-to\n"
290287
"Creates a link accept transaction on the blockchain."
291288
+ HelpRequiringPassphrase() +
292289
"\nLink Send Arguments:\n"
293290
"1. accept account (string) BDAP account accepting the link\n"
294291
"2. requestor account (string) Link requestor's BDAP account.\n"
295-
"3. registration days (int, optional) Number of days to keep the link accept on the blockchain before pruning.\n"
296292
"\nResult:\n"
297293
"{(json object)\n"
298294
" \"Requestor FQDN\" (string) Requestor's BDAP full path\n"
@@ -377,13 +373,7 @@ static UniValue SendLinkAccept(const JSONRPCRequest& request)
377373
if (!CreateSignatureProof(key, strRequestorFQDN, txLinkAccept.SignatureProof))
378374
throw std::runtime_error("BDAP_ACCEPT_LINK_RPC_ERROR: ERRCODE: 4110 - Error signing " + strRequestorFQDN + _("'s signature proof."));
379375

380-
int64_t nDays = DEFAULT_REGISTRATION_DAYS; //default to 4 years.
381-
if (request.params.size() > 3) {
382-
if (!ParseInt64(request.params[3].get_str(), &nDays))
383-
throw std::runtime_error("BDAP_SEND_LINK_RPC_ERROR: ERRCODE: 4111 - Error parsing registration days parameter = " + request.params[3].get_str());
384-
}
385-
int64_t nSeconds = nDays * SECONDS_PER_DAY;
386-
txLinkAccept.nExpireTime = chainActive.Tip()->GetMedianTimePast() + nSeconds;
376+
txLinkAccept.nExpireTime = DEFAULT_LINK_EXPIRE_TIME;
387377
CKeyEd25519 dhtKey;
388378
std::vector<unsigned char> vchSharedPubKey = GetLinkSharedPubKey(privAcceptDHTKey, entryRequestor.DHTPublicKey);
389379
txLinkAccept.SharedPubKey = vchSharedPubKey;
@@ -443,13 +433,17 @@ static UniValue SendLinkAccept(const JSONRPCRequest& request)
443433
CScript scriptData;
444434
scriptData << OP_RETURN << dataEncrypted;
445435

436+
// Get BDAP fees
437+
BDAP::ObjectType bdapType = ObjectType::BDAP_LINK_ACCEPT;
438+
int32_t nMonths = 0; // Links do not expire
439+
CAmount monthlyFee, oneTimeFee, depositFee;
440+
if (!GetBDAPFees(OP_BDAP_NEW, OP_BDAP_LINK_ACCEPT, bdapType, nMonths, monthlyFee, oneTimeFee, depositFee))
441+
throw JSONRPCError(RPC_BDAP_FEE_UNKNOWN, strprintf("Error calculating BDAP fees."));
442+
446443
// Send the transaction
447444
CWalletTx wtx;
448-
float fYears = ((float)nDays/365.25);
449-
CAmount nOperationFee = GetBDAPFee(scriptPubKey) * powf(3.1, fYears);
450-
CAmount nDataFee = (GetBDAPFee(scriptData) * powf(3.1, fYears)) + (GetBDAPFee(stealthScript) * powf(3.1, fYears));
451445
bool fUseInstantSend = false;
452-
SendLinkingTransaction(scriptData, scriptPubKey, stealthScript, wtx, nOperationFee, nDataFee, fUseInstantSend);
446+
SendLinkingTransaction(scriptData, scriptPubKey, stealthScript, wtx, oneTimeFee, depositFee, fUseInstantSend);
453447
txLinkAccept.txHash = wtx.GetHash();
454448

455449
UniValue oLink(UniValue::VOBJ);
@@ -912,10 +906,10 @@ static UniValue DenyLink(const JSONRPCRequest& request)
912906
oLink.push_back(Pair("list_data_size", (int)vchSerializedList.size()));
913907
oLink.push_back(Pair("list_records", nRecords));
914908
uint16_t nVersion = 1; // VGP encryption version 1
915-
uint32_t nExpire = 0; // Does not expire.
909+
uint64_t nExpire = DEFAULT_LINK_EXPIRE_TIME; // Does not expire.
916910
std::vector<std::vector<unsigned char>> vvchPubKeys;
917911
vvchPubKeys.push_back(getKey.GetPubKeyBytes());
918-
CDataRecord newRecord(strOperationType, nTotalSlots, vvchPubKeys, vchSerializedList, nVersion, nExpire, DHT::DataFormat::BinaryBlob);
912+
CDataRecord newRecord(strOperationType, nTotalSlots, vvchPubKeys, vchSerializedList, nVersion, (uint32_t)nExpire, DHT::DataFormat::BinaryBlob);
919913
if (newRecord.HasError())
920914
throw std::runtime_error("BDAP_DENY_LINK_RPC_ERROR: ERRCODE: 4245 - Error creating DHT data entry. " + newRecord.ErrorMessage() + _("\n"));
921915

src/bdap/rpcrawbdap.cpp

+13-16
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#include "bdap/domainentry.h"
66
#include "bdap/domainentrydb.h"
7+
#include "bdap/fees.h"
78
#include "bdap/utils.h"
89
#include "core_io.h" // for EncodeHexTx
9-
#include "dht/ed25519.h"
1010
#include "rpcprotocol.h"
1111
#include "rpcserver.h"
1212
#include "policy/policy.h"
@@ -57,12 +57,11 @@ UniValue createrawbdapaccount(const JSONRPCRequest& request)
5757
CharString vchObjectID = vchFromString(strObjectID);
5858
CharString vchCommonName = vchFromValue(request.params[1]);
5959

60-
int64_t nDays = DEFAULT_REGISTRATION_DAYS; //default to 2 years.
60+
int32_t nMonths = DEFAULT_REGISTRATION_MONTHS; // default to 1 year.
6161
if (request.params.size() >= 3) {
62-
if (!ParseInt64(request.params[2].get_str(), &nDays))
62+
if (!ParseInt32(request.params[2].get_str(), &nMonths))
6363
throw std::runtime_error("BDAP_CREATE_RAW_TX_RPC_ERROR: ERRCODE: 4500 - " + _("Error converting registration days to int"));
6464
}
65-
int64_t nSeconds = nDays * SECONDS_PER_DAY;
6665
BDAP::ObjectType bdapType = ObjectType::BDAP_USER;
6766
if (request.params.size() >= 4) {
6867
int32_t nObjectType;
@@ -89,8 +88,8 @@ UniValue createrawbdapaccount(const JSONRPCRequest& request)
8988
txDomainEntry.fPublicObject = 1; // make entry public
9089
txDomainEntry.nObjectType = GetObjectTypeInt(bdapType);
9190
// Add an extra 8 hours or 28,800 seconds to expire time.
92-
txDomainEntry.nExpireTime = chainActive.Tip()->GetMedianTimePast() + nSeconds + 28800;
93-
91+
txDomainEntry.nExpireTime = AddMonthsToCurrentEpoch((short)nMonths);
92+
9493
// Check if name already exists
9594
if (GetDomainEntry(txDomainEntry.vchFullObjectPath(), txDomainEntry))
9695
throw std::runtime_error("BDAP_CREATE_RAW_TX_RPC_ERROR: ERRCODE: 4503 - " + txDomainEntry.GetFullObjectPath() + _(" entry already exists. Can not add duplicate."));
@@ -121,8 +120,11 @@ UniValue createrawbdapaccount(const JSONRPCRequest& request)
121120
CharString data;
122121
txDomainEntry.Serialize(data);
123122

124-
// TODO (bdap): calculate real BDAP deposit once fee structure is implemented.
125-
CAmount nBDAPDeposit(2 * COIN);
123+
// Get BDAP fees
124+
CAmount monthlyFee, oneTimeFee, depositFee;
125+
if (!GetBDAPFees(OP_BDAP_NEW, OP_BDAP_ACCOUNT_ENTRY, bdapType, nMonths, monthlyFee, oneTimeFee, depositFee))
126+
throw JSONRPCError(RPC_BDAP_FEE_UNKNOWN, strprintf("Error calculating BDAP fees."));
127+
LogPrintf("%s -- monthlyFee %d, oneTimeFee %d, depositFee %d\n", __func__, monthlyFee, oneTimeFee, depositFee);
126128
// Create BDAP operation script
127129
CScript scriptPubKey;
128130
std::vector<unsigned char> vchFullObjectPath = txDomainEntry.vchFullObjectPath();
@@ -133,9 +135,6 @@ UniValue createrawbdapaccount(const JSONRPCRequest& request)
133135
scriptDestination = GetScriptForDestination(walletAddress.Get());
134136
scriptPubKey += scriptDestination;
135137

136-
// TODO (bdap): calculate BDAP registration fee once fee structure is implemented.
137-
CAmount nBDAPRegistrationFee(3 * COIN);
138-
139138
// Create BDAP OP_RETURN script
140139
CScript scriptData;
141140
scriptData << OP_RETURN << data;
@@ -151,19 +150,17 @@ UniValue createrawbdapaccount(const JSONRPCRequest& request)
151150
CScript stealthScript;
152151
stealthScript << OP_RETURN << vStealthData;
153152

154-
// TODO (bdap): decrease this amount after BDAP fee structure is implemented.
155-
CAmount nLinkAmount(30 * COIN);
156-
157153
// Add the Stealth OP return data
158154
CTxOut outStealthData(0, stealthScript);
159155
rawTx.vout.push_back(outStealthData);
160156
// Add the BDAP data output
161-
CTxOut outData(nBDAPRegistrationFee, scriptData);
157+
CTxOut outData(monthlyFee, scriptData);
162158
rawTx.vout.push_back(outData);
163159
// Add the BDAP operation output
164-
CTxOut outOP(nBDAPDeposit, scriptPubKey);
160+
CTxOut outOP(depositFee, scriptPubKey);
165161
rawTx.vout.push_back(outOP);
166162
// Add the BDAP link funds output
163+
CAmount nLinkAmount(0.0400004 * COIN); // enough for 4 links
167164
CTxOut outLinkFunds(nLinkAmount, scriptDest);
168165
rawTx.vout.push_back(outLinkFunds);
169166

src/rpcprotocol.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ enum RPCErrorCode {
8282
RPC_BDAP_SPORK_INACTIVE = -301, //! BDAP spork is not active
8383
RPC_BDAP_DB_ERROR = -302, //! BDAP database error
8484
RPC_BDAP_LINK_MNGR_ERROR = -303, //! BDAP link manager error
85-
RPC_BDAP_ACCOUNT_NOT_FOUND = -304, //! BDAP link manager error
85+
RPC_BDAP_ACCOUNT_NOT_FOUND = -304, //! BDAP account not found
86+
RPC_BDAP_FEE_UNKNOWN = -305, //! BDAP fee can not be calculated
8687
//! DHT errors
8788
RPC_DHT_ERROR = -400, //! Unspecified problem with the DHT
8889
RPC_DHT_NOT_STARTED = -401, //! DHT session not started

0 commit comments

Comments
 (0)