Skip to content

Commit

Permalink
Merge pull request #243 from zathras-crypto/0.0.9-Z-UIAlpha
Browse files Browse the repository at this point in the history
0.0.9 UI
  • Loading branch information
m21 committed Feb 8, 2015
2 parents 718d4c5 + 89f63d4 commit 11bf406
Show file tree
Hide file tree
Showing 49 changed files with 3,725 additions and 157 deletions.
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// Copyright year (2009-this)
// Todo: update this when changing our copyright comments in the source
#define COPYRIGHT_YEAR 2014
#define COPYRIGHT_YEAR 2015

#endif //HAVE_CONFIG_H

Expand Down
83 changes: 74 additions & 9 deletions src/mastercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ static const int nBlockTop = 0;

static int nWaterlineBlock = 0; //

uint64_t global_MSC_total = 0;
uint64_t global_MSC_RESERVED_total = 0;
uint64_t global_metadex_market;
uint64_t global_balance_money_maineco[100000];
uint64_t global_balance_reserved_maineco[100000];
uint64_t global_balance_money_testeco[100000];
Expand Down Expand Up @@ -321,6 +320,27 @@ bool isNonMainNet()
return (TestNet() || RegTest());
}

string FormatPriceMP(double n)
{
string str = strprintf("%lf", n);
// clean up trailing zeros - good for RPC not so much for UI
str.erase ( str.find_last_not_of('0') + 1, std::string::npos );
if (str.length() > 0) { std::string::iterator it = str.end() - 1; if (*it == '.') { str.erase(it); } } //get rid of trailing dot if non decimal
return str;
}

string FormatDivisibleShortMP(int64_t n)
{
int64_t n_abs = (n > 0 ? n : -n);
int64_t quotient = n_abs/COIN;
int64_t remainder = n_abs%COIN;
string str = strprintf("%d.%08d", quotient, remainder);
// clean up trailing zeros - good for RPC not so much for UI
str.erase ( str.find_last_not_of('0') + 1, std::string::npos );
if (str.length() > 0) { std::string::iterator it = str.end() - 1; if (*it == '.') { str.erase(it); } } //get rid of trailing dot if non decimal
return str;
}

// mostly taken from Bitcoin's FormatMoney()
string FormatDivisibleMP(int64_t n, bool fSign)
{
Expand Down Expand Up @@ -362,7 +382,7 @@ AcceptMap mastercore::my_accepts;
CMPSPInfo *mastercore::_my_sps;
CrowdMap mastercore::my_crowds;

static PendingMap my_pending;
PendingMap mastercore::my_pending;

static CMPPending *pendingDelete(const uint256 txid, bool bErase = false)
{
Expand Down Expand Up @@ -399,19 +419,20 @@ static CMPPending *pendingDelete(const uint256 txid, bool bErase = false)
return (CMPPending *) NULL;
}

static int pendingAdd(const uint256 &txid, const string &FromAddress, unsigned int propId, int64_t Amount)
static int pendingAdd(const uint256 &txid, const string &FromAddress, unsigned int propId, int64_t Amount, int64_t type, const string &txDesc)
{
CMPPending pending;

if (msc_debug_verbose3) file_log("%s(%s,%s,%u,%ld), line %d, file: %s\n", __FUNCTION__, txid.GetHex().c_str(), FromAddress.c_str(), propId, Amount, __LINE__, __FILE__);
if (msc_debug_verbose3) file_log("%s(%s,%s,%u,%ld,%d, %s), line %d, file: %s\n", __FUNCTION__, txid.GetHex().c_str(), FromAddress.c_str(), propId, Amount, type, txDesc,__LINE__, __FILE__);

// support for pending, 0-confirm
if (update_tally_map(FromAddress, propId, -Amount, PENDING))
{
pending.src = FromAddress;
pending.amount = Amount;
pending.prop = propId;

pending.desc = txDesc;
pending.type = type;
pending.print(txid);
my_pending.insert(std::make_pair(txid, pending));
}
Expand Down Expand Up @@ -2471,6 +2492,7 @@ int mastercore_init()
printf("Exception deleting folders for --startclean option.\n");
}
}

t_tradelistdb = new CMPTradeList(GetDataDir() / "MP_tradelist", 1<<20, false, fReindex);
s_stolistdb = new CMPSTOList(GetDataDir() / "MP_stolist", 1<<20, false, fReindex);
p_txlistdb = new CMPTxList(GetDataDir() / "MP_txlist", 1<<20, false, fReindex);
Expand Down Expand Up @@ -2692,7 +2714,7 @@ static int64_t selectCoins(const string &FromAddress, CCoinControl &coinControl,
// if referenceamount is set it is needed to be accounted for here too
if (0 < additional) n_max += additional;

LOCK(wallet->cs_wallet);
LOCK2(cs_main, wallet->cs_wallet);

string sAddress = "";

Expand Down Expand Up @@ -2988,6 +3010,11 @@ const unsigned int prop = PropertyID;
return 0;
}

