19 #include <boost/algorithm/string.hpp> 33 #define SIX_MONTHS 15780000 // Six months worth of seconds 35 #define OFFSET_THREE 3 37 #define OFFSET_TWENTY_THREE 23 44 static const auto MAX_NAME_LENGTH = 31;
45 static const auto MAX_CHANNEL_NAME_LENGTH = 12;
48 static const std::regex ROOT_NAME_CHARACTERS(
"^[A-Z0-9._]{3,}$");
49 static const std::regex SUB_NAME_CHARACTERS(
"^[A-Z0-9._]+$");
50 static const std::regex UNIQUE_TAG_CHARACTERS(
"^[-A-Za-z0-9@$%&*()[\\]{}_.?:]+$");
51 static const std::regex MSGCHANNEL_TAG_CHARACTERS(
"^[A-Za-z0-9_]+$");
52 static const std::regex VOTE_TAG_CHARACTERS(
"^[A-Z0-9._]+$");
55 static const std::regex QUALIFIER_NAME_CHARACTERS(
"#[A-Z0-9._]{3,}$");
56 static const std::regex SUB_QUALIFIER_NAME_CHARACTERS(
"#[A-Z0-9._]+$");
57 static const std::regex RESTRICTED_NAME_CHARACTERS(
"\\$[A-Z0-9._]{3,}$");
59 static const std::regex DOUBLE_PUNCTUATION(
"^.*[._]{2,}.*$");
60 static const std::regex LEADING_PUNCTUATION(
"^[._].*$");
61 static const std::regex TRAILING_PUNCTUATION(
"^.*[._]$");
62 static const std::regex QUALIFIER_LEADING_PUNCTUATION(
"^[#\\$][._].*$");
64 static const std::string SUB_NAME_DELIMITER =
"/";
65 static const std::string UNIQUE_TAG_DELIMITER =
"#";
66 static const std::string MSGCHANNEL_TAG_DELIMITER =
"~";
67 static const std::string VOTE_TAG_DELIMITER =
"^";
68 static const std::string RESTRICTED_TAG_DELIMITER =
"$";
70 static const char RESTRICTED_TAG_CHAR =
'$';
72 static const std::regex UNIQUE_INDICATOR(R
"(^[^^~#!]+#[^~#!\/]+$)"); 73 static const std::regex MSGCHANNEL_INDICATOR(R
"(^[^^~#!]+~[^~#!\/]+$)"); 74 static const std::regex OWNER_INDICATOR(R
"(^[^^~#!]+!$)"); 75 static const std::regex VOTE_INDICATOR(R
"(^[^^~#!]+\^[^~#!\/]+$)"); 77 static const std::regex QUALIFIER_INDICATOR(
"^[#][A-Z0-9._]{3,}$");
78 static const std::regex SUB_QUALIFIER_INDICATOR(
"^#[A-Z0-9._]+\\/#[A-Z0-9._]+$");
79 static const std::regex RESTRICTED_INDICATOR(
"^[\\$][A-Z0-9._]{3,}$");
81 static const std::regex RAVEN_NAMES(
"^RVN$|^RAVEN$|^RAVENCOIN$|^#RVN$|^#RAVEN$|^#RAVENCOIN$");
85 return std::regex_match(name, ROOT_NAME_CHARACTERS)
86 && !std::regex_match(name, DOUBLE_PUNCTUATION)
87 && !std::regex_match(name, LEADING_PUNCTUATION)
88 && !std::regex_match(name, TRAILING_PUNCTUATION)
89 && !std::regex_match(name, RAVEN_NAMES);
94 return std::regex_match(name, QUALIFIER_NAME_CHARACTERS)
95 && !std::regex_match(name, DOUBLE_PUNCTUATION)
96 && !std::regex_match(name, QUALIFIER_LEADING_PUNCTUATION)
97 && !std::regex_match(name, TRAILING_PUNCTUATION)
98 && !std::regex_match(name, RAVEN_NAMES);
103 return std::regex_match(name, RESTRICTED_NAME_CHARACTERS)
104 && !std::regex_match(name, DOUBLE_PUNCTUATION)
105 && !std::regex_match(name, LEADING_PUNCTUATION)
106 && !std::regex_match(name, TRAILING_PUNCTUATION)
107 && !std::regex_match(name, RAVEN_NAMES);
112 return std::regex_match(name, SUB_QUALIFIER_NAME_CHARACTERS)
113 && !std::regex_match(name, DOUBLE_PUNCTUATION)
114 && !std::regex_match(name, LEADING_PUNCTUATION)
115 && !std::regex_match(name, TRAILING_PUNCTUATION);
120 return std::regex_match(name, SUB_NAME_CHARACTERS)
121 && !std::regex_match(name, DOUBLE_PUNCTUATION)
122 && !std::regex_match(name, LEADING_PUNCTUATION)
123 && !std::regex_match(name, TRAILING_PUNCTUATION);
128 return std::regex_match(tag, UNIQUE_TAG_CHARACTERS);
133 return std::regex_match(tag, VOTE_TAG_CHARACTERS);
138 return std::regex_match(tag, MSGCHANNEL_TAG_CHARACTERS)
139 && !std::regex_match(tag, DOUBLE_PUNCTUATION)
140 && !std::regex_match(tag, LEADING_PUNCTUATION)
141 && !std::regex_match(tag, TRAILING_PUNCTUATION);
146 std::vector<std::string> parts;
147 boost::split(parts, name, boost::is_any_of(SUB_NAME_DELIMITER));
151 if (parts.size() > 1)
153 for (
unsigned long i = 1; i < parts.size(); i++)
164 std::vector<std::string> parts;
165 boost::split(parts, name, boost::is_any_of(SUB_NAME_DELIMITER));
170 if (parts.size() > 2) {
174 if (parts.size() > 1)
177 for (
unsigned long i = 1; i < parts.size(); i++)
188 std::vector<std::string> parts;
189 boost::split(parts, name, boost::is_any_of(SUB_NAME_DELIMITER));
193 return parts.size() > 1;
198 std::vector<std::string> parts;
199 boost::split(parts, name, boost::is_any_of(SUB_NAME_DELIMITER));
203 return parts.size() > 1;
210 if (std::regex_match(name, UNIQUE_INDICATOR))
218 else if (std::regex_match(name, MSGCHANNEL_INDICATOR))
226 else if (std::regex_match(name, OWNER_INDICATOR))
234 else if (std::regex_match(name, VOTE_INDICATOR))
242 else if (std::regex_match(name, QUALIFIER_INDICATOR))
254 else if (std::regex_match(name, SUB_QUALIFIER_INDICATOR))
264 else if (std::regex_match(name, RESTRICTED_INDICATOR))
303 return IsAssetNameValid(name) && std::regex_match(name, RESTRICTED_INDICATOR);
308 return IsAssetNameValid(name) && (std::regex_match(name, QUALIFIER_INDICATOR) || std::regex_match(name, SUB_QUALIFIER_INDICATOR));
313 return IsAssetNameValid(name) && std::regex_match(name, MSGCHANNEL_INDICATOR);
320 if (name.size() > MAX_NAME_LENGTH) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH);
return false; }
321 std::vector<std::string> parts;
322 boost::split(parts, name, boost::is_any_of(UNIQUE_TAG_DELIMITER));
324 if (!valid) { error =
"Unique name contains invalid characters (Valid characters are: A-Z a-z 0-9 @ $ % & * ( ) [ ] { } _ . ? : -)";
return false; }
327 if (name.size() > MAX_NAME_LENGTH) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH);
return false; }
328 std::vector<std::string> parts;
329 boost::split(parts, name, boost::is_any_of(MSGCHANNEL_TAG_DELIMITER));
331 if (parts.back().size() > MAX_CHANNEL_NAME_LENGTH) { error =
"Channel name is greater than max length of " + std::to_string(MAX_CHANNEL_NAME_LENGTH);
return false; }
332 if (!valid) { error =
"Message Channel name contains invalid characters (Valid characters are: A-Z 0-9 _ .) (special characters can't be the first or last characters)";
return false; }
335 if (name.size() > MAX_NAME_LENGTH) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH);
return false; }
337 if (!valid) { error =
"Owner name contains invalid characters (Valid characters are: A-Z 0-9 _ .) (special characters can't be the first or last characters)";
return false; }
340 if (name.size() > MAX_NAME_LENGTH) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH);
return false; }
341 std::vector<std::string> parts;
342 boost::split(parts, name, boost::is_any_of(VOTE_TAG_DELIMITER));
344 if (!valid) { error =
"Vote name contains invalid characters (Valid characters are: A-Z 0-9 _ .) (special characters can't be the first or last characters)";
return false; }
347 if (name.size() > MAX_NAME_LENGTH) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH);
return false; }
349 if (!valid) { error =
"Qualifier name contains invalid characters (Valid characters are: A-Z 0-9 _ .) (# must be the first character, _ . special characters can't be the first or last characters)";
return false; }
352 if (name.size() > MAX_NAME_LENGTH) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH);
return false; }
354 if (!valid) { error =
"Restricted name contains invalid characters (Valid characters are: A-Z 0-9 _ .) ($ must be the first character, _ . special characters can't be the first or last characters)";
return false; }
357 if (name.size() > MAX_NAME_LENGTH - 1) { error =
"Name is greater than max length of " + std::to_string(MAX_NAME_LENGTH - 1);
return false; }
360 if (!valid &&
IsAssetNameASubasset(name) && name.size() < 3) { error =
"Name must have at least 3 characters (Valid characters are: A-Z 0-9 _ .)";
return false; }
361 if (!valid) { error =
"Name contains invalid characters (Valid characters are: A-Z 0-9 _ .) (special characters can't be the first or last characters)";
return false; }
372 auto index = std::string::npos;
374 index = name.find_last_of(SUB_NAME_DELIMITER);
376 index = name.find_last_of(UNIQUE_TAG_DELIMITER);
378 index = name.find_last_of(MSGCHANNEL_TAG_DELIMITER);
380 index = name.find_last_of(VOTE_TAG_DELIMITER);
386 index = name.find_last_of(SUB_NAME_DELIMITER);
391 if (std::string::npos != index)
393 return name.substr(0, index);
401 std::string unique = parent +
"#" + tag;
442 std::stringstream ss;
443 ss <<
"Printing an asset" <<
"\n";
444 ss <<
"name : " <<
strName <<
"\n";
445 ss <<
"amount : " <<
nAmount <<
"\n";
446 ss <<
"units : " << std::to_string(
units) <<
"\n";
447 ss <<
"reissuable : " << std::to_string(
nReissuable) <<
"\n";
448 ss <<
"has_ipfs : " << std::to_string(
nHasIPFS) <<
"\n";
461 this->units = int8_t(units);
462 this->nReissuable = int8_t(nReissuable);
463 this->nHasIPFS = int8_t(nHasIPFS);
481 this->nHeight = nHeight;
482 this->blockHash = blockHash;
500 std::vector<unsigned char> vchMessage;
501 vchMessage.push_back(
RVN_R);
502 vchMessage.push_back(
RVN_V);
503 vchMessage.push_back(
RVN_N);
504 vchMessage.push_back(
RVN_Q);
506 vchMessage.
insert(vchMessage.end(), ssAsset.
begin(), ssAsset.
end());
515 std::vector<unsigned char> vchMessage;
516 vchMessage.push_back(
RVN_R);
517 vchMessage.push_back(
RVN_V);
518 vchMessage.push_back(
RVN_N);
519 vchMessage.push_back(
RVN_O);
521 vchMessage.insert(vchMessage.end(), ssOwner.
begin(), ssOwner.
end());
599 std::string ownerName;
600 std::string ownerAddress;
602 errorMsg =
"bad-txns-bad-owner";
606 int size = ownerName.size();
608 if (ownerAddress != address) {
609 errorMsg =
"bad-txns-owner-address-mismatch";
614 errorMsg =
"bad-txns-owner-asset-length";
618 if (ownerName != std::string(assetName +
OWNER_TAG)) {
619 errorMsg =
"bad-txns-owner-name-mismatch";
640 int nStartingIndex = 0;
650 std::vector<unsigned char> vchTransferAsset;
651 vchTransferAsset.insert(vchTransferAsset.end(), scriptPubKey.
begin() + 31, scriptPubKey.
end());
655 ssAsset >> assetTransfer;
656 }
catch(std::exception& e) {
657 std::cout <<
"Failed to get the transfer asset from the stream: " << e.what() << std::endl;
666 int nStartingIndex = 0;
675 std::vector<unsigned char> vchNewAsset;
676 vchNewAsset.insert(vchNewAsset.end(), scriptPubKey.
begin() + nStartingIndex, scriptPubKey.
end());
681 }
catch(std::exception& e) {
682 std::cout <<
"Failed to get the asset from the stream: " << e.what() << std::endl;
691 int nStartingIndex = 0;
700 std::vector<unsigned char> vchNewAsset;
701 vchNewAsset.insert(vchNewAsset.end(), scriptPubKey.
begin() + nStartingIndex, scriptPubKey.
end());
706 }
catch(std::exception& e) {
707 std::cout <<
"Failed to get the msg channel asset from the stream: " << e.what() << std::endl;
716 int nStartingIndex = 0;
725 std::vector<unsigned char> vchNewAsset;
726 vchNewAsset.insert(vchNewAsset.end(), scriptPubKey.
begin() + nStartingIndex, scriptPubKey.
end());
731 }
catch(std::exception& e) {
732 std::cout <<
"Failed to get the qualifier asset from the stream: " << e.what() << std::endl;
741 int nStartingIndex = 0;
750 std::vector<unsigned char> vchNewAsset;
751 vchNewAsset.insert(vchNewAsset.end(), scriptPubKey.
begin() + nStartingIndex, scriptPubKey.
end());
756 }
catch(std::exception& e) {
757 std::cout <<
"Failed to get the restricted asset from the stream: " << e.what() << std::endl;
766 int nStartingIndex = 0;
775 std::vector<unsigned char> vchOwnerAsset;
776 vchOwnerAsset.insert(vchOwnerAsset.end(), scriptPubKey.
begin() + nStartingIndex, scriptPubKey.
end());
780 ssOwner >> assetName;
781 }
catch(std::exception& e) {
782 std::cout <<
"Failed to get the owner asset from the stream: " << e.what() << std::endl;
791 int nStartingIndex = 0;
800 std::vector<unsigned char> vchReissueAsset;
801 vchReissueAsset.insert(vchReissueAsset.end(), scriptPubKey.
begin() + nStartingIndex, scriptPubKey.
end());
807 }
catch(std::exception& e) {
808 std::cout <<
"Failed to get the reissue asset from the stream: " << e.what() << std::endl;
826 std::vector<unsigned char> vchAssetData;
832 }
catch(std::exception& e) {
833 std::cout <<
"Failed to get the asset tx data from the stream: " << e.what() << std::endl;
846 std::vector<unsigned char> vchAssetData;
847 vchAssetData.insert(vchAssetData.end(), scriptPubKey.
begin() +
OFFSET_FOUR, scriptPubKey.
end());
852 }
catch(std::exception& e) {
853 std::cout <<
"Failed to get the global restriction asset tx data from the stream: " << e.what() << std::endl;
866 std::vector<unsigned char> vchAssetData;
867 vchAssetData.insert(vchAssetData.end(), scriptPubKey.
begin() +
OFFSET_THREE, scriptPubKey.
end());
871 ssData >> verifierData;
872 }
catch(std::exception& e) {
873 std::cout <<
"Failed to get the verifier string from the stream: " << e.what() << std::endl;
892 CScript script = vout[vout.size() - 1].scriptPubKey;
916 if (vout.size() < 3) {
917 strError =
"bad-txns-unique-vout-size-to-small";
922 std::set<std::string> setUniqueAssets;
923 std::string assetRoot =
"";
924 int assetOutpointCount = 0;
926 for (
auto out : vout) {
931 strError =
"bad-txns-issue-unique-asset-from-script";
935 if (assetRoot.compare(
"") == 0)
937 if (assetRoot.compare(root) != 0) {
938 strError =
"bad-txns-issue-unique-asset-compare-failed";
943 if (setUniqueAssets.count(asset.
strName)) {
944 strError =
"bad-txns-issue-unique-duplicate-name-in-same-tx";
948 setUniqueAssets.insert(asset.
strName);
949 assetOutpointCount += 1;
953 if (assetOutpointCount == 0) {
954 strError =
"bad-txns-issue-unique-asset-bad-outpoint-count";
959 bool fBurnOutpointFound =
false;
960 for (
auto out : vout) {
962 fBurnOutpointFound =
true;
967 if (!fBurnOutpointFound) {
968 strError =
"bad-txns-issue-unique-asset-burn-outpoints-not-found";
973 bool fOwnerOutFound =
false;
974 for (
auto out : vout) {
976 std::string transferAddress;
979 fOwnerOutFound =
true;
985 if (!fOwnerOutFound) {
986 strError =
"bad-txns-issue-unique-asset-missing-owner-asset";
997 if (nOwners > 0 || nReissues > 0 || nIssues != assetOutpointCount) {
998 strError =
"bad-txns-failed-unique-asset-formatting-check";
1008 if (vout.size() < 3) {
1009 strError =
"bad-txns-issue-vout-size-to-small";
1015 strError =
"bad-txns-issue-data-not-found";
1021 strError =
"bad-txns-issue-owner-data-not-found";
1027 std::string address;
1028 if (!
AssetFromScript(vout[vout.size() - 1].scriptPubKey, asset, address)) {
1029 strError =
"bad-txns-issue-serialzation-failed";
1030 return error(
"%s : Failed to get new asset from transaction: %s", __func__, this->GetHash().GetHex());
1036 std::string strOwnerName;
1038 strError =
"bad-txns-issue-owner-serialzation-failed";
1043 strError =
"bad-txns-issue-owner-name-doesn't-match";
1048 bool fFoundIssueBurnTx =
false;
1049 for (
auto out : vout) {
1051 fFoundIssueBurnTx =
true;
1056 if (!fFoundIssueBurnTx) {
1057 strError =
"bad-txns-issue-burn-not-found";
1068 if (nOwners != 1 || nIssues != 1 || nReissues > 0) {
1069 strError =
"bad-txns-failed-issue-asset-formatting-check";
1093 if (vout.size() < 3) {
1094 strError =
"bad-txns-issue-msgchannel-vout-size-to-small";
1100 strError =
"bad-txns-issue-data-not-found";
1106 std::string address;
1108 strError =
"bad-txns-issue-msgchannel-serialzation-failed";
1109 return error(
"%s : Failed to get new msgchannel asset from transaction: %s", __func__, this->GetHash().GetHex());
1116 bool fFoundIssueBurnTx =
false;
1117 for (
auto out : vout) {
1119 fFoundIssueBurnTx =
true;
1124 if (!fFoundIssueBurnTx) {
1125 strError =
"bad-txns-issue-msgchannel-burn-not-found";
1131 bool fOwnerOutFound =
false;
1132 for (
auto out : vout) {
1134 std::string transferAddress;
1137 fOwnerOutFound =
true;
1143 if (!fOwnerOutFound) {
1144 strError =
"bad-txns-issue-msg-channel-asset-bad-owner-asset";
1155 if (nOwners != 0 || nIssues != 1 || nReissues > 0) {
1156 strError =
"bad-txns-failed-issue-msgchannel-asset-formatting-check";
1180 if (vout.size() < 2) {
1181 strError =
"bad-txns-issue-qualifier-vout-size-to-small";
1187 strError =
"bad-txns-issue-qualifider-data-not-found";
1193 std::string address;
1195 strError =
"bad-txns-issue-qualifier-serialzation-failed";
1196 return error(
"%s : Failed to get new qualifier asset from transaction: %s", __func__, this->GetHash().GetHex());
1203 bool fFoundIssueBurnTx =
false;
1204 for (
auto out : vout) {
1206 fFoundIssueBurnTx =
true;
1211 if (!fFoundIssueBurnTx) {
1212 strError =
"bad-txns-issue-qualifier-burn-not-found";
1218 bool fOwnerOutFound =
false;
1220 for (
auto out : vout) {
1222 std::string transferAddress;
1224 if (root == transfer.
strName) {
1225 fOwnerOutFound =
true;
1231 if (!fOwnerOutFound) {
1232 strError =
"bad-txns-issue-sub-qualifier-parent-outpoint-not-found";
1244 if (nOwners != 0 || nIssues != 1 || nReissues > 0) {
1245 strError =
"bad-txns-failed-issue-asset-formatting-check";
1268 if (vout.size() < 4) {
1269 strError =
"bad-txns-issue-restricted-vout-size-to-small";
1275 strError =
"bad-txns-issue-restricted-data-not-found";
1281 std::string address;
1283 strError =
"bad-txns-issue-restricted-serialization-failed";
1284 return error(
"%s : Failed to get new restricted asset from transaction: %s", __func__, this->GetHash().GetHex());
1291 bool fFoundIssueBurnTx =
false;
1292 for (
auto out : vout) {
1294 fFoundIssueBurnTx =
true;
1299 if (!fFoundIssueBurnTx) {
1300 strError =
"bad-txns-issue-restricted-burn-not-found";
1305 bool fRootOwnerOutFound =
false;
1307 std::string strippedRoot = root.substr(1, root.size() -1) +
OWNER_TAG;
1308 for (
auto out : vout) {
1310 std::string transferAddress;
1312 if (strippedRoot == transfer.
strName) {
1313 fRootOwnerOutFound =
true;
1319 if (!fRootOwnerOutFound) {
1320 strError =
"bad-txns-issue-restricted-root-owner-token-outpoint-not-found";
1326 if (!GetVerifierStringFromTx(verifier, strError)) {
1339 if (nOwners != 0 || nIssues != 1 || nReissues > 0) {
1340 strError =
"bad-txns-failed-issue-asset-formatting-check";
1352 for (
auto out : vout) {
1353 if (out.scriptPubKey.IsNullAssetVerifierTxDataScript()) {
1357 strError =
_(
"Multiple verifier strings found in transaction");
1361 strError =
_(
"Failed to get verifier string from output: ") + out.ToString();
1372 strError =
_(
"Verifier string not found");
1375 return found && count == 1;
1380 bool fNotFound =
false;
1381 return GetVerifierStringFromTx(verifier, strError, fNotFound);
1397 if (vout.size() < 3) {
1398 strError =
"bad-txns-vout-size-to-small";
1404 strError =
"bad-txns-reissue-data-not-found";
1409 std::string address;
1411 strError =
"bad-txns-reissue-serialization-failed";
1420 std::string asset_name_to_check = reissue.
strName;
1424 asset_name_to_check = reissue.
strName.substr(1, reissue.
strName.size() -1);
1428 bool fOwnerOutFound =
false;
1429 for (
auto out : vout) {
1431 std::string transferAddress;
1434 fOwnerOutFound =
true;
1440 if (!fOwnerOutFound) {
1441 strError =
"bad-txns-reissue-owner-outpoint-not-found";
1446 bool fFoundReissueBurnTx =
false;
1447 for (
auto out : vout) {
1449 fFoundReissueBurnTx =
true;
1454 if (!fFoundReissueBurnTx) {
1455 strError =
"bad-txns-reissue-burn-outpoint-not-found";
1466 if (nOwners > 0 || nReissues != 1 || nIssues > 0) {
1467 strError =
"bad-txns-failed-reissue-asset-formatting-check";
1477 bool fBurnOutpointFound =
false;
1478 for (
auto out : vout) {
1480 fBurnOutpointFound =
true;
1485 return fBurnOutpointFound;
1493 this->message = message;
1494 if (!message.empty()) {
1496 this->nExpireTime = nExpireTime;
1498 this->nExpireTime = 0;
1511 strError =
"Invalid parameter: asset_name must only consist of valid characters and have a size between 3 and 30 characters. See help for more details.";
1518 strError =
"Invalid parameter: asset amount can't be equal to or less than zero.";
1522 if (message.empty() && nExpireTime > 0) {
1523 strError =
"Invalid parameter: asset transfer expiration time requires a message to be attached to the transfer";
1527 if (nExpireTime < 0) {
1528 strError =
"Invalid parameter: expiration time must be a positive value";
1532 if (message.size() && !
CheckEncoded(message, strError)) {
1545 strError =
_(
"Verifier String doesn't exist for asset: ") + this->
strName;
1558 ssTransfer << *
this;
1560 std::vector<unsigned char> vchMessage;
1561 vchMessage.push_back(
RVN_R);
1562 vchMessage.push_back(
RVN_V);
1563 vchMessage.push_back(
RVN_N);
1564 vchMessage.push_back(
RVN_T);
1566 vchMessage.
insert(vchMessage.end(), ssTransfer.
begin(), ssTransfer.
end());
1576 this->nReissuable = int8_t(nReissuable);
1578 this->nUnits = nUnits;
1586 std::vector<unsigned char> vchMessage;
1587 vchMessage.push_back(
RVN_R);
1588 vchMessage.push_back(
RVN_V);
1589 vchMessage.push_back(
RVN_N);
1590 vchMessage.push_back(
RVN_R);
1592 vchMessage.
insert(vchMessage.end(), ssReissue.
begin(), ssReissue.
end());
1603 AddToAssetBalance(transferAsset.
strName, address, transferAsset.
nAmount);
1608 if (setNewTransferAssetsToRemove.count(newTransfer))
1609 setNewTransferAssetsToRemove.erase(newTransfer);
1611 setNewTransferAssetsToAdd.insert(newTransfer);
1619 auto pair = std::make_pair(strName, address);
1624 mapAssetsAddressAmount.insert(make_pair(pair, 0));
1630 mapAssetsAddressAmount.at(pair) +=
nAmount;
1637 std::string address =
"";
1638 std::string assetName =
"";
1643 bool fIsOwner =
false;
1661 return error(
"%s : ERROR Failed to get owner asset from the OutPoint: %s", __func__,
1677 if (address !=
"" && assetName !=
"" && nAmount > 0) {
1681 auto pair = make_pair(assetName, address);
1682 if (mapAssetsAddressAmount.count(pair))
1683 mapAssetsAddressAmount.at(pair) -=
nAmount;
1685 if (mapAssetsAddressAmount.at(pair) < 0)
1686 mapAssetsAddressAmount.at(pair) = 0;
1689 vSpentAssets.push_back(spend);
1693 return error(
"%s : ERROR Failed to get asset from the OutPoint: %s", __func__, out.
ToString());
1701 return CheckIfAssetExists(asset.
strName);
1706 return CheckIfAssetExists(assetName);
1711 std::string strAddress =
"";
1712 std::string assetName =
"";
1717 bool fIsOwner =
false;
1723 return error(
"%s : Failed to get asset from script while trying to undo asset spend. OutPoint : %s",
1734 "%s : Failed to get transfer asset from script while trying to undo asset spend. OutPoint : %s",
1741 std::string ownerName;
1744 "%s : Failed to get owner asset from script while trying to undo asset spend. OutPoint : %s",
1746 assetName = ownerName;
1752 "%s : Failed to get reissue asset from script while trying to undo asset spend. OutPoint : %s",
1759 if (assetName ==
"" || strAddress ==
"" || nAmount == 0)
1760 return error(
"%s : AssetName, Address or nAmount is invalid., Asset Name: %s, Address: %s, Amount: %d", __func__, assetName, strAddress, nAmount);
1762 if (!AddBackSpentAsset(coin, assetName, strAddress, nAmount, out))
1763 return error(
"%s : Failed to add back the spent asset. OutPoint : %s", __func__, out.
ToString());
1773 auto pair = std::make_pair(assetName, address);
1777 mapAssetsAddressAmount.insert(std::make_pair(pair, 0));
1779 mapAssetsAddressAmount.at(pair) +=
nAmount;
1784 vUndoAssetAmount.push_back(undoAmount);
1795 return error(
"%s : Failed to get the assets address balance from the database. Asset : %s Address : %s",
1796 __func__, transfer.
strName, address);
1798 auto pair = std::make_pair(transfer.
strName, address);
1799 if (!mapAssetsAddressAmount.count(pair))
1801 "%s : Tried undoing a transfer and the map of address amount didn't have the asset address pair. Asset : %s Address : %s",
1802 __func__, transfer.
strName, address);
1804 if (mapAssetsAddressAmount.at(pair) < transfer.
nAmount)
1806 "%s : Tried undoing a transfer and the map of address amount had less than the amount we are trying to undo. Asset : %s Address : %s",
1807 __func__, transfer.
strName, address);
1810 mapAssetsAddressAmount[pair] -= transfer.
nAmount;
1819 if (!CheckIfAssetExists(asset.
strName))
1820 return error(
"%s : Tried removing an asset that didn't exist. Asset Name : %s", __func__, asset.
strName);
1824 if (setNewAssetsToAdd.count(newAsset))
1825 setNewAssetsToAdd.erase(newAsset);
1827 setNewAssetsToRemove.insert(newAsset);
1830 mapAssetsAddressAmount[std::make_pair(asset.
strName, address)] = 0;
1838 if(CheckIfAssetExists(asset.
strName))
1839 return error(
"%s: Tried adding new asset, but it already existed in the set of assets: %s", __func__, asset.
strName);
1843 if (setNewAssetsToRemove.count(newAsset))
1844 setNewAssetsToRemove.erase(newAsset);
1846 setNewAssetsToAdd.insert(newAsset);
1850 mapAssetsAddressAmount[std::make_pair(asset.
strName, address)] = asset.
nAmount;
1859 auto pair = std::make_pair(reissue.
strName, address);
1864 if (!GetAssetMetaDataIfExists(reissue.
strName, asset, assetHeight, assetBlockHash))
1865 return error(
"%s: Failed to get the original asset that is getting reissued. Asset Name : %s",
1869 if (!mapReissuedAssetData.count(reissue.
strName)) {
1872 if (reissue.
nUnits != -1)
1879 mapReissuedAssetData.insert(make_pair(reissue.
strName, asset));
1881 mapReissuedAssetData.at(reissue.
strName).nAmount += reissue.
nAmount;
1883 if (reissue.
nUnits != -1) {
1884 mapReissuedAssetData.at(reissue.
strName).units = reissue.
nUnits;
1887 mapReissuedAssetData.at(reissue.
strName).nHasIPFS = 1;
1894 if (setNewReissueToRemove.count(reissueAsset))
1895 setNewReissueToRemove.erase(reissueAsset);
1897 setNewReissueToAdd.insert(reissueAsset);
1902 mapAssetsAddressAmount.insert(make_pair(pair, 0));
1905 mapAssetsAddressAmount[pair] += reissue.
nAmount;
1915 auto pair = std::make_pair(reissue.
strName, address);
1920 if (!GetAssetMetaDataIfExists(reissue.
strName, assetData, height, blockHash))
1921 return error(
"%s: Tried undoing reissue of an asset, but that asset didn't exist: %s", __func__, reissue.
strName);
1927 bool fVerifierStringChanged =
false;
1928 std::string verifierString =
"";
1930 for (
auto undoItem : vUndoIPFS) {
1931 if (undoItem.first == reissue.
strName) {
1932 if (undoItem.second.fChangedIPFS)
1934 if(undoItem.second.fChangedUnits)
1935 assetData.
units = undoItem.second.nUnits;
1938 if (undoItem.second.fChangedVerifierString) {
1939 fVerifierStringChanged =
true;
1940 verifierString = undoItem.second.verifierString;
1947 mapReissuedAssetData[assetData.
strName] = assetData;
1951 if (setNewReissueToAdd.count(reissueAsset))
1952 setNewReissueToAdd.erase(reissueAsset);
1954 setNewReissueToRemove.insert(reissueAsset);
1957 if (fVerifierStringChanged) {
1958 RemoveRestrictedVerifier(assetData.
strName, verifierString,
true);
1965 return error(
"%s : Trying to undo reissue of an asset but the assets amount isn't in the database",
1968 mapAssetsAddressAmount[pair] -= reissue.
nAmount;
1970 if (mapAssetsAddressAmount[pair] < 0)
1971 return error(
"%s : Tried undoing reissue of an asset, but the assets amount went negative: %s", __func__,
1984 if (setNewOwnerAssetsToRemove.count(newOwner))
1985 setNewOwnerAssetsToRemove.erase(newOwner);
1987 setNewOwnerAssetsToAdd.insert(newOwner);
2002 if (setNewOwnerAssetsToAdd.count(newOwner))
2003 setNewOwnerAssetsToAdd.erase(newOwner);
2005 setNewOwnerAssetsToRemove.insert(newOwner);
2008 auto pair = std::make_pair(assetsName, address);
2009 mapAssetsAddressAmount[pair] = 0;
2018 if (!UndoTransfer(transfer, address, out))
2019 return error(
"%s : Failed to undo the transfer", __func__);
2022 if (setNewTransferAssetsToAdd.count(newTransfer))
2023 setNewTransferAssetsToAdd.erase(newTransfer);
2025 setNewTransferAssetsToRemove.insert(newTransfer);
2037 if (setNewQualifierAddressToRemove.count(newQualifier)) {
2038 setNewQualifierAddressToRemove.erase(newQualifier);
2042 if (setNewQualifierAddressToAdd.count(newQualifier)) {
2043 setNewQualifierAddressToAdd.erase(newQualifier);
2056 setNewQualifierAddressToAdd.insert(newQualifier);
2068 if (setNewQualifierAddressToAdd.count(newQualifier)) {
2069 setNewQualifierAddressToAdd.erase(newQualifier);
2073 if (setNewQualifierAddressToRemove.count(newQualifier)) {
2074 setNewQualifierAddressToRemove.erase(newQualifier);
2089 setNewQualifierAddressToRemove.insert(newQualifier);
2102 if (setNewRestrictedAddressToRemove.count(newRestricted)) {
2103 setNewRestrictedAddressToRemove.erase(newRestricted);
2107 if (setNewRestrictedAddressToAdd.count(newRestricted)) {
2108 setNewRestrictedAddressToAdd.erase(newRestricted);
2111 setNewRestrictedAddressToAdd.insert(newRestricted);
2123 if (setNewRestrictedAddressToAdd.count(newRestricted)) {
2124 setNewRestrictedAddressToAdd.erase(newRestricted);
2128 if (setNewRestrictedAddressToRemove.count(newRestricted)) {
2129 setNewRestrictedAddressToRemove.erase(newRestricted);
2132 setNewRestrictedAddressToRemove.insert(newRestricted);
2144 if (setNewRestrictedGlobalToRemove.count(newGlobalRestriction)) {
2145 setNewRestrictedGlobalToRemove.erase(newGlobalRestriction);
2149 if (setNewRestrictedGlobalToAdd.count(newGlobalRestriction)) {
2150 setNewRestrictedGlobalToAdd.erase(newGlobalRestriction);
2153 setNewRestrictedGlobalToAdd.insert(newGlobalRestriction);
2165 if (setNewRestrictedGlobalToAdd.count(newGlobalRestriction)) {
2166 setNewRestrictedGlobalToAdd.erase(newGlobalRestriction);
2170 if (setNewRestrictedGlobalToRemove.count(newGlobalRestriction)) {
2171 setNewRestrictedGlobalToRemove.erase(newGlobalRestriction);
2174 setNewRestrictedGlobalToRemove.insert(newGlobalRestriction);
2185 if (setNewRestrictedVerifierToRemove.count(newVerifier))
2186 setNewRestrictedVerifierToRemove.erase(newVerifier);
2188 setNewRestrictedVerifierToAdd.insert(newVerifier);
2199 if (setNewRestrictedVerifierToAdd.count(newVerifier))
2200 setNewRestrictedVerifierToAdd.erase(newVerifier);
2202 setNewRestrictedVerifierToRemove.insert(newVerifier);
2211 std::string message;
2214 for (
auto newAsset : setNewAssetsToRemove) {
2218 message =
"_Failed Erasing New Asset Data from database";
2222 return error(
"%s : %s", __func__, message);
2227 message =
"_Failed Erasing verifier of new asset removal data from database";
2233 message =
"_Failed Erasing Address Balance from database";
2238 message =
"_Failed Erasing New Asset Address Balance from AddressAsset database";
2243 return error(
"%s : %s", __func__, message);
2248 for (
auto newAsset : setNewAssetsToAdd) {
2252 message =
"_Failed Writing New Asset Data to database";
2256 return error(
"%s : %s", __func__, message);
2261 newAsset.asset.nAmount)) {
2263 message =
"_Failed Writing Address Balance to database";
2267 newAsset.asset.nAmount)) {
2269 message =
"_Failed Writing Address Balance to database";
2274 return error(
"%s : %s", __func__, message);
2280 for (
auto ownerAsset : setNewOwnerAssetsToRemove) {
2283 message =
"_Failed Erasing Owner Address Balance from database";
2288 message =
"_Failed Erasing New Owner Address Balance from AddressAsset database";
2292 return error(
"%s : %s", __func__, message);
2297 for (
auto ownerAsset : setNewOwnerAssetsToAdd) {
2298 auto pair = std::make_pair(ownerAsset.assetName, ownerAsset.address);
2299 if (mapAssetsAddressAmount.count(pair) && mapAssetsAddressAmount.at(pair) > 0) {
2301 mapAssetsAddressAmount.at(pair))) {
2303 message =
"_Failed Writing Owner Address Balance to database";
2307 mapAssetsAddressAmount.at(pair))) {
2309 message =
"_Failed Writing Address Balance to database";
2313 return error(
"%s : %s", __func__, message);
2320 for (
auto undoTransfer : setNewTransferAssetsToRemove) {
2321 auto pair = std::make_pair(undoTransfer.transfer.strName, undoTransfer.address);
2322 if (mapAssetsAddressAmount.count(pair)) {
2323 if (mapAssetsAddressAmount.at(pair) == 0) {
2325 undoTransfer.address)) {
2327 message =
"_Failed Erasing Address Quantity from database";
2331 undoTransfer.transfer.strName)) {
2333 message =
"_Failed Erasing UndoTransfer Address Balance from AddressAsset database";
2337 return error(
"%s : %s", __func__, message);
2341 undoTransfer.address,
2342 mapAssetsAddressAmount.at(pair))) {
2344 message =
"_Failed Writing updated Address Quantity to database when undoing transfers";
2348 undoTransfer.transfer.strName,
2349 mapAssetsAddressAmount.at(pair))) {
2351 message =
"_Failed Writing Address Balance to database";
2355 return error(
"%s : %s", __func__, message);
2363 for (
auto newTransfer : setNewTransferAssetsToAdd) {
2364 auto pair = std::make_pair(newTransfer.transfer.strName, newTransfer.address);
2366 if (mapAssetsAddressAmount.count(pair)) {
2368 mapAssetsAddressAmount.at(pair))) {
2370 message =
"_Failed Writing new address quantity to database";
2374 mapAssetsAddressAmount.at(pair))) {
2376 message =
"_Failed Writing Address Balance to database";
2380 return error(
"%s : %s", __func__, message);
2386 for (
auto newReissue : setNewReissueToAdd) {
2387 auto reissue_name = newReissue.reissue.strName;
2388 auto pair = make_pair(reissue_name, newReissue.address);
2389 if (mapReissuedAssetData.count(reissue_name)) {
2390 if(!
passetsdb->
WriteAssetData(mapReissuedAssetData.at(reissue_name), newReissue.blockHeight, newReissue.blockHash)) {
2392 message =
"_Failed Writing reissue asset data to database";
2396 return error(
"%s : %s", __func__, message);
2403 if (mapAssetsAddressAmount.count(pair) && mapAssetsAddressAmount.at(pair) > 0) {
2405 mapAssetsAddressAmount.at(pair))) {
2407 message =
"_Failed Writing reissue asset quantity to the address quantity database";
2411 mapAssetsAddressAmount.at(pair))) {
2413 message =
"_Failed Writing Address Balance to database";
2417 return error(
"%s, %s", __func__, message);
2424 for (
auto undoReissue : setNewReissueToRemove) {
2428 CNewAsset asset(undoReissue.reissue.strName, 0);
2430 if (setNewAssetsToRemove.count(testNewAssetCache)) {
2434 auto reissue_name = undoReissue.reissue.strName;
2435 if (mapReissuedAssetData.count(reissue_name)) {
2436 if(!
passetsdb->
WriteAssetData(mapReissuedAssetData.at(reissue_name), undoReissue.blockHeight, undoReissue.blockHash)) {
2438 message =
"_Failed Writing undo reissue asset data to database";
2442 auto pair = make_pair(undoReissue.reissue.strName, undoReissue.address);
2443 if (mapAssetsAddressAmount.count(pair)) {
2444 if (mapAssetsAddressAmount.at(pair) == 0) {
2447 message =
"_Failed Erasing Address Balance from database";
2452 message =
"_Failed Erasing UndoReissue Balance from AddressAsset database";
2456 mapAssetsAddressAmount.at(pair))) {
2458 message =
"_Failed Writing the undo of reissue of asset from database";
2462 mapAssetsAddressAmount.at(pair))) {
2464 message =
"_Failed Writing Address Balance to database";
2471 return error(
"%s : %s", __func__, message);
2479 for (
auto newVerifier : setNewRestrictedVerifierToAdd) {
2480 auto assetName = newVerifier.assetName;
2483 message =
"_Failed Writing restricted verifier to database";
2487 return error(
"%s : %s", __func__, message);
2494 for (
auto undoVerifiers : setNewRestrictedVerifierToRemove) {
2495 auto assetName = undoVerifiers.assetName;
2498 if (undoVerifiers.fUndoingRessiue) {
2501 message =
"_Failed Writing undo restricted verifer to database";
2506 message =
"_Failed Writing undo restricted verifer to database";
2511 return error(
"%s : %s", __func__, message);
2518 for (
auto newQualifierAddress : setNewQualifierAddressToAdd) {
2523 message =
"_Failed Erasing address qualifier from database";
2527 newQualifierAddress.assetName)) {
2529 message =
"_Failed Erasing qualifier address from database";
2537 message =
"_Failed Writing address qualifier to database";
2543 message =
"_Failed Writing qualifier address to database";
2549 return error(
"%s : %s", __func__, message);
2554 for (
auto undoQualifierAddress : setNewQualifierAddressToRemove) {
2559 message =
"_Failed undoing a removal of a address qualifier from database";
2565 message =
"_Failed undoing a removal of a qualifier address from database";
2573 message =
"_Failed undoing a addition of a address qualifier to database";
2577 undoQualifierAddress.assetName)) {
2579 message =
"_Failed undoing a addition of a qualifier address from database";
2585 return error(
"%s : %s", __func__, message);
2590 for (
auto newRestrictedAddress : setNewRestrictedAddressToAdd) {
2595 message =
"_Failed Erasing restricted address from database";
2602 message =
"_Failed Writing restricted address to database";
2607 return error(
"%s : %s", __func__, message);
2612 for (
auto undoRestrictedAddress : setNewRestrictedAddressToRemove) {
2617 message =
"_Failed undoing a removal of a restricted address from database";
2624 message =
"_Failed undoing a addition of a restricted address to database";
2629 return error(
"%s : %s", __func__, message);
2634 for (
auto newGlobalRestriction : setNewRestrictedGlobalToAdd) {
2639 message =
"_Failed Erasing global restriction from database";
2646 message =
"_Failed Writing global restriction to database";
2651 return error(
"%s : %s", __func__, message);
2656 for (
auto undoGlobalRestriction : setNewRestrictedGlobalToRemove) {
2661 message =
"_Failed undoing a global unfreeze of a restricted asset from database";
2668 message =
"_Failed undoing a global freeze of a restricted asset to database";
2673 return error(
"%s : %s", __func__, message);
2679 for (
auto undoSpend : vUndoAssetAmount) {
2680 auto pair = std::make_pair(undoSpend.assetName, undoSpend.address);
2681 if (mapAssetsAddressAmount.count(pair)) {
2683 mapAssetsAddressAmount.at(pair))) {
2685 message =
"_Failed Writing updated Address Quantity to database when undoing spends";
2689 mapAssetsAddressAmount.at(pair))) {
2691 message =
"_Failed Writing Address Balance to database";
2695 return error(
"%s : %s", __func__, message);
2702 for (
auto spentAsset : vSpentAssets) {
2703 auto pair = make_pair(spentAsset.assetName, spentAsset.address);
2704 if (mapAssetsAddressAmount.count(pair)) {
2705 if (mapAssetsAddressAmount.at(pair) == 0) {
2708 message =
"_Failed Erasing a Spent Asset, from database";
2713 message =
"_Failed Erasing a Spent Asset from AddressAsset database";
2717 return error(
"%s : %s", __func__, message);
2721 mapAssetsAddressAmount.at(pair))) {
2723 message =
"_Failed Erasing a Spent Asset, from database";
2727 mapAssetsAddressAmount.at(pair))) {
2729 message =
"_Failed Writing Address Balance to database";
2733 return error(
"%s : %s", __func__, message);
2743 }
catch (
const std::runtime_error& e) {
2744 return error(
"%s : %s ", __func__, std::string(
"System error while flushing assets: ") + e.what());
2754 return error(
"%s: Couldn't find passets pointer while trying to flush assets cache", __func__);
2757 for (
auto &item : setNewAssetsToAdd) {
2763 for (
auto &item : setNewAssetsToRemove) {
2769 for (
auto &item : mapAssetsAddressAmount)
2772 for (
auto &item : mapReissuedAssetData)
2775 for (
auto &item : setNewOwnerAssetsToAdd) {
2781 for (
auto &item : setNewOwnerAssetsToRemove) {
2787 for (
auto &item : setNewReissueToAdd) {
2793 for (
auto &item : setNewReissueToRemove) {
2799 for (
auto &item : setNewTransferAssetsToAdd) {
2805 for (
auto &item : setNewTransferAssetsToRemove) {
2811 for (
auto &item : vSpentAssets) {
2815 for (
auto &item : vUndoAssetAmount) {
2819 for(
auto &item : setNewQualifierAddressToAdd) {
2831 for(
auto &item : setNewQualifierAddressToRemove) {
2843 for(
auto &item : setNewRestrictedAddressToAdd) {
2855 for(
auto &item : setNewRestrictedAddressToRemove) {
2867 for(
auto &item : setNewRestrictedGlobalToAdd) {
2879 for(
auto &item : setNewRestrictedGlobalToRemove) {
2891 for (
auto &item : setNewRestrictedVerifierToAdd) {
2903 for (
auto &item : setNewRestrictedVerifierToRemove) {
2915 for (
auto &item : mapRootQualifierAddressesAdd) {
2916 for (
auto asset : item.second) {
2921 for (
auto &item : mapRootQualifierAddressesRemove) {
2922 for (
auto asset : item.second) {
2929 }
catch (
const std::runtime_error& e) {
2930 return error(
"%s : %s ", __func__, std::string(
"System error while flushing assets: ") + e.what());
2938 return memusage::DynamicUsage(mapAssetsAddressAmount) + memusage::DynamicUsage(mapReissuedAssetData);
2956 size += (32 + 40 + 8) * vUndoAssetAmount.size();
2958 size += (40 + 40 + 32) * setNewTransferAssetsToRemove.size();
2959 size += (40 + 40 + 32) * setNewTransferAssetsToAdd.size();
2961 size += 72 * setNewOwnerAssetsToAdd.size();
2962 size += 72 * setNewOwnerAssetsToRemove.size();
2964 size += (32 + 40 + 8) * vSpentAssets.size();
2966 size += (80 + 40 + 32 +
sizeof(int)) * setNewAssetsToAdd.size();
2967 size += (80 + 40 + 32 +
sizeof(int)) * setNewAssetsToRemove.size();
2969 size += (80 + 40 + 32 + 32 +
sizeof(int)) * setNewReissueToAdd.size();
2970 size += (80 + 40 + 32 + 32 +
sizeof(int)) * setNewReissueToRemove.size();
2991 size += memusage::DynamicUsage(vUndoAssetAmount);
2992 size += memusage::DynamicUsage(setNewTransferAssetsToRemove);
2993 size += memusage::DynamicUsage(setNewTransferAssetsToAdd);
2994 size += memusage::DynamicUsage(setNewOwnerAssetsToAdd);
2995 size += memusage::DynamicUsage(setNewOwnerAssetsToRemove);
2996 size += memusage::DynamicUsage(vSpentAssets);
2997 size += memusage::DynamicUsage(setNewAssetsToAdd);
2998 size += memusage::DynamicUsage(setNewAssetsToRemove);
2999 size += memusage::DynamicUsage(setNewReissueToAdd);
3000 size += memusage::DynamicUsage(setNewReissueToRemove);
3011 std::string burnAddress =
"";
3018 burnAmount *= numberIssued;
3021 if (!(txOut.
nValue == burnAmount))
3035 if (!(strDestination == burnAddress))
3073 int nStartingIndex = 0;
3110 bool fIsOwner =
false;
3111 if (scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex)) {
3126 bool fIsOwner =
false;
3127 if (!scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex))
3131 std::string address;
3151 bool fIsOwner =
false;
3152 if (!scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex))
3156 std::string address;
3177 bool fIsOwner =
false;
3178 if (scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex)) {
3194 bool fIsOwner =
false;
3195 if (scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex)) {
3211 bool fIsOwner =
false;
3212 if (scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex)) {
3228 bool fIsOwner =
false;
3229 if (!scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex))
3233 std::string address;
3253 bool fIsOwner =
false;
3254 if (!scriptPubKey.
IsAssetScript(nType, fIsOwner, nStartingIndex))
3258 std::string address;
3284 if (setNewAssetsToRemove.count(cachedAsset)) {
3293 if (setNewAssetsToAdd.count(cachedAsset)) {
3294 if (fForceDuplicateCheck) {
3298 LogPrintf(
"%s : Found asset %s in setNewAssetsToAdd but force duplicate check wasn't true\n", __func__, name);
3303 if (fForceDuplicateCheck) {
3307 LogPrintf(
"%s : Found asset %s in setNewAssetsToAdd but force duplicate check wasn't true\n", __func__, name);
3314 if (fForceDuplicateCheck) {
3318 LogPrintf(
"%s : Found asset %s in passetsCache but force duplicate check wasn't true\n", __func__, name);
3327 if (fForceDuplicateCheck) {
3331 LogPrintf(
"%s : Found asset %s in passetsdb but force duplicate check wasn't true\n", __func__, name);
3344 return GetAssetMetaDataIfExists(name, asset, height, hash);
3350 if (mapReissuedAssetData.count(name)) {
3351 asset = mapReissuedAssetData.at(name);
3367 if (setNewAssetsToRemove.count(cachedAsset)) {
3368 LogPrintf(
"%s : Found in new assets to Remove - Returning False\n", __func__);
3374 LogPrintf(
"%s : Found in new assets to Remove - Returning False\n", __func__);
3378 auto setIterator = setNewAssetsToAdd.find(cachedAsset);
3379 if (setIterator != setNewAssetsToAdd.end()) {
3380 asset = setIterator->asset;
3381 nHeight = setIterator->blockHeight;
3382 blockHash = setIterator->blockHash;
3388 asset = setIterator->asset;
3389 nHeight = setIterator->blockHeight;
3390 blockHash = setIterator->blockHash;
3419 LogPrintf(
"%s : Didn't find asset meta data anywhere. Returning False\n", __func__);
3443 std::string address =
"";
3444 std::string assetName =
"";
3447 bool fIsOwner =
false;
3475 LogPrintf(
"Failed to get transfer from script\n");
3507 void GetAllMyAssets(
CWallet* pwallet, std::vector<std::string>& names,
int nMinConf,
bool fIncludeAdministrator,
bool fOnlyAdministrator)
3512 std::map<std::string, std::vector<COutput> > mapAssets;
3513 pwallet->
AvailableAssets(mapAssets,
true,
nullptr, 1, MAX_MONEY, MAX_MONEY, 0, nMinConf);
3515 for (
auto item : mapAssets) {
3519 if (fOnlyAdministrator || fIncludeAdministrator)
3520 names.emplace_back(item.first);
3522 if (fOnlyAdministrator)
3524 names.emplace_back(item.first);
3648 auto pair = make_pair(assetName, address);
3673 bool GetAllMyAssetBalances(std::map<std::string, std::vector<COutput> >& outputs, std::map<std::string, CAmount>& amounts,
const int confirmations,
const std::string&
prefix) {
3680 vpwallets[0]->AvailableAssets(outputs,
true,
nullptr, 1, MAX_MONEY, MAX_MONEY, 0, confirmations);
3683 for (
const auto& pair : outputs) {
3684 if (prefix.empty() || pair.first.find(prefix) == 0) {
3686 for (
auto txout : pair.second) {
3688 if (
GetAssetData(txout.tx->tx->vout[txout.i].scriptPubKey, data))
3691 amounts.insert(std::make_pair(pair.first, balance));
3701 if (encoded.size() == 46) {
3702 std::vector<unsigned char> b;
3704 return std::string(b.begin(), b.end());
3707 else if (encoded.size() == 64 &&
IsHex(encoded)) {
3708 std::vector<unsigned char> vec =
ParseHex(encoded);
3709 return std::string(vec.begin(), vec.end());
3718 if (decoded.size() == 34) {
3721 else if (decoded.size() == 32){
3731 std::vector<unsigned char> b;
3733 return std::string(b.begin(), b.end());
3738 std::vector<char> charData(decoded.begin(), decoded.end());
3739 std::vector<unsigned char> unsignedCharData;
3740 for (
char c : charData)
3741 unsignedCharData.push_back(static_cast<unsigned char>(c));
3747 std::vector<CNewAsset> assets;
3748 assets.push_back(asset);
3749 return CreateAssetTransaction(pwallet, coinControl, assets, address, error, wtxNew, reservekey, nFeeRequired, verifier_string);
3758 std::string strError;
3759 for (
auto asset : assets) {
3766 if (!change_address.empty()) {
3775 std::string strFailReason;
3786 std::string parentName;
3787 for (
auto asset : assets) {
3797 if (parentName.empty())
3798 parentName = parent;
3799 if (parentName != parent) {
3812 if (curBalance < burnAmount) {
3825 std::string strTxError;
3826 std::vector<CRecipient> vecSend;
3827 int nChangePosRet = -1;
3828 bool fSubtractFeeFromAmount =
false;
3830 CRecipient recipient = {scriptPubKey, burnAmount, fSubtractFeeFromAmount};
3840 CRecipient rec = {scriptTransferOwnerAsset, 0, fSubtractFeeFromAmount};
3851 CRecipient rec = {scriptTransferQualifierAsset, 0, fSubtractFeeFromAmount};
3858 for (
auto asset : assets) {
3868 for (
auto asset : assets) {
3880 std::string strStripped = parentName.substr(1, parentName.size() - 1);
3890 CRecipient ownerRec = {scriptTransferOwnerAsset, 0, fSubtractFeeFromAmount};
3894 if (!verifier_string) {
3909 if (!fSubtractFeeFromAmount && burnAmount + nFeeRequired > curBalance)
3910 strTxError =
strprintf(
"Error: This transaction requires a transaction fee of at least %s",
FormatMoney(nFeeRequired));
3920 std::string strTxError;
3921 std::vector<CRecipient> vecSend;
3922 int nChangePosRet = -1;
3923 bool fSubtractFeeFromAmount =
false;
3926 std::string asset_name = reissueAsset.
strName;
3940 if (!change_address.empty()) {
3948 std::string strFailReason;
3960 error = std::make_pair(
RPC_INVALID_PARAMS, std::string(
"Invalid asset name: ") + asset_name);
3966 error = std::make_pair(
RPC_INVALID_PARAMS, std::string(
"Owner Assets are not able to be reissued"));
3972 if (!currentActiveAssetCache) {
3973 error = std::make_pair(
RPC_DATABASE_ERROR, std::string(
"passets isn't initialized"));
3980 std::string(
"passetsCache isn't initialized"));
3985 std::string strError;
3988 std::string(
"Failed to create reissue asset object. Error: ") + strError);
3993 std::string stripped_asset_name = asset_name.substr(1, asset_name.size() - 1);
4015 if (curBalance < burnAmount) {
4038 if (verifier_string) {
4039 if (reissueAsset.
nAmount > 0) {
4040 std::string strError =
"";
4045 std::string strError =
"";
4051 if (reissueAsset.
nAmount > 0) {
4056 std::string strError =
"";
4063 if (verifier_string) {
4078 CRecipient recipient = {scriptPubKeyBurn, burnAmount, fSubtractFeeFromAmount};
4079 CRecipient recipient2 = {scriptTransferOwnerAsset, 0, fSubtractFeeFromAmount};
4081 vecSend.push_back(recipient2);
4083 if (!fSubtractFeeFromAmount && burnAmount + nFeeRequired > curBalance)
4084 strTxError =
strprintf(
"Error: This transaction requires a transaction fee of at least %s",
FormatMoney(nFeeRequired));
4094 bool CreateTransferAssetTransaction(
CWallet* pwallet,
const CCoinControl& coinControl,
const std::vector< std::pair<CAssetTransfer, std::string> >vTransfers,
const std::string& changeAddress, std::pair<int, std::string>&
error,
CWalletTx& wtxNew,
CReserveKey& reservekey,
CAmount& nFeeRequired, std::vector<std::pair<CNullAssetTxData, std::string> >* nullAssetTxData, std::vector<CNullAssetTxData>* nullGlobalRestrictionData)
4097 std::string strTxError;
4098 std::vector<CRecipient> vecSend;
4099 int nChangePosRet = -1;
4100 bool fSubtractFeeFromAmount =
false;
4104 if (curBalance == 0) {
4105 error = std::make_pair(
RPC_WALLET_INSUFFICIENT_FUNDS, std::string(
"This wallet doesn't contain any RVN, transfering an asset requires a network fee"));
4117 std::string address =
transfer.second;
4118 std::string asset_name =
transfer.first.strName;
4119 std::string message =
transfer.first.message;
4121 int64_t expireTime =
transfer.first.nExpireTime;
4128 if (!currentActiveAssetCache) {
4129 error = std::make_pair(
RPC_DATABASE_ERROR, std::string(
"passets isn't initialized"));
4140 _(
"When transferring an 'Ownership Asset' the amount must always be 1. Please try again with the amount of 1")));
4147 std::string strError =
"";
4151 error = std::make_pair(
RPC_INVALID_PARAMETER,
_(
"Unable to transfer restricted asset, this restricted asset has been globally frozen"));
4155 if (!
transfer.first.ContextualCheckAgainstVerifyString(
passets, address, strError)) {
4169 std::string(
_(
"Change address can not be sent to because it doesn't have the correct qualifier tags") + strError));
4177 CAssetTransfer assetTransfer(asset_name, nAmount, message, expireTime);
4180 CRecipient recipient = {scriptPubKey, 0, fSubtractFeeFromAmount};
4185 if (nullAssetTxData) {
4186 std::string strError =
"";
4187 int nAddTagCount = 0;
4188 for (
auto pair : *nullAssetTxData) {
4202 pair.first.ConstructTransaction(dataScript);
4204 CRecipient recipient = {dataScript, 0,
false};
4212 vecSend.push_back(addTagBurnRecipient);
4217 if (nullGlobalRestrictionData) {
4218 std::string strError =
"";
4219 for (
auto dataObject : *nullGlobalRestrictionData) {
4225 dataObject.ConstructGlobalRestrictionTransaction(dataScript);
4226 CRecipient recipient = {dataScript, 0,
false};
4233 if (!fSubtractFeeFromAmount && nFeeRequired > curBalance) {
4261 pairError = std::make_pair(
RPC_WALLET_ERROR,
strprintf(
"Wallet not found. Can't verify if it contains: %s", asset_name));
4265 std::vector<COutput> vCoins;
4266 std::map<std::string, std::vector<COutput> > mapAssetCoins;
4269 if (mapAssetCoins.count(asset_name))
4279 return nAmount % int64_t(pow(10, (
MAX_UNIT - nUnits))) == 0;
4284 if (encodedStr.substr(0, 2) ==
"Qm" && encodedStr.size() == 46) {
4289 if (
IsHex(encodedStr) && encodedStr.length() == 64) {
4294 strError =
_(
"Invalid parameter: ipfs_hash is not valid, or txid hash is not the right length");
4299 void GetTxOutAssetTypes(
const std::vector<CTxOut>& vout,
int& issues,
int& reissues,
int& transfers,
int& owners)
4301 for (
auto out: vout) {
4304 if (out.scriptPubKey.IsAssetScript(type, fIsOwner)) {
4320 int _nStartingPoint;
4321 std::string _strAddress;
4322 bool isAsset =
false;
4323 if (scriptPubKey.
IsAssetScript(nType, fIsOwner, _nStartingPoint)) {
4330 LogPrintf(
"%s : Couldn't get new owner asset from script: %s", __func__,
HexStr(scriptPubKey));
4339 LogPrintf(
"%s : Couldn't get new asset from script: %s", __func__,
HexStr(scriptPubKey));
4349 LogPrintf(
"%s : Couldn't get reissue asset from script: %s", __func__,
HexStr(scriptPubKey));
4358 LogPrintf(
"%s : Couldn't get transfer asset from script: %s", __func__,
HexStr(scriptPubKey));
4361 LogPrintf(
"%s : Unsupported asset type: %s", __func__, nType);
4368 hashBytes =
uint160(std::vector <unsigned char>(scriptPubKey.
begin()+3, scriptPubKey.
begin()+23));
4377 this->asset_name = strAssetname;
4385 strError =
_(
"Asset name is not valid");
4390 strError =
_(
"Asset must be a qualifier, sub qualifier, or a restricted asset");
4394 if (flag != 0 || flag != 1) {
4395 strError =
_(
"Flag must be 1 or 0");
4399 if (fForceCheckPrimaryAssetExists) {
4401 strError =
_(
"Asset doesn't exist: ") + asset_name;
4412 ssAssetTxData << *
this;
4414 std::vector<unsigned char> vchMessage;
4415 vchMessage.
insert(vchMessage.end(), ssAssetTxData.
begin(), ssAssetTxData.
end());
4422 ssAssetTxData << *
this;
4424 std::vector<unsigned char> vchMessage;
4425 vchMessage.
insert(vchMessage.end(), ssAssetTxData.
begin(), ssAssetTxData.
end());
4432 this->verifier_string = verifier;
4438 ssAssetTxData << *
this;
4440 std::vector<unsigned char> vchMessage;
4441 vchMessage.
insert(vchMessage.end(), ssAssetTxData.
begin(), ssAssetTxData.
end());
4461 auto setIterator = setNewRestrictedVerifierToRemove.find(tempCacheVerifier);
4463 if (!fSkipTempCache && setIterator != setNewRestrictedVerifierToRemove.end()) {
4464 if (setIterator->fUndoingRessiue) {
4474 if (setIterator->fUndoingRessiue) {
4481 setIterator = setNewRestrictedVerifierToAdd.find(tempCacheVerifier);
4482 if (!fSkipTempCache && setIterator != setNewRestrictedVerifierToAdd.end()) {
4502 std::string verifier;
4529 auto setIterator = setNewQualifierAddressToRemove.find(cachedQualifierAddress);
4530 if (!fSkipTempCache &&setIterator != setNewQualifierAddressToRemove.end()) {
4542 setIterator = setNewQualifierAddressToAdd.find(cachedQualifierAddress);
4543 if (!fSkipTempCache && setIterator != setNewQualifierAddressToAdd.end()) {
4556 if (!fSkipTempCache && mapRootQualifierAddressesAdd.count(tempCache)){
4557 if (mapRootQualifierAddressesAdd[tempCache].size()) {
4608 auto setIterator = setNewRestrictedAddressToRemove.find(cachedRestrictedAddress);
4609 if (!fSkipTempCache && setIterator != setNewRestrictedAddressToRemove.end()) {
4620 setIterator = setNewRestrictedAddressToAdd.find(cachedRestrictedAddress);
4621 if (!fSkipTempCache && setIterator != setNewRestrictedAddressToAdd.end()) {
4667 auto setIterator = setNewRestrictedGlobalToRemove.find(cachedRestrictedGlobal);
4668 if (!fSkipTempCache && setIterator != setNewRestrictedGlobalToRemove.end()) {
4679 setIterator = setNewRestrictedGlobalToAdd.find(cachedRestrictedGlobal);
4680 if (fSkipTempCache && setIterator != setNewRestrictedGlobalToAdd.end()) {
4711 std::string s(verifier);
4713 std::regex regexSearch;
4715 regexSearch = std::regex(R
"(#[A-Z0-9_.]+)"); 4717 regexSearch = std::regex(R
"([A-Z0-9_.]+)"); 4721 while (std::regex_search(s,match,regexSearch)) {
4722 for (
auto str : match)
4723 qualifiers.insert(str);
4724 s = match.suffix().str();
4736 return str_without_qualifier_tags;
4739 bool CheckVerifierString(
const std::string& verifier, std::set<std::string>& setFoundQualifiers, std::string& strError,
bool fWithTags)
4742 if (verifier ==
"true") {
4747 if (verifier.empty()) {
4748 strError =
_(
"Verifier string can not be empty. To default to true, use \"true\"");
4756 if (strippedVerifier.length() > 80){
4757 strError =
_(
"Verifier string has length greater than 80 after whitespaces and '#' are removed");
4770 for (
auto qualifier : setFoundQualifiers) {
4772 std::string edited_qualifier;
4776 edited_qualifier = qualifier;
4780 strError =
"bad-txns-null-verifier-invalid-asset-name-" + qualifier;
4784 vals.insert(std::make_pair(qualifier,
true));
4790 }
catch (
const std::runtime_error& run_error) {
4791 strError =
"bad-txns-null-verifier-failed-syntax-check";
4792 return error(
"%s : Verifier string failed to resolve. Please check string syntax - exception: %s\n", __func__, run_error.what());
4799 if (flag != 0 && flag != 1) {
4800 strError =
"bad-txns-null-data-flag-must-be-0-or-1";
4817 if (fHasQualifier) {
4818 strError =
"bad-txns-null-data-add-qualifier-when-already-assigned";
4822 if (!fHasQualifier) {
4823 strError =
"bad-txns-null-data-removing-qualifier-when-not-assigned";
4845 strError =
"bad-txns-null-data-freeze-address-when-already-frozen";
4850 strError =
"bad-txns-null-data-unfreeze-address-when-not-frozen";
4871 if (fIsGloballyFrozen) {
4872 strError =
"bad-txns-null-data-global-freeze-when-already-frozen";
4876 if (!fIsGloballyFrozen) {
4877 strError =
"bad-txns-null-data-global-unfreeze-when-not-frozen";
4892 strError =
"bad-txns-null-verifier-data-serialization";
4898 strError =
"bad-txns-null-verifier-data-contained-whitespaces";
4904 strError =
"bad-txns-null-verifier-data-contained-qualifier-character-#";
4908 std::set<std::string> setFoundQualifiers;
4919 std::string address;
4921 strError =
"bad-txns-null-asset-data-serialization";
4936 strError =
"bad-txns-null-asset-data-on-non-restricted-or-qualifier-asset";
4948 strError =
"bad-txns-null-global-asset-data-serialization";
4964 strError =
"bad-txns-null-verifier-data-serialization";
4969 std::string strError =
"";
4970 std::string address =
"";
4982 if (verifier ==
"true")
4986 std::set<std::string> setFoundQualifiers;
4991 for(
auto qualifier : setFoundQualifiers) {
4992 std::string search = qualifier;
4996 strError =
"bad-txns-null-verifier-contains-non-issued-qualifier";
5003 if (check_address.empty())
5010 for (
auto qualifier : setFoundQualifiers) {
5011 std::string search = qualifier;
5019 vals.insert(std::make_pair(qualifier, has_qualifier));
5025 error(
"%s : The address %s failed to verify against: %s", __func__, check_address, verifier);
5026 strError =
"bad-txns-null-verifier-address-failed-verification";
5030 }
catch (
const std::runtime_error& run_error) {
5031 strError =
"bad-txns-null-verifier-failed-contexual-syntax-check";
5032 return error(
"%s : Verifier string failed to resolve. Please check string syntax - exception: %s\n", __func__, run_error.what());
5041 strError =
"Invalid parameter: asset_name must only consist of valid characters and have a size between 3 and 30 characters. See help for more details.";
5047 strError =
"Invalid parameter: asset amount can't be equal to or less than zero.";
5052 strError =
"Invalid parameter: asset transfer expiration time requires a message to be attached to the transfer";
5057 strError =
"Invalid parameter: expiration time must be a positive value";
5069 strError =
"bad-txns-transfer-msgchannel-before-messaging-is-active";
5076 strError =
"bad-txns-transfer-restricted-before-it-is-active";
5082 strError =
"bad-txns-transfer-restricted-asset-that-is-globally-restricted";
5088 std::string strError =
"";
5090 error(
"%s : %s", __func__, strError);
5098 strError =
"bad-txns-transfer-qualifier-before-it-is-active";
5111 strError =
_(
"Invalid parameter: asset_name must only consist of valid characters and have a size between 3 and 30 characters. See help for more details.");
5125 strError =
_(
"Invalid parameter: reissuable must be 0");
5140 strError =
_(
"Invalid parameter: reissuable must be 0");
5150 strError =
_(
"Invalid parameters: asset_name can't have a '!' at the end of it. See help for more details.");
5155 strError =
_(
"Invalid parameter: asset amount can't be equal to or less than zero.");
5159 if (asset.
nAmount > MAX_MONEY) {
5160 strError =
_(
"Invalid parameter: asset amount greater than max money: ") + std::to_string(MAX_MONEY / COIN);
5165 strError =
_(
"Invalid parameter: units must be between 0-8.");
5170 strError =
_(
"Invalid parameter: amount must be divisible by the smaller unit assigned to the asset");
5175 strError =
_(
"Invalid parameter: reissuable must be 0 or 1");
5180 strError =
_(
"Invalid parameter: has_ipfs must be 0 or 1.");
5190 strError =
"bad-txns-new-asset-when-assets-is-not-active";
5199 strError = std::string(
_(
"Invalid parameter: asset_name '")) + asset.
strName + std::string(
_(
"' has already been used"));
5204 if (fCheckMempool) {
5206 strError =
_(
"Asset with this name is already in the mempool");
5214 strError =
_(
"Invalid parameter: ipfs_hash must be 46 characters. Txid must be valid 64 character hash");
5218 strError =
_(
"Invalid parameter: ipfs_hash must be 46 characters. Txid must be valid 64 character hash");
5237 strError =
_(
"Unable to reissue asset: amount must be 0 or larger");
5242 strError =
_(
"Unable to reissue asset: unit must be between 8 and -1");
5259 strError =
_(
"Unable to reissue asset: reissuable must be 0 or 1");
5277 std::string strAddress;
5279 strError =
"bad-txns-reissue-asset-contextual-check";
5290 strError =
_(
"Unable to reissue asset: asset_name '") + reissue_asset.
strName +
_(
"' doesn't exist in the database");
5296 strError =
_(
"Unable to reissue asset: reissuable is set to false");
5301 strError =
_(
"Unable to reissue asset: asset_name '") + reissue_asset.
strName +
5302 _(
"' the amount trying to reissue is to large");
5307 strError =
_(
"Unable to reissue asset: amount must be divisible by the smaller unit assigned to the asset");
5312 strError =
_(
"Unable to reissue asset: unit must be larger than current unit selection");
5318 strError =
_(
"Invalid parameter: ipfs_hash must be 34 bytes, Txid must be 32 bytes");
5329 bool fNotFound =
false;
5339 if (reissue_asset.
nAmount > 0) {
5349 error(
"%s : failed to get verifier string from a restricted asset, this shouldn't happen, database is out of sync. Reindex required. Please report this is to development team asset name: %s, txhash : %s",__func__, reissue_asset.
strName, tx.
GetHash().
GetHex());
5350 strError =
"failed to get verifier string from a restricted asset, database is out of sync. Reindex required. Please report this is to development team";
5374 strError =
_(
"Unable to reissue asset: asset_name '") + reissue_asset.
strName +
5375 _(
"' doesn't exist in the database");
5381 strError =
_(
"Unable to reissue asset: reissuable is set to false");
5386 strError =
_(
"Unable to reissue asset: asset_name '") + reissue_asset.
strName +
5387 _(
"' the amount trying to reissue is to large");
5392 strError =
_(
"Unable to reissue asset: amount must be divisible by the smaller unit assigned to the asset");
5397 strError =
_(
"Unable to reissue asset: unit must be larger than current unit selection");
5404 strError =
_(
"Invalid parameter: ipfs_hash must be 34 bytes, Txid must be 32 bytes");
5418 for (
auto out : tx.
vout)
5423 std::string strAddress;
5425 strError =
"bad-txns-issue-unique-serialization-failed";
bool QualifierAssetFromTransaction(const CTransaction &tx, CNewAsset &asset, std::string &strAddress)
bool WriteQualifierAddress(const std::string &address, const std::string &tag)
std::set< CAssetCacheRestrictedVerifiers > setNewRestrictedVerifierToAdd
Restricted Assets Verifier Caches.
bool WriteAssetAddressQuantity(const std::string &assetName, const std::string &address, const CAmount &quantity)
Aliases for backward compatibility.
CAmount GetAddNullQualifierTagBurnAmount()
bool DecodeBase58(const char *psz, std::vector< unsigned char > &vch)
Decode a base58-encoded string (psz) into a byte vector (vchRet).
const std::string & IssueUniqueAssetBurnAddress() const
CAmount GetIssueAssetBurnAmount()
Functions to be used to get access to the current burn amount required for specific asset issuance tr...
#define OWNER_ASSET_AMOUNT
#define UNIQUE_ASSET_AMOUNT
bool ContextualCheckUniqueAsset(CAssetsCache *assetCache, const CNewAsset &unique_asset, std::string &strError)
bool CheckAddingTagBurnFee(const int &count) const
bool IsNewOwnerTxValid(const CTransaction &tx, const std::string &assetName, const std::string &address, std::string &errorMsg)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
void ConstructOwnerTransaction(CScript &script) const
std::map< std::string, bool > Vals
Valuation of atomic propositions.
void ConstructTransaction(CScript &script) const
CAmount GetBurnAmount(const int nType)
bool CheckIssueDataTx(const CTxOut &txOut)
issue asset scripts to make sure script meets the standards
bool CreateAssetTransaction(CWallet *pwallet, CCoinControl &coinControl, const CNewAsset &asset, const std::string &address, std::pair< int, std::string > &error, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRequired, std::string *verifier_string)
Creates new asset issuance transaction.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
#define UNIQUE_ASSET_UNITS
Keypool ran out, call keypoolrefill first.
std::set< CAssetCacheRestrictedAddress > setNewRestrictedAddressToAdd
Restricted Address Asset Caches.
bool WriteAddressQualifier(const std::string &address, const std::string &tag)
const CAmount & IssueQualifierAssetBurnAmount() const
bool VerifyRestrictedAddressChange(CAssetsCache &cache, const CNullAssetTxData &data, const std::string &address, std::string &strError)
bool IsNewRestrictedAsset() const
Make sure to call VerifyNewAsset if this call returns true.
bool ContextualCheckReissueAsset(CAssetsCache *assetCache, const CReissueAsset &reissue_asset, std::string &strError, const CTransaction &tx)
bool RemoveGlobalRestricted(const std::string &assetName, const RestrictedType type)
Changes Memory Only, this is only called when undoing a block from the chain.
bool TrySpendCoin(const COutPoint &out, const CTxOut &coin)
Cache only validation functions.
CLRUCache< std::string, int8_t > * passetsQualifierCache
Global variable that points to the asset address qualifier LRU Cache (protected by cs_main) ...
bool CheckOwnerDataTx(const CTxOut &txOut)
std::string GetBurnAddress(const int nType)
bool RemoveTransfer(const CAssetTransfer &transfer, const std::string &address, const COutPoint &out)
Changes Memory Only.
bool CheckForGlobalRestriction(const std::string &restricted_name, bool fSkipTempCache=false)
Return true if the restricted asset is globally freezing trading.
CCriticalSection cs_wallet
const CAmount & IssueSubQualifierAssetBurnAmount() const
bool AddOwnerAsset(const std::string &assetsName, const std::string address)
Changes Memory Only.
THESE ARE ONLY TO BE USED WHEN ADDING THINGS TO THE CACHE DURING CONNECT AND DISCONNECT BLOCK...
const uint256 & GetHash() const
bool CreateTransferAssetTransaction(CWallet *pwallet, const CCoinControl &coinControl, const std::vector< std::pair< CAssetTransfer, std::string > >vTransfers, const std::string &changeAddress, std::pair< int, std::string > &error, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRequired, std::vector< std::pair< CNullAssetTxData, std::string > > *nullAssetTxData, std::vector< CNullAssetTxData > *nullGlobalRestrictionData)
Create a transfer asset transaction.
std::string EncodeIPFS(std::string decoded)
CRestrictedDB * prestricteddb
Global variable that points to the active restricted asset database (protected by cs_main) ...
std::set< CAssetCacheQualifierAddress > setNewQualifierAddressToRemove
#define OFFSET_TWENTY_THREE
bool AssetFromScript(const CScript &scriptPubKey, CNewAsset &assetNew, std::string &strAddress)
bool EraseQualifierAddress(const std::string &address, const std::string &tag)
std::set< CAssetCacheNewOwner > setNewOwnerAssetsToRemove
bool TransferAssetFromScript(const CScript &scriptPubKey, CAssetTransfer &assetTransfer, std::string &strAddress)
Get specific asset type metadata from the given scripts.
CCriticalSection cs_main
Global state.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CTxOut out
unspent transaction output
void ConstructTransaction(CScript &script) const
CTxDestination DecodeDestination(const std::string &str)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
bool Flush()
Flush all new cache entries into the passets global cache.
static std::string removeWhitespaces(const std::string &source)
std::string EncodeBase58(const unsigned char *pbegin, const unsigned char *pend)
Why base-58 instead of standard base-64 encoding?
bool EraseAddressQualifier(const std::string &address, const std::string &tag)
bool AssetFromTransaction(const CTransaction &tx, CNewAsset &asset, std::string &strAddress)
These types of asset tx, have specific metadata at certain indexes in the transaction.
bool IsSubNameValid(const std::string &name)
const CAmount & IssueMsgChannelAssetBurnAmount() const
bool ReadAssetAddressQuantity(const std::string &assetName, const std::string &address, CAmount &quantity)
bool QualifierAssetFromScript(const CScript &scriptPubKey, CNewAsset &assetNew, std::string &strAddress)
std::vector< CWalletRef > vpwallets
std::string DecodeIPFS(std::string encoded)
void ConstructTransaction(CScript &script) const
bool VerifyNewUniqueAsset(std::string &strError) const
Call this function after IsNewUniqueAsset.
size_t GetCacheSizeV2() const
Get an estimated size of the cache in bytes that will be needed inorder to save to database...
const std::string & IssueSubQualifierAssetBurnAddress() const
Double ended buffer combining vector and stream-like interfaces.
bool AssetNullDataFromScript(const CScript &scriptPubKey, CNullAssetTxData &assetData, std::string &strAddress)
CAmount GetIssueSubAssetBurnAmount()
std::string ToString() const
std::set< CAssetCacheNewTransfer > setNewTransferAssetsToRemove
bool RemoveRestrictedVerifier(const std::string &assetName, const std::string &verifier, const bool fUndoingReissue=false)
Changes Memory Only.
CAmount GetIssueSubQualifierAssetBurnAmount()
bool IsAssetNameASubQualifier(const std::string &name)
Check if an asset is a sub qualifier.
bool ContainsAsset(const CNewAsset &asset)
Help functions.
CAssetsDB * passetsdb
RVN START.
bool ReissueAssetFromScript(const CScript &scriptPubKey, CReissueAsset &reissue, std::string &strAddress)
bool IsScriptNewMsgChannelAsset(const CScript &scriptPubKey)
Check script and see if it matches the message channel issuance template.
bool IsNewQualifierAsset() const
Make sure to call VerifyNewQualifierAsset if this call returns true.
const CAmount & IssueUniqueAssetBurnAmount() const
bool IsValid(std::string &strError) const
bool RemoveNewAsset(const CNewAsset &asset, const std::string address)
Cache only undo functions.
bool ReadGlobalRestriction(const std::string &assetName)
bool IsNewAsset() const
RVN START.
CAmount GetBalance() const
bool CheckIssueBurnTx(const CTxOut &txOut, const AssetType &type, const int numberIssued)
Check to make sure the script contains the burn transaction.
#define QUALIFIER_ASSET_MAX_AMOUNT
Invalid, missing or duplicate parameter.
bool EraseAddressAssetQuantity(const std::string &address, const std::string &assetName)
const std::string & ReissueAssetBurnAddress() const
std::set< CAssetCacheNewOwner > setNewOwnerAssetsToAdd
Ownership Assets Caches.
CLRUCache< std::string, int8_t > * passetsRestrictionCache
Global variable that points to the asset address restriction LRU Cache (protected by cs_main) ...
bool IsVoteTagValid(const std::string &tag)
static std::string removeCharacter(const std::string &source, const char ch)
bool GetAssetData(const CScript &script, CAssetOutputEntry &data)
bool IsAssetNameAnMsgChannel(const std::string &name)
Check if an asset is a message channel.
bool IsNameValidBeforeTag(const std::string &name)
#define QUALIFIER_ASSET_UNITS
int64_t CAmount
Amount in corbies (Can be negative)
std::vector< CAssetCacheUndoAssetAmount > vUndoAssetAmount
These are memory only containers that show dirty entries that will be databased when flushed...
std::set< CAssetCacheNewAsset > setNewAssetsToRemove
New Assets Caches.
bool RemoveOwnerAsset(const std::string &assetsName, const std::string address)
Changes Memory Only.
std::vector< CAssetCacheSpendAsset > vSpentAssets
bool CheckTransferOwnerTx(const CTxOut &txOut)
General error during transaction or block submission.
bool IsQualifierNameValidBeforeTag(const std::string &name)
bool OwnerFromTransaction(const CTransaction &tx, std::string &ownerName, std::string &strAddress)
void GetAllMyAssets(CWallet *pwallet, std::vector< std::string > &names, int nMinConf, bool fIncludeAdministrator, bool fOnlyAdministrator)
bool AreMessagingDeployed()
bool IsMsgChannelTagValid(const std::string &tag)
bool GlobalAssetNullDataFromScript(const CScript &scriptPubKey, CNullAssetTxData &assetData)
bool VerifyGlobalRestrictedChange(CAssetsCache &cache, const CNullAssetTxData &data, std::string &strError)
bool IsAssetNameValid(const std::string &name, AssetType &assetType, std::string &error)
void push_back(const T &value)
const std::string & IssueMsgChannelAssetBurnAddress() const
std::string DecodeAssetData(std::string encoded)
Decode and Encode IPFS hashes, or OIP hashes.
bool IsAssetNameASubasset(const std::string &name)
bool DumpCacheToDatabase()
Write asset cache data to database.
bool UndoTransfer(const CAssetTransfer &transfer, const std::string &address, const COutPoint &outToRemove)
Changes Memory Only.
bool ContextualCheckVerifierAssetTxOut(const CTxOut &txout, CAssetsCache *assetCache, std::string &strError)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
CAmount GetIssueUniqueAssetBurnAmount()
bool CheckIfAssetExists(const std::string &name, bool fForceDuplicateCheck=true)
Returns true if an asset with this name already exists.
std::set< CAssetCacheRestrictedAddress > setNewRestrictedAddressToRemove
bool CreateTransactionWithReissueAsset(const std::vector< CRecipient > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl &coin_control, const CReissueAsset &reissueAsset, const CTxDestination destination, bool sign=true)
bool IsScriptOwnerAsset(const CScript &scriptPubKey)
Check script and see if it matches the owner issuance template.
CLRUCache< std::string, CNullAssetTxVerifierString > * passetsVerifierCache
Global variable that points to the asset verifier LRU Cache (protected by cs_main) ...
bool WriteAddressAssetQuantity(const std::string &address, const std::string &assetName, const CAmount &quantity)
bool AreAssetsDeployed()
RVN START.
bool VerifyNewQualfierAsset(std::string &strError) const
To be called on CTransactions where IsNewQualifierAsset returns true.
UniValue transfer(const JSONRPCRequest &request)
bool VerifyNullAssetDataFlag(const int &flag, std::string &strError)
Helper methods that validate changes to null asset data transaction databases.
bool GetAssetMetaDataIfExists(const std::string &name, CNewAsset &asset)
Returns true if an asset with the name exists, and it was able to get the asset metadata from databas...
CAssetsCache * GetCurrentAssetCache()
bool IsRootNameValid(const std::string &name)
bool MsgChannelAssetFromTransaction(const CTransaction &tx, CNewAsset &asset, std::string &strAddress)
void ExtractVerifierStringQualifiers(const std::string &verifier, std::set< std::string > &qualifiers, bool fWithTag)
Helper method for extracting #TAGS from a verifier string.
bool EraseAssetAddressQuantity(const std::string &assetName, const std::string &address)
void ConstructTransaction(CScript &script) const
Constructs a CScript that carries the asset name and quantity and adds to to the end of the given scr...
bool IsScriptNewRestrictedAsset(const CScript &scriptPubKey)
Check script and see if it matches the restricted issueance template.
bool EraseGlobalRestriction(const std::string &assetName)
bool ContextualCheckNewAsset(CAssetsCache *assetCache, const CNewAsset &asset, std::string &strError, bool fCheckMempool)
const uint256 & GetHash() const
bool ContextualCheckNullAssetTxOut(const CTxOut &txout, CAssetsCache *assetCache, std::string &strError)
bool ReadVerifier(const std::string &assetName, std::string &verifier)
CTxDestination destChange
bool EraseVerifier(const std::string &assetName)
std::map< std::string, uint256 > mapReissuedAssets
bool CheckForAddressRootQualifier(const std::string &address, const std::string &qualifier)
bool RemoveQualifierAddress(const std::string &assetName, const std::string &address, const QualifierType type)
Changes Memory Only, this is only called when undoing a block from the chain.
std::string GetRejectReason() const
bool ParseAssetScript(CScript scriptPubKey, uint160 &hashBytes, std::string &assetName, CAmount &assetAmount)
Helper method for extracting address bytes, asset name and amount from an asset script.
bool ReadAssetData(const std::string &strName, CNewAsset &asset, int &nHeight, uint256 &blockHash)
bool IsHex(const std::string &str)
const std::vector< CTxOut > vout
CAmount GetIssueRestrictedAssetBurnAmount()
bool IsValid(std::string &strError, CAssetsCache &assetCache, bool fForceCheckPrimaryAssetExists) const
bool CreateNewChangeAddress(CReserveKey &reservekey, CKeyID &keyID, std::string &strFailReason)
RVN START.
bool VerifyQualifierChange(CAssetsCache &cache, const CNullAssetTxData &data, const std::string &address, std::string &strError)
static bool resolve(const std::string &source, const Vals &valuation)
bool EraseRestrictedAddress(const std::string &address, const std::string &assetName)
bool ContextualCheckGlobalAssetTxOut(const CTxOut &txout, CAssetsCache *assetCache, std::string &strError)
bool CreateTransactionWithAssets(const std::vector< CRecipient > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl &coin_control, const std::vector< CNewAsset > assets, const CTxDestination destination, const AssetType &assetType, bool sign=true)
RVN START.
const CAmount & ReissueAssetBurnAmount() const
bool GetAssetInfoFromScript(const CScript &scriptPubKey, std::string &strName, CAmount &nAmount)
std::set< CAssetCacheQualifierAddress > setNewQualifierAddressToAdd
Qualfier Address Asset Caches.
bool IsRestrictedNameValid(const std::string &name)
bool OwnerAssetFromScript(const CScript &scriptPubKey, std::string &assetName, std::string &strAddress)
An output of a transaction.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Raven scriptPubKey for the given CTxDestination.
CNullAssetTxVerifierString()
bool CheckReissueBurnTx(const CTxOut &txOut)
Check to make sure the script contains the reissue burn data.
CNewAsset & operator=(const CNewAsset &asset)
const std::string & IssueQualifierAssetBurnAddress() const
bool IsScriptNewAsset(const CScript &scriptPubKey)
Check script and see if it matches the asset issuance template.
const std::string & IssueRestrictedAssetBurnAddress() const
An outpoint - a combination of a transaction hash and an index n into its vout.
bool GetVerifierStringFromTx(CNullAssetTxVerifierString &verifier, std::string &strError) const
bool IsNullAssetVerifierTxDataScript() const
CAmount GetReissueAssetBurnAmount()
bool SendAssetTransaction(CWallet *pwallet, CWalletTx &transaction, CReserveKey &reserveKey, std::pair< int, std::string > &error, std::string &txid)
Send any type of asset transaction to the network.
CLRUCache< std::string, int8_t > * passetsGlobalRestrictionCache
Global variable that points to the global asset restriction LRU Cache (protected by cs_main) ...
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
void ConstructTransaction(CScript &script) const
const std::string & AddNullQualifierTagBurnAddress() const
CAmount GetIssueMsgChannelAssetBurnAmount()
bool RemoveReissueAsset(const CReissueAsset &reissue, const std::string address, const COutPoint &out, const std::vector< std::pair< std::string, CBlockAssetUndo > > &vUndoIPFS)
Changes Memory Only.
bool AddGlobalRestricted(const std::string &assetName, const RestrictedType type)
Changes Memory Only, this only called when adding a block to the chain.
bool EraseAssetData(const std::string &assetName)
std::string GetUniqueAssetName(const std::string &parent, const std::string &tag)
Build a unique asset buy giving the root name, and the tag name (ROOT, TAG) => ROOT::TAG.
std::map< std::pair< std::string, std::string >, CAmount > mapAssetsAddressAmount
std::string GetStrippedVerifierString(const std::string &verifier)
bool ContextualCheckAgainstVerifyString(CAssetsCache *assetCache, const std::string &address, std::string &strError) const
bool WriteAssetData(const CNewAsset &asset, const int nHeight, const uint256 &blockHash)
A transaction with a bunch of additional info that only the owner cares about.
std::map< CAssetCacheRootQualifierChecker, std::set< std::string > > mapRootQualifierAddressesAdd
Root Qualifier Address Map.
bool RestrictedAssetFromTransaction(const CTransaction &tx, CNewAsset &asset, std::string &strAddress)
void GetAllAdministrativeAssets(CWallet *pwallet, std::vector< std::string > &names, int nMinConf)
bool UniqueAssetFromTransaction(const CTransaction &tx, CNewAsset &asset, std::string &strAddress)
CAmount GetIssueQualifierAssetBurnAmount()
bool ReadAddressQualifier(const std::string &address, const std::string &tag)
bool AreRestrictedAssetsDeployed()
std::set< CAssetCacheReissueAsset > setNewReissueToRemove
New Reissue Caches.
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
bool RemoveRestrictedAddress(const std::string &assetName, const std::string &address, const RestrictedType type)
Changes Memory Only, this is only called when undoing a block from the chain.
std::set< CAssetCacheNewAsset > setNewAssetsToAdd
const CAmount & IssueAssetBurnAmount() const
RVN Start.
bool MsgChannelAssetFromScript(const CScript &scriptPubKey, CNewAsset &assetNew, std::string &strAddress)
bool IsScriptTransferAsset(const CScript &scriptPubKey)
Check script and see if it matches the transfer asset template.
bool AddQualifierAddress(const std::string &assetName, const std::string &address, const QualifierType type)
Changes Memory Only, this only called when adding a block to the chain.
bool IsScriptReissueAsset(const CScript &scriptPubKey)
Check script and see if it matches the reissue template.
bool GetAssetInfoFromCoin(const Coin &coin, std::string &strName, CAmount &nAmount)
std::atomic_bool fReindex
bool AddRestrictedAddress(const std::string &assetName, const std::string &address, const RestrictedType type)
Changes Memory Only, this only called when adding a block to the chain.
void AvailableAssets(std::map< std::string, std::vector< COutput > > &mapAssetCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t &nMaximumCount=0, const int &nMinDepth=0, const int &nMaxDepth=9999999) const
Helper function that calls AvailableCoinsAll, used for transfering assets.
CAssetsCache * passets
Global variable that point to the active assets (protected by cs_main)
bool AddTransferAsset(const CAssetTransfer &transferAsset, const std::string &address, const COutPoint &out, const CTxOut &txOut)
bool AddNewAsset(const CNewAsset &asset, const std::string address, const int &nHeight, const uint256 &blockHash)
Cache only add asset functions.
bool WriteRestrictedAddress(const std::string &address, const std::string &assetName)
std::set< CAssetCacheReissueAsset > setNewReissueToAdd
const_iterator end() const
const std::string & IssueSubAssetBurnAddress() const
std::string EncodeDestination(const CTxDestination &dest)
const_iterator begin() const
iterator insert(iterator it, const char &x=char())
A key allocated from the key pool.
bool ReissueAssetFromTransaction(const CTransaction &tx, CReissueAsset &reissue, std::string &strAddress)
bool VerifyWalletHasAsset(const std::string &asset_name, std::pair< int, std::string > &pairError)
Verifies that this wallet owns the give asset.
std::map< std::string, uint256 > mapAssetToHash
const CChainParams & Params()
Return the currently selected parameters.
bool IsNewMsgChannelAsset() const
Make sure to call VerifyNewUniqueAsset if this call returns true.
bool IsNullAssetTxDataScript() const
Serialized script, used inside transaction inputs and outputs.
bool CreateReissueAssetTransaction(CWallet *pwallet, CCoinControl &coinControl, const CReissueAsset &reissueAsset, const std::string &address, std::pair< int, std::string > &error, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRequired, std::string *verifier_string)
Create a reissue asset transaction.
bool CheckAmountWithUnits(const CAmount &nAmount, const int8_t nUnits)
Checks the amount and units, and makes sure that the amount uses the correct decimals.
Not enough funds in wallet or account.
std::string GetParentName(const std::string &name)
Get the root name of an asset.
bool GetAllMyAssetBalances(std::map< std::string, std::vector< COutput > > &outputs, std::map< std::string, CAmount > &amounts, const int confirmations, const std::string &prefix)
sets balances with the total quantity of each owned asset
std::string verifier_string
std::map< uint256, std::string > mapReissuedTx
std::set< CAssetCacheRestrictedGlobal > setNewRestrictedGlobalToRemove
const CAmount & IssueRestrictedAssetBurnAmount() const
bool CheckForAddressQualifier(const std::string &qualifier_name, const std::string &address, bool fSkipTempCache=false)
Return true if the address has the given qualifier assigned to it.
A reference to a CKey: the Hash160 of its serialized public key.
bool ContextualCheckVerifierString(CAssetsCache *cache, const std::string &verifier, const std::string &check_address, std::string &strError, bool fWithTags)
std::set< CAssetCacheRestrictedGlobal > setNewRestrictedGlobalToAdd
Restricted Global Asset Caches.
#define DEFAULT_REISSUABLE
bool GetBestAssetAddressAmount(CAssetsCache &cache, const std::string &assetName, const std::string &address)
This will get the amount that an address for a certain asset contains from the database if they cache...
std::string GetHex() const
bool VerifyNewMsgChannelAsset(std::string &strError) const
To be called on CTransactions where IsNewAsset returns true.
bool CheckEncoded(const std::string &hash, std::string &strError)
Check the Encoded hash and make sure it is either an IPFS hash or a OIP hash.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
size_t GetCacheSize() const
Get the size of the none databased cache.
bool IsAssetNameAQualifier(const std::string &name)
Check if an asset is a qualifier asset or sub qualifier.
std::unique_ptr< CConnman > g_connman
bool ContextualCheckTransferAsset(CAssetsCache *assetCache, const CAssetTransfer &transfer, const std::string &address, std::string &strError)
bool VerifyReissueAsset(std::string &strError) const
To be called on CTransactions where IsReissueAsset returns true.
void GetTxOutAssetTypes(const std::vector< CTxOut > &vout, int &issues, int &reissues, int &transfers, int &owners)
bool RestrictedAssetFromScript(const CScript &scriptPubKey, CNewAsset &assetNew, std::string &strAddress)
bool error(const char *fmt, const Args &... args)
const std::string & IssueAssetBurnAddress() const
bool WriteGlobalRestriction(const std::string &assetName)
bool AssetNullVerifierDataFromScript(const CScript &scriptPubKey, CNullAssetTxVerifierString &verifierData)
bool CheckVerifierAssetTxOut(const CTxOut &txout, std::string &strError)
bool CreateTransactionWithTransferAsset(const std::vector< CRecipient > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl &coin_control, bool sign=true)
static const std::string TESTNET
Standard JSON-RPC 2.0 errors.
bool IsSubQualifierNameValid(const std::string &name)
bool CheckVerifierString(const std::string &verifier, std::set< std::string > &setFoundQualifiers, std::string &strError, bool fWithTags)
bool CheckReissueAsset(const CReissueAsset &asset, std::string &strError)
bool AddRestrictedVerifier(const std::string &assetName, const std::string &verifier)
Changes Memory Only.
size_t DynamicMemoryUsage() const
Calculate the size of the CAssets (in bytes)
bool IsTypeCheckNameValid(const AssetType type, const std::string &name, std::string &error)
Given a type, and an asset name, return if that name is valid based on the type.
UniValue JSONRPCError(int code, const std::string &message)
bool IsReissueAsset() const
No valid connection manager instance found.
bool GetAssetVerifierStringIfExists(const std::string &name, CNullAssetTxVerifierString &verifier, bool fSkipTempCache=false)
Returns true if the Asset Verifier String was found for an asset_name, if fSkipTempCache is true...
bool CheckForAddressRestriction(const std::string &restricted_name, const std::string &address, bool fSkipTempCache=false)
Return true if the address is marked as frozen.
The basic transaction that is broadcasted on the network and contained in blocks. ...
CLRUCache< std::string, CDatabasedAssetData > * passetsCache
Global variable that point to the assets metadata LRU Cache (protected by cs_main) ...
void AddToAssetBalance(const std::string &strName, const std::string &address, const CAmount &nAmount)
bool AddReissueAsset(const CReissueAsset &reissue, const std::string address, const COutPoint &out)
Changes Memory Only.
bool WriteVerifier(const std::string &assetName, const std::string &verifier)
bool VerifyNewRestrictedAsset(std::string &strError) const
To be called on CTransactions where IsNewRestrictedAsset returns true.
std::set< CAssetCacheNewTransfer > setNewTransferAssetsToAdd
Transfer Assets Caches.
CTxDestination destination
std::set< CAssetCacheRestrictedVerifiers > setNewRestrictedVerifierToRemove
bool IsNewUniqueAsset() const
Make sure to call VerifyNewUniqueAsset if this call returns true.
bool VerifyNewAsset(std::string &strError) const
To be called on CTransactions where IsNewAsset returns true.
void ConstructGlobalRestrictionTransaction(CScript &script) const
bool AddBackSpentAsset(const Coin &coin, const std::string &assetName, const std::string &address, const CAmount &nAmount, const COutPoint &out)
Changes Memory Only.
std::string EncodeAssetData(std::string decoded)
std::map< std::string, CNewAsset > mapReissuedAssetData
#define QUALIFIER_ASSET_MIN_AMOUNT
bool IsUniqueTagValid(const std::string &tag)
Check if an unique tagname is valid.
bool IsNullGlobalRestrictionAssetTxDataScript() const
bool ContextualCheckUniqueAssetTx(CAssetsCache *assetCache, std::string &strError, const CTransaction &tx)
const CAmount & IssueSubAssetBurnAmount() const
const CAmount & AddNullQualifierTagBurnAmount() const
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
bool CheckReissueDataTx(const CTxOut &txOut)
UniValue reissue(const JSONRPCRequest &request)
bool IsQualifierNameValid(const std::string &name)
CScript GetScriptForNullAssetDataDestination(const CTxDestination &dest)
Generate a script that contains an address used for qualifier, and restricted assets data transaction...
bool IsScriptNewQualifierAsset(const CScript &scriptPubKey)
Check script and see if it matches the qualifier issuance template.
bool IsAssetNameAnRestricted(const std::string &name)
Check if an asset is a restricted asset.
bool UndoAssetCoin(const Coin &coin, const COutPoint &out)
std::vector< unsigned char > ToByteVector(const T &in)
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.
bool IsAssetScript(int &nType, bool &fIsOwner, int &nStartingIndex) const
std::vector< unsigned char > ParseHex(const char *psz)
bool IsScriptNewUniqueAsset(const CScript &scriptPubKey)
Check script and see if it matches the unquie issuance template.
bool CommitTransaction(CWalletTx &wtxNew, CReserveKey &reservekey, CConnman *connman, CValidationState &state)
RVN END.
bool ReadRestrictedAddress(const std::string &address, const std::string &assetName)
bool CheckNewAsset(const CNewAsset &asset, std::string &strError)