Skip to content

Commit

Permalink
Use constant for both v0 & v1 STO fee calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
zathras-crypto committed Jun 20, 2016
1 parent 6cd1fc2 commit 0769602
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/omnicore/omnicore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3052,7 +3052,7 @@ std::string CMPSTOList::getMySTOReceipts(string filterAddress)
return mySTOReceipts;
}

void CMPSTOList::getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *stoFee)
void CMPSTOList::getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *numRecipients)
{
if (!pdb) return;

Expand All @@ -3066,9 +3066,8 @@ void CMPSTOList::getRecipients(const uint256 txid, string filterAddress, Array *
// iterate through SDB, dropping all records where key is not filterAddress (if filtering)
int count = 0;

// ugly way to do this, really we should store the fee used but for now since we know it is
// always num_addresses * 0.00000001 MSC we can recalculate it on the fly
*stoFee = 0;
// the fee is variable based on version of STO - provide number of recipients and allow calling function to work out fee
*numRecipients = 0;

Slice skey, svalue;
Iterator* it = NewIterator();
Expand All @@ -3082,7 +3081,7 @@ void CMPSTOList::getRecipients(const uint256 txid, string filterAddress, Array *
size_t txidMatch = strValue.find(txid.ToString());
if(txidMatch!=std::string::npos)
{
++*stoFee;
++*numRecipients;
// the txid exists inside the data, this address was a recipient of this STO, check filter and add the details
if(filter)
{
Expand Down
2 changes: 1 addition & 1 deletion src/omnicore/omnicore.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class CMPSTOList : public CDBBase
if (msc_debug_persistence) PrintToLog("CMPSTOList closed\n");
}

void getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *stoFee);
void getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *numRecipients);
std::string getMySTOReceipts(string filterAddress);
int deleteAboveBlock(int blockNum);
void printStats();
Expand Down
13 changes: 8 additions & 5 deletions src/omnicore/rpctxobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "omnicore/pending.h"
#include "omnicore/rpctxobject.h"
#include "omnicore/sp.h"
#include "omnicore/sto.h"
#include "omnicore/tx.h"
#include "omnicore/utilsbitcoin.h"
#include "omnicore/wallettxs.h"
Expand Down Expand Up @@ -500,13 +501,15 @@ void populateRPCTypeActivation(CMPTransaction& omniObj, Object& txobj)
void populateRPCExtendedTypeSendToOwners(const uint256 txid, std::string extendedDetailsFilter, Object& txobj, uint16_t version)
{
Array receiveArray;
uint64_t tmpAmount = 0, stoFee = 0;
uint64_t tmpAmount = 0, stoFee = 0, numRecipients = 0;
LOCK(cs_tally);
s_stolistdb->getRecipients(txid, extendedDetailsFilter, &receiveArray, &tmpAmount, &stoFee);
if (version > MP_TX_PKT_V0) {
stoFee = stoFee * 100; // just awful, but until we start storing the fee somewhere it's a workaround
s_stolistdb->getRecipients(txid, extendedDetailsFilter, &receiveArray, &tmpAmount, &numRecipients);
if (version == MP_TX_PKT_V0) {
stoFee = numRecipients * TRANSFER_FEE_PER_OWNER;
} else {
stoFee = numRecipients * TRANSFER_FEE_PER_OWNER_V1;
}
txobj.push_back(Pair("totalstofee", FormatDivisibleMP(stoFee))); // fee always MSC so always divisible
txobj.push_back(Pair("totalstofee", FormatDivisibleMP(stoFee))); // fee always OMNI so always divisible
txobj.push_back(Pair("recipients", receiveArray));
}

Expand Down

0 comments on commit 0769602

Please sign in to comment.