int64_t rawTransactionType = TransactionType;
int64_t rawPropertyID = PropertyID;
int64_t rawPropertyID_2 = PropertyID_2;
int64_t rawAmount = Amount;
int64_t rawAmount_2 = Amount_2;
vector<unsigned char> data;
swapByteOrder32(TransactionType);
swapByteOrder32(PropertyID);
Expand Down Expand Up @@ -3019,7 +3046,46 @@ const unsigned int prop = PropertyID;

if (0 == rc)
{
(void) pendingAdd(txid, FromAddress, prop, amount);
// only simple sends and metadex pending needed at moment
Object txobj;
txobj.push_back(Pair("txid", txid.GetHex()));
txobj.push_back(Pair("sendingaddress", FromAddress));
if (rawTransactionType == MSC_TYPE_SIMPLE_SEND) txobj.push_back(Pair("referenceaddress", ToAddress));
txobj.push_back(Pair("confirmations", 0));
// txobj->push_back(Pair("fee", ValueFromAmount(nFee)));
txobj.push_back(Pair("version", (int64_t)0)); //we only send v0 currently so all pending v0
txobj.push_back(Pair("type_int", (int64_t)rawTransactionType));
bool divisible = false;
bool desiredDivisible = false;
string amountStr;
string amountDStr;
switch (rawTransactionType)
{
case 0: //simple send
txobj.push_back(Pair("type", "Simple send"));
txobj.push_back(Pair("propertyid", rawPropertyID));
divisible = isPropertyDivisible(rawPropertyID);
txobj.push_back(Pair("divisible", divisible));
if (divisible) { amountStr = FormatDivisibleMP(rawAmount); } else { amountStr = FormatIndivisibleMP(rawAmount); }
txobj.push_back(Pair("amount", amountStr));
break;
case 21: //metadex sell
txobj.push_back(Pair("type", "MetaDEx token trade"));
divisible = isPropertyDivisible(rawPropertyID);
desiredDivisible = isPropertyDivisible(rawPropertyID_2);
if (divisible) { amountStr = FormatDivisibleMP(rawAmount); } else { amountStr = FormatIndivisibleMP(rawAmount); }
if (desiredDivisible) { amountDStr = FormatDivisibleMP(rawAmount_2); } else { amountDStr = FormatIndivisibleMP(rawAmount_2); }
txobj.push_back(Pair("amountoffered", amountStr));
txobj.push_back(Pair("propertyoffered", rawPropertyID));
txobj.push_back(Pair("propertyofferedisdivisible", divisible));
txobj.push_back(Pair("amountdesired", amountDStr));
txobj.push_back(Pair("propertydesired", rawPropertyID_2));
txobj.push_back(Pair("propertydesiredisdivisible", desiredDivisible));
txobj.push_back(Pair("action", additional));
break;
}
string txDesc = write_string(Value(txobj), false);
(void) pendingAdd(txid, FromAddress, prop, amount, rawTransactionType, txDesc);
}

return txid;
Expand Down Expand Up @@ -4413,7 +4479,6 @@ std::string new_global_alert_message;
break;

default:

return (PKT_ERROR -100);
}

