Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
mastercore.h
Go to the documentation of this file.
1 // global Master Protocol header file
2 // globals consts (DEFINEs for now) should be here
3 //
4 // for now (?) class declarations go here -- work in progress; probably will get pulled out into a separate file, note: some declarations are still in the .cpp file
5 
6 #ifndef _MASTERCOIN
7 #define _MASTERCOIN 1
8 
9 #include "netbase.h"
10 #include "protocol.h"
11 
12 #include "tinyformat.h"
13 
14 #define DISABLE_METADEX
15 
16 #define LOG_FILENAME "mastercore.log"
17 #define INFO_FILENAME "mastercore_crowdsales.log"
18 #define OWNERS_FILENAME "mastercore_owners.log"
19 
20 int const MAX_STATE_HISTORY = 50;
21 
22 #define TEST_ECO_PROPERTY_1 (0x80000003UL)
23 
24 // could probably also use: int64_t maxInt64 = std::numeric_limits<int64_t>::max();
25 // maximum numeric values from the spec:
26 #define MAX_INT_8_BYTES (9223372036854775807UL)
27 
28 // what should've been in the Exodus address for this block if none were spent
29 #define DEV_MSC_BLOCK_290629 (1743358325718)
30 
31 #define SP_STRING_FIELD_LEN 256
32 
33 // in Mastercoin Satoshis (Willetts)
34 #define TRANSFER_FEE_PER_OWNER (1)
35 
36 // some boost formats
37 #define FORMAT_BOOST_TXINDEXKEY "index-tx-%s"
38 #define FORMAT_BOOST_SPKEY "sp-%d"
39 
40 // Master Protocol Transaction (Packet) Version
41 #define MP_TX_PKT_V0 0
42 #define MP_TX_PKT_V1 1
43 
44 // Maximum outputs per BTC Transaction
45 #define MAX_BTC_OUTPUTS 16
46 
47 #define MAX_SHA256_OBFUSCATION_TIMES 255
48 
49 #define PACKET_SIZE_CLASS_A 19
50 #define PACKET_SIZE 31
51 #define MAX_PACKETS 64
52 
53 // Transaction types, from the spec
76 };
77 
78 #define MSC_PROPERTY_TYPE_INDIVISIBLE 1
79 #define MSC_PROPERTY_TYPE_DIVISIBLE 2
80 #define MSC_PROPERTY_TYPE_INDIVISIBLE_REPLACING 65
81 #define MSC_PROPERTY_TYPE_DIVISIBLE_REPLACING 66
82 #define MSC_PROPERTY_TYPE_INDIVISIBLE_APPENDING 129
83 #define MSC_PROPERTY_TYPE_DIVISIBLE_APPENDING 130
84 
85 // block height (MainNet) with which the corresponding transaction is considered valid, per spec
87 // starting block for parsing on TestNet
90  MONEYMAN_REGTEST_BLOCK= 101, // new address to assign MSC & TMSC on RegTest
91  MONEYMAN_TESTNET_BLOCK= 270775, // new address to assign MSC & TMSC on TestNet
93  MSC_DEX_BLOCK = 290630,
94  MSC_SP_BLOCK = 297110,
95  GENESIS_BLOCK = 249498,
97  MSC_STO_BLOCK = 999999,
99  MSC_BET_BLOCK = 999999,
101  P2SH_BLOCK = 322000,
102 };
103 
104 enum FILETYPES {
111 };
112 
113 #define PKT_RETURNED_OBJECT (1000)
114 
115 #define PKT_ERROR ( -9000)
116 #define DEX_ERROR_SELLOFFER (-10000)
117 #define DEX_ERROR_ACCEPT (-20000)
118 #define DEX_ERROR_PAYMENT (-30000)
119 // Smart Properties
120 #define PKT_ERROR_SP (-40000)
121 // Send To Owners
122 #define PKT_ERROR_STO (-50000)
123 #define PKT_ERROR_SEND (-60000)
124 #define PKT_ERROR_TRADEOFFER (-70000)
125 #define PKT_ERROR_METADEX (-80000)
126 #define METADEX_ERROR (-81000)
127 #define PKT_ERROR_TOKENS (-82000)
128 
129 #define OMNI_PROPERTY_BTC 0
130 #define OMNI_PROPERTY_MSC 1
131 #define OMNI_PROPERTY_TMSC 2
132 
133 int mp_LogPrintStr(const std::string &str);
134 
135 /* When we switch to C++11, this can be switched to variadic templates instead
136  * of this macro-based construction (see tinyformat.h).
137  */
138 #define MP_MAKE_ERROR_AND_LOG_FUNC(n) \
139  /* Print to debug.log if -debug=category switch is given OR category is NULL. */ \
140  template<TINYFORMAT_ARGTYPES(n)> \
141  static inline int mp_category_log(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \
142  { \
143  if(!LogAcceptCategory(category)) return 0; \
144  return mp_LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
145  } \
146  template<TINYFORMAT_ARGTYPES(n)> \
147  static inline int mp_log(TINYFORMAT_VARARGS(n)) \
148  { \
149  return mp_LogPrintStr(tfm::format("%s", TINYFORMAT_PASSARGS(n))); \
150  } \
151  template<TINYFORMAT_ARGTYPES(n)> \
152  static inline int mp_log(const char* format, TINYFORMAT_VARARGS(n)) \
153  { \
154  return mp_LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
155  } \
156  template<TINYFORMAT_ARGTYPES(n)> \
157  static inline int file_log(const char* format, TINYFORMAT_VARARGS(n)) \
158  { \
159  return mp_LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
160  } \
161  template<TINYFORMAT_ARGTYPES(n)> \
162  static inline int file_log(TINYFORMAT_VARARGS(n)) \
163  { \
164  return mp_LogPrintStr(tfm::format("%s", TINYFORMAT_PASSARGS(n))); \
165  } \
166  /* Log error and return false */ \
167  template<TINYFORMAT_ARGTYPES(n)> \
168  static inline bool mp_error(const char* format, TINYFORMAT_VARARGS(n)) \
169  { \
170  mp_LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \
171  return false; \
172  }
173 
175 //--- CUT HERE ---
176 
177 // forward declarations
178 std::string FormatDivisibleMP(int64_t n, bool fSign = false);
179 std::string FormatMP(unsigned int, int64_t n, bool fSign = false);
180 uint256 send_MP(const string &FromAddress, const string &ToAddress, const string &RedeemAddress, unsigned int PropertyID, uint64_t Amount);
181 int64_t feeCheck(const string &address);
182 
183 const std::string ExodusAddress();
184 
186 
187 extern const int msc_debug_dex;
188 
190 
191 class CMPTally
192 {
193 private:
194 typedef struct
195 {
196  int64_t balance[TALLY_TYPE_COUNT];
197 } BalanceRecord;
198 
199  typedef std::map<unsigned int, BalanceRecord> TokenMap;
200  TokenMap mp_token;
201  TokenMap::iterator my_it;
202 
203  bool propertyExists(unsigned int which_property) const
204  {
205  const TokenMap::const_iterator it = mp_token.find(which_property);
206 
207  return (it != mp_token.end());
208  }
209 
210 public:
211 
212  unsigned int init()
213  {
214  unsigned int ret = 0;
215 
216  my_it = mp_token.begin();
217  if (my_it != mp_token.end()) ret = my_it->first;
218 
219  return ret;
220  }
221 
222  unsigned int next()
223  {
224  unsigned int ret;
225 
226  if (my_it == mp_token.end()) return 0;
227 
228  ret = my_it->first;
229 
230  ++my_it;
231 
232  return ret;
233  }
234 
235  bool updateMoney(unsigned int which_property, int64_t amount, TallyType ttype)
236  {
237  bool bRet = false;
238  int64_t now64;
239 
240  if (TALLY_TYPE_COUNT <= ttype) return false;
241 
242  LOCK(cs_tally);
243 
244  now64 = mp_token[which_property].balance[ttype];
245 
246  if ((PENDING != ttype) && (0>(now64 + amount)))
247  {
248  }
249  else
250  {
251  now64 += amount;
252  mp_token[which_property].balance[ttype] = now64;
253 
254  bRet = true;
255  }
256 
257  return bRet;
258  }
259 
260  // the constructor -- create an empty tally for an address
262  {
263  my_it = mp_token.begin();
264  }
265 
266  int64_t print(int which_property = OMNI_PROPERTY_MSC, bool bDivisible = true)
267  {
268  int64_t money = 0;
269  int64_t so_r = 0;
270  int64_t a_r = 0;
271  int64_t pending = 0;
272 
273  if (propertyExists(which_property))
274  {
275  money = mp_token[which_property].balance[BALANCE];
276  so_r = mp_token[which_property].balance[SELLOFFER_RESERVE];
277  a_r = mp_token[which_property].balance[ACCEPT_RESERVE];
278  pending = mp_token[which_property].balance[PENDING];
279  }
280 
281  if (bDivisible)
282  {
283  printf("%22s [SO_RESERVE= %22s , ACCEPT_RESERVE= %22s ] %22s\n",
284  FormatDivisibleMP(money, true).c_str(), FormatDivisibleMP(so_r, true).c_str(), FormatDivisibleMP(a_r, true).c_str(), FormatDivisibleMP(pending, true).c_str());
285  }
286  else
287  {
288  printf("%14lu [SO_RESERVE= %14lu , ACCEPT_RESERVE= %14lu ] %14ld\n", money, so_r, a_r, pending);
289  }
290 
291  return (money + so_r + a_r);
292  }
293 
294  int64_t getMoney(unsigned int which_property, TallyType ttype)
295  {
296  int64_t ret64 = 0;
297 
298  if (TALLY_TYPE_COUNT <= ttype) return 0;
299 
300  LOCK(cs_tally);
301 
302  if (propertyExists(which_property)) ret64 = mp_token[which_property].balance[ttype];
303 
304  return ret64;
305  }
306 };
307 
308 /* leveldb-based storage for sto recipients */
310 {
311  protected:
312  // datebase options reused from MPTxList
313  leveldb::Options options;
314  leveldb::ReadOptions readoptions;
315  leveldb::ReadOptions iteroptions;
316  leveldb::WriteOptions writeoptions;
317  leveldb::WriteOptions syncoptions;
318  leveldb::DB *sdb;
319  // statistics
320  unsigned int sWritten;
321  unsigned int sRead;
322 
323 public:
324  CMPSTOList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe):sWritten(0),sRead(0)
325  {
326  options.paranoid_checks = true;
327  options.create_if_missing = true;
328  readoptions.verify_checksums = true;
329  iteroptions.verify_checksums = true;
330  iteroptions.fill_cache = false;
331  syncoptions.sync = true;
332  leveldb::Status status = leveldb::DB::Open(options, path.string(), &sdb);
333  printf("%s(): %s, line %d, file: %s\n", __FUNCTION__, status.ToString().c_str(), __LINE__, __FILE__);
334  }
335 
337  {
338  delete sdb;
339  sdb = NULL;
340  }
341 
342  void getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *stoFee);
343  std::string getMySTOReceipts(string filterAddress);
344  int deleteAboveBlock(int blockNum);
345  void printStats();
346  void printAll();
347  bool exists(string address);
348  void recordSTOReceive(std::string, const uint256&, int, unsigned int, uint64_t);
349 };
350 
351 /* leveldb-based storage for trade history - trades will be listed here atomically with key txid1:txid2 */
353 {
354 protected:
355  // datebase options reused from MPTxList
356  leveldb::Options options;
357  leveldb::ReadOptions readoptions;
358  leveldb::ReadOptions iteroptions;
359  leveldb::WriteOptions writeoptions;
360  leveldb::WriteOptions syncoptions;
361  leveldb::DB *tdb;
362  // statistics
363  unsigned int tWritten;
364  unsigned int tRead;
365 
366 public:
367  CMPTradeList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe):tWritten(0),tRead(0)
368  {
369  options.paranoid_checks = true;
370  options.create_if_missing = true;
371  readoptions.verify_checksums = true;
372  iteroptions.verify_checksums = true;
373  iteroptions.fill_cache = false;
374  syncoptions.sync = true;
375  leveldb::Status status = leveldb::DB::Open(options, path.string(), &tdb);
376  printf("%s(): %s, line %d, file: %s\n", __FUNCTION__, status.ToString().c_str(), __LINE__, __FILE__);
377  }
378 
380  {
381  delete tdb;
382  tdb = NULL;
383  }
384 
385  void recordTrade(const uint256 txid1, const uint256 txid2, string address1, string address2, unsigned int prop1, unsigned int prop2, uint64_t amount1, uint64_t amount2, int blockNum);
386  int deleteAboveBlock(int blockNum);
387  bool exists(const uint256 &txid);
388  void printStats();
389  void printAll();
390  bool getMatchingTrades(const uint256 txid, unsigned int propertyId, Array *tradeArray, uint64_t *totalSold, uint64_t *totalBought);
391  int getMPTradeCountTotal();
392 };
393 
394 /* leveldb-based storage for the list of ALL Master Protocol TXIDs (key) with validity bit & other misc data as value */
396 {
397 protected:
398  // database options used
399  leveldb::Options options;
400 
401  // options used when reading from the database
402  leveldb::ReadOptions readoptions;
403 
404  // options used when iterating over values of the database
405  leveldb::ReadOptions iteroptions;
406 
407  // options used when writing to the database
408  leveldb::WriteOptions writeoptions;
409 
410  // options used when sync writing to the database
411  leveldb::WriteOptions syncoptions;
412 
413  // the database itself
414  leveldb::DB *pdb;
415 
416  // statistics
417  unsigned int nWritten;
418  unsigned int nRead;
419 
420 public:
421  CMPTxList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe):nWritten(0),nRead(0)
422  {
423  options.paranoid_checks = true;
424  options.create_if_missing = true;
425 
426  readoptions.verify_checksums = true;
427  iteroptions.verify_checksums = true;
428  iteroptions.fill_cache = false;
429  syncoptions.sync = true;
430 
431  leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb);
432 
433  printf("%s(): %s, line %d, file: %s\n", __FUNCTION__, status.ToString().c_str(), __LINE__, __FILE__);
434  }
435 
437  {
438  delete pdb;
439  pdb = NULL;
440  }
441 
442  void recordTX(const uint256 &txid, bool fValid, int nBlock, unsigned int type, uint64_t nValue);
443  void recordPaymentTX(const uint256 &txid, bool fValid, int nBlock, unsigned int vout, unsigned int propertyId, uint64_t nValue, string buyer, string seller);
444  void recordMetaDExCancelTX(const uint256 &txidMaster, const uint256 &txidSub, bool fValid, int nBlock, unsigned int propertyId, uint64_t nValue);
445 
446  string getKeyValue(string key);
447  uint256 findMetaDExCancel(const uint256 txid);
448  int getNumberOfPurchases(const uint256 txid);
449  int getNumberOfMetaDExCancels(const uint256 txid);
450  bool getPurchaseDetails(const uint256 txid, int purchaseNumber, string *buyer, string *seller, uint64_t *vout, uint64_t *propertyId, uint64_t *nValue);
452  int getMPTransactionCountBlock(int block);
453 
454  bool exists(const uint256 &txid);
455  bool getTX(const uint256 &txid, string &value);
456 
457  int setLastAlert(int blockHeight);
458 
459  void printStats();
460  void printAll();
461 
462  bool isMPinBlockRange(int, int, bool);
463 };
464 
466 {
467 public:
468  string src; // the FromAddress
469  unsigned int prop;
470  int64_t amount;
471 
472  void print(uint256 txid) const
473  {
474  printf("%s : %s %d %ld\n", txid.GetHex().c_str(), src.c_str(), prop, amount);
475  }
476 };
477 
478 extern uint64_t global_MSC_total;
479 extern uint64_t global_MSC_RESERVED_total;
480 //temp - only supporting 100,000 properties per eco here, research best way to expand array
481 //these 4 arrays use about 3MB total memory with 100K properties limit (100000*8*4 bytes)
482 extern uint64_t global_balance_money_maineco[100000];
483 extern uint64_t global_balance_reserved_maineco[100000];
484 extern uint64_t global_balance_money_testeco[100000];
485 extern uint64_t global_balance_reserved_testeco[100000];
486 
487 int mastercore_init(void);
488 
489 int64_t getMPbalance(const string &Address, unsigned int property, TallyType ttype);
490 int64_t getUserAvailableMPbalance(const string &Address, unsigned int property);
491 bool IsMyAddress(const std::string &address);
492 
493 string getLabel(const string &address);
494 
495 int mastercore_handler_disc_begin(int nBlockNow, CBlockIndex const * pBlockIndex);
496 int mastercore_handler_disc_end(int nBlockNow, CBlockIndex const * pBlockIndex);
497 int mastercore_handler_block_begin(int nBlockNow, CBlockIndex const * pBlockIndex);
498 int mastercore_handler_block_end(int nBlockNow, CBlockIndex const * pBlockIndex, unsigned int);
499 int mastercore_handler_tx(const CTransaction &tx, int nBlock, unsigned int idx, CBlockIndex const *pBlockIndex );
500 int mastercore_save_state( CBlockIndex const *pBlockIndex );
501 
502 namespace mastercore
503 {
504 extern std::map<string, CMPTally> mp_tally_map;
505 extern CMPTxList *p_txlistdb;
507 extern CMPSTOList *s_stolistdb;
508 
509 typedef std::map<uint256, CMPPending> PendingMap;
510 
511 string strMPProperty(unsigned int i);
512 
513 int GetHeight(void);
514 uint32_t GetLatestBlockTime(void);
515 bool isPropertyDivisible(unsigned int propertyId);
516 string getPropertyName(unsigned int propertyId);
517 bool isCrowdsaleActive(unsigned int propertyId);
518 bool isCrowdsalePurchase(uint256 txid, string address, int64_t *propertyId = NULL, int64_t *userTokens = NULL, int64_t *issuerTokens = NULL);
519 bool isMPinBlockRange(int starting_block, int ending_block, bool bDeleteFound);
520 std::string FormatIndivisibleMP(int64_t n);
521 
522 int ClassB_send(const string &senderAddress, const string &receiverAddress, const string &redemptionAddress, const vector<unsigned char> &data, uint256 & txid, int64_t additional = 0);
523 
524 uint256 send_INTERNAL_1packet(const string &FromAddress, const string &ToAddress, const string &RedeemAddress, unsigned int PropertyID, uint64_t Amount,
525  unsigned int PropertyID_2, uint64_t Amount_2, unsigned int TransactionType, int64_t additional, int *error_code = NULL);
526 
527 bool isTestEcosystemProperty(unsigned int property);
528 bool isMainEcosystemProperty(unsigned int property);
529 
530 CMPTally *getTally(const string & address);
531 
532 bool isMetaDExOfferActive(const uint256 txid, unsigned int propertyId);
533 int64_t getTotalTokens(unsigned int propertyId, int64_t *n_owners_total = NULL);
534 bool checkExpiredAlerts(unsigned int curBlock, uint64_t curTime);
535 int set_wallet_totals();
536 
537 char *c_strMasterProtocolTXType(int i);
538 
539 bool isTransactionTypeAllowed(int txBlock, unsigned int txProperty, unsigned int txType, unsigned short version, bool bAllowNullProperty = false);
540 
541 bool getValidMPTX(const uint256 &txid, int *block = NULL, unsigned int *type = NULL, uint64_t *nAmended = NULL);
542 
543 bool update_tally_map(string who, unsigned int which_currency, int64_t amount, TallyType ttype);
544 std::string getMasterCoreAlertString();
545 }
546 
547 #endif
548 
uint32_t GetLatestBlockTime(void)
Definition: mastercore.cpp:168
uint256 send_MP(const string &FromAddress, const string &ToAddress, const string &RedeemAddress, unsigned int PropertyID, uint64_t Amount)
int getNumberOfPurchases(const uint256 txid)
uint64_t global_balance_reserved_maineco[100000]
Definition: mastercore.cpp:91
leveldb::DB * pdb
Definition: mastercore.h:414
unsigned int nWritten
Definition: mastercore.h:417
bool exists(const uint256 &txid)
int64_t getMoney(unsigned int which_property, TallyType ttype)
Definition: mastercore.h:294
bool isTestEcosystemProperty(unsigned int property)
Definition: mastercore.cpp:495
leveldb::Options options
Definition: mastercore.h:356
int deleteAboveBlock(int blockNum)
int ClassB_send(const string &senderAddress, const string &receiverAddress, const string &redemptionAddress, const vector< unsigned char > &data, uint256 &txid, int64_t additional=0)
bool getTX(const uint256 &txid, string &value)
int mastercore_handler_disc_begin(int nBlockNow, CBlockIndex const *pBlockIndex)
bool isMainEcosystemProperty(unsigned int property)
Definition: mastercore.cpp:502
int64_t getMPbalance(const string &Address, unsigned int property, TallyType ttype)
Definition: mastercore.cpp:437
bool exists(const uint256 &txid)
uint64_t global_MSC_RESERVED_total
Definition: mastercore.cpp:89
int64_t getUserAvailableMPbalance(const string &Address, unsigned int property)
Definition: mastercore.cpp:455
uint64_t global_balance_reserved_testeco[100000]
Definition: mastercore.cpp:93
leveldb::DB * tdb
Definition: mastercore.h:361
bool exists(string address)
bool update_tally_map(string who, unsigned int which_currency, int64_t amount, TallyType ttype)
Definition: mastercore.cpp:687
int64_t amount
Definition: mastercore.h:470
bool getMatchingTrades(const uint256 txid, unsigned int propertyId, Array *tradeArray, uint64_t *totalSold, uint64_t *totalBought)
void recordMetaDExCancelTX(const uint256 &txidMaster, const uint256 &txidSub, bool fValid, int nBlock, unsigned int propertyId, uint64_t nValue)
TokenMap mp_token
Definition: mastercore.h:200
const int msc_debug_dex
Definition: mastercore.cpp:109
bool propertyExists(unsigned int which_property) const
Definition: mastercore.h:203
CMPTradeList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe)
Definition: mastercore.h:367
CMPTally * getTally(const string &address)
Definition: mastercore.cpp:425
FILETYPES
Definition: mastercore.h:104
STL namespace.
void getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *stoFee)
int mastercore_handler_block_begin(int nBlockNow, CBlockIndex const *pBlockIndex)
string getLabel(const string &address)
uint64_t global_balance_money_maineco[100000]
Definition: mastercore.cpp:90
int mastercore_init(void)
int mastercore_save_state(CBlockIndex const *pBlockIndex)
#define OMNI_PROPERTY_MSC
Definition: mastercore.h:130
unsigned int init()
Definition: mastercore.h:212
leveldb::WriteOptions writeoptions
Definition: mastercore.h:359
leveldb::ReadOptions iteroptions
Definition: mastercore.h:405
string src
Definition: mastercore.h:468
bool isPropertyDivisible(unsigned int propertyId)
int deleteAboveBlock(int blockNum)
void recordPaymentTX(const uint256 &txid, bool fValid, int nBlock, unsigned int vout, unsigned int propertyId, uint64_t nValue, string buyer, string seller)
uint64_t global_balance_money_testeco[100000]
Definition: mastercore.cpp:92
int64_t print(int which_property=OMNI_PROPERTY_MSC, bool bDivisible=true)
Definition: mastercore.h:266
int getNumberOfMetaDExCancels(const uint256 txid)
char * c_strMasterProtocolTXType(int i)
TransactionType
Definition: mastercore.h:54
bool isCrowdsalePurchase(uint256 txid, string address, int64_t *propertyId=NULL, int64_t *userTokens=NULL, int64_t *issuerTokens=NULL)
bool getValidMPTX(const uint256 &txid, int *block=NULL, unsigned int *type=NULL, uint64_t *nAmended=NULL)
leveldb::WriteOptions syncoptions
Definition: mastercore.h:317
leveldb::WriteOptions syncoptions
Definition: mastercore.h:360
unsigned int tRead
Definition: mastercore.h:364
unsigned int next()
Definition: mastercore.h:222
leveldb::ReadOptions readoptions
Definition: mastercore.h:314
int mastercore_handler_tx(const CTransaction &tx, int nBlock, unsigned int idx, CBlockIndex const *pBlockIndex)
bool isMPinBlockRange(int, int, bool)
int getMPTradeCountTotal()
bool isCrowdsaleActive(unsigned int propertyId)
CCriticalSection cs_tally
Definition: mastercore.cpp:357
CMPTradeList * t_tradelistdb
Definition: mastercore.cpp:156
#define LOCK(cs)
Definition: sync.h:156
unsigned int sRead
Definition: mastercore.h:321
leveldb::ReadOptions readoptions
Definition: mastercore.h:402
unsigned int tWritten
Definition: mastercore.h:363
int setLastAlert(int blockHeight)
CMPTxList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe)
Definition: mastercore.h:421
bool updateMoney(unsigned int which_property, int64_t amount, TallyType ttype)
Definition: mastercore.h:235
unsigned int sWritten
Definition: mastercore.h:320
void printAll()
int mastercore_handler_block_end(int nBlockNow, CBlockIndex const *pBlockIndex, unsigned int)
bool isMPinBlockRange(int starting_block, int ending_block, bool bDeleteFound)
std::map< string, CMPTally > mp_tally_map
Definition: mastercore.cpp:423
void printStats()
bool isMetaDExOfferActive(const uint256 txid, unsigned int propertyId)
Definition: mastercore.cpp:509
int GetHeight(void)
Definition: mastercore.cpp:160
void print(uint256 txid) const
Definition: mastercore.h:472
void recordSTOReceive(std::string, const uint256 &, int, unsigned int, uint64_t)
leveldb::Options options
Definition: mastercore.h:399
TokenMap::iterator my_it
Definition: mastercore.h:201
uint256 send_INTERNAL_1packet(const string &FromAddress, const string &ToAddress, const string &RedeemAddress, unsigned int PropertyID, uint64_t Amount, unsigned int PropertyID_2, uint64_t Amount_2, unsigned int TransactionType, int64_t additional, int *error_code=NULL)
std::map< unsigned int, BalanceRecord > TokenMap
Definition: mastercore.h:199
std::string GetHex() const
Definition: uint256.h:297
uint256 findMetaDExCancel(const uint256 txid)
leveldb::DB * sdb
Definition: mastercore.h:318
int64_t getTotalTokens(unsigned int propertyId, int64_t *n_owners_total=NULL)
Definition: mastercore.cpp:646
CMPTxList * p_txlistdb
Definition: mastercore.cpp:155
string getKeyValue(string key)
string getPropertyName(unsigned int propertyId)
leveldb::WriteOptions writeoptions
Definition: mastercore.h:408
leveldb::ReadOptions iteroptions
Definition: mastercore.h:315
256-bit unsigned integer
Definition: uint256.h:531
bool getPurchaseDetails(const uint256 txid, int purchaseNumber, string *buyer, string *seller, uint64_t *vout, uint64_t *propertyId, uint64_t *nValue)
void printStats()
leveldb::ReadOptions readoptions
Definition: mastercore.h:357
int mastercore_handler_disc_end(int nBlockNow, CBlockIndex const *pBlockIndex)
string strMPProperty(unsigned int i)
Definition: mastercore.cpp:298
int set_wallet_totals()
Definition: mastercore.cpp:943
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: main.h:688
void recordTX(const uint256 &txid, bool fValid, int nBlock, unsigned int type, uint64_t nValue)
void printStats()
int getMPTransactionCountBlock(int block)
CMPSTOList * s_stolistdb
Definition: mastercore.cpp:157
BLOCKHEIGHTRESTRICTIONS
Definition: mastercore.h:86
std::string FormatIndivisibleMP(int64_t n)
Definition: mastercore.cpp:343
leveldb::WriteOptions writeoptions
Definition: mastercore.h:316
unsigned int prop
Definition: mastercore.h:469
#define MP_MAKE_ERROR_AND_LOG_FUNC(n)
Definition: mastercore.h:138
int const MAX_STATE_HISTORY
Definition: mastercore.h:20
leveldb::Options options
Definition: mastercore.h:313
CMPSTOList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe)
Definition: mastercore.h:324
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: core.h:183
std::string getMasterCoreAlertString()
Definition: mastercore.cpp:530
unsigned int nRead
Definition: mastercore.h:418
static const CCheckpointData data
Definition: checkpoints.cpp:56
int getMPTransactionCountTotal()
bool checkExpiredAlerts(unsigned int curBlock, uint64_t curTime)
Definition: mastercore.cpp:535
int mp_LogPrintStr(const std::string &str)
Definition: mastercore.cpp:204
leveldb::ReadOptions iteroptions
Definition: mastercore.h:358
#define TINYFORMAT_FOREACH_ARGNUM(m)
Definition: tinyformat.h:429
void printAll()
int64_t feeCheck(const string &address)
std::string FormatMP(unsigned int, int64_t n, bool fSign=false)
Definition: mastercore.cpp:349
std::map< uint256, CMPPending > PendingMap
Definition: mastercore.h:509
bool IsMyAddress(const std::string &address)
const std::string ExodusAddress()
std::string getMySTOReceipts(string filterAddress)
bool isTransactionTypeAllowed(int txBlock, unsigned int txProperty, unsigned int txType, unsigned short version, bool bAllowNullProperty=false)
Definition: mastercore.cpp:859
leveldb::WriteOptions syncoptions
Definition: mastercore.h:411
void recordTrade(const uint256 txid1, const uint256 txid2, string address1, string address2, unsigned int prop1, unsigned int prop2, uint64_t amount1, uint64_t amount2, int blockNum)
std::string FormatDivisibleMP(int64_t n, bool fSign=false)
Definition: mastercore.cpp:325
uint64_t global_MSC_total
Definition: mastercore.cpp:88
TallyType
Definition: mastercore.h:189