@@ -47,7 +47,7 @@ bool AssetCalcAmounts(struct CCcontract_info *cpAssets, int64_t &inputs, int64_t
|
||||
//int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); // --> GetTokenBalance()
|
||||
int64_t AddAssetInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, CPubKey pk, uint256 assetid, int64_t total, int32_t maxinputs);
|
||||
|
||||
UniValue AssetOrders(uint256 tokenid, CPubKey pubkey);
|
||||
UniValue AssetOrders(uint256 tokenid, CPubKey pubkey, uint8_t additionalEvalCode);
|
||||
//UniValue AssetInfo(uint256 tokenid);
|
||||
//UniValue AssetList();
|
||||
//std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description);
|
||||
|
||||
@@ -66,7 +66,7 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK
|
||||
}
|
||||
*/
|
||||
|
||||
UniValue AssetOrders(uint256 refassetid, CPubKey pk)
|
||||
UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode)
|
||||
{
|
||||
static uint256 zero;
|
||||
UniValue result(UniValue::VARR);
|
||||
@@ -161,7 +161,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk)
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputsTokens, unspentOutputsCoins;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputsTokens, unspentOutputsDualEvalTokens, unspentOutputsCoins;
|
||||
|
||||
char assetsUnspendableAddr[64];
|
||||
GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL));
|
||||
@@ -177,18 +177,31 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk)
|
||||
GetTokensCCaddress(cpAssets, assetsTokensUnspendableAddr, GetUnspendable(cpAssets, NULL));
|
||||
SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr);
|
||||
|
||||
// tokenasks:
|
||||
// tokenbids:
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator itCoins = unspentOutputsCoins.begin();
|
||||
itCoins != unspentOutputsCoins.end();
|
||||
itCoins++)
|
||||
addOrders(cpAssets, itCoins);
|
||||
|
||||
// tokenbids:
|
||||
// tokenasks:
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator itTokens = unspentOutputsTokens.begin();
|
||||
itTokens != unspentOutputsTokens.end();
|
||||
itTokens++)
|
||||
addOrders(cpAssets, itTokens);
|
||||
|
||||
|
||||
if (additionalEvalCode != 0) { //this would be mytokenorders
|
||||
char assetsDualEvalTokensUnspendableAddr[64];
|
||||
|
||||
// try also dual eval tokenasks (and we do not need bids):
|
||||
cpAssets->additionalTokensEvalcode2 = additionalEvalCode;
|
||||
GetTokensCCaddress(cpAssets, assetsDualEvalTokensUnspendableAddr, GetUnspendable(cpAssets, NULL));
|
||||
SetCCunspents(unspentOutputsDualEvalTokens, assetsDualEvalTokensUnspendableAddr);
|
||||
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator itDualEvalTokens = unspentOutputsDualEvalTokens.begin();
|
||||
itDualEvalTokens != unspentOutputsDualEvalTokens.end();
|
||||
itDualEvalTokens++)
|
||||
addOrders(cpAssets, itDualEvalTokens);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -7052,21 +7052,25 @@ UniValue tokenorders(const UniValue& params, bool fHelp)
|
||||
// memset(&tokenid, 0, sizeof(tokenid));
|
||||
throw runtime_error("no tokenid\n");
|
||||
}
|
||||
return(AssetOrders(tokenid, CPubKey()));
|
||||
return AssetOrders(tokenid, CPubKey(), 0);
|
||||
}
|
||||
|
||||
|
||||
UniValue mytokenorders(const UniValue& params, bool fHelp)
|
||||
{
|
||||
uint256 tokenid;
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error("mytokenorders\n");
|
||||
if (fHelp || params.size() > 2)
|
||||
throw runtime_error("mytokenorders [evalcode]\n");
|
||||
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0)
|
||||
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
return(AssetOrders(zeroid, Mypubkey()));
|
||||
uint8_t additionalEvalCode = 0;
|
||||
if (params.size() == 1)
|
||||
additionalEvalCode = strtol(params[0].get_str().c_str(), NULL, 0); // supports also 0xEE-like values
|
||||
|
||||
return AssetOrders(zeroid, Mypubkey(), additionalEvalCode);
|
||||
}
|
||||
|
||||
UniValue tokenbalance(const UniValue& params, bool fHelp)
|
||||
|
||||
Reference in New Issue
Block a user