Expand Down
18 changes: 14 additions & 4 deletions src/mastercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ enum FILETYPES {
#define OMNI_PROPERTY_MSC 1
#define OMNI_PROPERTY_TMSC 2

#include <boost/multiprecision/cpp_dec_float.hpp>
using boost::multiprecision::cpp_dec_float_100;
typedef cpp_dec_float_100 XDOUBLE;

int mp_LogPrintStr(const std::string &str);

/* When we switch to C++11, this can be switched to variadic templates instead
Expand Down Expand Up @@ -175,13 +179,17 @@ TINYFORMAT_FOREACH_ARGNUM(MP_MAKE_ERROR_AND_LOG_FUNC)
//--- CUT HERE ---

// forward declarations
std::string FormatPriceMP(double n);
std::string FormatDivisibleMP(int64_t n, bool fSign = false);
std::string FormatDivisibleShortMP(int64_t);
std::string FormatMP(unsigned int, int64_t n, bool fSign = false);
uint256 send_MP(const string &FromAddress, const string &ToAddress, const string &RedeemAddress, unsigned int PropertyID, uint64_t Amount);
int64_t feeCheck(const string &address);

const std::string ExodusAddress();

extern int msc_debug_ui;

extern CCriticalSection cs_tally;

extern const int msc_debug_dex;
Expand Down Expand Up @@ -468,17 +476,19 @@ class CMPPending
string src; // the FromAddress
unsigned int prop;
int64_t amount;
int64_t type;
string desc; // the description

void print(uint256 txid) const
{
printf("%s : %s %d %ld\n", txid.GetHex().c_str(), src.c_str(), prop, amount);
printf("%s : %s %d %ld %ld %s\n", txid.GetHex().c_str(), src.c_str(), prop, amount, type, desc.c_str());
}

};

extern uint64_t global_MSC_total;
extern uint64_t global_MSC_RESERVED_total;
//temp - only supporting 100,000 properties per eco here, research best way to expand array
//these 4 arrays use about 3MB total memory with 100K properties limit (100000*8*4 bytes)
extern uint64_t global_metadex_market;
extern uint64_t global_balance_money_maineco[100000];
extern uint64_t global_balance_reserved_maineco[100000];
extern uint64_t global_balance_money_testeco[100000];
Expand Down Expand Up @@ -507,7 +517,7 @@ extern CMPTradeList *t_tradelistdb;
extern CMPSTOList *s_stolistdb;

typedef std::map<uint256, CMPPending> PendingMap;

extern PendingMap my_pending;
string strMPProperty(unsigned int i);

int GetHeight(void);
Expand Down
1 change: 1 addition & 0 deletions src/mastercore_dex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ const XDOUBLE desprice = (1/buyersprice); // inverse, to be matched against that

if (msc_debug_metadex1) file_log("==== TRADED !!! %u=%s\n", NewReturn, getTradeReturnType(NewReturn));

// record the trade in MPTradeList
t_tradelistdb->recordTrade(p_older->getHash(), newo->getHash(),
p_older->getAddr(), newo->getAddr(), p_older->getDesProperty(), newo->getDesProperty(), seller_amountGot, buyer_amountGot, newo->getBlock());

Expand Down
2 changes: 1 addition & 1 deletion src/mastercore_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ Value getinfo_MP(const Array& params, bool fHelp)
// other bits of info we want to report should be included here

// provide the mastercore and bitcoin version and if available commit id
infoResponse.push_back(Pair("mastercoreversion", "0.0." + boost::lexical_cast<string>((double)OMNICORE_VERSION_BASE/10) + OMNICORE_VERSION_TYPE ));
infoResponse.push_back(Pair("mastercoreversion", "0.0." + strprintf("%.1f",(double)OMNICORE_VERSION_BASE/10) + OMNICORE_VERSION_TYPE ));
infoResponse.push_back(Pair("bitcoincoreversion", "0." + boost::lexical_cast<string>((int)CLIENT_VERSION/100)));
infoResponse.push_back(Pair("commitinfo", COMMIT_INFO));

Expand Down
26 changes: 26 additions & 0 deletions src/qt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ QT_FORMS_UI = \
forms/sendcoinsdialog.ui \
forms/sendcoinsentry.ui \
forms/sendmpdialog.ui \
forms/txhistorydialog.ui \
forms/lookupspdialog.ui \
forms/lookupaddressdialog.ui \
forms/lookuptxdialog.ui \
forms/signverifymessagedialog.ui \
forms/transactiondescdialog.ui

Expand Down Expand Up @@ -137,6 +141,10 @@ QT_MOC_CPP = \
moc_sendcoinsdialog.cpp \
moc_sendcoinsentry.cpp \
moc_sendmpdialog.cpp \
moc_txhistorydialog.cpp \
moc_lookupspdialog.cpp \
moc_lookupaddressdialog.cpp \
moc_lookuptxdialog.cpp \
moc_signverifymessagedialog.cpp \
moc_splashscreen.cpp \
moc_trafficgraphwidget.cpp \
Expand Down Expand Up @@ -203,6 +211,10 @@ BITCOIN_QT_H = \
sendcoinsdialog.h \
sendcoinsentry.h \
sendmpdialog.h \
txhistorydialog.h \
lookupspdialog.h \
lookupaddressdialog.h \
lookuptxdialog.h \
signverifymessagedialog.h \
splashscreen.h \
trafficgraphwidget.h \
Expand All @@ -221,11 +233,21 @@ BITCOIN_QT_H = \
winshutdownmonitor.h

RES_ICONS = \
res/icons/transaction_invalid.png \
res/icons/mp_exchange.png \
res/icons/mp_toolbox.png \
res/icons/mp_sp.png \
res/icons/mp_balances.png \
res/icons/mp_history.png \
res/icons/mp_home.png \
res/icons/mp_receive.png \
res/icons/mp_send.png \
res/icons/mp_meta_cancelled.png \
res/icons/mp_meta_filled.png \
res/icons/mp_meta_open.png \
res/icons/mp_meta_partialclosed.png \
res/icons/mp_meta_partial.png \
res/icons/mp_meta_pending.png \
res/icons/add.png \
res/icons/address-book.png \
res/icons/bitcoin.ico \
Expand Down Expand Up @@ -310,6 +332,10 @@ BITCOIN_QT_CPP += \
sendcoinsdialog.cpp \
sendcoinsentry.cpp \
sendmpdialog.cpp \
txhistorydialog.cpp \
lookupspdialog.cpp \
lookupaddressdialog.cpp \
lookuptxdialog.cpp \
signverifymessagedialog.cpp \
transactiondesc.cpp \
transactiondescdialog.cpp \
Expand Down
Loading

0 comments on commit 11bf406

Please sign in to comment.