17 #include <boost/algorithm/string.hpp>
18 #include <boost/algorithm/string/find.hpp>
19 #include <boost/lexical_cast.hpp>
20 #include <boost/format.hpp>
22 #include "json/json_spirit_utils.h"
23 #include "json/json_spirit_value.h"
25 #include "leveldb/db.h"
26 #include "leveldb/write_batch.h"
28 #include <openssl/sha.h>
31 using namespace boost;
49 property_obj.push_back(Pair(
"name", sProperty.
name));
50 property_obj.push_back(Pair(
"category", sProperty.
category));
51 property_obj.push_back(Pair(
"subcategory", sProperty.
subcategory));
52 property_obj.push_back(Pair(
"data", sProperty.
data));
53 property_obj.push_back(Pair(
"url", sProperty.
url));
54 property_obj.push_back(Pair(
"divisible", sProperty.
isDivisible()));
70 metadex_obj.push_back(Pair(
"address", obj.
getAddr()));
72 metadex_obj.push_back(Pair(
"ecosystem", strEcosystem));
73 metadex_obj.push_back(Pair(
"property_owned", (uint64_t) obj.
getProperty()));
74 metadex_obj.push_back(Pair(
"property_desired", (uint64_t) obj.
getDesProperty()));
75 metadex_obj.push_back(Pair(
"property_owned_divisible", spProperty.
isDivisible()));
76 metadex_obj.push_back(Pair(
"property_desired_divisible", spDesProperty.
isDivisible()));
77 metadex_obj.push_back(Pair(
"amount_original", strAmountOriginal));
78 metadex_obj.push_back(Pair(
"amount_desired", strAmountDesired));
79 metadex_obj.push_back(Pair(
"action", (
int) obj.
getAction()));
80 metadex_obj.push_back(Pair(
"block", obj.
getBlock()));
81 metadex_obj.push_back(Pair(
"blocktime", obj.
getBlockTime()));
89 std::sort (vMetaDexObjs.begin(), vMetaDexObjs.end(), compareByHeight);
91 for (std::vector<CMPMetaDEx>::const_iterator it = vMetaDexObjs.begin(); it != vMetaDexObjs.end(); ++it) {
95 response.push_back(metadex_obj);
99 void BalanceToJSON(
const std::string& address, uint32_t property, Object& balance_obj)
104 int64_t nReserved = 0;
109 balance_obj.push_back(Pair(
"balance",
FormatMP(property, nAvailable)));
110 balance_obj.push_back(Pair(
"reserved",
FormatMP(property, nReserved)));
114 Value
mscrpc(
const Array& params,
bool fHelp)
117 int extra2 = 0, extra3 = 0;
119 if (fHelp || params.size() > 3)
122 "\nReturns the number of blocks in the longest block chain.\n"
124 "n (numeric) The current block count\n"
130 if (0 < params.size()) extra =
atoi(params[0].get_str());
131 if (1 < params.size()) extra2 =
atoi(params[1].get_str());
132 if (2 < params.size()) extra3 =
atoi(params[2].get_str());
134 printf(
"%s(extra=%d,extra2=%d,extra3=%d)\n", __FUNCTION__, extra, extra2, extra3);
151 printf(
"%34s => ", (my_it->first).c_str());
152 total += (my_it->second).print(extra2, bDivisible);
155 printf(
"total for property %d = %X is %s\n", extra2, extra2,
FormatDivisibleMP(total).c_str());
178 printf(
"%34s => ", (my_it->first).c_str());
179 (my_it->second).print(extra2);
181 (my_it->second).init();
182 while (0 != (
id = (my_it->second).next()))
184 printf(
"Id: %u=0x%X ",
id,
id);
193 (it->second).print(it->first);
198 printf(
"isMPinBlockRange(%d,%d)=%s\n", extra2, extra3,
isMPinBlockRange(extra2, extra3,
false) ?
"YES":
"NO");
223 if (fHelp || params.size() != 2)
225 "getbalance_MP \"address\" propertyid\n"
226 "\nReturns the Master Protocol balance for a given address and currency/property.\n"
228 "n (numeric) The applicable balance for address:currency/propertyID pair\n"
230 ">mastercored getbalance_MP 1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P 1\n"
232 std::string address = params[0].get_str();
233 int64_t tmpPropertyId = params[1].get_int64();
234 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
237 unsigned int propertyId =
int(tmpPropertyId);
250 Value
send_MP(
const Array& params,
bool fHelp)
252 if (fHelp || params.size() < 4 || params.size() > 6)
254 "send_MP \"fromaddress\" \"toaddress\" propertyid \"amount\" ( \"redeemaddress\" \"referenceamount\" )\n"
255 "\nCreates and broadcasts a simple send for a given amount and currency/property ID.\n"
257 "FromAddress : the address to send from\n"
258 "ToAddress : the address to send to\n"
259 "PropertyID : the id of the smart property to send\n"
260 "Amount : the amount to send\n"
261 "RedeemAddress : (optional) the address that can redeem the bitcoin outputs. Defaults to FromAddress\n"
262 "ReferenceAmount:(optional)\n"
264 "txid (string) The transaction ID of the sent transaction\n"
266 ">mastercored send_MP 1FromAddress 1ToAddress PropertyID Amount 1RedeemAddress\n"
269 std::string FromAddress = (params[0].get_str());
270 std::string ToAddress = (params[1].get_str());
271 std::string RedeemAddress = (params.size() > 4) ? (params[4].get_str()):
"";
273 int64_t tmpPropertyId = params[2].get_int64();
274 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
276 unsigned int propertyId =
int(tmpPropertyId);
285 string strAmount = params[3].get_str();
286 int64_t Amount = 0, additional = 0;
292 std::string strAdditional = (params.size() > 5) ? (params[5].get_str()):
"0";
295 int n = params.size();
296 printf(
"#: %d, additional= %ld\n", n, additional);
298 if ((0.01 *
COIN) < additional)
314 if (fHelp || params.size() < 3 || params.size() > 4)
316 "sendtoowners_MP \"fromaddress\" propertyid \"amount\" ( \"redeemaddress\" )\n"
317 "\nCreates and broadcasts a send-to-owners transaction for a given amount and currency/property ID.\n"
319 "FromAddress : the address to send from\n"
320 "PropertyID : the id of the smart property to send\n"
321 "Amount (string): the amount to send\n"
322 "RedeemAddress : (optional) the address that can redeem the bitcoin outputs. Defaults to FromAddress\n"
324 "txid (string) The transaction ID of the sent transaction\n"
326 ">mastercored send_MP 1FromAddress PropertyID Amount 1RedeemAddress\n"
329 std::string FromAddress = (params[0].get_str());
330 std::string RedeemAddress = (params.size() > 3) ? (params[3].get_str()):
"";
332 int64_t tmpPropertyId = params[1].get_int64();
333 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
336 unsigned int propertyId =
int(tmpPropertyId);
347 string strAmount = params[2].get_str();
369 if (fHelp || params.size() < 2 || params.size() > 5)
371 "sendrawtx_MP \"fromaddress\" \"hexstring\" ( \"toaddress\" \"redeemaddress\" \"referenceamount\" )\n"
372 "\nCreates and broadcasts a raw Master protocol transaction.\n"
374 "FromAddress : the address to send from\n"
375 "RawTX : the hex-encoded raw transaction\n"
376 "ToAddress : the address to send to. This should be empty: (\"\") for transaction\n"
377 " types that do not use a reference/to address\n"
378 "RedeemAddress : (optional) the address that can redeem the bitcoin outputs. Defaults to FromAddress\n"
379 "ReferenceAmount:(optional)\n"
381 "txid (string) The transaction ID of the sent transaction\n"
383 ">mastercored sendrawtx_MP 1FromAddress <tx bytes hex> 1ToAddress 1RedeemAddress\n"
386 std::string fromAddress = (params[0].get_str());
387 std::string hexTransaction = (params[1].get_str());
388 std::string toAddress = (params.size() > 2) ? (params[2].get_str()):
"";
389 std::string redeemAddress = (params.size() > 3) ? (params[3].get_str()):
"";
391 int64_t referenceAmount = 0;
393 if (params.size() > 4)
394 referenceAmount =
StrToInt64(params[4].get_str(),
true);
399 int rc =
ClassB_send(fromAddress, toAddress, redeemAddress, data, newTX, referenceAmount);
410 if (fHelp || params.size() != 1)
412 "getallbalancesforid_MP propertyid\n"
413 "\nGet a list of balances for a given currency or property identifier.\n"
415 "1. propertyid (int, required) The property identifier\n"
418 " \"address\" : \"1Address\", (string) The address\n"
419 " \"balance\" : \"x.xxx\", (string) The available balance of the address\n"
420 " \"reserved\" : \"x.xxx\", (string) The amount reserved by sell offers and accepts\n"
428 int64_t tmpPropertyId = params[0].get_int64();
429 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
432 unsigned int propertyId =
int(tmpPropertyId);
443 bool includeAddress=
false;
444 string address = (my_it->first).c_str();
445 (my_it->second).init();
446 while (0 != (
id = (my_it->second).next()))
448 if(
id==propertyId) { includeAddress=
true;
break; }
451 if (!includeAddress)
continue;
454 balance_obj.push_back(Pair(
"address", address));
457 response.push_back(balance_obj);
466 if (fHelp || params.size() != 1)
468 "getallbalancesforaddress_MP \"address\"\n"
469 "\nGet a list of all balances for a given address.\n"
471 "1. address (string, required) The address\n"
474 " \"propertyid\" : x, (numeric) the property id\n"
475 " \"balance\" : \"x.xxx\", (string) The available balance of the address\n"
476 " \"reserved\" : \"x.xxx\", (string) The amount reserved by sell offers and accepts\n"
484 address = params[0].get_str();
492 if (NULL == addressTally)
495 addressTally->
init();
498 while (0 != (propertyId = addressTally->
next()))
501 balance_obj.push_back(Pair(
"propertyid", propertyId));
504 response.push_back(balance_obj);
512 if (fHelp || params.size() != 1)
514 "getproperty_MP propertyid\n"
515 "\nGet details for a property identifier.\n"
517 "1. propertyid (int, required) The property identifier\n"
520 " \"name\" : \"PropertyName\", (string) the property name\n"
521 " \"category\" : \"PropertyCategory\", (string) the property category\n"
522 " \"subcategory\" : \"PropertySubCategory\", (string) the property subcategory\n"
523 " \"data\" : \"PropertyData\", (string) the property data\n"
524 " \"url\" : \"PropertyURL\", (string) the property URL\n"
525 " \"divisible\" : false, (boolean) whether the property is divisible\n"
526 " \"issuer\" : \"1Address\", (string) the property issuer address\n"
527 " \"issueancetype\" : \"Fixed\", (string) the property method of issuance\n"
528 " \"totaltokens\" : x (string) the total number of tokens in existence\n"
536 int64_t tmpPropertyId = params[0].get_int64();
537 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
540 unsigned int propertyId =
int(tmpPropertyId);
547 std::string strCreationHash = sp.
txid.
GetHex();
548 std::string strTotalTokens =
FormatMP(propertyId, nTotalTokens);
551 response.push_back(Pair(
"propertyid", (uint64_t) propertyId));
553 response.push_back(Pair(
"issuer", sp.
issuer));
554 response.push_back(Pair(
"creationtxid", strCreationHash));
555 response.push_back(Pair(
"fixedissuance", sp.
fixed));
556 response.push_back(Pair(
"totaltokens", strTotalTokens));
565 "listproperties_MP\n"
566 "\nLists all smart properties.\n"
569 " \"name\" : \"PropertyName\", (string) the property name\n"
570 " \"category\" : \"PropertyCategory\", (string) the property category\n"
571 " \"subcategory\" : \"PropertySubCategory\", (string) the property subcategory\n"
572 " \"data\" : \"PropertyData\", (string) the property data\n"
573 " \"url\" : \"PropertyURL\", (string) the property URL\n"
574 " \"divisible\" : false, (boolean) whether the property is divisible\n"
586 for (propertyId = 1; propertyId<nextSPID; propertyId++)
592 property_obj.push_back(Pair(
"propertyid", propertyId));
595 response.push_back(property_obj);
606 property_obj.push_back(Pair(
"propertyid", propertyId));
609 response.push_back(property_obj);
617 if (fHelp || params.size() < 1 )
619 "getcrowdsale_MP propertyid\n"
620 "\nGet information about a crowdsale for a property identifier.\n"
622 "1. propertyid (int, required) The property identifier\n"
625 " \"name\" : \"PropertyName\", (string) the property name\n"
626 " \"active\" : false, (boolean) whether the crowdsale is active\n"
627 " \"issuer\" : \"1Address\", (string) the issuer address\n"
628 " \"creationtxid\" : \"txid\", (string) the transaction that created the crowdsale\n"
629 " \"propertyiddesired\" : x, (numeric) the property ID desired\n"
630 " \"tokensperunit\" : x, (numeric) the number of tokens awarded per unit\n"
631 " \"earlybonus\" : x, (numeric) the percentage per week early bonus applied\n"
632 " \"percenttoissuer\" : x, (numeric) the percentage awarded to the issuer\n"
633 " \"starttime\" : xxx, (numeric) the start time of the crowdsale\n"
634 " \"deadline\" : xxx, (numeric) the time the crowdsale will automatically end\n"
635 " \"closedearly\" : false, (boolean) whether the crowdsale was ended early\n"
636 " \"maxtokens\" : false, (boolean) whether the crowdsale was ended early due to maxing the token count\n"
637 " \"endedtime\" : xxx, (numeric) the time the crowdsale ended\n"
638 " \"closetx\" : \"txid\", (string) the transaction that closed the crowdsale\n"
646 int64_t tmpPropertyId = params[0].get_int64();
647 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
650 unsigned int propertyId =
int(tmpPropertyId);
656 bool showVerbose =
false;
657 if (params.size() > 1) showVerbose = params[1].get_bool();
659 bool fixedIssuance = sp.
fixed;
660 bool manualIssuance = sp.
manual;
661 if (fixedIssuance || manualIssuance)
678 string propertyName = sp.
name;
687 string issuer = sp.
issuer;
688 int64_t amountRaised = 0;
693 std::map<std::string, std::vector<uint64_t> > database;
697 bool crowdFound =
false;
702 if (tmpPropertyId == propertyId)
720 Array participanttxs;
721 std::map<std::string, std::vector<uint64_t> >::const_iterator it;
722 for(it = database.begin(); it != database.end(); it++)
724 Object participanttx;
726 string txid = it->first;
727 int64_t userTokens = it->second.at(2);
728 int64_t issuerTokens = it->second.at(3);
729 int64_t amountSent = it->second.at(0);
731 amountRaised += amountSent;
732 participanttx.push_back(Pair(
"txid", txid));
733 participanttx.push_back(Pair(
"amountsent",
FormatMP(propertyIdDesired, amountSent)));
734 participanttx.push_back(Pair(
"participanttokens",
FormatMP(propertyId, userTokens)));
735 participanttx.push_back(Pair(
"issuertokens",
FormatMP(propertyId, issuerTokens)));
736 participanttxs.push_back(participanttx);
739 response.push_back(Pair(
"name", propertyName));
740 response.push_back(Pair(
"active", active));
741 response.push_back(Pair(
"issuer", issuer));
742 response.push_back(Pair(
"propertyiddesired", propertyIdDesired));
743 response.push_back(Pair(
"tokensperunit",
FormatMP(propertyId, tokensPerUnit)));
744 response.push_back(Pair(
"earlybonus", earlyBonus));
745 response.push_back(Pair(
"percenttoissuer", percentToIssuer));
746 response.push_back(Pair(
"starttime", startTime));
747 response.push_back(Pair(
"deadline", deadline));
748 response.push_back(Pair(
"amountraised",
FormatMP(propertyIdDesired, amountRaised)));
749 response.push_back(Pair(
"tokensissued",
FormatMP(propertyId, tokensIssued)));
750 response.push_back(Pair(
"addedissuertokens",
FormatMP(propertyId, missedTokens)));
752 if (!active) response.push_back(Pair(
"closedearly", closeEarly));
753 if (!active) response.push_back(Pair(
"maxtokens", maxTokens));
754 if (closeEarly) response.push_back(Pair(
"endedtime", timeClosed));
755 if (closeEarly && !maxTokens) response.push_back(Pair(
"closetx", txidClosed));
760 response.push_back(Pair(
"participanttransactions", participanttxs));
769 "getactivecrowdsales_MP\n"
770 "\nGet active crowdsales.\n"
773 " \"name\" : \"PropertyName\", (string) the property name\n"
774 " \"issuer\" : \"1Address\", (string) the issuer address\n"
775 " \"creationtxid\" : \"txid\", (string) the transaction that created the crowdsale\n"
776 " \"propertyiddesired\" : x, (numeric) the property ID desired\n"
777 " \"tokensperunit\" : x, (numeric) the number of tokens awarded per unit\n"
778 " \"earlybonus\" : x, (numeric) the percentage per week early bonus applied\n"
779 " \"percenttoissuer\" : x, (numeric) the percentage awarded to the issuer\n"
780 " \"starttime\" : xxx, (numeric) the start time of the crowdsale\n"
781 " \"deadline\" : xxx, (numeric) the time the crowdsale will automatically end\n"
811 string propertyName = sp.
name;
816 string issuer = sp.
issuer;
820 responseObj.push_back(Pair(
"propertyid", propertyId));
821 responseObj.push_back(Pair(
"name", propertyName));
822 responseObj.push_back(Pair(
"issuer", issuer));
823 responseObj.push_back(Pair(
"propertyiddesired", propertyIdDesired));
824 responseObj.push_back(Pair(
"tokensperunit",
FormatMP(propertyId, tokensPerUnit)));
825 responseObj.push_back(Pair(
"earlybonus", earlyBonus));
826 responseObj.push_back(Pair(
"percenttoissuer", percentToIssuer));
827 responseObj.push_back(Pair(
"starttime", startTime));
828 responseObj.push_back(Pair(
"deadline", deadline));
830 response.push_back(responseObj);
839 if (fHelp || params.size() != 1 )
841 "getgrants_MP propertyid\n"
842 "\nGet information about grants and revokes for a property identifier.\n"
844 "1. propertyid (int, required) The property identifier\n"
847 " \"name\" : \"PropertyName\", (string) the property name\n"
848 " \"issuer\" : \"1Address\", (string) the issuer address\n"
849 " \"creationtxid\" : \"txid\", (string) the transaction that created the crowdsale\n"
850 " \"totaltokens\" : \"1234\", (string) the number of tokens in circulation\n"
851 " \"issuances\" : [\n"
853 " \"txid\" : \"txid\", (string) the transaction that granted/revoked tokens\n"
854 " \"grant\" : \"1234\", (string) the number of tokens granted\n"
857 " \"txid\" : \"txid\", (string) the transaction that granted/revoked tokens\n"
858 " \"revoke\" : \"1234\", (string) the number of tokens revoked\n"
869 int64_t tmpPropertyId = params[0].get_int64();
870 if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId))
873 unsigned int propertyId =
int(tmpPropertyId);
879 bool fixedIssuance = sp.
fixed;
880 bool manualIssuance = sp.
manual;
881 if (fixedIssuance || !manualIssuance)
890 string propertyName = sp.
name;
891 string issuer = sp.
issuer;
895 std::map<std::string, std::vector<uint64_t> >::const_iterator it;
899 string txid = it->first;
900 int64_t grantedTokens = it->second.at(0);
901 int64_t revokedTokens = it->second.at(1);
902 if (grantedTokens > 0){
904 granttx.push_back(Pair(
"txid", txid));
905 granttx.push_back(Pair(
"grant",
FormatMP(propertyId, grantedTokens)));
906 issuancetxs.push_back(granttx);
909 if (revokedTokens > 0){
911 revoketx.push_back(Pair(
"txid", txid));
912 revoketx.push_back(Pair(
"revoke",
FormatMP(propertyId, revokedTokens)));
913 issuancetxs.push_back(revoketx);
917 response.push_back(Pair(
"name", propertyName));
918 response.push_back(Pair(
"issuer", issuer));
919 response.push_back(Pair(
"creationtxid", creationHash.
GetHex()));
920 response.push_back(Pair(
"totaltokens",
FormatMP(propertyId, totalTokens)));
921 response.push_back(Pair(
"issuances", issuancetxs));
928 if ((1 > tmpPropId) || (4294967295 < tmpPropId))
936 #ifndef DISABLE_METADEX
937 Value
trade_MP(
const Array& params,
bool fHelp)
939 if (fHelp || params.size() < 6)
941 "trade_MP \"address\" \"amountforsale\" propertyid1 \"amountdesired\" propertid2 action ( \"redeemaddress\" )\n"
942 "\nPlace or cancel an offer on the distributed token exchange.\n"
945 "1. address (string, required) address that is making the sale\n"
946 "2. amount_for_sale (string, required) amount owned to put up on sale\n"
947 "3. property_id1 (int, required) property owned to put up on sale\n"
948 "4. amount_desired (string, required) amount wanted/willing to purchase\n"
949 "5. property_id2 (int, required) property wanted/willing to purchase\n"
950 "6. action (int, required) decision to either start a new (1), cancel_price (2), cancel_pair (3), or cancel_all (4) for an offer\n"
951 "7. redeem_address (optional) the address that can redeem the bitcoin outputs, defaults to sender\n"
954 std::string fromAddress = params[0].get_str();
955 std::string redeemAddress = (params.size() > 6) ? (params[6].get_str()) :
"";
957 uint32_t propertyIdSale =
static_cast<uint32_t
>(params[2].get_int64());
958 uint32_t propertyIdWant =
static_cast<uint32_t
>(params[4].get_int64());
960 int64_t amountSale = 0;
961 int64_t amountWant = 0;
962 int64_t action = params[5].get_int64();
972 "Invalid property identifier (Sale)",
973 "Property identifier does not exist (Sale)");
976 "Invalid property identifier (Want)",
977 "Property identifier does not exist (Want)");
982 if (propertyIdSale == propertyIdWant)
990 bool divisible_sale =
false, divisible_want =
false;
998 std::string strAmountSale = params[1].get_str();
999 amountSale =
StrToInt64(strAmountSale, divisible_sale);
1001 std::string strAmountWant = params[3].get_str();
1002 amountWant =
StrToInt64(strAmountWant, divisible_want);
1004 if (0 >= amountSale)
1007 if (0 >= amountWant)
1021 if (fHelp || params.size() < 1)
1022 throw runtime_error(
1023 "getorderbook_MP property_id1 ( property_id2 )\n"
1024 "\nAllows user to request active order information from the order book\n"
1027 "1. property_id1 (int, required) amount owned to up on sale\n"
1028 "2. property_id2 (int, optional) property owned to put up on sale\n"
1031 unsigned int propertyIdSaleFilter = 0, propertyIdWantFilter = 0;
1033 bool filter_by_desired = (params.size() == 2) ?
true :
false;
1035 propertyIdSaleFilter =
check_prop_valid( params[0].get_int64() ,
"Invalid property identifier (Sale)",
"Property identifier does not exist (Sale)");
1037 if ( filter_by_desired ) {
1038 propertyIdWantFilter =
check_prop_valid( params[1].get_int64() ,
"Invalid property identifier (Want)",
"Property identifier does not exist (Want)");
1043 std::vector<CMPMetaDEx> vMetaDexObjects;
1045 for (md_PropertiesMap::iterator my_it =
metadex.begin(); my_it !=
metadex.end(); ++my_it)
1048 for (md_PricesMap::iterator it = prices.begin(); it != prices.end(); ++it)
1050 md_Set & indexes = (it->second);
1051 for (md_Set::iterator it = indexes.begin(); it != indexes.end(); ++it)
1056 bool filter = ( filter_by_desired && ( obj.
getProperty() == propertyIdSaleFilter ) && ( obj.
getDesProperty() == propertyIdWantFilter ) ) || ( !filter_by_desired && ( obj.
getProperty() == propertyIdSaleFilter ) );
1059 vMetaDexObjects.push_back(obj);
1074 throw runtime_error(
1075 "gettradessince_MP\n"
1076 "\nAllows user to request last known orders from order book\n"
1079 "1. timestamp (int, optional, default=[" +
strprintf(
"%s",
GetLatestBlockTime() - 1209600) +
"]) starting from the timestamp, orders to show"
1080 "2. property_id1 (int, optional) filter orders by property_id1 on either side of the trade \n"
1081 "3. property_id2 (int, optional) filter orders by property_id1 and property_id2\n"
1084 unsigned int propertyIdSaleFilter = 0, propertyIdWantFilter = 0;
1086 uint64_t timestamp = (params.size() > 0) ? params[0].get_int64() :
GetLatestBlockTime() - 1209600;
1088 bool filter_by_one = (params.size() > 1) ?
true :
false;
1089 bool filter_by_both = (params.size() > 2) ?
true :
false;
1091 if( filter_by_one ) {
1092 propertyIdSaleFilter =
check_prop_valid( params[1].get_int64() ,
"Invalid property identifier (Sale)",
"Property identifier does not exist (Sale)");
1095 if ( filter_by_both ) {
1096 propertyIdWantFilter =
check_prop_valid( params[2].get_int64() ,
"Invalid property identifier (Want)",
"Property identifier does not exist (Want)");
1099 std::vector<CMPMetaDEx> vMetaDexObjects;
1101 for (md_PropertiesMap::iterator my_it =
metadex.begin(); my_it !=
metadex.end(); ++my_it)
1104 for (md_PricesMap::iterator it = prices.begin(); it != prices.end(); ++it)
1106 md_Set & indexes = (it->second);
1107 for (md_Set::iterator it = indexes.begin(); it != indexes.end(); ++it)
1113 if( filter_by_one || filter_by_both ) {
1115 filter = ( filter_by_both && ( obj.
getProperty() == propertyIdSaleFilter ) && ( obj.
getDesProperty() == propertyIdWantFilter ) ) || ( !filter_by_both && ( obj.
getProperty() == propertyIdSaleFilter ) );
1119 vMetaDexObjects.push_back(obj);
1134 throw runtime_error(
1136 "\nAllows user to request active order information from the order book\n"
1139 "1. property_id1 (int, required) amount owned to up on sale\n"
1140 "2. property_id2 (int, optional) property owned to put up on sale\n"
1143 "[ (array of string)\n"
1144 " \"hash\" (string) Transaction id\n"
1152 return "\nNot Implemented";
1157 if (fHelp || params.size() < 1)
1158 throw runtime_error(
1159 "gettradehistory_MP\n"
1160 "\nAllows user to retreive trade history for some address on the Metadex\n"
1163 "1. address (string, required) address to query history on\n"
1164 "2. number (int, optional ) number of trades to retreive\n"
1165 "3. property_id (int, optional) filter by propertyid on one side\n"
1168 string address = params[0].get_str();
1169 unsigned int number_trades = (params.size() == 2 ? (
unsigned int) params[1].get_int64() : 512);
1170 unsigned int propertyIdFilter = 0;
1172 bool filter_by_one = (params.size() == 3) ?
true :
false;
1174 if( filter_by_one ) {
1175 propertyIdFilter =
check_prop_valid( params[2].get_int64() ,
"Invalid property identifier (Sale)",
"Property identifier does not exist (Sale)");
1178 std::vector<CMPMetaDEx> vMetaDexObjects;
1180 for (md_PropertiesMap::iterator my_it =
metadex.begin(); my_it !=
metadex.end(); ++my_it)
1183 for (md_PricesMap::iterator it = prices.begin(); it != prices.end(); ++it)
1185 md_Set & indexes = (it->second);
1186 for (md_Set::iterator it = indexes.begin(); it != indexes.end(); ++it)
1193 filter = (obj.
getAddr() == address) &&
1194 ( ( ( filter_by_one && (obj.
getProperty() == propertyIdFilter) == 1 ) ) || !filter_by_one ) &&
1195 (vMetaDexObjects.size() < number_trades);
1197 vMetaDexObjects.push_back(obj);
1213 throw runtime_error(
1214 "getactivedexsells_MP\n"
1215 "\nGet currently active offers on the distributed exchange.\n"
1226 bool addressFilter =
false;
1227 string addressParam;
1229 if (params.size() > 0)
1231 addressParam = params[0].get_str();
1232 addressFilter =
true;
1240 string sellCombo = it->first;
1241 string seller = sellCombo.substr(0, sellCombo.size()-2);
1244 if ((addressFilter) && (seller != addressParam))
continue;
1247 string txid = sellHash.
GetHex();
1249 uint64_t minFee = selloffer.
getMinFee();
1257 double unitPriceFloat = 0;
1258 if ((sellOfferAmount>0) && (sellBitcoinDesired > 0)) unitPriceFloat = (double)sellBitcoinDesired/(
double)sellOfferAmount;
1260 uint64_t bitcoinDesired =
rounduint64(amountAvailable*unitPriceFloat);
1264 responseObj.push_back(Pair(
"txid", txid));
1265 responseObj.push_back(Pair(
"propertyid", propertyId));
1266 responseObj.push_back(Pair(
"seller", seller));
1267 responseObj.push_back(Pair(
"amountavailable",
FormatDivisibleMP(amountAvailable)));
1268 responseObj.push_back(Pair(
"bitcoindesired",
FormatDivisibleMP(bitcoinDesired)));
1270 responseObj.push_back(Pair(
"timelimit", timeLimit));
1274 responseObj.push_back(Pair(
"amountaccepted",
FormatDivisibleMP(amountAccepted)));
1275 Array acceptsMatched;
1278 Object matchedAccept;
1281 string acceptCombo = ait->first;
1284 if (matchedHash == sellHash)
1287 string buyer = acceptCombo.substr((acceptCombo.find(
"+")+1),(acceptCombo.size()-(acceptCombo.find(
"+")+1)));
1290 matchedAccept.push_back(Pair(
"buyer", buyer));
1291 matchedAccept.push_back(Pair(
"block", acceptBlock));
1293 acceptsMatched.push_back(matchedAccept);
1296 responseObj.push_back(Pair(
"accepts", acceptsMatched));
1299 response.push_back(responseObj);
1307 if (fHelp || params.size() != 1)
1308 throw runtime_error(
1309 "listblocktransactions_MP index\n"
1310 "\nReturns all Master Protocol transactions in a block.\n"
1312 "1. index (numeric, required) The block height or index\n"
1314 "[ (array of string)\n"
1315 " \"hash\" (string) Transaction id\n"
1325 int blockHeight = params[0].get_int();
1326 if (blockHeight < 0 || blockHeight >
GetHeight())
1367 bool bIsMine =
false;
1368 bool isMPTx =
false;
1371 unsigned int MPTxTypeInt;
1372 string selectedAddress;
1373 string senderAddress;
1376 bool showReference =
false;
1377 uint64_t propertyId = 0;
1378 bool divisible =
false;
1379 uint64_t amount = 0;
1381 uint64_t sell_minfee = 0;
1382 unsigned char sell_timelimit = 0;
1383 unsigned char sell_subaction = 0;
1384 uint64_t sell_btcdesired = 0;
1386 bool crowdPurchase =
false;
1387 int64_t crowdPropertyId = 0;
1388 int64_t crowdTokens = 0;
1389 int64_t issuerTokens = 0;
1390 bool crowdDivisible =
false;
1392 string propertyName;
1393 bool mdex_propertyId_Div =
false;
1394 uint64_t mdex_propertyWanted = 0;
1395 uint64_t mdex_amountWanted = 0;
1396 bool mdex_propertyWanted_Div =
false;
1397 unsigned int mdex_action = 0;
1398 string mdex_actionStr;
1405 int blockHeight = pBlockIndex->
nHeight;
1426 txobj->push_back(Pair(
"txid", wtxid.
GetHex()));
1427 txobj->push_back(Pair(
"confirmations", confirmations));
1428 txobj->push_back(Pair(
"blocktime", blockTime));
1429 txobj->push_back(Pair(
"type",
"DEx Purchase"));
1435 uint64_t tmpPropertyId;
1437 txobj->push_back(Pair(
"sendingaddress", tmpBuyer));
1441 if (0<numberOfPurchases)
1443 for(
int purchaseNumber = 1; purchaseNumber <= numberOfPurchases; purchaseNumber++)
1457 if (!filterAddress.empty())
if ((buyer != filterAddress) && (seller != filterAddress))
return -1;
1458 uint64_t amountPaid = wtx.
vout[vout].nValue;
1459 purchaseObj.push_back(Pair(
"vout", vout));
1461 purchaseObj.push_back(Pair(
"ismine", bIsMine));
1462 purchaseObj.push_back(Pair(
"referenceaddress", seller));
1463 purchaseObj.push_back(Pair(
"propertyid", propertyId));
1465 purchaseObj.push_back(Pair(
"valid",
true));
1466 purchases.push_back(purchaseObj);
1469 txobj->push_back(Pair(
"purchases", purchases));
1476 if (0<=mp_obj.
step1())
1479 MPTxTypeInt = mp_obj.
getType();
1482 if (!filterAddress.empty())
if ((senderAddress != filterAddress) && (refAddress != filterAddress))
return -1;
1487 uint64_t amountNew=0;
1488 valid=
getValidMPTX(wtxid, &tmpblock, &tmptype, &amountNew);
1490 switch (MPTxTypeInt)
1503 mdex_action = temp_metadexoffer.
getAction();
1504 if(1 == mdex_action) mdex_actionStr =
"new sell";
1505 if(2 == mdex_action) mdex_actionStr =
"cancel price";
1506 if(3 == mdex_action) mdex_actionStr =
"cancel pair";
1507 if(4 == mdex_action) mdex_actionStr =
"cancel all";
1515 showReference =
true;
1561 showReference =
true;
1563 crowdPurchase =
isCrowdsalePurchase(wtxid, refAddress, &crowdPropertyId, &crowdTokens, &issuerTokens);
1566 MPTxType =
"Crowdsale Purchase";
1570 crowdName = sp.
name;
1587 if (3 < sell_subaction) sell_subaction=0;
1589 if ((0 == sell_subaction) && (0 < amount)) sell_subaction=1;
1590 if ((0 == sell_subaction) && (0 == amount)) sell_subaction=3;
1592 if ((valid) && (amountNew>0)) amount=amountNew;
1599 showReference =
true;
1601 if ((valid) && (amountNew>0)) amount=amountNew;
1644 txobj->push_back(Pair(
"txid", wtxid.
GetHex()));
1645 txobj->push_back(Pair(
"sendingaddress", senderAddress));
1646 if (showReference) txobj->push_back(Pair(
"referenceaddress", refAddress));
1647 txobj->push_back(Pair(
"ismine", bIsMine));
1648 txobj->push_back(Pair(
"confirmations", confirmations));
1650 txobj->push_back(Pair(
"blocktime", blockTime));
1651 txobj->push_back(Pair(
"version", (int64_t)mp_obj.
getVersion()));
1652 txobj->push_back(Pair(
"type_int", (int64_t)mp_obj.
getType()));
1653 txobj->push_back(Pair(
"type", MPTxType));
1654 if (
MSC_TYPE_METADEX != MPTxTypeInt) txobj->push_back(Pair(
"propertyid", propertyId));
1657 txobj->push_back(Pair(
"propertyname", propertyName));
1659 if (
MSC_TYPE_METADEX != MPTxTypeInt) txobj->push_back(Pair(
"divisible", divisible));
1663 txobj->push_back(Pair(
"purchasedpropertyid", crowdPropertyId));
1664 txobj->push_back(Pair(
"purchasedpropertyname", crowdName));
1665 txobj->push_back(Pair(
"purchasedpropertydivisible", crowdDivisible));
1666 txobj->push_back(Pair(
"purchasedtokens",
FormatMP(crowdPropertyId, crowdTokens)));
1667 txobj->push_back(Pair(
"issuertokens",
FormatMP(crowdPropertyId, issuerTokens)));
1672 txobj->push_back(Pair(
"timelimit", sell_timelimit));
1673 if (1 == sell_subaction) txobj->push_back(Pair(
"subaction",
"New"));
1674 if (2 == sell_subaction) txobj->push_back(Pair(
"subaction",
"Update"));
1675 if (3 == sell_subaction) txobj->push_back(Pair(
"subaction",
"Cancel"));
1676 txobj->push_back(Pair(
"bitcoindesired",
ValueFromAmount(sell_btcdesired)));
1680 txobj->push_back(Pair(
"amountoffered",
FormatMP(propertyId, amount)));
1681 txobj->push_back(Pair(
"propertyoffered", propertyId));
1682 txobj->push_back(Pair(
"propertyofferedisdivisible", mdex_propertyId_Div));
1683 txobj->push_back(Pair(
"amountdesired",
FormatMP(mdex_propertyWanted, mdex_amountWanted)));
1684 txobj->push_back(Pair(
"propertydesired", mdex_propertyWanted));
1685 txobj->push_back(Pair(
"propertydesiredisdivisible", mdex_propertyWanted_Div));
1686 txobj->push_back(Pair(
"action", mdex_actionStr));
1693 txobj->push_back(Pair(
"valid", valid));
1702 if (fHelp || params.size() != 1)
1703 throw runtime_error(
1704 "gettransaction_MP \"txid\"\n"
1705 "\nGet detailed information about a Master Protocol transaction <txid>\n"
1707 "1. \"txid\" (string, required) The transaction id\n"
1710 " \"txid\" : \"transactionid\", (string) The transaction id\n"
1711 " \"sendingaddress\" : \"sender\", (string) The sending address\n"
1712 " \"referenceaddress\" : \"receiving address\", (string) The receiving address (if applicable)\n"
1713 " \"ismine\" : true/false\", (boolean) Whether the transaction involes an address in the wallet\n"
1714 " \"confirmations\" : n, (numeric) The number of confirmations\n"
1715 " \"blocktime\" : ttt, (numeric) The time in seconds since epoch (1 Jan 1970 GMT)\n"
1716 " \"type\" : \"transaction type\", (string) The type of transaction\n"
1717 " \"propertyid\" : \"property id\", (numeric) The ID of the property transacted\n"
1718 " \"propertyname\" : \"property name\", (string) The name of the property (for creation transactions)\n"
1719 " \"divisible\" : true/false\", (boolean) Whether the property is divisible\n"
1720 " \"amount\" : \"x.xxx\", (string) The transaction amount\n"
1721 " \"valid\" : true/false\", (boolean) Whether the transaction is valid\n"
1725 +
HelpExampleCli(
"gettransaction_MP",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1726 +
HelpExampleRpc(
"gettransaction_MP",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1730 hash.
SetHex(params[0].get_str());
1735 if (0>populateResult)
1738 switch (populateResult)
1751 \"Crowdsale Purchase\" without valid property identifier");
1769 if (fHelp || params.size() > 5)
1770 throw runtime_error(
1771 "listtransactions_MP ( \"address\" count skip startblock endblock )\n"
1772 "\nList wallet transactions filtered on counts and block boundaries\n"
1778 string sAddress =
"";
1779 string addressParam =
"";
1783 addressFilter =
false;
1784 if (params.size() > 0)
1787 if ( (
"*" != params[0].get_str()) && (
"" != params[0].get_str()) )
1789 addressParam = params[0].get_str();
1790 addressFilter =
true;
1794 int64_t nCount = 10;
1795 if (params.size() > 1) nCount = params[1].get_int64();
1798 if (params.size() > 2) nFrom = params[2].get_int64();
1800 int64_t nStartBlock = 0;
1801 if (params.size() > 3) nStartBlock = params[3].get_int64();
1803 int64_t nEndBlock = 999999;
1804 if (params.size() > 4) nEndBlock = params[4].get_int64();
1812 std::vector<std::string> vecReceipts;
1813 boost::split(vecReceipts, mySTOReceipts, boost::is_any_of(
","), token_compress_on);
1814 int64_t lastTXBlock = 999999;
1818 std::list<CAccountingEntry> acentries;
1822 for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
1824 CWalletTx *
const pwtx = (*it).second.first;
1829 if ((0 == blockHash) || (NULL ==
mapBlockIndex[blockHash]))
continue;
1831 if (NULL == pBlockIndex)
continue;
1832 int blockHeight = pBlockIndex->
nHeight;
1833 if ((blockHeight < nStartBlock) || (blockHeight > nEndBlock))
continue;
1836 for(uint32_t i = 0; i<vecReceipts.size(); i++)
1838 std::vector<std::string> svstr;
1839 boost::split(svstr, vecReceipts[i], boost::is_any_of(
":"), token_compress_on);
1840 if(4 == svstr.size())
1842 if((
atoi(svstr[1]) < lastTXBlock) && (
atoi(svstr[1]) > blockHeight))
1848 int populateResult = -1;
1850 if (0 == populateResult)
1853 uint64_t tmpAmount = 0;
1854 uint64_t stoFee = 0;
1858 txobj.push_back(Pair(
"recipients", receiveArray));
1859 response.push_back(txobj);
1862 if ((
int)response.size() >= (nCount+nFrom))
break;
1872 int populateResult = -1;
1881 if (0 == populateResult) response.push_back(txobj);
1882 lastTXBlock = blockHeight;
1885 if ((
int)response.size() >= (nCount+nFrom))
break;
1889 if (nFrom > (
int)response.size())
1890 nFrom = response.size();
1891 if ((nFrom + nCount) > (
int)response.size())
1892 nCount = response.size() - nFrom;
1893 Array::iterator first = response.begin();
1894 std::advance(first, nFrom);
1895 Array::iterator last = response.begin();
1896 std::advance(last, nFrom+nCount);
1898 if (last != response.end()) response.erase(last, response.end());
1899 if (first != response.begin()) response.erase(response.begin(), first);
1901 std::reverse(response.begin(), response.end());
1907 Object infoResponse;
1912 infoResponse.push_back(Pair(
"bitcoincoreversion",
"0." + boost::lexical_cast<string>((
int)
CLIENT_VERSION/100)));
1913 infoResponse.push_back(Pair(
"commitinfo",
COMMIT_INFO));
1921 infoResponse.push_back(Pair(
"block", block));
1922 infoResponse.push_back(Pair(
"blocktime", blockTime));
1923 infoResponse.push_back(Pair(
"blocktransactions", blockMPTransactions));
1926 infoResponse.push_back(Pair(
"totaltrades", totalMPTrades));
1928 infoResponse.push_back(Pair(
"totaltransactions", totalMPTransactions));
1931 Object alertResponse;
1933 int32_t alertType = 0;
1934 uint64_t expiryValue = 0;
1935 uint32_t typeCheck = 0;
1936 uint32_t verCheck = 0;
1937 std::vector<std::string> vstr;
1938 string alertMessage;
1941 if(!global_alert_message.empty())
1943 boost::split(vstr, global_alert_message, boost::is_any_of(
":"), token_compress_on);
1945 if (5 == vstr.size())
1949 alertType = boost::lexical_cast<int32_t>(vstr[0]);
1950 expiryValue = boost::lexical_cast<uint64_t>(vstr[1]);
1951 typeCheck = boost::lexical_cast<uint32_t>(vstr[2]);
1952 verCheck = boost::lexical_cast<uint32_t>(vstr[3]);
1953 alertMessage = vstr[4];
1954 }
catch (
const boost::bad_lexical_cast &e)
1956 file_log(
"DEBUG ALERT - error in converting values from global alert string\n");
1959 alertMessage =
"error";
1961 string alertTypeStr;
1964 case 0: alertTypeStr =
"error";
break;
1965 case 1: alertTypeStr =
"textalertexpiringbyblock";
break;
1966 case 2: alertTypeStr =
"textalertexpiringbytime";
break;
1967 case 3: alertTypeStr =
"textalertexpiringbyversion";
break;
1968 case 4: alertTypeStr =
"updatealerttxcheck";
break;
1970 alertResponse.push_back(Pair(
"alerttype", alertTypeStr));
1973 alertResponse.push_back(Pair(
"alertmessage", alertMessage.c_str()));
1977 file_log(
"DEBUG ALERT ERROR - Something went wrong decoding the global alert string.\n");
1981 infoResponse.push_back(Pair(
"alert", alertResponse));
1982 return infoResponse;
1987 if (fHelp || params.size() < 1 || params.size() > 2)
1988 throw runtime_error(
1989 "getsto_MP \"txid\" \"recipientfilter\"\n"
1990 "\nGet information and recipients of send to owners transaction <txid>\n"
1992 "1. \"txid\" (string, required) The transaction id\n"
1993 "2. \"recipientfilter\" (string, optional) The recipient address filter (wallet by default, \"*\" for all)\n"
1996 " \"txid\" : \"transactionid\", (string) The transaction id\n"
1997 +
HelpExampleCli(
"getsto_MP",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1998 +
HelpExampleRpc(
"getsto_MP",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
2002 hash.
SetHex(params[0].get_str());
2003 string filterAddress =
"";
2004 if (params.size() == 2) filterAddress=params[1].get_str();
2009 uint64_t propertyId = 0;
2014 if (0<=mp_obj.
step1())
2021 if (propertyId == 0)
2027 if (0>populateResult)
2030 switch (populateResult)
2040 \"Crowdsale Purchase\" without valid property identifier");
2049 uint64_t tmpAmount = 0;
2050 uint64_t stoFee = 0;
2054 txobj.push_back(Pair(
"recipients", receiveArray));
2062 if (fHelp || params.size() != 1)
2063 throw runtime_error(
2064 "gettrade_MP \"txid\"\n"
2065 "\nGet detailed information and trade matches for a Master Protocol MetaDEx trade offer <txid>\n"
2067 "1. \"txid\" (string, required) The transaction id\n"
2070 " \"txid\" : \"transactionid\", (string) The transaction id\n"
2071 +
HelpExampleCli(
"gettrade_MP",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
2072 +
HelpExampleRpc(
"gettrade_MP",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
2076 hash.
SetHex(params[0].get_str());
2082 string senderAddress;
2083 unsigned int propertyId = 0;
2091 if (0<=mp_obj.
step1())
2100 if (propertyId == 0)
2102 if (senderAddress.empty())
2109 if (0>populateResult)
2112 switch (populateResult)
2122 \"Crowdsale Purchase\" without valid property identifier");
2131 uint64_t amountForSale = mp_obj.
getAmount();
2135 uint64_t totalBought = 0;
2136 uint64_t totalSold = 0;
2146 bool partialFilled =
false;
2147 bool filled =
false;
2149 if(totalSold>0) partialFilled =
true;
2150 if(totalSold>=amountForSale) filled =
true;
2151 statusText =
"unknown";
2152 if((!orderOpen) && (!partialFilled)) statusText =
"cancelled";
2153 if((!orderOpen) && (partialFilled)) statusText =
"cancelled part filled";
2154 if((!orderOpen) && (filled)) statusText =
"filled";
2155 if((orderOpen) && (!partialFilled)) statusText =
"open";
2156 if((orderOpen) && (partialFilled)) statusText =
"open part filled";
2157 if(actionByte==1) txobj.push_back(Pair(
"status", statusText));
2164 if (0<numberOfCancels)
2166 for(
int refNumber = 1; refNumber <= numberOfCancels; refNumber++)
2170 if (!strValue.empty())
2172 std::vector<std::string> vstr;
2173 boost::split(vstr, strValue, boost::is_any_of(
":"), token_compress_on);
2174 if (3 <= vstr.size())
2176 uint64_t propId = boost::lexical_cast<uint64_t>(vstr[1]);
2177 uint64_t amountUnreserved = boost::lexical_cast<uint64_t>(vstr[2]);
2178 cancelTx.push_back(Pair(
"txid", vstr[0]));
2179 cancelTx.push_back(Pair(
"propertyid", propId));
2180 cancelTx.push_back(Pair(
"amountunreserved",
FormatMP(propId, amountUnreserved)));
2181 cancelArray.push_back(cancelTx);
2186 txobj.push_back(Pair(
"cancelledtransactions", cancelArray));
2191 if((statusText ==
"cancelled") || (statusText ==
"cancelled part filled")) { txobj.push_back(Pair(
"canceltxid",
p_txlistdb->
findMetaDExCancel(hash).
GetHex())); }
2193 txobj.push_back(Pair(
"matches", tradeArray));
uint32_t GetLatestBlockTime(void)
int getNumberOfPurchases(const uint256 txid)
void SetHex(const char *psz)
const string & getSender() const
#define OMNICORE_VERSION_TYPE
#define OMNICORE_VERSION_BASE
string global_alert_message
bool isTestEcosystemProperty(unsigned int property)
Value getallbalancesforid_MP(const Array ¶ms, bool fHelp)
int ClassB_send(const string &senderAddress, const string &receiverAddress, const string &redemptionAddress, const vector< unsigned char > &data, uint256 &txid, int64_t additional=0)
Value sendtoowners_MP(const Array ¶ms, bool fHelp)
uint64_t getFeePaid() const
CCriticalSection cs_wallet
Main wallet lock.
bool exists(const uint256 &txid)
json_spirit::Value gettradehistory_MP(const json_spirit::Array ¶ms, bool fHelp)
int parseTransaction(bool bRPConly, const CTransaction &wtx, int nBlock, unsigned int idx, CMPTransaction *mp_tx, unsigned int nTime)
std::string HelpExampleRpc(string methodname, string args)
static const int CLIENT_VERSION
const string & getReceiver() const
bool getMatchingTrades(const uint256 txid, unsigned int propertyId, Array *tradeArray, uint64_t *totalSold, uint64_t *totalBought)
CMPTally * getTally(const string &address)
uint64_t getOfferAmountOriginal() const
Value getactivedexsells_MP(const Array ¶ms, bool fHelp)
void getRecipients(const uint256 txid, string filterAddress, Array *recipientArray, uint64_t *total, uint64_t *stoFee)
#define TEST_ECO_PROPERTY_1
json_spirit::Value gettradessince_MP(const json_spirit::Array ¶ms, bool fHelp)
Object JSONRPCError(int code, const string &message)
Value sendrawtx_MP(const Array ¶ms, bool fHelp)
std::map< std::string, std::vector< uint64_t > > getDatabase() const
json_spirit::Value getorderbook_MP(const json_spirit::Array ¶ms, bool fHelp)
int populateRPCTransactionObject(uint256 txid, Object *txobj, string filterAddress="")
CChain chainActive
The currently-connected chain of blocks.
bool isPropertyDivisible(unsigned int propertyId)
unsigned int property_desired
Value gettransaction_MP(const Array ¶ms, bool fHelp)
std::map< std::string, std::vector< uint64_t > > historicalData
json_spirit::Value getopenorders_MP(const json_spirit::Array ¶ms, bool fHelp)
unsigned char getSubaction() const
Value send_MP(const Array ¶ms, bool fHelp)
unsigned int getProperty() const
Value getsto_MP(const Array ¶ms, bool fHelp)
int getNumberOfMetaDExCancels(const uint256 txid)
std::multimap< int64_t, TxPair > TxItems
bool IsMyAddress(const std::string &address)
const char * step2_SmartProperty(int &error_code)
uint64_t getAcceptAmountRemaining() const
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)
int Height() const
Return the maximal height in the chain.
void MetaDexObjectToJSON(const CMPMetaDEx &obj, Object &metadex_obj)
Value ValueFromAmount(int64_t amount)
Value listblocktransactions_MP(const Array ¶ms, bool fHelp)
int getMPTradeCountTotal()
bool isCrowdsaleActive(unsigned int propertyId)
CMPTradeList * t_tradelistdb
void BalanceToJSON(const std::string &address, uint32_t property, Object &balance_obj)
std::vector< CTxOut > vout
uint64_t rounduint64(long double ld)
Converts numbers to 64 bit wide unsigned integer whereby any signedness is ignored.
const std::string COMMIT_INFO
uint64_t getBTCDesiredOriginal() const
uint64_t getMinFee() const
Value mscrpc(const Array ¶ms, bool fHelp)
int check_prop_valid(int64_t tmpPropId, string error, string exist_error)
static bool error(const char *format)
bool isMPinBlockRange(int starting_block, int ending_block, bool bDeleteFound)
unsigned short getVersion() const
std::map< string, CMPTally > mp_tally_map
bool isMetaDExOfferActive(const uint256 txid, unsigned int propertyId)
std::string error_str(int ec)
bool getSP(unsigned int spid, Entry &info)
Value listtransactions_MP(const Array ¶ms, bool fHelp)
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)
void MetaDEx_debug_print(bool bShowPriceLevel=false, bool bDisplay=false)
std::map< XDOUBLE, md_Set > md_PricesMap
unsigned int getProperty() const
std::string GetHex() const
uint256 findMetaDExCancel(const uint256 txid)
Value getallbalancesforaddress_MP(const Array ¶ms, bool fHelp)
int64_t getTotalTokens(unsigned int propertyId, int64_t *n_owners_total=NULL)
A transaction with a bunch of additional info that only the owner cares about.
string getKeyValue(string key)
json_spirit::Value trade_MP(const json_spirit::Array ¶ms, bool fHelp)
static const int64_t COIN
std::set< CMPMetaDEx, MetaDEx_compare > md_Set
bool getPurchaseDetails(const uint256 txid, int purchaseNumber, string *buyer, string *seller, uint64_t *vout, uint64_t *propertyId, uint64_t *nValue)
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos)
uint64_t getAmount() const
void PropertyToJSON(const CMPSPInfo::Entry &sProperty, Object &property_obj)
The block chain is a tree shaped structure starting with the genesis block at the root...
unsigned char getBlockTimeLimit() const
std::string ToString() const
int getMPTransactionCountBlock(int block)
unsigned int findSPByTX(uint256 const &txid)
std::string FormatIndivisibleMP(int64_t n)
unsigned int peekNextSPID(unsigned char ecosystem)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Value getbalance_MP(const Array ¶ms, bool fHelp)
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
Retrieve a transaction (from memory pool, or from disk, if possible)
Value getgrants_MP(const Array ¶ms, bool fHelp)
std::string FormatMP(unsigned int property, int64_t n, bool fSign)
string FormatDivisibleMP(int64_t n, bool fSign)
Value getcrowdsale_MP(const Array ¶ms, bool fHelp)
std::string HelpExampleCli(string methodname, string args)
std::vector< CTransaction > vtx
The basic transaction that is broadcasted on the network and contained in blocks. ...
std::string getMasterCoreAlertString()
static const CCheckpointData data
int getMPTransactionCountTotal()
const string getTypeString() const
void MetaDexObjectsToJSON(std::vector< CMPMetaDEx > &vMetaDexObjs, Array &response)
unsigned int getPropertyId() const
Value gettrade_MP(const Array ¶ms, bool fHelp)
map< uint256, CBlockIndex * > mapBlockIndex
vector< unsigned char > ParseHex(const char *psz)
int64_t StrToInt64(const std::string &str, bool divisible)
int64_t getMPbalance(const string &Address, unsigned int property, TallyType ttype)
Value getactivecrowdsales_MP(const Array ¶ms, bool fHelp)
int interpretPacket(CMPOffer *obj_o=NULL, CMPMetaDEx *mdex_o=NULL)
Value getinfo_MP(const Array ¶ms, bool fHelp)
Value listproperties_MP(const Array ¶ms, bool fHelp)
int64_t getUserAvailableMPbalance(const string &Address, unsigned int property)
std::string getMySTOReceipts(string filterAddress)
Value getproperty_MP(const Array ¶ms, bool fHelp)
int atoi(const std::string &str)
TxItems OrderedTxItems(std::list< CAccountingEntry > &acentries, std::string strAccount="")
Get the wallet's activity log.
unsigned int getType() const