Cleanup
This commit is contained in:
@@ -97,24 +97,6 @@ bool SetAssetFillamounts(int32_t sellflag,uint64_t &received_nValue,uint64_t &re
|
||||
} else return(false);
|
||||
}
|
||||
|
||||
/*CC *MakeAssetCond(CPubKey pk)
|
||||
{
|
||||
std::vector<CC*> pks; uint8_t evalcode = EVAL_ASSETS;
|
||||
pks.push_back(CCNewSecp256k1(pk));
|
||||
CC *assetCC = CCNewEval(E_MARSHAL(ss << evalcode));
|
||||
CC *Sig = CCNewThreshold(1, pks);
|
||||
return CCNewThreshold(2, {assetCC, Sig});
|
||||
}
|
||||
|
||||
CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk)
|
||||
{
|
||||
CTxOut vout;
|
||||
CC *payoutCond = MakeCCcond1(EVAL_ASSETS,pk);
|
||||
vout = CTxOut(nValue,CCPubKey(payoutCond));
|
||||
cc_free(payoutCond);
|
||||
return(vout);
|
||||
}*/
|
||||
|
||||
CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector<uint8_t> origpubkey,std::string name,std::string description)
|
||||
{
|
||||
CScript opret; uint8_t evalcode = EVAL_ASSETS;
|
||||
|
||||
@@ -34,19 +34,40 @@
|
||||
//BTCD Privkey: UvtvQVgVScXEYm4J3r4nE4nbFuGXSVM5pKec8VWXwgG9dmpWBuDh
|
||||
//BTCD Address: RSavingsEYcivt2DFsxsKeCjqArV6oVtVZ
|
||||
//BTCD Privkey: Ux6XQekTxokko6gZHz24B7PUsmUQtWFzG2W9nUA8jba7UoVbPBF4
|
||||
|
||||
// Assets, aka Tokens
|
||||
#define FUNCNAME IsAssetsInput
|
||||
#define EVALCODE EVAL_ASSETS
|
||||
const char *AssetsCCaddr = "RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6" ;//"RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u";
|
||||
char AssetsCChexstr[67] = { "02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702" };
|
||||
uint8_t AssetsCCpriv[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43, 0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67, 0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 };
|
||||
|
||||
#include "CCcustom.inc"
|
||||
#undef FUNCNAME
|
||||
#undef EVALCODE
|
||||
|
||||
// Faucet
|
||||
#define FUNCNAME IsFaucetInput
|
||||
#define EVALCODE EVAL_FAUCET
|
||||
const char *FaucetCCaddr = "R9zHrofhRbub7ER77B7NrVch3A63R39GuC" ;//"RKQV4oYs4rvxAWx1J43VnT73rSTVtUeckk";
|
||||
char FaucetCChexstr[67] = { "03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12" };
|
||||
uint8_t FaucetCCpriv[32] = { 0xd4, 0x4f, 0xf2, 0x31, 0x71, 0x7d, 0x28, 0x02, 0x4b, 0xc7, 0xdd, 0x71, 0xa0, 0x39, 0xc4, 0xbe, 0x1a, 0xfe, 0xeb, 0xc2, 0x46, 0xda, 0x76, 0xf8, 0x07, 0x53, 0x3d, 0x96, 0xb4, 0xca, 0xa0, 0xe9 };
|
||||
|
||||
#include "CCcustom.inc"
|
||||
#undef FUNCNAME
|
||||
#undef EVALCODE
|
||||
|
||||
// Rewards
|
||||
#define FUNCNAME IsRewardsInput
|
||||
#define EVALCODE EVAL_REWARDS
|
||||
const char *RewardsCCaddr = "RJCqA4jQTFEZ841dZgxko8aYgUU3FRNGNm" ;//"RYRJGMAYEfLCZ6ZddbpxPiUZ1sens8vPYK";
|
||||
char RewardsCChexstr[67] = { "026f00fdc2f1ed0006d66e2ca1787633590581c2fc90e7cb7b01a6c1131b40e94d" };
|
||||
uint8_t RewardsCCpriv[32] = { 0x9f, 0x0c, 0x57, 0xdc, 0x6f, 0x78, 0xae, 0xb0, 0xc7, 0x62, 0x9e, 0x7d, 0x2b, 0x90, 0x6b, 0xbd, 0x40, 0x78, 0x19, 0x5b, 0x3c, 0xb8, 0x82, 0x2d, 0x29, 0x84, 0x72, 0x7a, 0x59, 0x5a, 0x4b, 0x69 };
|
||||
#include "CCcustom.inc"
|
||||
#undef FUNCNAME
|
||||
#undef EVALCODE
|
||||
|
||||
bool IsAssetsInput(CScript const& scriptSig)
|
||||
/*bool IsAssetsInput(CScript const& scriptSig)
|
||||
{
|
||||
CC *cond;
|
||||
if (!(cond = GetCryptoCondition(scriptSig)))
|
||||
@@ -80,27 +101,9 @@ bool IsFaucetInput(CScript const& scriptSig)
|
||||
return out;
|
||||
}
|
||||
|
||||
bool IsCCinput(uint8_t evalcode,CScript const& scriptSig)
|
||||
{
|
||||
CC *cond;
|
||||
if (!(cond = GetCryptoCondition(scriptSig)))
|
||||
return false;
|
||||
// Recurse the CC tree to find asset condition
|
||||
auto findEval = [&] (CC *cond, struct CCVisitor _) {
|
||||
bool r = cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == evalcode;
|
||||
// false for a match, true for continue
|
||||
return r ? 0 : 1;
|
||||
};
|
||||
CCVisitor visitor = {findEval, (uint8_t*)"", 0, NULL};
|
||||
bool out =! cc_visit(cond, visitor);
|
||||
cc_free(cond);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool IsRewardsInput(CScript const& scriptSig)
|
||||
{
|
||||
return(IsCCinput(EVAL_REWARDS,scriptSig));
|
||||
/*CC *cond;
|
||||
CC *cond;
|
||||
if (!(cond = GetCryptoCondition(scriptSig)))
|
||||
return false;
|
||||
// Recurse the CC tree to find asset condition
|
||||
@@ -112,8 +115,10 @@ bool IsRewardsInput(CScript const& scriptSig)
|
||||
CCVisitor visitor = {findEval, (uint8_t*)"", 0, NULL};
|
||||
bool out =! cc_visit(cond, visitor);
|
||||
cc_free(cond);
|
||||
return out;*/
|
||||
}
|
||||
return out;
|
||||
}*/
|
||||
|
||||
uint64_t AddFaucetInputs(CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs);
|
||||
|
||||
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv)
|
||||
{
|
||||
@@ -141,54 +146,3 @@ CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv)
|
||||
else return(nullpk);
|
||||
}
|
||||
|
||||
/*CC *MakeCC(uint8_t evalcode,CPubKey pk)
|
||||
{
|
||||
if ( evalcode == EVAL_ASSETS || evalcode == EVAL_FAUCET || evalcode == EVAL_REWARDS )
|
||||
{
|
||||
std::vector<CC*> pks;
|
||||
pks.push_back(CCNewSecp256k1(pk));
|
||||
CC *assetCC = CCNewEval(E_MARSHAL(ss << evalcode));
|
||||
CC *Sig = CCNewThreshold(1, pks);
|
||||
return CCNewThreshold(2, {assetCC, Sig});
|
||||
} else return(0);
|
||||
}
|
||||
|
||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
||||
{
|
||||
CC *payoutCond;
|
||||
destaddr[0] = 0;
|
||||
if ( pk.size() == 0 )
|
||||
pk = GetUnspendable(evalcode,0);
|
||||
if ( evalcode == EVAL_ASSETS )
|
||||
{
|
||||
if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 )
|
||||
{
|
||||
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
||||
cc_free(payoutCond);
|
||||
}
|
||||
return(destaddr[0] != 0);
|
||||
}
|
||||
else if ( evalcode == EVAL_FAUCET )
|
||||
{
|
||||
if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 )
|
||||
//if ( (payoutCond= MakeFaucetCond(pk)) != 0 )
|
||||
{
|
||||
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
||||
cc_free(payoutCond);
|
||||
}
|
||||
return(destaddr[0] != 0);
|
||||
}
|
||||
else if ( evalcode == EVAL_REWARDS )
|
||||
{
|
||||
if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 )
|
||||
{
|
||||
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
||||
cc_free(payoutCond);
|
||||
}
|
||||
return(destaddr[0] != 0);
|
||||
}
|
||||
fprintf(stderr,"GetCCaddress %02x is invalid evalcode\n",evalcode);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
18
src/cc/CCcustom.inc
Normal file
18
src/cc/CCcustom.inc
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
bool FUNCNAME(CScript const& scriptSig)
|
||||
{
|
||||
CC *cond;
|
||||
if (!(cond = GetCryptoCondition(scriptSig)))
|
||||
return false;
|
||||
// Recurse the CC tree to find asset condition
|
||||
auto findEval = [&] (CC *cond, struct CCVisitor _) {
|
||||
bool r = cc_typeId(cond) == CC_Eval && cond->codeLength == 1 && cond->code[0] == EVALCODE;
|
||||
// false for a match, true for continue
|
||||
return r ? 0 : 1;
|
||||
};
|
||||
CCVisitor visitor = {findEval, (uint8_t*)"", 0, NULL};
|
||||
bool out =! cc_visit(cond, visitor);
|
||||
cc_free(cond);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ extern char FaucetCChexstr[67];
|
||||
|
||||
// CCcustom
|
||||
bool IsFaucetInput(CScript const& scriptSig);
|
||||
//CC *MakeFaucetCond(CPubKey pk);
|
||||
|
||||
std::string FaucetFund(uint64_t txfee,uint64_t funds);
|
||||
std::string FaucetGet(uint64_t txfee);
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ static uint256 zeroid;
|
||||
|
||||
// CCcustom
|
||||
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv);
|
||||
//CC *MakeCC(uint8_t evalcode,CPubKey pk);
|
||||
//bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
|
||||
|
||||
// CCutils
|
||||
CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk);
|
||||
|
||||
@@ -26,25 +26,6 @@
|
||||
To implement this, we can simply make any faucet vout fund the faucet. Then we can limit the number of confirmed utxo by combining faucet outputs and then only using utxo which are confirmed. This combined with a vout size limit will drastically limit the funds that can be withdrawn from the faucet.
|
||||
*/
|
||||
|
||||
/*CC *MakeFaucetCond(CPubKey pk)
|
||||
{
|
||||
std::vector<CC*> pks; uint8_t evalcode = EVAL_FAUCET;
|
||||
pks.push_back(CCNewSecp256k1(pk));
|
||||
CC *faucetCC = CCNewEval(E_MARSHAL(ss << evalcode));
|
||||
CC *Sig = CCNewThreshold(1, pks);
|
||||
return CCNewThreshold(2, {faucetCC, Sig});
|
||||
}
|
||||
|
||||
CTxOut MakeFaucetVout(CAmount nValue,CPubKey pk)
|
||||
{
|
||||
CTxOut vout;
|
||||
//CC *payoutCond = MakeFaucetCond(pk);
|
||||
CC *payoutCond = MakeCCcond1(EVAL_FAUCET,pk);
|
||||
vout = CTxOut(nValue,CCPubKey(payoutCond));
|
||||
cc_free(payoutCond);
|
||||
return(vout);
|
||||
}*/
|
||||
|
||||
uint64_t IsFaucetvout(const CTransaction& tx,int32_t v)
|
||||
{
|
||||
char destaddr[64];
|
||||
|
||||
Reference in New Issue
Block a user