Merge pull request #1612 from jl777/jl777

Jl777
This commit is contained in:
jl777
2019-07-12 22:35:07 -11:00
committed by GitHub
48 changed files with 859 additions and 597 deletions

View File

@@ -72,7 +72,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
// Tell the main threads to shutdown. // Tell the main threads to shutdown.
if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT)) if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT))
{ {
fprintf(stderr,"error: earlytx must be before block height 100 or tx does not exist\n"); fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown(); StartShutdown();
} }
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )

View File

@@ -39,7 +39,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode)
txid = it->first.txhash; txid = it->first.txhash;
LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() checking txid=" << txid.GetHex() << std::endl); LOGSTREAM("ccassets", CCLOG_DEBUG2, stream << "addOrders() checking txid=" << txid.GetHex() << std::endl);
if ( GetTransaction(txid, ordertx, hashBlock, false) != 0 ) if ( myGetTransaction(txid, ordertx, hashBlock) != 0 )
{ {
// for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey); // for logging: funcid = DecodeAssetOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey);
if (ordertx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(ordertx.vout[ordertx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0) if (ordertx.vout.size() > 0 && (funcid = DecodeAssetTokenOpRet(ordertx.vout[ordertx.vout.size()-1].scriptPubKey, evalCode, assetid, assetid2, price, origpubkey)) != 0)
@@ -273,7 +273,7 @@ std::string CreateBuyOffer(int64_t txfee, int64_t bidamount, uint256 assetid, in
fprintf(stderr,"negative bidamount %lld, pricetotal %lld\n", (long long)bidamount, (long long)pricetotal); fprintf(stderr,"negative bidamount %lld, pricetotal %lld\n", (long long)bidamount, (long long)pricetotal);
return(""); return("");
} }
if (GetTransaction(assetid, vintx, hashBlock, false) == 0) if (myGetTransaction(assetid, vintx, hashBlock) == 0)
{ {
fprintf(stderr,"cant find assetid\n"); fprintf(stderr,"cant find assetid\n");
return(""); return("");
@@ -470,7 +470,7 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid)
if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) if (AddNormalinputs(mtx, mypk, txfee, 3) > 0)
{ {
mask = ~((1LL << mtx.vin.size()) - 1); mask = ~((1LL << mtx.vin.size()) - 1);
if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) if (myGetTransaction(bidtxid, vintx, hashBlock) != 0)
{ {
std::vector<uint8_t> vopretNonfungible; std::vector<uint8_t> vopretNonfungible;
GetNonfungibleData(assetid, vopretNonfungible); GetNonfungibleData(assetid, vopretNonfungible);
@@ -520,7 +520,7 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid)
if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) if (AddNormalinputs(mtx, mypk, txfee, 3) > 0)
{ {
mask = ~((1LL << mtx.vin.size()) - 1); mask = ~((1LL << mtx.vin.size()) - 1);
if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) if (myGetTransaction(asktxid, vintx, hashBlock) != 0)
{ {
std::vector<uint8_t> vopretNonfungible; std::vector<uint8_t> vopretNonfungible;
GetNonfungibleData(assetid, vopretNonfungible); GetNonfungibleData(assetid, vopretNonfungible);
@@ -594,7 +594,7 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f
if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0)
{ {
mask = ~((1LL << mtx.vin.size()) - 1); mask = ~((1LL << mtx.vin.size()) - 1);
if (GetTransaction(bidtxid, vintx, hashBlock, false) != 0) if (myGetTransaction(bidtxid, vintx, hashBlock) != 0)
{ {
bidamount = vintx.vout[bidvout].nValue; bidamount = vintx.vout[bidvout].nValue;
SetAssetOrigpubkey(origpubkey, origprice, vintx); SetAssetOrigpubkey(origpubkey, origprice, vintx);
@@ -697,7 +697,7 @@ std::string FillSell(int64_t txfee, uint256 assetid, uint256 assetid2, uint256 a
//if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0) //if (AddNormalinputs(mtx, mypk, 2*txfee, 3) > 0)
//{ //{
//mask = ~((1LL << mtx.vin.size()) - 1); //mask = ~((1LL << mtx.vin.size()) - 1);
if (GetTransaction(asktxid, vintx, hashBlock, false) != 0) if (myGetTransaction(asktxid, vintx, hashBlock) != 0)
{ {
orig_assetoshis = vintx.vout[askvout].nValue; orig_assetoshis = vintx.vout[askvout].nValue;
SetAssetOrigpubkey(origpubkey, total_nValue, vintx); SetAssetOrigpubkey(origpubkey, total_nValue, vintx);

View File

@@ -52,9 +52,11 @@ one other technical note is that komodod has the insight-explorer extensions bui
#include "../utlist.h" #include "../utlist.h"
#include "../uthash.h" #include "../uthash.h"
#include "merkleblock.h" #include "merkleblock.h"
#include "../komodo_nSPV_defs.h"
#define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead"
#define CC_MAXVINS 1024 #define CC_MAXVINS 1024
#define CC_REQUIREMENTS_MSG (KOMODO_NSPV!=0?"to use CC contracts you need to nspv_login first\n":"to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n")
#define SMALLVAL 0.000000000000001 #define SMALLVAL 0.000000000000001
#define SATOSHIDEN ((uint64_t)100000000L) #define SATOSHIDEN ((uint64_t)100000000L)
@@ -151,6 +153,7 @@ struct oracleprice_info
}; };
typedef std::vector<uint8_t> vscript_t; typedef std::vector<uint8_t> vscript_t;
extern struct NSPV_CCmtxinfo NSPV_U;
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
extern CWallet* pwalletMain; extern CWallet* pwalletMain;
@@ -287,6 +290,7 @@ extern std::vector<CPubKey> NULL_pubkeys;
std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector<CPubKey> pubkeys = NULL_pubkeys); std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector<CPubKey> pubkeys = NULL_pubkeys);
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool CCflag = true);
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool CCflag = true);
int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr);
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs);
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag);

View File

@@ -654,7 +654,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C
if (ivin != mtx.vin.size()) // that is, the tx.vout is already added to mtx.vin (in some previous calls) if (ivin != mtx.vin.size()) // that is, the tx.vout is already added to mtx.vin (in some previous calls)
continue; continue;
if (GetTransaction(vintxid, vintx, hashBlock, false) != 0) if (myGetTransaction(vintxid, vintx, hashBlock) != 0)
{ {
Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey); Getscriptaddress(destaddr, vintx.vout[vout].scriptPubKey);
if (strcmp(destaddr, tokenaddr) != 0 && if (strcmp(destaddr, tokenaddr) != 0 &&
@@ -870,7 +870,12 @@ std::string TokenTransfer(int64_t txfee, uint256 tokenid, vscript_t destpubkey,
if (txfee == 0) if (txfee == 0)
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if (AddNormalinputs(mtx, mypk, txfee, 3) > 0) /*if ( cp->tokens1of2addr[0] == 0 )
{
GetTokensCCaddress(cp, cp->tokens1of2addr, mypk);
fprintf(stderr,"set tokens1of2addr <- %s\n",cp->tokens1of2addr);
}*/
if (AddNormalinputs(mtx, mypk, txfee, 3) > 0)
{ {
mask = ~((1LL << mtx.vin.size()) - 1); // seems, mask is not used anymore mask = ~((1LL << mtx.vin.size()) - 1); // seems, mask is not used anymore
@@ -920,7 +925,7 @@ int64_t GetTokenBalance(CPubKey pk, uint256 tokenid)
// CCerror = strprintf("obsolete, cannot return correct value without eval"); // CCerror = strprintf("obsolete, cannot return correct value without eval");
// return 0; // return 0;
if (GetTransaction(tokenid, tokentx, hashBlock, false) == 0) if (myGetTransaction(tokenid, tokentx, hashBlock) == 0)
{ {
LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl); LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "cant find tokenid" << std::endl);
CCerror = strprintf("cant find tokenid"); CCerror = strprintf("cant find tokenid");
@@ -945,14 +950,14 @@ UniValue TokenInfo(uint256 tokenid)
cpTokens = CCinit(&tokensCCinfo, EVAL_TOKENS); cpTokens = CCinit(&tokensCCinfo, EVAL_TOKENS);
if( !GetTransaction(tokenid, tokenbaseTx, hashBlock, false) ) if( !myGetTransaction(tokenid, tokenbaseTx, hashBlock) )
{ {
fprintf(stderr, "TokenInfo() cant find tokenid\n"); fprintf(stderr, "TokenInfo() cant find tokenid\n");
result.push_back(Pair("result", "error")); result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "cant find tokenid")); result.push_back(Pair("error", "cant find tokenid"));
return(result); return(result);
} }
if (hashBlock.IsNull()) { if ( KOMODO_NSPV == 0 && hashBlock.IsNull()) {
result.push_back(Pair("result", "error")); result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "the transaction is still in mempool")); result.push_back(Pair("error", "the transaction is still in mempool"));
return(result); return(result);
@@ -1031,7 +1036,7 @@ UniValue TokenList()
cp = CCinit(&C, EVAL_TOKENS); cp = CCinit(&C, EVAL_TOKENS);
auto addTokenId = [&](uint256 txid) { auto addTokenId = [&](uint256 txid) {
if (GetTransaction(txid, vintx, hashBlock, false) != 0) { if (myGetTransaction(txid, vintx, hashBlock) != 0) {
if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) != 0) { if (vintx.vout.size() > 0 && DecodeTokenCreateOpRet(vintx.vout[vintx.vout.size() - 1].scriptPubKey, origpubkey, name, description) != 0) {
result.push_back(txid.GetHex()); result.push_back(txid.GetHex());
} }

View File

@@ -17,6 +17,7 @@
#include "key_io.h" #include "key_io.h"
std::vector<CPubKey> NULL_pubkeys; std::vector<CPubKey> NULL_pubkeys;
struct NSPV_CCmtxinfo NSPV_U;
/* /*
FinalizeCCTx is a very useful function that will properly sign both CC and normal inputs, adds normal change and the opreturn. FinalizeCCTx is a very useful function that will properly sign both CC and normal inputs, adds normal change and the opreturn.
@@ -45,7 +46,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());
CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0; CTransaction vintx; std::string hex; CPubKey globalpk; uint256 hashBlock; uint64_t mask=0,nmask=0,vinimask=0;
int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0; int64_t utxovalues[CC_MAXVINS],change,normalinputs=0,totaloutputs=0,normaloutputs=0,totalinputs=0,normalvins=0,ccvins=0;
int32_t i,flag,utxovout,n,err = 0; int32_t i,flag,mgret,utxovout,n,err = 0;
char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64],CC1of2CCaddr[64]; char myaddr[64], destaddr[64], unspendable[64], mytokensaddr[64], mysingletokensaddr[64], unspendabletokensaddr[64],CC1of2CCaddr[64];
uint8_t *privkey, myprivkey[32], unspendablepriv[32], /*tokensunspendablepriv[32],*/ *msg32 = 0; uint8_t *privkey, myprivkey[32], unspendablepriv[32], /*tokensunspendablepriv[32],*/ *msg32 = 0;
CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond=0, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL; CC *mycond=0, *othercond=0, *othercond2=0,*othercond4=0, *othercond3=0, *othercond1of2=NULL, *othercond1of2tokens = NULL, *cond=0, *condCC2=0,*mytokenscond = NULL, *mysingletokenscond = NULL, *othertokenscond = NULL;
@@ -96,13 +97,19 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
//This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation.
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if (i==0 && mtx.vin[i].prevout.n==10e8) continue; if (i==0 && mtx.vin[i].prevout.n==10e8)
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 ) continue;
if ( myGetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock) != 0 && mtx.vin[i].prevout.n < vintx.vout.size() )
{ {
if ( vintx.vout[mtx.vin[i].prevout.n].scriptPubKey.IsPayToCryptoCondition() == 0 && ccvins==0) if ( vintx.vout[mtx.vin[i].prevout.n].scriptPubKey.IsPayToCryptoCondition() == 0 && ccvins==0)
normalvins++; normalvins++;
else ccvins++; else ccvins++;
} }
else
{
fprintf(stderr,"vin.%d vout.%d is bigger than vintx.%d\n",i,mtx.vin[i].prevout.n,(int32_t)vintx.vout.size());
return("");
}
} }
if (normalvins>1 && ccvins) if (normalvins>1 && ccvins)
{ {
@@ -116,7 +123,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if (i==0 && mtx.vin[i].prevout.n==10e8) continue; if (i==0 && mtx.vin[i].prevout.n==10e8) continue;
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 ) if ( (mgret= myGetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock)) != 0 )
{ {
utxovout = mtx.vin[i].prevout.n; utxovout = mtx.vin[i].prevout.n;
utxovalues[i] = vintx.vout[utxovout].nValue; utxovalues[i] = vintx.vout[utxovout].nValue;
@@ -131,7 +138,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
{ {
mask |= (1LL << i); mask |= (1LL << i);
} }
} else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str()); } else fprintf(stderr,"FinalizeCCTx couldnt find %s mgret.%d\n",mtx.vin[i].prevout.hash.ToString().c_str(),mgret);
} }
nmask = (1LL << n) - 1; nmask = (1LL << n) - 1;
if ( 0 && (mask & nmask) != (CCmask & nmask) ) if ( 0 && (mask & nmask) != (CCmask & nmask) )
@@ -147,8 +154,9 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
n = mtx.vin.size(); n = mtx.vin.size();
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if (i==0 && mtx.vin[i].prevout.n==10e8) continue; if (i==0 && mtx.vin[i].prevout.n==10e8)
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 ) continue;
if ( (mgret= myGetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock)) != 0 )
{ {
utxovout = mtx.vin[i].prevout.n; utxovout = mtx.vin[i].prevout.n;
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 ) if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
@@ -160,6 +168,11 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
} }
else else
{ {
{
char addr[64];
Getscriptaddress(addr,vintx.vout[utxovout].scriptPubKey);
fprintf(stderr,"vout[%d] %.8f -> %s\n",utxovout,dstr(vintx.vout[utxovout].nValue),addr);
}
if ( NSPV_SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey,0) == 0 ) if ( NSPV_SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey,0) == 0 )
fprintf(stderr,"NSPV signing error for vini.%d of %llx\n",i,(long long)vinimask); fprintf(stderr,"NSPV signing error for vini.%d of %llx\n",i,(long long)vinimask);
} }
@@ -167,11 +180,11 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
else else
{ {
Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey); Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey);
//fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,cp->unspendableaddr2); //fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,mysingletokensaddr);
//std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl; //std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl;
if( strcmp(destaddr, myaddr) == 0 ) if( strcmp(destaddr, myaddr) == 0 )
{ {
//fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr); //fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr);
privkey = myprivkey; privkey = myprivkey;
cond = mycond; cond = mycond;
} }
@@ -179,30 +192,30 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
{ {
privkey = myprivkey; privkey = myprivkey;
cond = mytokenscond; cond = mytokenscond;
//fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr); //fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr);
} }
else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout
{ {
privkey = myprivkey; privkey = myprivkey;
cond = mysingletokenscond; cond = mysingletokenscond;
//fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr); //fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr);
} }
else if ( strcmp(destaddr,unspendable) == 0 ) else if ( strcmp(destaddr,unspendable) == 0 )
{ {
privkey = unspendablepriv; privkey = unspendablepriv;
cond = othercond; cond = othercond;
//fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable); //fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable);
} }
else if (strcmp(destaddr, unspendabletokensaddr) == 0) else if (strcmp(destaddr, unspendabletokensaddr) == 0)
{ {
privkey = unspendablepriv; privkey = unspendablepriv;
cond = othertokenscond; cond = othertokenscond;
//fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr); //fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr);
} }
// check if this is the 2nd additional evalcode + 'unspendable' cc addr: // check if this is the 2nd additional evalcode + 'unspendable' cc addr:
else if ( strcmp(destaddr, cp->unspendableaddr2) == 0) else if ( strcmp(destaddr, cp->unspendableaddr2) == 0)
{ {
//fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2); //fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2);
privkey = cp->unspendablepriv2; privkey = cp->unspendablepriv2;
if( othercond2 == 0 ) if( othercond2 == 0 )
othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2); othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2);
@@ -211,7 +224,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
// check if this is 3rd additional evalcode + 'unspendable' cc addr: // check if this is 3rd additional evalcode + 'unspendable' cc addr:
else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 ) else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 )
{ {
//fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3); //fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3);
privkey = cp->unspendablepriv3; privkey = cp->unspendablepriv3;
if( othercond3 == 0 ) if( othercond3 == 0 )
othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3); othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3);
@@ -220,7 +233,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
// check if this is spending from 1of2 cc coins addr: // check if this is spending from 1of2 cc coins addr:
else if (strcmp(cp->coins1of2addr, destaddr) == 0) else if (strcmp(cp->coins1of2addr, destaddr) == 0)
{ {
//fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr); //fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr);
privkey = cp->coins1of2priv;//myprivkey; privkey = cp->coins1of2priv;//myprivkey;
if (othercond1of2 == 0) if (othercond1of2 == 0)
othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]); othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]);
@@ -228,7 +241,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
} }
else if ( strcmp(CC1of2CCaddr,destaddr) == 0 ) else if ( strcmp(CC1of2CCaddr,destaddr) == 0 )
{ {
//fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr); //fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr);
privkey = unspendablepriv; privkey = unspendablepriv;
if (condCC2 == 0) if (condCC2 == 0)
condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk); condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk);
@@ -237,7 +250,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
// check if this is spending from 1of2 cc tokens addr: // check if this is spending from 1of2 cc tokens addr:
else if (strcmp(cp->tokens1of2addr, destaddr) == 0) else if (strcmp(cp->tokens1of2addr, destaddr) == 0)
{ {
//fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr); //fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr);
privkey = cp->tokens1of2priv;//myprivkey; privkey = cp->tokens1of2priv;//myprivkey;
if (othercond1of2tokens == 0) if (othercond1of2tokens == 0)
// NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc // NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc
@@ -262,32 +275,34 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
cond = othercond4; cond = othercond4;
flag = 1; flag = 1;
} }
} } //else privkey = myprivkey;
if ( flag == 0 ) if ( flag == 0 )
{ {
fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr); fprintf(stderr,"CC signing error: vini.%d has unknown CC address.(%s)\n",i,destaddr);
return(""); return("");
} }
} }
uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL, utxovalues[i],consensusBranchId, &txdata); uint256 sighash = SignatureHash(CCPubKey(cond), mtx, i, SIGHASH_ALL,utxovalues[i],consensusBranchId, &txdata);
int32_t z;
for (z=0; z<32; z++)
fprintf(stderr,"%02x",privkey[z]);
fprintf(stderr," privkey, ");
for (z=0; z<32; z++)
fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]);
fprintf(stderr," sighash [%d] %.8f %x\n",i,(double)utxovalues[i]/COIN,consensusBranchId);
if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 ) if ( cc_signTreeSecp256k1Msg32(cond,privkey,sighash.begin()) != 0 )
{ {
//int32_t z; mtx.vin[i].scriptSig = CCSig(cond);
//for (z=0; z<32; z++)
// fprintf(stderr,"%02x",((uint8_t *)sighash.begin())[z]);
//fprintf(stderr," sighash, ");
//for (z=0; z<32; z++)
// fprintf(stderr,"%02x",privkey[z]);
//fprintf(stderr," signed with privkey\n");
mtx.vin[i].scriptSig = CCSig(cond);
} }
else else
{ {
fprintf(stderr,"vini.%d has CC signing error address.(%s)\n",i,destaddr); fprintf(stderr,"vini.%d has CC signing error address.(%s) %s\n",i,destaddr,EncodeHexTx(mtx).c_str());
memset(myprivkey,0,sizeof(myprivkey));
return(""); return("");
} }
} }
} else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str()); } else fprintf(stderr,"FinalizeCCTx2 couldnt find %s mgret.%d\n",mtx.vin[i].prevout.hash.ToString().c_str(),mgret);
} }
if ( mycond != 0 ) if ( mycond != 0 )
cc_free(mycond); cc_free(mycond);
@@ -311,15 +326,23 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
cc_free(mysingletokenscond); cc_free(mysingletokenscond);
if ( othertokenscond != 0 ) if ( othertokenscond != 0 )
cc_free(othertokenscond); cc_free(othertokenscond);
memset(myprivkey,0,sizeof(myprivkey));
std::string strHex = EncodeHexTx(mtx); std::string strHex = EncodeHexTx(mtx);
if ( strHex.size() > 0 ) if ( strHex.size() > 0 )
return(strHex); return(strHex);
else return("0"); else return("0");
} }
void NSPV_CCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag);
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag) void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag)
{ {
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses; int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
if ( KOMODO_NSPV != 0 )
{
NSPV_CCunspents(unspentOutputs,coinaddr,ccflag);
return;
}
n = (int32_t)strlen(coinaddr); n = (int32_t)strlen(coinaddr);
addrstr.resize(n+1); addrstr.resize(n+1);
ptr = (char *)addrstr.data(); ptr = (char *)addrstr.data();
@@ -522,9 +545,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3
{ {
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV != 0 )
{ return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U));
//return(NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_utxoresp *ptr,int32_t num));
}
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
assert(pwalletMain != NULL); assert(pwalletMain != NULL);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
@@ -621,9 +642,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up;
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV != 0 )
{ return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NSPV_U));
//return(NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_utxoresp *ptr,int32_t num));
}
utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos));
if ( maxinputs > CC_MAXVINS ) if ( maxinputs > CC_MAXVINS )
maxinputs = CC_MAXVINS; maxinputs = CC_MAXVINS;

View File

@@ -18,6 +18,7 @@
*/ */
#include "CCinclude.h" #include "CCinclude.h"
#include "komodo_structs.h" #include "komodo_structs.h"
#include "key_io.h"
#ifdef TESTMODE #ifdef TESTMODE
#define MIN_NON_NOTARIZED_CONFIRMS 2 #define MIN_NON_NOTARIZED_CONFIRMS 2
@@ -208,10 +209,14 @@ void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, u
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey)
{ {
CTxDestination address; txnouttype whichType; CTxDestination address; txnouttype whichType;
if ( ExtractDestination(scriptPubKey,address) != 0 ) destaddr[0] = 0;
if ( scriptPubKey.begin() != 0 )
{ {
strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); if ( ExtractDestination(scriptPubKey,address) != 0 )
return(true); {
strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str());
return(true);
}
} }
//fprintf(stderr,"ExtractDestination failed\n"); //fprintf(stderr,"ExtractDestination failed\n");
return(false); return(false);
@@ -438,13 +443,19 @@ std::vector<uint8_t> Mypubkey()
return(pubkey); return(pubkey);
} }
extern CKey NSPV_key; extern char NSPV_wifstr[],NSPV_pubkeystr[];
bool Myprivkey(uint8_t myprivkey[]) bool Myprivkey(uint8_t myprivkey[])
{ {
char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33]; char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33];
if ( KOMODO_NSPV != 0 ) if ( KOMODO_NSPV != 0 )
{ {
NSPV_key.SetKey32(myprivkey); vchSecret = DecodeSecret(NSPV_wifstr);
memcpy(myprivkey,vchSecret.begin(),32);
//for (i=0; i<32; i++)
// fprintf(stderr,"%02x",myprivkey[i]);
//fprintf(stderr," myprivkey %s\n",NSPV_wifstr);
memset((uint8_t *)vchSecret.begin(),0,32);
return true; return true;
} }
if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 ) if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 )
@@ -461,6 +472,7 @@ bool Myprivkey(uint8_t myprivkey[])
if ( pwalletMain->GetKey(keyID,vchSecret) != 0 ) if ( pwalletMain->GetKey(keyID,vchSecret) != 0 )
{ {
memcpy(myprivkey,vchSecret.begin(),32); memcpy(myprivkey,vchSecret.begin(),32);
memset((uint8_t *)vchSecret.begin(),0,32);
if ( 0 ) if ( 0 )
{ {
for (i=0; i<32; i++) for (i=0; i<32; i++)

View File

@@ -131,7 +131,7 @@ int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu
// prevent dup // prevent dup
if ( it->second.satoshis < 1000000 ) if ( it->second.satoshis < 1000000 )
continue; continue;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsAuctionvout(cp,vintx,(int32_t)it->first.index)) > 0 ) if ( (nValue= IsAuctionvout(cp,vintx,(int32_t)it->first.index)) > 0 )
{ {

View File

@@ -520,7 +520,7 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK
if ( it->second.satoshis < threshold || it->second.satoshis == txfee ) if ( it->second.satoshis < threshold || it->second.satoshis == txfee )
continue; continue;
// no need to prevent dup // no need to prevent dup
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) >= 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) >= 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
@@ -550,7 +550,7 @@ int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe
//char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN);
if ( it->second.satoshis < txfee ) if ( it->second.satoshis < txfee )
continue; continue;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsCClibvout(cp,vintx,vout,coinaddr)) != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( (nValue= IsCClibvout(cp,vintx,vout,coinaddr)) != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {

View File

@@ -416,7 +416,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C
else marker=2; else marker=2;
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
{ {
if ( (int32_t)it->first.index==0 && GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0) if ( (int32_t)it->first.index==0 && myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0)
{ {
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 &&
(tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && IsChannelsMarkervout(cp,tx,marker==1?srcpub:destpub,marker)>0 && (tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && IsChannelsMarkervout(cp,tx,marker==1?srcpub:destpub,marker)>0 &&
@@ -517,7 +517,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0)
{ {
CCerror = strprintf("invalid channel open txid"); CCerror = strprintf("invalid channel open txid");
LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -555,7 +555,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2
if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0) if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount)>=0)
{ {
numpayments=amount/payment; numpayments=amount/payment;
if (GetTransaction(prevtxid,prevTx,hashblock,false) != 0 && (numvouts=prevTx.vout.size()) > 0 && if (myGetTransaction(prevtxid,prevTx,hashblock) != 0 && (numvouts=prevTx.vout.size()) > 0 &&
((funcid = DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, prevdepth, param2, param3)) != 0) && ((funcid = DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, prevdepth, param2, param3)) != 0) &&
(funcid == 'P' || funcid=='O')) (funcid == 'P' || funcid=='O'))
{ {
@@ -642,7 +642,7 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid)
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0)
{ {
CCerror = strprintf("invalid channel open txid"); CCerror = strprintf("invalid channel open txid");
LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -702,7 +702,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if (GetTransaction(closetxid,channelCloseTx,hashblock,false) == 0) if (myGetTransaction(closetxid,channelCloseTx,hashblock) == 0)
{ {
CCerror = strprintf("invalid channel close txid"); CCerror = strprintf("invalid channel close txid");
LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -726,7 +726,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl);
return (""); return ("");
} }
if (GetTransaction(opentxid,channelOpenTx,hashblock,false) == 0) if (myGetTransaction(opentxid,channelOpenTx,hashblock) == 0)
{ {
CCerror = strprintf("invalid channel open txid"); CCerror = strprintf("invalid channel open txid");
LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("channelscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -754,7 +754,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
{ {
if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0) if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds>0)
{ {
if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && if ((myGetTransaction(prevtxid,prevTx,hashblock) != 0) && (numvouts=prevTx.vout.size()) > 0 &&
DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0) DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, tokenid, txid, srcpub, destpub, param1, param2, param3) != 0)
{ {
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CC_MARKER_VALUE,mypk));
@@ -799,7 +799,7 @@ UniValue ChannelsList()
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second; nValue = (int64_t)it->second;
if ( (vout == 1 || vout == 2) && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) if ( (vout == 1 || vout == 2) && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 )
{ {
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O')
{ {
@@ -822,7 +822,7 @@ UniValue ChannelsInfo(uint256 channeltxid)
cp = CCinit(&C,EVAL_CHANNELS); cp = CCinit(&C,EVAL_CHANNELS);
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if (GetTransaction(channeltxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && if (myGetTransaction(channeltxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 &&
(DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'O')) (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'O'))
{ {
GetCCaddress(cp,CCaddr,mypk); GetCCaddress(cp,CCaddr,mypk);
@@ -845,7 +845,7 @@ UniValue ChannelsInfo(uint256 channeltxid)
SetCCtxids(addressIndex,CCaddr,true); SetCCtxids(addressIndex,CCaddr,true);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
if (GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) if (myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 )
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid)) if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid))
txids.push_back(it->first.txhash); txids.push_back(it->first.txhash);
} }
@@ -861,7 +861,7 @@ UniValue ChannelsInfo(uint256 channeltxid)
for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid=*it; txid=*it;
if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) if (txid!=prevtxid && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 )
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid) if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid)
@@ -870,7 +870,7 @@ UniValue ChannelsInfo(uint256 channeltxid)
} }
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid) else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid)
{ {
if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && if (myGetTransaction(opentxid,opentx,hashBlock) != 0 && (numvouts=opentx.vout.size()) > 0 &&
DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O') DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O')
{ {
Getscriptaddress(str,tx.vout[3].scriptPubKey); Getscriptaddress(str,tx.vout[3].scriptPubKey);

View File

@@ -3354,7 +3354,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu
//char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN); //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f vs %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN,(double)threshold/COIN);
if ( it->second.satoshis < threshold || it->second.satoshis == DILITHIUM_TXFEE ) if ( it->second.satoshis < threshold || it->second.satoshis == DILITHIUM_TXFEE )
continue; continue;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts= vintx.vout.size()) > 1 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 && (numvouts= vintx.vout.size()) > 1 )
{ {
if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {

View File

@@ -129,7 +129,7 @@ bool Eval::GetTxUnconfirmed(const uint256 &hash, CTransaction &txOut, uint256 &h
{ {
return(myGetTransaction(hash, txOut,hashBlock)); return(myGetTransaction(hash, txOut,hashBlock));
/*if (!myGetTransaction(hash, txOut,hashBlock)) { /*if (!myGetTransaction(hash, txOut,hashBlock)) {
return(GetTransaction(hash, txOut,hashBlock)); return(myGetTransaction(hash, txOut,hashBlock));
} else return(true);*/ } else return(true);*/
} }

View File

@@ -159,7 +159,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
continue; continue;
//char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); //char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN);
// no need to prevent dup // no need to prevent dup
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsFaucetvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( (nValue= IsFaucetvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
@@ -221,6 +221,7 @@ std::string FaucetFund(uint64_t txfee,int64_t funds)
{ {
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C; CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C;
cp = CCinit(&C,EVAL_FAUCET); cp = CCinit(&C,EVAL_FAUCET);
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;

View File

@@ -133,7 +133,7 @@ int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey
// prevent dup // prevent dup
if ( it->second.satoshis < 1000000 ) if ( it->second.satoshis < 1000000 )
continue; continue;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsFSMvout(cp,vintx,(int32_t)it->first.index)) > 0 ) if ( (nValue= IsFSMvout(cp,vintx,(int32_t)it->first.index)) > 0 )
{ {

View File

@@ -823,7 +823,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::string refcoin,tmprefcoin; CPubKey withdrawpub,destpub; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::string refcoin,tmprefcoin; CPubKey withdrawpub,destpub;
uint256 tokenid,txid,oracletxid,tmpbindtxid,tmptokenid,deposittxid,hashBlock; uint256 tokenid,txid,oracletxid,tmpbindtxid,tmptokenid,deposittxid,hashBlock;
if ( GetTransaction(bindtxid,bindtx,hashBlock,false) != 0 ) if ( myGetTransaction(bindtxid,bindtx,hashBlock) != 0 )
{ {
if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B') if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B')
{ {
@@ -839,7 +839,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
{ {
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
funcid=DecodeGatewaysOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey); funcid=DecodeGatewaysOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey);
if ((vout==0 && funcid=='B' && bindtxid==txid && total != 0 && maxinputs != 0) || if ((vout==0 && funcid=='B' && bindtxid==txid && total != 0 && maxinputs != 0) ||
@@ -932,7 +932,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) if ( myGetTransaction(oracletxid,oracletx,hashBlock) == 0 || (numvouts= oracletx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid)); CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -982,7 +982,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "GatewaysDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl); LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "GatewaysDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl);
if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,bindtx,hashBlock) == 0 || (numvouts= bindtx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1059,7 +1059,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
gatewayspk = GetUnspendable(cp,0); gatewayspk = GetUnspendable(cp,0);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1077,7 +1077,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if ( GetTransaction(deposittxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(deposittxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find deposittxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find deposittxid %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1138,7 +1138,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
gatewayspk = GetUnspendable(cp, 0); gatewayspk = GetUnspendable(cp, 0);
if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1164,7 +1164,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
K=0; K=0;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 &&
(funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P'))
{ {
if (funcid=='W' && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' if (funcid=='W' && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W'
@@ -1176,7 +1176,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
} }
else if (funcid=='P' && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && else if (funcid=='P' && DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' &&
GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' myGetTransaction(withdrawtxid,tx,hashBlock)!=0 && (numvouts=tx.vout.size())>0 && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,tmpamount)=='W'
&& refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid) && refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid)
{ {
CCerror = strprintf("unable to create withdraw, another withdraw pending"); CCerror = strprintf("unable to create withdraw, another withdraw pending");
@@ -1220,7 +1220,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
gatewayspk = GetUnspendable(cp,0); gatewayspk = GetUnspendable(cp,0);
if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0
|| (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P'))
{ {
CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid));
@@ -1242,7 +1242,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1264,7 +1264,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts= tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1283,7 +1283,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1320,7 +1320,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
gatewayspk = GetUnspendable(cp,0); gatewayspk = GetUnspendable(cp,0);
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0
|| (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) || (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P'))
{ {
CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid));
@@ -1336,7 +1336,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1364,7 +1364,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())==0)
{ {
CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1382,7 +1382,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1418,7 +1418,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) if (myGetTransaction(completetxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0)
{ {
CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1436,7 +1436,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) else if (myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())==0)
{ {
CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1448,7 +1448,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) else if (myGetTransaction(bindtxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1485,7 +1485,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin)
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
gatewayspk = GetUnspendable(cp,0); gatewayspk = GetUnspendable(cp,0);
_GetCCaddress(coinaddr,EVAL_GATEWAYS,mypk); _GetCCaddress(coinaddr,EVAL_GATEWAYS,mypk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid))));
@@ -1503,7 +1503,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,cointxid,claimvout,hex,proof,destpub,amount) == 'D' DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,cointxid,claimvout,hex,proof,destpub,amount) == 'D'
&& tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0)
{ {
@@ -1540,7 +1540,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin)
gatewayspk = GetUnspendable(cp,0); gatewayspk = GetUnspendable(cp,0);
_GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk);
GetTokensCCaddress(cp,tokensaddr,gatewayspk); GetTokensCCaddress(cp,tokensaddr,gatewayspk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid))));
@@ -1567,7 +1567,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin)
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
K=0; K=0;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 &&
(funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0)
{ {
if (funcid=='W') if (funcid=='W')
@@ -1576,7 +1576,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin)
} }
else if (funcid=='P') else if (funcid=='P')
{ {
if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || GetTransaction(withdrawtxid,tx,hashBlock,false)==0 if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || myGetTransaction(withdrawtxid,tx,hashBlock)==0
|| (numvouts=tx.vout.size())<=0 || DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)!='W' || (numvouts=tx.vout.size())<=0 || DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,tmpbindtxid,coin,withdrawpub,amount)!='W'
|| refcoin!=coin || tmptokenid!=tokenid || tmpbindtxid!=bindtxid) || refcoin!=coin || tmptokenid!=tokenid || tmpbindtxid!=bindtxid)
continue; continue;
@@ -1628,7 +1628,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin)
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
gatewayspk = GetUnspendable(cp,0); gatewayspk = GetUnspendable(cp,0);
_GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk); _GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid))));
@@ -1654,10 +1654,10 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 &&
DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0)
{ {
if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 if (myGetTransaction(withdrawtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0
&& DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin || tmptokenid!=tokenid) && DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin || tmptokenid!=tokenid)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
@@ -1689,7 +1689,7 @@ UniValue GatewaysList()
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 )
{ {
@@ -1706,7 +1706,7 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey)
std::string coin; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys; std::string coin; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys;
cp = CCinit(&C,EVAL_GATEWAYS); cp = CCinit(&C,EVAL_GATEWAYS);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid))));
@@ -1730,7 +1730,7 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key)
std::string coin,priv; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys; std::string coin,priv; int64_t numvouts,totalsupply; char str[65],addr[65],depositaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys;
cp = CCinit(&C,EVAL_GATEWAYS); cp = CCinit(&C,EVAL_GATEWAYS);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid))));
@@ -1759,7 +1759,7 @@ UniValue GatewaysInfo(uint256 bindtxid)
cp = CCinit(&C,EVAL_GATEWAYS); cp = CCinit(&C,EVAL_GATEWAYS);
Gatewayspk = GetUnspendable(cp,0); Gatewayspk = GetUnspendable(cp,0);
GetTokensCCaddress(cp,gatewaystokens,Gatewayspk); GetTokensCCaddress(cp,gatewaystokens,Gatewayspk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)))); result.push_back(Pair("error",strprintf("cant find bindtxid %s",uint256_str(str,bindtxid))));
@@ -1771,7 +1771,7 @@ UniValue GatewaysInfo(uint256 bindtxid)
result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str())));
return(result); return(result);
} }
if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) != 0 )
{ {
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
result.push_back(Pair("name","Gateways")); result.push_back(Pair("name","Gateways"));

View File

@@ -531,7 +531,7 @@ template <class Helper> int64_t Add1of2AddressInputs(struct CCcontract_info* cp,
//std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl; //std::cerr << "Add1of2AddressInputs() txid=" << txid.GetHex() << std::endl;
if (GetTransaction(txid, heirtx, hashBlock, false) != 0) { if (myGetTransaction(txid, heirtx, hashBlock) != 0) {
uint256 tokenid; uint256 tokenid;
uint256 fundingTxidInOpret; uint256 fundingTxidInOpret;
uint8_t hasHeirSpendingBegunDummy; uint8_t hasHeirSpendingBegunDummy;
@@ -579,7 +579,7 @@ template <class Helper> int64_t LifetimeHeirContractFunds(struct CCcontract_info
CTransaction heirtx; CTransaction heirtx;
// TODO: check all funding tx should contain unspendable markers // TODO: check all funding tx should contain unspendable markers
if (GetTransaction(txid, heirtx, hashBlock, false) && heirtx.vout.size() > 0) { if (myGetTransaction(txid, heirtx, hashBlock) && heirtx.vout.size() > 0) {
uint256 tokenid; uint256 tokenid;
uint256 fundingTxidInOpret; uint256 fundingTxidInOpret;
uint8_t hasHeirSpendingBegunDummy; uint8_t hasHeirSpendingBegunDummy;
@@ -1232,7 +1232,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result)
//std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n'; //std::cerr << "HeirList() checking txid=" << txid.GetHex() << " vout=" << vout << '\n';
CTransaction fundingtx; CTransaction fundingtx;
if (GetTransaction(txid, fundingtx, hashBlock, false)) { if (myGetTransaction(txid, fundingtx, hashBlock)) {
CPubKey ownerPubkey, heirPubkey; CPubKey ownerPubkey, heirPubkey;
std::string heirName, memo; std::string heirName, memo;
int64_t inactivityTimeSec; int64_t inactivityTimeSec;

View File

@@ -1,6 +1,6 @@
How this works: How this works:
- earlytxid must be a transaction included in the chain before block 100. The chain MUST not have any other of these type of tx before block 100, or someone may be able to change it and mess things up. - earlytxid must be a transaction included in the chain before block KOMODO_EARLYTXID_HEIGHT. The chain MUST not have any other of these type of tx before block KOMODO_EARLYTXID_HEIGHT, or someone may be able to change it and mess things up.
- When it gets to block 100, it takes the txid specified by the -earlytxid param (does not affect magic) - When it gets to block KOMODO_EARLYTXID_HEIGHT, it takes the txid specified by the -earlytxid param (does not affect magic)
- Looks up the transaction searches for the opreturn, then permenantly appends it to the end of ac_script in RAM. - Looks up the transaction searches for the opreturn, then permenantly appends it to the end of ac_script in RAM.
- After every daemon restart, the first time the daemon mines a block, or receives a block that pays ac_script it will look up the op_return and save it again. - After every daemon restart, the first time the daemon mines a block, or receives a block that pays ac_script it will look up the op_return and save it again.
- this enables it to always reach consensus but doesnt need to constantly keep looking up the tx in the chain. - this enables it to always reach consensus but doesnt need to constantly keep looking up the tx in the chain.

View File

@@ -367,7 +367,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string
return(-1); return(-1);
} }
// check for valid burn from external coin blockchain and if valid return(0); // check for valid burn from external coin blockchain and if valid return(0);
if (GetTransaction(bindtxid, bindtx, hashBlock, false) == 0 || (numvouts = bindtx.vout.size()) <= 0) if (myGetTransaction(bindtxid, bindtx, hashBlock) == 0 || (numvouts = bindtx.vout.size()) <= 0)
{ {
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport cant find bindtxid=" << bindtxid.GetHex() << std::endl); LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport cant find bindtxid=" << bindtxid.GetHex() << std::endl);
return(-1); return(-1);
@@ -397,7 +397,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport bindtx not yet confirmed/notarized" << std::endl); LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport bindtx not yet confirmed/notarized" << std::endl);
return(-1); return(-1);
} }
else if (GetTransaction(oracletxid, oracletx, hashBlock, false) == 0 || (numvouts = oracletx.vout.size()) <= 0) else if (myGetTransaction(oracletxid, oracletx, hashBlock) == 0 || (numvouts = oracletx.vout.size()) <= 0)
{ {
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport cant find oracletxid=" << oracletxid.GetHex() << std::endl); LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport cant find oracletxid=" << oracletxid.GetHex() << std::endl);
return(-1); return(-1);
@@ -417,7 +417,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,regtx,hashBlock,false) != 0 && regtx.vout.size() > 0 if ( myGetTransaction(txid,regtx,hashBlock) != 0 && regtx.vout.size() > 0
&& DecodeOraclesOpRet(regtx.vout[regtx.vout.size()-1].scriptPubKey,tmporacletxid,regpk,datafee) == 'R' && oracletxid == tmporacletxid ) && DecodeOraclesOpRet(regtx.vout[regtx.vout.size()-1].scriptPubKey,tmporacletxid,regpk,datafee) == 'R' && oracletxid == tmporacletxid )
{ {
pubkeys.push_back(regpk); pubkeys.push_back(regpk);

View File

@@ -525,7 +525,7 @@ std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 ) if ( myGetTransaction(oracletxid,oracletx,hashBlock) == 0 || (numvouts= oracletx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid)); CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -581,7 +581,7 @@ std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,
return std::string(""); return std::string("");
} }
LOGSTREAM("importgateway",CCLOG_DEBUG1, stream << "ImportGatewayDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl); LOGSTREAM("importgateway",CCLOG_DEBUG1, stream << "ImportGatewayDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl);
if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,bindtx,hashBlock) == 0 || (numvouts= bindtx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -651,7 +651,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
importgatewaypk = GetUnspendable(cp, 0); importgatewaypk = GetUnspendable(cp, 0);
if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -677,7 +677,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
K=0; K=0;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 &&
(funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P')) (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P'))
{ {
if (funcid=='W' && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' if (funcid=='W' && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W'
@@ -689,7 +689,7 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re
} }
else if (funcid=='P' && DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' && else if (funcid=='P' && DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)=='P' &&
GetTransaction(withdrawtxid,tx,hashBlock,false)!=0 && (numvouts=tx.vout.size())>0 && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W' myGetTransaction(withdrawtxid,tx,hashBlock)!=0 && (numvouts=tx.vout.size())>0 && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,tmpamount)=='W'
&& refcoin==coin && tmpbindtxid==bindtxid) && refcoin==coin && tmpbindtxid==bindtxid)
{ {
CCerror = strprintf("unable to create withdraw, another withdraw pending"); CCerror = strprintf("unable to create withdraw, another withdraw pending");
@@ -722,7 +722,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
importgatewaypk = GetUnspendable(cp,0); importgatewaypk = GetUnspendable(cp,0);
if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0
|| (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) || (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P'))
{ {
CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid)); CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid));
@@ -744,7 +744,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -766,7 +766,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0) else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts= tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid)); CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -785,7 +785,7 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -822,7 +822,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
importgatewaypk = GetUnspendable(cp,0); importgatewaypk = GetUnspendable(cp,0);
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
if (GetTransaction(lasttxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0 if (myGetTransaction(lasttxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0
|| (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P')) || (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P'))
{ {
CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid)); CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid));
@@ -838,7 +838,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -866,7 +866,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0) else if (myGetTransaction(withdrawtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())==0)
{ {
CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -884,7 +884,7 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0) else if (myGetTransaction(bindtxid,tmptx,hashBlock)==0 || (numvouts=tmptx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -920,7 +920,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 10000; txfee = 10000;
if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0) if (myGetTransaction(completetxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())<=0)
{ {
CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid)); CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -938,7 +938,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0) else if (myGetTransaction(withdrawtxid,tx,hashBlock)==0 || (numvouts= tx.vout.size())==0)
{ {
CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid)); CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -950,7 +950,7 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) else if (myGetTransaction(bindtxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid)); CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -987,7 +987,7 @@ UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin)
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
importgatewaypk = GetUnspendable(cp,0); importgatewaypk = GetUnspendable(cp,0);
_GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,mypk); _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,mypk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1005,7 +1005,7 @@ UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
DecodeImportGatewayDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,burntxid,claimvout,hex,proof,destpub,amount) == 'D' DecodeImportGatewayDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,publishers,txids,height,burntxid,claimvout,hex,proof,destpub,amount) == 'D'
&& tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) && tmpbindtxid==bindtxid && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0)
{ {
@@ -1041,7 +1041,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin)
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
importgatewaypk = GetUnspendable(cp,0); importgatewaypk = GetUnspendable(cp,0);
_GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1068,7 +1068,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin)
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
K=0; K=0;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 &&
(funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) (funcid=DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey))!=0 && (funcid=='W' || funcid=='P') && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0)
{ {
if (funcid=='W') if (funcid=='W')
@@ -1077,7 +1077,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin)
} }
else if (funcid=='P') else if (funcid=='P')
{ {
if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || GetTransaction(withdrawtxid,tx,hashBlock,false)==0 if (DecodeImportGatewayPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,hex)!='P' || myGetTransaction(withdrawtxid,tx,hashBlock)==0
|| (numvouts=tx.vout.size())<=0 || DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,amount)!='W' || (numvouts=tx.vout.size())<=0 || DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmpbindtxid,coin,withdrawpub,amount)!='W'
|| refcoin!=coin || tmpbindtxid!=bindtxid) || refcoin!=coin || tmpbindtxid!=bindtxid)
continue; continue;
@@ -1129,7 +1129,7 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin)
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
importgatewaypk = GetUnspendable(cp,0); importgatewaypk = GetUnspendable(cp,0);
_GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk); _GetCCaddress(coinaddr,EVAL_IMPORTGATEWAY,importgatewaypk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1155,10 +1155,10 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if ( vout == 0 && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 && if ( vout == 0 && nValue == 10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0 &&
DecodeImportGatewayCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0) DecodeImportGatewayCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex) == 'S' && refcoin == coin && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0)
{ {
if (GetTransaction(withdrawtxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size())>0 if (myGetTransaction(withdrawtxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size())>0
&& DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin) && DecodeImportGatewayWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,bindtxid,coin,withdrawpub,amount) == 'W' || refcoin!=coin)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
@@ -1192,7 +1192,7 @@ UniValue ImportGatewayList()
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 )
{ {
@@ -1209,7 +1209,7 @@ UniValue ImportGatewayExternalAddress(uint256 bindtxid,CPubKey pubkey)
std::string coin; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys; std::string coin; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys;
cp = CCinit(&C,EVAL_IMPORTGATEWAY); cp = CCinit(&C,EVAL_IMPORTGATEWAY);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1233,7 +1233,7 @@ UniValue ImportGatewayDumpPrivKey(uint256 bindtxid,CKey key)
std::string coin,priv; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys; std::string coin,priv; int64_t numvouts; char str[65],addr[65],burnaddr[65]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> msigpubkeys;
cp = CCinit(&C,EVAL_IMPORTGATEWAY); cp = CCinit(&C,EVAL_IMPORTGATEWAY);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1262,7 +1262,7 @@ UniValue ImportGatewayInfo(uint256 bindtxid)
cp = CCinit(&C,EVAL_IMPORTGATEWAY); cp = CCinit(&C,EVAL_IMPORTGATEWAY);
ImportGatewaypk = GetUnspendable(cp,0); ImportGatewaypk = GetUnspendable(cp,0);
GetTokensCCaddress(cp,gatewaystokens,ImportGatewaypk); GetTokensCCaddress(cp,gatewaystokens,ImportGatewaypk);
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{ {
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid)); CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1274,7 +1274,7 @@ UniValue ImportGatewayInfo(uint256 bindtxid)
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 ) if ( myGetTransaction(bindtxid,tx,hashBlock) != 0 )
{ {
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
result.push_back(Pair("name","ImportGateway")); result.push_back(Pair("name","ImportGateway"));

View File

@@ -173,7 +173,7 @@ int64_t AddLottoInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK
// prevent dup // prevent dup
if ( it->second.satoshis < COIN ) if ( it->second.satoshis < COIN )
continue; continue;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsLottovout(cp,vintx,(int32_t)it->first.index)) > 0 ) if ( (nValue= IsLottovout(cp,vintx,(int32_t)it->first.index)) > 0 )
{ {
@@ -214,7 +214,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u
{ {
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 )
{ {
// need to implement this! if ( (funcid= DecodeLottoOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'F' || funcid == 'T' ) // need to implement this! if ( (funcid= DecodeLottoOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'F' || funcid == 'T' )
{ {
@@ -233,7 +233,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u
UniValue LottoInfo(uint256 lottoid) UniValue LottoInfo(uint256 lottoid)
{ {
UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CCcontract_info *cp,C; char str[67],numstr[65]; UniValue result(UniValue::VOBJ); uint256 hashBlock,hentropy; CTransaction vintx; uint64_t lockedfunds,sbits; int32_t ticketsize,odds,firstheight,period; CPubKey lottopk; struct CCcontract_info *cp,C; char str[67],numstr[65];
if ( GetTransaction(lottoid,vintx,hashBlock,false) == 0 ) if ( myGetTransaction(lottoid,vintx,hashBlock) == 0 )
{ {
fprintf(stderr,"cant find lottoid\n"); fprintf(stderr,"cant find lottoid\n");
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
@@ -270,7 +270,7 @@ UniValue LottoList()
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeLottoFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,ticketsize,odds,firstheight,period,hentropy) == 'F' ) if ( vintx.vout.size() > 0 && DecodeLottoFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,ticketsize,odds,firstheight,period,hentropy) == 'F' )
{ {

View File

@@ -360,7 +360,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx,
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
//fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); //fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout);
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.IsCoinBase() != 0 && vintx.vout.size() == 2 && vintx.vout[1].nValue == 0 ) if ( vintx.IsCoinBase() != 0 && vintx.vout.size() == 2 && vintx.vout[1].nValue == 0 )
{ {
@@ -399,7 +399,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector<CPubKey> &pubkeys,
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
if ( it->second.satoshis < threshold ) if ( it->second.satoshis < threshold )
continue; continue;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' )
{ {
@@ -468,7 +468,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height)
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
if ( (nValue= it->second.satoshis) < threshold ) if ( (nValue= it->second.satoshis) < threshold )
continue; continue;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && vout < numvouts && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' ) if ( (funcid= DecodeMaramaraCoinbaseOpRet(tx.vout[numvouts-1].scriptPubKey,pk,ht,unlockht)) == 'C' || funcid == 'P' || funcid == 'L' )
{ {
@@ -516,7 +516,7 @@ int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx)
uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector<CPubKey> pubkeys; struct CCcontract_info *cp,C; uint64_t txfee; uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector<CPubKey> pubkeys; struct CCcontract_info *cp,C; uint64_t txfee;
txfee = 10000; txfee = 10000;
vout = mtx.vin[0].prevout.n; vout = mtx.vin[0].prevout.n;
if ( GetTransaction(mtx.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) if ( myGetTransaction(mtx.vin[0].prevout.hash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts )
{ {
cp = CCinit(&C,EVAL_MARMARA); cp = CCinit(&C,EVAL_MARMARA);
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
@@ -553,7 +553,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid)
height = chainActive.LastTip()->GetHeight(); height = chainActive.LastTip()->GetHeight();
if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 ) if ( (n= MarmaraGetbatontxid(creditloop,batontxid,refbatontxid)) > 0 )
{ {
if ( GetTransaction(batontxid,batontx,hashBlock,false) != 0 && (numvouts= batontx.vout.size()) > 1 ) if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && (numvouts= batontx.vout.size()) > 1 )
{ {
if ( (funcid= MarmaraDecodeLoopOpret(batontx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 ) if ( (funcid= MarmaraDecodeLoopOpret(batontx.vout[numvouts-1].scriptPubKey,refcreatetxid,pk,refamount,refmatures,refcurrency)) != 0 )
{ {
@@ -593,7 +593,7 @@ UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid)
pubkeys.push_back(mypk); pubkeys.push_back(mypk);
for (i=1; i<n; i++) for (i=1; i<n; i++)
{ {
if ( GetTransaction(creditloop[i],tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( myGetTransaction(creditloop[i],tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 )
{ {
@@ -674,7 +674,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector<uint256> &issuanc
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
//fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout); //fprintf(stderr,"txid.%s/v%d\n",txid.GetHex().c_str(),vout);
if ( vout == 1 && GetTransaction(txid,tx,hashBlock,false) != 0 ) if ( vout == 1 && myGetTransaction(txid,tx,hashBlock) != 0 )
{ {
if ( tx.IsCoinBase() == 0 && (numvouts= tx.vout.size()) > 2 && tx.vout[numvouts - 1].nValue == 0 ) if ( tx.IsCoinBase() == 0 && (numvouts= tx.vout.size()) > 2 && tx.vout[numvouts - 1].nValue == 0 )
{ {
@@ -814,7 +814,7 @@ UniValue MarmaraCreditloop(uint256 txid)
cp = CCinit(&C,EVAL_MARMARA); cp = CCinit(&C,EVAL_MARMARA);
if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 )
{ {
if ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
result.push_back(Pair("result",(char *)"success")); result.push_back(Pair("result",(char *)"success"));
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG);
@@ -886,7 +886,7 @@ UniValue MarmaraCreditloop(uint256 txid)
} }
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if ( GetTransaction(creditloop[i],tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( myGetTransaction(creditloop[i],tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 ) if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,pk,amount,matures,currency)) != 0 )
{ {

View File

@@ -759,7 +759,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
//char str[65]; fprintf(stderr,"oracle check %s/v%d\n",uint256_str(str,txid),vout); //char str[65]; fprintf(stderr,"oracle check %s/v%d\n",uint256_str(str,txid),vout);
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts=vintx.vout.size()-1)>0) if ( myGetTransaction(txid,vintx,hashBlock) != 0 && (numvouts=vintx.vout.size()-1)>0)
{ {
if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts].scriptPubKey,tmporacletxid,tmppk,tmpnum))!=0 && (funcid=='S' || funcid=='D')) if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts].scriptPubKey,tmporacletxid,tmppk,tmpnum))!=0 && (funcid=='S' || funcid=='D'))
{ {
@@ -795,7 +795,7 @@ int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubK
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,subtx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,subtx,hashBlock) != 0 )
{ {
if ( subtx.vout.size() > 0 && DecodeOraclesOpRet(subtx.vout[subtx.vout.size()-1].scriptPubKey,subtxid,pk,num) == 'S' && subtxid == oracletxid && pk == publisher ) if ( subtx.vout.size() > 0 && DecodeOraclesOpRet(subtx.vout[subtx.vout.size()-1].scriptPubKey,subtxid,pk,num) == 'S' && subtxid == oracletxid && pk == publisher )
{ {
@@ -818,7 +818,7 @@ int64_t AddMyOraclesFunds(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = it->second.satoshis; nValue = it->second.satoshis;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 && (numvouts=vintx.vout.size())>0) if ( myGetTransaction(txid,vintx,hashBlock) != 0 && (numvouts=vintx.vout.size())>0)
{ {
if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts-1].scriptPubKey,tmporacletxid,tmppk,tmpamount))!=0 && funcid=='F' && tmppk==pk if ((funcid=DecodeOraclesOpRet(vintx.vout[numvouts-1].scriptPubKey,tmporacletxid,tmppk,tmpamount))!=0 && funcid=='F' && tmppk==pk
&& tmporacletxid==oracletxid && tmpamount==nValue && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout)==0) && tmporacletxid==oracletxid && tmpamount==nValue && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout)==0)
@@ -986,7 +986,7 @@ std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector <uint8_t> da
fprintf(stderr,"%s\n", CCerror.c_str() ); fprintf(stderr,"%s\n", CCerror.c_str() );
return(""); return("");
} }
if ( GetTransaction(oracletxid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) if ( myGetTransaction(oracletxid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 )
{ {
if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' ) if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' )
{ {
@@ -1061,11 +1061,11 @@ UniValue OracleDataSample(uint256 reforacletxid,uint256 txid)
CPubKey pk; std::string name,description,format; int32_t numvouts; std::vector<uint8_t> data; char str[67], *formatstr = 0; CPubKey pk; std::string name,description,format; int32_t numvouts; std::vector<uint8_t> data; char str[67], *formatstr = 0;
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
if ( GetTransaction(reforacletxid,oracletx,hashBlock,false) != 0 && (numvouts=oracletx.vout.size()) > 0 ) if ( myGetTransaction(reforacletxid,oracletx,hashBlock) != 0 && (numvouts=oracletx.vout.size()) > 0 )
{ {
if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' ) if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' )
{ {
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 )
{ {
if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid ) if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid )
{ {
@@ -1094,7 +1094,7 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num)
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; int64_t nValue; std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; int64_t nValue;
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
if ( GetTransaction(reforacletxid,oracletx,hashBlock,false) != 0 && (numvouts=oracletx.vout.size()) > 0 ) if ( myGetTransaction(reforacletxid,oracletx,hashBlock) != 0 && (numvouts=oracletx.vout.size()) > 0 )
{ {
if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' ) if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) == 'C' )
{ {
@@ -1122,7 +1122,7 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num)
txid=it->first.txhash; txid=it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second; nValue = (int64_t)it->second;
if (vout==1 && nValue==10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0 ) if (vout==1 && nValue==10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 )
{ {
if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid ) if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid )
{ {
@@ -1155,14 +1155,14 @@ UniValue OracleInfo(uint256 origtxid)
cp = CCinit(&C,EVAL_ORACLES); cp = CCinit(&C,EVAL_ORACLES);
CCtxidaddr(markeraddr,origtxid); CCtxidaddr(markeraddr,origtxid);
if ( GetTransaction(origtxid,tx,hashBlock,false) == 0 ) if ( myGetTransaction(origtxid,tx,hashBlock) == 0 )
{ {
fprintf(stderr,"cant find oracleid\n"); fprintf(stderr,"cant find oracleid\n");
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
result.push_back(Pair("error","cant find oracleid")); result.push_back(Pair("error","cant find oracleid"));
return(result); return(result);
} }
if ( GetTransaction(origtxid,tx,hashBlock,false) != 0 ) if ( myGetTransaction(origtxid,tx,hashBlock) != 0 )
{ {
if ( tx.vout.size() > 0 && DecodeOraclesCreateOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,name,description,format) == 'C' ) if ( tx.vout.size() > 0 && DecodeOraclesCreateOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,name,description,format) == 'C' )
{ {
@@ -1177,7 +1177,7 @@ UniValue OracleInfo(uint256 origtxid)
{ {
txid = it->first.txhash; txid = it->first.txhash;
height = (int32_t)it->second.blockHeight; height = (int32_t)it->second.blockHeight;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 &&
DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R' && oracletxid == origtxid ) DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R' && oracletxid == origtxid )
{ {
if (publishers.find(pk)==publishers.end() || height>publishers[pk].second) if (publishers.find(pk)==publishers.end() || height>publishers[pk].second)
@@ -1189,7 +1189,7 @@ UniValue OracleInfo(uint256 origtxid)
} }
for (std::map<CPubKey,std::pair<uint256,int32_t>>::iterator it = publishers.begin(); it != publishers.end(); ++it) for (std::map<CPubKey,std::pair<uint256,int32_t>>::iterator it = publishers.begin(); it != publishers.end(); ++it)
{ {
if ( GetTransaction(it->second.first,tx,hashBlock,false) != 0 && DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R') if ( myGetTransaction(it->second.first,tx,hashBlock) != 0 && DecodeOraclesOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,oracletxid,pk,datafee) == 'R')
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("publisher",pubkey33_str(str,(uint8_t *)pk.begin()))); obj.push_back(Pair("publisher",pubkey33_str(str,(uint8_t *)pk.begin())));
@@ -1222,7 +1222,7 @@ UniValue OraclesList()
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,createtx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,createtx,hashBlock) != 0 )
{ {
if ( createtx.vout.size() > 0 && DecodeOraclesCreateOpRet(createtx.vout[createtx.vout.size()-1].scriptPubKey,name,description,format) == 'C' ) if ( createtx.vout.size() > 0 && DecodeOraclesCreateOpRet(createtx.vout[createtx.vout.size()-1].scriptPubKey,name,description,format) == 'C' )
{ {

View File

@@ -559,7 +559,7 @@ int64_t AddPaymentsInputs(bool fLockedBlocks,int8_t GetBalance,struct CCcontract
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
//fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr); //fprintf(stderr,"iter.%d %s/v%d %s\n",iter,txid.GetHex().c_str(),vout,coinaddr);
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( (nValue= IsPaymentsvout(cp,vintx,vout,coinaddr,ccopret)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( (nValue= IsPaymentsvout(cp,vintx,vout,coinaddr,ccopret)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {

View File

@@ -382,7 +382,7 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
// no need to prevent dup // no need to prevent dup
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if (myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if (myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
@@ -413,7 +413,7 @@ int64_t AddPegsTokenInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,u
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
// no need to prevent dup // no need to prevent dup
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if (myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 && DecodePegsOpRet(vintx,tmppegstxid,tmptokenid)!=0 && tmppegstxid==pegstxid && tmptokenid==tokenid) if (myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 && DecodePegsOpRet(vintx,tmppegstxid,tmptokenid)!=0 && tmppegstxid==pegstxid && tmptokenid==tokenid)
{ {
@@ -521,7 +521,7 @@ double PegsGetTokenPrice(uint256 tokenid)
int64_t *tokensyn,*btcusd; double price; CTransaction tokentx; uint256 hashBlock; int64_t *tokensyn,*btcusd; double price; CTransaction tokentx; uint256 hashBlock;
std::string name,desc; std::vector<uint8_t> vorigpubkey; int32_t numvouts; std::string name,desc; std::vector<uint8_t> vorigpubkey; int32_t numvouts;
if (GetTransaction(tokenid,tokentx,hashBlock,false)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') if (myGetTransaction(tokenid,tokentx,hashBlock)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c')
{ {
tokensyn = (int64_t *)calloc(sizeof(*tokensyn) * 3, 1 + PRICES_DAYWINDOW * 2 + PRICES_SMOOTHWIDTH); tokensyn = (int64_t *)calloc(sizeof(*tokensyn) * 3, 1 + PRICES_DAYWINDOW * 2 + PRICES_SMOOTHWIDTH);
btcusd = (int64_t *)calloc(sizeof(*btcusd) * 3, 1 + PRICES_DAYWINDOW * 2 + PRICES_SMOOTHWIDTH); btcusd = (int64_t *)calloc(sizeof(*btcusd) * 3, 1 + PRICES_DAYWINDOW * 2 + PRICES_SMOOTHWIDTH);
@@ -539,7 +539,7 @@ std::string PegsGetTokenName(uint256 tokenid)
{ {
CTransaction tokentx; uint256 hashBlock; std::string name,desc; std::vector<uint8_t> vorigpubkey; int32_t numvouts; CTransaction tokentx; uint256 hashBlock; std::string name,desc; std::vector<uint8_t> vorigpubkey; int32_t numvouts;
if (GetTransaction(tokenid,tokentx,hashBlock,false)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c') if (myGetTransaction(tokenid,tokentx,hashBlock)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c')
{ {
return (name); return (name);
} }
@@ -555,7 +555,7 @@ double PegsGetAccountRatio(uint256 pegstxid,uint256 tokenid,uint256 accounttxid)
std::pair<int64_t,int64_t> account; struct CCcontract_info *cp,C; std::pair<int64_t,int64_t> account; struct CCcontract_info *cp,C;
cp = CCinit(&C,EVAL_PEGS); cp = CCinit(&C,EVAL_PEGS);
if (GetTransaction(accounttxid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if (myGetTransaction(accounttxid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid && tokenid==tmptokenid) (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid && tokenid==tmptokenid)
{ {
PegsDecodeAccountTx(tx,pk,amount,account); PegsDecodeAccountTx(tx,pk,amount,account);
@@ -581,7 +581,7 @@ double PegsGetGlobalRatio(uint256 pegstxid)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if (vout == 0 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if (vout == 0 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid && (funcid=='F' || funcid=='G' || funcid=='E')) (funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid && (funcid=='F' || funcid=='G' || funcid=='E'))
{ {
PegsDecodeAccountTx(tx,pk,amount,account); PegsDecodeAccountTx(tx,pk,amount,account);
@@ -597,7 +597,7 @@ double PegsGetGlobalRatio(uint256 pegstxid)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if (GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid) if (myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid)
{ {
globalaccounts[tokenid].first+=nValue; globalaccounts[tokenid].first+=nValue;
} }
@@ -660,7 +660,7 @@ std::string PegsCreate(uint64_t txfee,int64_t amount, std::vector<uint256> bindt
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
for(auto txid : bindtxids) for(auto txid : bindtxids)
{ {
if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); CCerror = strprintf("cant find bindtxid %s",txid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -697,7 +697,7 @@ std::string PegsFund(uint64_t txfee,uint256 pegstxid, uint256 tokenid,int64_t am
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -711,7 +711,7 @@ std::string PegsFund(uint64_t txfee,uint256 pegstxid, uint256 tokenid,int64_t am
} }
for(auto txid : bindtxids) for(auto txid : bindtxids)
{ {
if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); CCerror = strprintf("cant find bindtxid %s",txid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -794,7 +794,7 @@ std::string PegsGet(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64_t am
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -855,7 +855,7 @@ std::string PegsRedeem(uint64_t txfee,uint256 pegstxid, uint256 tokenid)
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -869,7 +869,7 @@ std::string PegsRedeem(uint64_t txfee,uint256 pegstxid, uint256 tokenid)
} }
for(auto txid : bindtxids) for(auto txid : bindtxids)
{ {
if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); CCerror = strprintf("cant find bindtxid %s",txid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -968,7 +968,7 @@ std::string PegsExchange(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -982,7 +982,7 @@ std::string PegsExchange(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64
} }
for(auto txid : bindtxids) for(auto txid : bindtxids)
{ {
if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); CCerror = strprintf("cant find bindtxid %s",txid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1026,7 +1026,7 @@ std::string PegsExchange(uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if (accounttxid!=zeroid && GetTransaction(accounttxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,tmpamount,account).empty()) if (accounttxid!=zeroid && myGetTransaction(accounttxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,tmpamount,account).empty())
{ {
CCerror = strprintf("invalid account tx from which to exchange coins to tokens %s!",accounttxid.GetHex()); CCerror = strprintf("invalid account tx from which to exchange coins to tokens %s!",accounttxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1104,7 +1104,7 @@ std::string PegsLiquidate(uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint
txfee = 10000; txfee = 10000;
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
if (GetTransaction(pegstxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(pegstxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex()); CCerror = strprintf("cant find pegstxid %s",pegstxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1118,7 +1118,7 @@ std::string PegsLiquidate(uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint
} }
for(auto txid : bindtxids) for(auto txid : bindtxids)
{ {
if (GetTransaction(txid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0) if (myGetTransaction(txid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0)
{ {
CCerror = strprintf("cant find bindtxid %s",txid.GetHex()); CCerror = strprintf("cant find bindtxid %s",txid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1160,7 +1160,7 @@ std::string PegsLiquidate(uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if (liquidatetxid!=zeroid && GetTransaction(liquidatetxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,amount,account).empty()) if (liquidatetxid!=zeroid && myGetTransaction(liquidatetxid,tx,hashBlock)==0 || (numvouts=tx.vout.size())<=0 || PegsDecodeAccountTx(tx,tmppk,amount,account).empty())
{ {
CCerror = strprintf("cannot find account to liquidate or invalid tx %s!",liquidatetxid.GetHex()); CCerror = strprintf("cannot find account to liquidate or invalid tx %s!",liquidatetxid.GetHex());
LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("pegscc",CCLOG_INFO, stream << CCerror << std::endl);
@@ -1235,7 +1235,7 @@ UniValue PegsAccountHistory(uint256 pegstxid)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second; nValue = (int64_t)it->second;
if (vout == 1 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if (vout == 1 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid) (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
@@ -1272,7 +1272,7 @@ UniValue PegsAccountInfo(uint256 pegstxid)
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
//LOGSTREAM("pegscc",CCLOG_DEBUG2, stream << "txid=" << txid.GetHex() << ", vout=" << vout << ", nValue=" << nValue << std::endl); //LOGSTREAM("pegscc",CCLOG_DEBUG2, stream << "txid=" << txid.GetHex() << ", vout=" << vout << ", nValue=" << nValue << std::endl);
if (vout == 1 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if (vout == 1 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid) (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid)
{ {
//LOGSTREAM("pegscc",CCLOG_DEBUG2, stream << "txid=" << txid.GetHex() << ", vout=" << vout << ", nValue=" << nValue << ", tokenid=" << tmptokenid.GetHex() << std::endl); //LOGSTREAM("pegscc",CCLOG_DEBUG2, stream << "txid=" << txid.GetHex() << ", vout=" << vout << ", nValue=" << nValue << ", tokenid=" << tmptokenid.GetHex() << std::endl);
@@ -1314,7 +1314,7 @@ UniValue PegsWorstAccounts(uint256 pegstxid)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if (vout == 0 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if (vout == 0 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid) (funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid)
{ {
PegsDecodeAccountTx(tx,pk,amount,account); PegsDecodeAccountTx(tx,pk,amount,account);
@@ -1366,7 +1366,7 @@ UniValue PegsInfo(uint256 pegstxid)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if (vout == 0 && nValue == CC_MARKER_VALUE && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && if (vout == 0 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid) (funcid=DecodePegsOpRet(tx,tmppegstxid,tokenid))!=0 && pegstxid==tmppegstxid)
{ {
PegsDecodeAccountTx(tx,pk,amount,account); PegsDecodeAccountTx(tx,pk,amount,account);
@@ -1382,7 +1382,7 @@ UniValue PegsInfo(uint256 pegstxid)
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
nValue = (int64_t)it->second.satoshis; nValue = (int64_t)it->second.satoshis;
if (GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid) if (myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 && DecodePegsOpRet(tx,tmppegstxid,tokenid)!=0 && pegstxid==tmppegstxid)
{ {
globalaccounts[tokenid].first+=nValue; globalaccounts[tokenid].first+=nValue;
} }

View File

@@ -590,7 +590,7 @@ int64_t AddPricesInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, ch
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
//if (vout == exclvout && txid == excltxid) // exclude vout which is added directly to vins outside this function //if (vout == exclvout && txid == excltxid) // exclude vout which is added directly to vins outside this function
// continue; // continue;
if (GetTransaction(txid, vintx, hashBlock, false) != 0 && vout < vintx.vout.size()) if (myGetTransaction(txid, vintx, hashBlock) != 0 && vout < vintx.vout.size())
{ {
vscript_t vopret; vscript_t vopret;
uint8_t funcId = PricesCheckOpret(vintx, vopret); uint8_t funcId = PricesCheckOpret(vintx, vopret);
@@ -2161,7 +2161,7 @@ UniValue PricesList(uint32_t filter, CPubKey mypk)
std::vector<uint16_t> vec; std::vector<uint16_t> vec;
CTransaction vintx; CTransaction vintx;
if (GetTransaction(txid, vintx, hashBlock, false) != 0) if (myGetTransaction(txid, vintx, hashBlock) != 0)
{ {
// TODO: forget old tx // TODO: forget old tx

View File

@@ -357,7 +357,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont
break; break;
if ( j != mtx.vin.size() ) if ( j != mtx.vin.size() )
continue; continue;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) != 0 ) if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) != 0 )
{ {
@@ -409,7 +409,7 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra
{ {
txid = it->first.txhash; txid = it->first.txhash;
vout = (int32_t)it->first.index; vout = (int32_t)it->first.index;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 )
{ {
if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'F' || funcid == 'A' || funcid == 'U' || funcid == 'L' ) if ( (funcid= DecodeRewardsOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid)) == 'F' || funcid == 'A' || funcid == 'U' || funcid == 'L' )
{ {
@@ -439,7 +439,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa
{ {
//int height = it->first.blockHeight; //int height = it->first.blockHeight;
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 )
{ {
//char str[65]; fprintf(stderr,"rewards plan %s\n",uint256_str(str,txid)); //char str[65]; fprintf(stderr,"rewards plan %s\n",uint256_str(str,txid));
if ( DecodeRewardsFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) == 'F' ) if ( DecodeRewardsFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) == 'F' )
@@ -455,7 +455,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa
UniValue RewardsInfo(uint256 rewardsid) UniValue RewardsInfo(uint256 rewardsid)
{ {
UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CCcontract_info *cp,C; char str[67],numstr[65]; UniValue result(UniValue::VOBJ); uint256 hashBlock; CTransaction vintx; uint64_t lockedfunds,APR,minseconds,maxseconds,mindeposit,sbits,funding; CPubKey rewardspk; struct CCcontract_info *cp,C; char str[67],numstr[65];
if ( GetTransaction(rewardsid,vintx,hashBlock,false) == 0 ) if ( myGetTransaction(rewardsid,vintx,hashBlock) == 0 )
{ {
fprintf(stderr,"cant find fundingtxid\n"); fprintf(stderr,"cant find fundingtxid\n");
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
@@ -498,7 +498,7 @@ UniValue RewardsList()
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) != 0 ) if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) != 0 )
{ {
@@ -657,7 +657,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2
CCerror = "locktxid/v0 is spent"; CCerror = "locktxid/v0 is spent";
return(""); return("");
} }
if ( GetTransaction(locktxid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) if ( myGetTransaction(locktxid,tx,hashBlock) != 0 && tx.vout.size() > 0 && tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 )
{ {
scriptPubKey = tx.vout[1].scriptPubKey; scriptPubKey = tx.vout[1].scriptPubKey;
mtx.vin.push_back(CTxIn(locktxid,0,CScript())); mtx.vin.push_back(CTxIn(locktxid,0,CScript()));

View File

@@ -2730,7 +2730,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
decode_hex((uint8_t *)&txid,32,txidstr); decode_hex((uint8_t *)&txid,32,txidstr);
txid = revuint256(txid); txid = revuint256(txid);
result.push_back(Pair("txid",txid.GetHex())); result.push_back(Pair("txid",txid.GetHex()));
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' ) if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' )
{ {
@@ -2780,7 +2780,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
//char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN);
if ( it->second.satoshis != txfee || vout != 0 ) if ( it->second.satoshis != txfee || vout != 0 )
continue; continue;
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) if ( (nValue= IsCClibvout(cp,tx,vout,coinaddr)) == txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{ {
@@ -2861,7 +2861,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
result.push_back(Pair("txid",txid.GetHex())); result.push_back(Pair("txid",txid.GetHex()));
if ( CCgettxout(txid,0,1,0) < 0 ) if ( CCgettxout(txid,0,1,0) < 0 )
result.push_back(Pair("error","already solved")); result.push_back(Pair("error","already solved"));
else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) else if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey); Getscriptaddress(checkaddr,tx.vout[1].scriptPubKey);
if ( strcmp(checkaddr,CCaddr) != 0 ) if ( strcmp(checkaddr,CCaddr) != 0 )

View File

@@ -18,6 +18,8 @@
******************************************************************************/ ******************************************************************************/
#include "consensus/upgrades.h" #include "consensus/upgrades.h"
extern int32_t KOMODO_NSPV;
#define NSPV_BRANCHID 0x76b809bb
/** /**
* General information about each network upgrade. * General information about each network upgrade.
@@ -97,7 +99,10 @@ int CurrentEpoch(int nHeight, const Consensus::Params& params) {
return Consensus::BASE_SPROUT; return Consensus::BASE_SPROUT;
} }
uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params) { uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params)
{
if ( KOMODO_NSPV != 0 )
return(NSPV_BRANCHID);
return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId; return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId;
} }

View File

@@ -272,9 +272,13 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength,
unsigned char msgHash[32]; unsigned char msgHash[32];
if (doHashMsg) sha256(msg, msgLength, msgHash); if (doHashMsg) sha256(msg, msgLength, msgHash);
else memcpy(msgHash, msg, 32); else memcpy(msgHash, msg, 32);
int32_t z;
for (z=0; z<32; z++)
fprintf(stderr,"%02x",msgHash[z]);
fprintf(stderr," msgHash msglen.%d\n",msgLength);
if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) { if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) {
fprintf(stderr,"cc_verify error C\n"); fprintf(stderr," cc_verify error C\n");
return 0; return 0;
} }

View File

@@ -157,7 +157,11 @@ static int secp256k1Sign(CC *cond, CCVisitor visitor) {
int rc = secp256k1_ecdsa_sign(ec_ctx_sign, &sig, visitor.msg, signing->sk, NULL, NULL); int rc = secp256k1_ecdsa_sign(ec_ctx_sign, &sig, visitor.msg, signing->sk, NULL, NULL);
unlockSign(); unlockSign();
if (rc != 1) return 0; if (rc != 1)
{
fprintf(stderr,"secp256k1Sign rc.%d\n",rc);
return 0;
}
if (!cond->signature) cond->signature = calloc(1, SECP256K1_SIG_SIZE); if (!cond->signature) cond->signature = calloc(1, SECP256K1_SIG_SIZE);
secp256k1_ecdsa_signature_serialize_compact(ec_ctx_verify, cond->signature, &sig); secp256k1_ecdsa_signature_serialize_compact(ec_ctx_verify, cond->signature, &sig);
@@ -188,16 +192,22 @@ int cc_signTreeSecp256k1Msg32(CC *cond, const unsigned char *privateKey, const u
} }
// serialize pubkey // serialize pubkey
unsigned char *publicKey = calloc(1, SECP256K1_PK_SIZE); //unsigned char *publicKey = calloc(1, SECP256K1_PK_SIZE);
unsigned char publicKey[SECP256K1_PK_SIZE];
size_t ol = SECP256K1_PK_SIZE; size_t ol = SECP256K1_PK_SIZE;
secp256k1_ec_pubkey_serialize(ec_ctx_verify, publicKey, &ol, &spk, SECP256K1_EC_COMPRESSED); secp256k1_ec_pubkey_serialize(ec_ctx_verify, publicKey, &ol, &spk, SECP256K1_EC_COMPRESSED);
{
int32_t z;
for (z=0; z<33; z++)
fprintf(stderr,"%02x",publicKey[z]);
fprintf(stderr," pubkey\n");
}
// sign // sign
CCSecp256k1SigningData signing = {publicKey, privateKey, 0}; CCSecp256k1SigningData signing = {publicKey, privateKey, 0};
CCVisitor visitor = {&secp256k1Sign, msg32, 32, &signing}; CCVisitor visitor = {&secp256k1Sign, msg32, 32, &signing};
cc_visit(cond, visitor); cc_visit(cond, visitor);
free(publicKey); //free(publicKey);
return signing.nSigned; return signing.nSigned;
} }

View File

@@ -1496,6 +1496,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
InitBlockIndex(); InitBlockIndex();
SetRPCWarmupFinished(); SetRPCWarmupFinished();
uiInterface.InitMessage(_("Done loading")); uiInterface.InitMessage(_("Done loading"));
pwalletMain = new CWallet("tmptmp.wallet");
return !fRequestShutdown; return !fRequestShutdown;
} }
// ********************************************************* Step 7: load block chain // ********************************************************* Step 7: load block chain

View File

@@ -47,6 +47,8 @@ using namespace std;
#include "komodo_interest.h" #include "komodo_interest.h"
CKey NSPV_key;
char NSPV_pubkeystr[67],NSPV_wifstr[64];
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight) uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight)
{ {
return(0); return(0);

View File

@@ -2109,7 +2109,7 @@ bool komodo_appendACscriptpub()
{ {
CTransaction tx; uint256 blockhash; CTransaction tx; uint256 blockhash;
// get transaction and check that it occured before height 100. // get transaction and check that it occured before height 100.
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 ) if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < KOMODO_EARLYTXID_HEIGHT )
{ {
for (int i = 0; i < tx.vout.size(); i++) for (int i = 0; i < tx.vout.size(); i++)
{ {
@@ -2144,15 +2144,15 @@ void GetKomodoEarlytxidScriptPub()
StartShutdown(); StartShutdown();
return; return;
} }
if ( chainActive.Height() < 100 ) if ( chainActive.Height() < KOMODO_EARLYTXID_HEIGHT )
{ {
fprintf(stderr, "Cannot fetch -earlytxid before block 100.\n"); fprintf(stderr, "Cannot fetch -earlytxid before block %d.\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown(); StartShutdown();
return; return;
} }
CTransaction tx; uint256 blockhash; int32_t i; CTransaction tx; uint256 blockhash; int32_t i;
// get transaction and check that it occured before height 100. // get transaction and check that it occured before height 100.
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 ) if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < KOMODO_EARLYTXID_HEIGHT )
{ {
for (i = 0; i < tx.vout.size(); i++) for (i = 0; i < tx.vout.size(); i++)
if ( tx.vout[i].scriptPubKey[0] == OP_RETURN ) if ( tx.vout[i].scriptPubKey[0] == OP_RETURN )
@@ -2193,7 +2193,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{ {
static bool didinit = false; static bool didinit = false;
if ( !didinit && height > 100 && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) if ( !didinit && height > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
{ {
fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true; didinit = true;

View File

@@ -17,7 +17,7 @@
#define KOMODO_DEFS_H #define KOMODO_DEFS_H
#include "komodo_nk.h" #include "komodo_nk.h"
#define KOMODO_EARLYTXID_HEIGHT 200 #define KOMODO_EARLYTXID_HEIGHT 100
#define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7 #define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP 2000
@@ -275,7 +275,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED,KOMODO_NSPV; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED,KOMODO_NSPV;
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET;
extern bool VERUS_MINTBLOCKS; extern bool VERUS_MINTBLOCKS;
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2]; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2];
extern const char *ASSETCHAINS_ALGORITHMS[]; extern const char *ASSETCHAINS_ALGORITHMS[];
extern int32_t VERUS_MIN_STAKEAGE; extern int32_t VERUS_MIN_STAKEAGE;
extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];

View File

@@ -653,6 +653,7 @@ const char *banned_txids[] =
//"6e4980a9e1bd669f4df04732dc6f11b7773b6de88d1abcf89a6b9007d72ef9ac", //"6e4980a9e1bd669f4df04732dc6f11b7773b6de88d1abcf89a6b9007d72ef9ac",
//"6cc1d0495170bc0e11fd3925297623562e529ea1336b66ea61f8a1159041aed2", //"6cc1d0495170bc0e11fd3925297623562e529ea1336b66ea61f8a1159041aed2",
//"250875424cece9bcd98cb226b09da7671625633d6958589e3a462bad89ad87cc", // missed //"250875424cece9bcd98cb226b09da7671625633d6958589e3a462bad89ad87cc", // missed
//"ea8659011de52f4dac42cda12326064b7b5013b8492f88e33159884ca299aa05", // missed
}; };
int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts) int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts)

View File

@@ -75,7 +75,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF;
uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0,ASSETCHAINS_CBOPRET=0;
uint64_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_LASTERA = 1;
uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_PEGSCCPARAMS[3]; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1],ASSETCHAINS_PEGSCCPARAMS[3];
uint8_t ASSETCHAINS_CCDISABLES[256]; uint8_t ASSETCHAINS_CCDISABLES[256];
std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS; std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;

View File

@@ -16,11 +16,12 @@
// todo: // todo:
// myprivkey, scrub all destination buffers
// oversized tx
// headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs // headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs
// interest calculations are currently just using what is returned, it should calculate it from scratch
// CC signing
// make sure to sanity check all vector lengths on receipt // make sure to sanity check all vector lengths on receipt
// make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database) // make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database)
// bug: under load, fullnode was returning all 0 nServices // bug: under load, fullnode was returning all 0 nServices
@@ -28,34 +29,7 @@
#ifndef KOMODO_NSPV_H #ifndef KOMODO_NSPV_H
#define KOMODO_NSPV_H #define KOMODO_NSPV_H
#define NSPV_POLLITERS 15 int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf)
#define NSPV_POLLMICROS 100000
#define NSPV_MAXVINS 64
#define NSPV_AUTOLOGOUT 777
#define NSPV_BRANCHID 0x76b809bb
// nSPV defines and struct definitions with serialization and purge functions
#define NSPV_INFO 0x00
#define NSPV_INFORESP 0x01
#define NSPV_UTXOS 0x02
#define NSPV_UTXOSRESP 0x03
#define NSPV_NTZS 0x04
#define NSPV_NTZSRESP 0x05
#define NSPV_NTZSPROOF 0x06
#define NSPV_NTZSPROOFRESP 0x07
#define NSPV_TXPROOF 0x08
#define NSPV_TXPROOFRESP 0x09
#define NSPV_SPENTINFO 0x0a
#define NSPV_SPENTINFORESP 0x0b
#define NSPV_BROADCAST 0x0c
#define NSPV_BROADCASTRESP 0x0d
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum);
extern uint256 SIG_TXHASH;
uint32_t NSPV_blocktime(int32_t hdrheight);
int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,uint16_t len,uint8_t *buf)
{ {
if ( rwflag != 0 ) if ( rwflag != 0 )
memcpy(serialized,buf,len); memcpy(serialized,buf,len);
@@ -63,18 +37,6 @@ int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,uint16_t len,uint8_t *bu
return(len); return(len);
} }
struct NSPV_equihdr
{
int32_t nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
uint256 hashFinalSaplingRoot;
uint32_t nTime;
uint32_t nBits;
uint256 nNonce;
uint8_t nSolution[1344];
};
int32_t NSPV_rwequihdr(int32_t rwflag,uint8_t *serialized,struct NSPV_equihdr *ptr) int32_t NSPV_rwequihdr(int32_t rwflag,uint8_t *serialized,struct NSPV_equihdr *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -104,26 +66,19 @@ int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsize
return(len); return(len);
} }
int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep,uint8_t **ptrp) int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,uint8_t **ptrp)
{ {
int32_t vsize,len = 0; int32_t vsize,len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(*vecsizep),vecsizep); len += iguana_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp);
if ( (vsize= *vecsizep) != 0 ) if ( (vsize= *biglenp) > 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING )
{ {
if ( *ptrp == 0 ) if ( *ptrp == 0 )
*ptrp = (uint8_t *)calloc(1,vsize); // relies on uint16_t being "small" to prevent mem exhaustion *ptrp = (uint8_t *)calloc(1,vsize);
len += iguana_rwbuf(rwflag,&serialized[len],vsize,*ptrp); len += iguana_rwbuf(rwflag,&serialized[len],vsize,*ptrp);
} }
return(len); return(len);
} }
struct NSPV_utxoresp
{
uint256 txid;
int64_t satoshis,extradata;
int32_t vout,height;
};
int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp *ptr) int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -135,15 +90,6 @@ int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp
return(len); return(len);
} }
struct NSPV_utxosresp
{
struct NSPV_utxoresp *utxos;
char coinaddr[64];
int64_t total,interest;
int32_t nodeheight;
uint16_t numutxos; uint8_t CCflag,pad8;
};
int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosresp *ptr) // check mempool int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosresp *ptr) // check mempool
{ {
int32_t i,len = 0; int32_t i,len = 0;
@@ -183,11 +129,15 @@ void NSPV_utxosresp_purge(struct NSPV_utxosresp *ptr)
} }
} }
struct NSPV_ntz void NSPV_utxosresp_copy(struct NSPV_utxosresp *dest,struct NSPV_utxosresp *ptr)
{ {
uint256 blockhash,txid,othertxid; *dest = *ptr;
int32_t height,txidheight; if ( ptr->utxos != 0 )
}; {
dest->utxos = (struct NSPV_utxoresp *)malloc(ptr->numutxos * sizeof(*ptr->utxos));
memcpy(dest->utxos,ptr->utxos,ptr->numutxos * sizeof(*ptr->utxos));
}
}
int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr) int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr)
{ {
@@ -200,12 +150,6 @@ int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr)
return(len); return(len);
} }
struct NSPV_ntzsresp
{
struct NSPV_ntz prevntz,nextntz;
int32_t reqheight;
};
int32_t NSPV_rwntzsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsresp *ptr) int32_t NSPV_rwntzsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsresp *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -226,14 +170,6 @@ void NSPV_ntzsresp_purge(struct NSPV_ntzsresp *ptr)
memset(ptr,0,sizeof(*ptr)); memset(ptr,0,sizeof(*ptr));
} }
struct NSPV_inforesp
{
struct NSPV_ntz notarization;
uint256 blockhash;
int32_t height,hdrheight;
struct NSPV_equihdr H;
};
int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp *ptr) int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -252,15 +188,6 @@ void NSPV_inforesp_purge(struct NSPV_inforesp *ptr)
memset(ptr,0,sizeof(*ptr)); memset(ptr,0,sizeof(*ptr));
} }
struct NSPV_txproof
{
uint256 txid;
int64_t unspentvalue;
int32_t height,vout,pad;
uint16_t txlen,txprooflen;
uint8_t *tx,*txproof;
};
int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *ptr) int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -268,7 +195,6 @@ int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *p
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad),&ptr->pad);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof);
return(len); return(len);
@@ -277,7 +203,7 @@ int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *p
void NSPV_txproof_copy(struct NSPV_txproof *dest,struct NSPV_txproof *ptr) void NSPV_txproof_copy(struct NSPV_txproof *dest,struct NSPV_txproof *ptr)
{ {
*dest = *ptr; *dest = *ptr;
if ( ptr->tx != 0 ) if ( ptr->tx != 0 && ptr->txlen < MAX_TX_SIZE_AFTER_SAPLING )
{ {
dest->tx = (uint8_t *)malloc(ptr->txlen); dest->tx = (uint8_t *)malloc(ptr->txlen);
memcpy(dest->tx,ptr->tx,ptr->txlen); memcpy(dest->tx,ptr->tx,ptr->txlen);
@@ -301,13 +227,6 @@ void NSPV_txproof_purge(struct NSPV_txproof *ptr)
} }
} }
struct NSPV_ntzproofshared
{
struct NSPV_equihdr *hdrs;
int32_t prevht,nextht,pad32;
uint16_t numhdrs,pad16;
};
int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzproofshared *ptr) int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzproofshared *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -320,26 +239,17 @@ int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz
return(len); return(len);
} }
struct NSPV_ntzsproofresp
{
struct NSPV_ntzproofshared common;
uint256 prevtxid,nexttxid;
int32_t pad32,prevtxidht,nexttxidht;
uint16_t prevtxlen,nexttxlen;
uint8_t *prevntz,*nextntz;
};
int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsproofresp *ptr) int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsproofresp *ptr)
{ {
int32_t len = 0; int32_t len = 0;
len += NSPV_rwntzproofshared(rwflag,&serialized[len],&ptr->common); len += NSPV_rwntzproofshared(rwflag,&serialized[len],&ptr->common);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz); len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz);
//fprintf(stderr,"retlen.%d\n",len);
return(len); return(len);
} }
@@ -377,19 +287,6 @@ void NSPV_ntzsproofresp_purge(struct NSPV_ntzsproofresp *ptr)
} }
} }
struct NSPV_MMRproof
{
struct NSPV_ntzproofshared common;
// tbd
};
struct NSPV_spentinfo
{
struct NSPV_txproof spent;
uint256 txid;
int32_t vout,spentvini;
};
int32_t NSPV_rwspentinfo(int32_t rwflag,uint8_t *serialized,struct NSPV_spentinfo *ptr) // check mempool int32_t NSPV_rwspentinfo(int32_t rwflag,uint8_t *serialized,struct NSPV_spentinfo *ptr) // check mempool
{ {
int32_t len = 0; int32_t len = 0;
@@ -409,12 +306,6 @@ void NSPV_spentinfo_purge(struct NSPV_spentinfo *ptr)
} }
} }
struct NSPV_broadcastresp
{
uint256 txid;
int32_t retcode;
};
int32_t NSPV_rwbroadcastresp(int32_t rwflag,uint8_t *serialized,struct NSPV_broadcastresp *ptr) int32_t NSPV_rwbroadcastresp(int32_t rwflag,uint8_t *serialized,struct NSPV_broadcastresp *ptr)
{ {
int32_t len = 0; int32_t len = 0;
@@ -458,11 +349,14 @@ uint256 NSPV_hdrhash(struct NSPV_equihdr *hdr)
int32_t NSPV_txextract(CTransaction &tx,uint8_t *data,int32_t datalen) int32_t NSPV_txextract(CTransaction &tx,uint8_t *data,int32_t datalen)
{ {
std::vector<uint8_t> rawdata; std::vector<uint8_t> rawdata;
rawdata.resize(datalen); if ( datalen < MAX_TX_SIZE_AFTER_SAPLING )
memcpy(&rawdata[0],data,datalen); {
if ( DecodeHexTx(tx,HexStr(rawdata)) != 0 ) rawdata.resize(datalen);
return(0); memcpy(&rawdata[0],data,datalen);
else return(-1); if ( DecodeHexTx(tx,HexStr(rawdata)) != 0 )
return(0);
}
return(-1);
} }
bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime); bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey,uint32_t nTime);

144
src/komodo_nSPV_defs.h Normal file
View File

@@ -0,0 +1,144 @@
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#ifndef KOMODO_NSPV_DEFSH
#define KOMODO_NSPV_DEFSH
#define NSPV_POLLITERS 100
#define NSPV_POLLMICROS 50000
#define NSPV_MAXVINS 64
#define NSPV_AUTOLOGOUT 777
#define NSPV_BRANCHID 0x76b809bb
// nSPV defines and struct definitions with serialization and purge functions
#define NSPV_INFO 0x00
#define NSPV_INFORESP 0x01
#define NSPV_UTXOS 0x02
#define NSPV_UTXOSRESP 0x03
#define NSPV_NTZS 0x04
#define NSPV_NTZSRESP 0x05
#define NSPV_NTZSPROOF 0x06
#define NSPV_NTZSPROOFRESP 0x07
#define NSPV_TXPROOF 0x08
#define NSPV_TXPROOFRESP 0x09
#define NSPV_SPENTINFO 0x0a
#define NSPV_SPENTINFORESP 0x0b
#define NSPV_BROADCAST 0x0c
#define NSPV_BROADCASTRESP 0x0d
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum);
UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis);
extern uint256 SIG_TXHASH;
uint32_t NSPV_blocktime(int32_t hdrheight);
struct NSPV_equihdr
{
int32_t nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
uint256 hashFinalSaplingRoot;
uint32_t nTime;
uint32_t nBits;
uint256 nNonce;
uint8_t nSolution[1344];
};
struct NSPV_utxoresp
{
uint256 txid;
int64_t satoshis,extradata;
int32_t vout,height;
};
struct NSPV_utxosresp
{
struct NSPV_utxoresp *utxos;
char coinaddr[64];
int64_t total,interest;
int32_t nodeheight;
uint16_t numutxos; uint8_t CCflag,pad8;
};
struct NSPV_ntz
{
uint256 blockhash,txid,othertxid;
int32_t height,txidheight;
};
struct NSPV_ntzsresp
{
struct NSPV_ntz prevntz,nextntz;
int32_t reqheight;
};
struct NSPV_inforesp
{
struct NSPV_ntz notarization;
uint256 blockhash;
int32_t height,hdrheight;
struct NSPV_equihdr H;
};
struct NSPV_txproof
{
uint256 txid;
int64_t unspentvalue;
int32_t height,vout,txlen,txprooflen;
uint8_t *tx,*txproof;
};
struct NSPV_ntzproofshared
{
struct NSPV_equihdr *hdrs;
int32_t prevht,nextht,pad32;
uint16_t numhdrs,pad16;
};
struct NSPV_ntzsproofresp
{
struct NSPV_ntzproofshared common;
uint256 prevtxid,nexttxid;
int32_t prevtxidht,nexttxidht,prevtxlen,nexttxlen;
uint8_t *prevntz,*nextntz;
};
struct NSPV_MMRproof
{
struct NSPV_ntzproofshared common;
// tbd
};
struct NSPV_spentinfo
{
struct NSPV_txproof spent;
uint256 txid;
int32_t vout,spentvini;
};
struct NSPV_broadcastresp
{
uint256 txid;
int32_t retcode;
};
struct NSPV_CCmtxinfo
{
struct NSPV_utxosresp U;
struct NSPV_utxoresp used[NSPV_MAXVINS];
};
#endif // KOMODO_NSPV_DEFSH

View File

@@ -126,6 +126,7 @@ int32_t NSPV_getinfo(struct NSPV_inforesp *ptr,int32_t reqheight)
{ {
ptr->height = pindex->GetHeight(); ptr->height = pindex->GetHeight();
ptr->blockhash = pindex->GetBlockHash(); ptr->blockhash = pindex->GetBlockHash();
memset(&pair,0,sizeof(pair));
if ( NSPV_getntzsresp(&pair,ptr->height-1) < 0 ) if ( NSPV_getntzsresp(&pair,ptr->height-1) < 0 )
return(-1); return(-1);
ptr->notarization = pair.prevntz; ptr->notarization = pair.prevntz;
@@ -184,12 +185,11 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr,bool isCC
return(0); return(0);
} }
uint8_t *NSPV_getrawtx(CTransaction &tx,uint256 &hashBlock,uint16_t *txlenp,uint256 txid) uint8_t *NSPV_getrawtx(CTransaction &tx,uint256 &hashBlock,int32_t *txlenp,uint256 txid)
{ {
uint8_t *rawtx = 0; uint8_t *rawtx = 0;
*txlenp = 0; *txlenp = 0;
{ {
LOCK(cs_main);
if (!GetTransaction(txid, tx, hashBlock, false)) if (!GetTransaction(txid, tx, hashBlock, false))
return(0); return(0);
string strHex = EncodeHexTx(tx); string strHex = EncodeHexTx(tx);
@@ -209,7 +209,7 @@ int32_t NSPV_sendrawtransaction(struct NSPV_broadcastresp *ptr,uint8_t *data,int
ptr->retcode = 0; ptr->retcode = 0;
if ( NSPV_txextract(tx,data,n) == 0 ) if ( NSPV_txextract(tx,data,n) == 0 )
{ {
LOCK(cs_main); //LOCK(cs_main);
ptr->txid = tx.GetHash(); ptr->txid = tx.GetHash();
//fprintf(stderr,"try to addmempool transaction %s\n",ptr->txid.GetHex().c_str()); //fprintf(stderr,"try to addmempool transaction %s\n",ptr->txid.GetHex().c_str());
if ( myAddtomempool(tx) != 0 ) if ( myAddtomempool(tx) != 0 )
@@ -306,6 +306,7 @@ int32_t NSPV_getntzsproofresp(struct NSPV_ntzsproofresp *ptr,uint256 prevntztxid
return(-1); return(-1);
} }
} }
//fprintf(stderr,"sizeof ptr %ld, common.%ld lens.%d %d\n",sizeof(*ptr),sizeof(ptr->common),ptr->prevtxlen,ptr->nexttxlen);
return(sizeof(*ptr) + sizeof(*ptr->common.hdrs)*ptr->common.numhdrs - sizeof(ptr->common.hdrs) - sizeof(ptr->prevntz) - sizeof(ptr->nextntz) + ptr->prevtxlen + ptr->nexttxlen); return(sizeof(*ptr) + sizeof(*ptr->common.hdrs)*ptr->common.numhdrs - sizeof(ptr->common.hdrs) - sizeof(ptr->prevntz) - sizeof(ptr->nextntz) + ptr->prevtxlen + ptr->nexttxlen);
} }
@@ -426,9 +427,9 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz); iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz);
iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz); iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz);
memset(&P,0,sizeof(P)); memset(&P,0,sizeof(P));
//fprintf(stderr,"msg prev.%s next.%s\n",prevntz.GetHex().c_str(),nextntz.GetHex().c_str());
if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 ) if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 )
{ {
// fprintf(stderr,"slen.%d msg prev.%s next.%s\n",slen,prevntz.GetHex().c_str(),nextntz.GetHex().c_str());
response.resize(1 + slen); response.resize(1 + slen);
response[0] = NSPV_NTZSPROOFRESP; response[0] = NSPV_NTZSPROOFRESP;
if ( NSPV_rwntzsproofresp(1,&response[1],&P) == slen ) if ( NSPV_rwntzsproofresp(1,&response[1],&P) == slen )
@@ -437,7 +438,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
pfrom->prevtimes[ind] = timestamp; pfrom->prevtimes[ind] = timestamp;
} }
NSPV_ntzsproofresp_purge(&P); NSPV_ntzsproofresp_purge(&P);
} } else fprintf(stderr,"err.%d\n",slen);
} }
} }
} }
@@ -495,14 +496,14 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
{ {
if ( timestamp > pfrom->prevtimes[ind] ) if ( timestamp > pfrom->prevtimes[ind] )
{ {
struct NSPV_broadcastresp B; uint16_t n,offset; uint256 txid; struct NSPV_broadcastresp B; uint32_t n,offset; uint256 txid;
if ( len > 1+sizeof(txid)+sizeof(n) ) if ( len > 1+sizeof(txid)+sizeof(n) )
{ {
iguana_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid); iguana_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid);
iguana_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n); iguana_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n);
memset(&B,0,sizeof(B)); memset(&B,0,sizeof(B));
offset = 1 + sizeof(txid) + sizeof(n); offset = 1 + sizeof(txid) + sizeof(n);
if ( request.size() == offset+n && (slen= NSPV_sendrawtransaction(&B,&request[offset],n)) > 0 ) if ( n < MAX_TX_SIZE_AFTER_SAPLING && request.size() == offset+n && (slen= NSPV_sendrawtransaction(&B,&request[offset],n)) > 0 )
{ {
response.resize(1 + slen); response.resize(1 + slen);
response[0] = NSPV_BROADCASTRESP; response[0] = NSPV_BROADCASTRESP;

View File

@@ -66,16 +66,32 @@ struct NSPV_ntzsresp *NSPV_ntzsresp_add(struct NSPV_ntzsresp *ptr)
struct NSPV_txproof *NSPV_txproof_find(uint256 txid) struct NSPV_txproof *NSPV_txproof_find(uint256 txid)
{ {
int32_t i; int32_t i; struct NSPV_txproof *backup = 0;
for (i=0; i<sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache); i++) for (i=0; i<sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache); i++)
if ( NSPV_txproof_cache[i].txid == txid ) if ( NSPV_txproof_cache[i].txid == txid )
return(&NSPV_txproof_cache[i]); {
return(0); if ( NSPV_txproof_cache[i].txprooflen != 0 )
return(&NSPV_txproof_cache[i]);
else backup = &NSPV_txproof_cache[i];
}
return(backup);
} }
struct NSPV_txproof *NSPV_txproof_add(struct NSPV_txproof *ptr) struct NSPV_txproof *NSPV_txproof_add(struct NSPV_txproof *ptr)
{ {
int32_t i; int32_t i;
for (i=0; i<sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache); i++)
if ( NSPV_txproof_cache[i].txid == ptr->txid )
{
if ( NSPV_txproof_cache[i].txprooflen == 0 && ptr->txprooflen != 0 )
{
NSPV_txproof_purge(&NSPV_txproof_cache[i]);
NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr);
return(&NSPV_txproof_cache[i]);
}
else if ( NSPV_txproof_cache[i].txprooflen != 0 || ptr->txprooflen == 0 )
return(&NSPV_txproof_cache[i]);
}
for (i=0; i<sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache); i++) for (i=0; i<sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache); i++)
if ( NSPV_txproof_cache[i].txlen == 0 ) if ( NSPV_txproof_cache[i].txlen == 0 )
break; break;
@@ -191,7 +207,7 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
if ( pnode == 0 ) if ( pnode == 0 )
{ {
memset(pnodes,0,sizeof(pnodes)); memset(pnodes,0,sizeof(pnodes));
LOCK(cs_vNodes); //LOCK(cs_vNodes);
n = 0; n = 0;
BOOST_FOREACH(CNode *ptr,vNodes) BOOST_FOREACH(CNode *ptr,vNodes)
{ {
@@ -431,6 +447,7 @@ UniValue NSPV_broadcast_json(struct NSPV_broadcastresp *ptr,uint256 txid)
UniValue NSPV_login(char *wifstr) UniValue NSPV_login(char *wifstr)
{ {
UniValue result(UniValue::VOBJ); char coinaddr[64]; uint8_t data[128]; int32_t len,valid = 0; UniValue result(UniValue::VOBJ); char coinaddr[64]; uint8_t data[128]; int32_t len,valid = 0;
NSPV_logout();
len = bitcoin_base58decode(data,wifstr); len = bitcoin_base58decode(data,wifstr);
if ( strlen(wifstr) < 64 && (len == 38 && data[len-5] == 1) || (len == 37 && data[len-5] != 1) ) if ( strlen(wifstr) < 64 && (len == 38 && data[len-5] == 1) || (len == 37 && data[len-5] != 1) )
valid = 1; valid = 1;
@@ -576,7 +593,7 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
msg[len++] = NSPV_NTZSPROOF; msg[len++] = NSPV_NTZSPROOF;
len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid); len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid);
len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid); len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid);
//for (iter=0; iter<3; iter++); for (iter=0; iter<3; iter++);
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
{ {
for (i=0; i<NSPV_POLLITERS; i++) for (i=0; i<NSPV_POLLITERS; i++)
@@ -585,7 +602,7 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
if ( NSPV_ntzsproofresult.prevtxid == prevtxid && NSPV_ntzsproofresult.nexttxid == nexttxid ) if ( NSPV_ntzsproofresult.prevtxid == prevtxid && NSPV_ntzsproofresult.nexttxid == nexttxid )
return(NSPV_ntzsproof_json(&NSPV_ntzsproofresult)); return(NSPV_ntzsproof_json(&NSPV_ntzsproofresult));
} }
} //else sleep(1); } else sleep(1);
memset(&P,0,sizeof(P)); memset(&P,0,sizeof(P));
return(NSPV_ntzsproof_json(&P)); return(NSPV_ntzsproof_json(&P));
} }
@@ -654,7 +671,7 @@ UniValue NSPV_spentinfo(uint256 txid,int32_t vout)
UniValue NSPV_broadcast(char *hex) UniValue NSPV_broadcast(char *hex)
{ {
uint8_t *msg,*data; uint256 txid; uint16_t n; int32_t i,iter,len = 0; struct NSPV_broadcastresp B; uint8_t *msg,*data; uint256 txid; int32_t i,n,iter,len = 0; struct NSPV_broadcastresp B;
NSPV_broadcast_purge(&NSPV_broadcastresult); NSPV_broadcast_purge(&NSPV_broadcastresult);
n = (int32_t)strlen(hex) >> 1; n = (int32_t)strlen(hex) >> 1;
data = (uint8_t *)malloc(n); data = (uint8_t *)malloc(n);
@@ -686,5 +703,4 @@ UniValue NSPV_broadcast(char *hex)
return(NSPV_broadcast_json(&B,txid)); return(NSPV_broadcast_json(&B,txid));
} }
#endif // KOMODO_NSPVSUPERLITE_H #endif // KOMODO_NSPVSUPERLITE_H

View File

@@ -44,7 +44,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
if ( blockhash != ptr->common.hdrs[i].hashPrevBlock ) if ( blockhash != ptr->common.hdrs[i].hashPrevBlock )
return(-i-13); return(-i-13);
} }
sleep(1); sleep(1); // need this to get past the once per second rate limiter per message
if ( NSPV_txextract(tx,ptr->prevntz,ptr->prevtxlen) < 0 ) if ( NSPV_txextract(tx,ptr->prevntz,ptr->prevtxlen) < 0 )
return(-8); return(-8);
else if ( tx.GetHash() != ptr->prevtxid ) else if ( tx.GetHash() != ptr->prevtxid )
@@ -61,6 +61,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum) int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum)
{ {
struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector<uint8_t> proof; struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector<uint8_t> proof;
//fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height);
if ( (ptr= NSPV_txproof_find(txid)) == 0 ) if ( (ptr= NSPV_txproof_find(txid)) == 0 )
{ {
NSPV_txproof(vout,txid,height); NSPV_txproof(vout,txid,height);
@@ -73,8 +74,10 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
} }
else if ( NSPV_txextract(tx,ptr->tx,ptr->txlen) < 0 || ptr->txlen <= 0 ) else if ( NSPV_txextract(tx,ptr->tx,ptr->txlen) < 0 || ptr->txlen <= 0 )
retval = -2000; retval = -2000;
else if ( skipvalidation == 0 && ptr->unspentvalue <= 0 ) else if ( tx.GetHash() != txid )
retval = -2001; retval = -2001;
else if ( skipvalidation == 0 && ptr->unspentvalue <= 0 )
retval = -2002;
else if ( ASSETCHAINS_SYMBOL[0] == 0 && extradata >= 0 && tiptime != 0 ) else if ( ASSETCHAINS_SYMBOL[0] == 0 && extradata >= 0 && tiptime != 0 )
{ {
rewards = komodo_interestnew(height,tx.vout[vout].nValue,tx.nLockTime,tiptime); rewards = komodo_interestnew(height,tx.vout[vout].nValue,tx.nLockTime,tiptime);
@@ -82,6 +85,9 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
fprintf(stderr,"extradata %.8f vs rewards %.8f\n",dstr(extradata),dstr(rewards)); fprintf(stderr,"extradata %.8f vs rewards %.8f\n",dstr(extradata),dstr(rewards));
rewardsum += rewards; rewardsum += rewards;
} }
//char coinaddr[64];
//Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); causes crash??
//fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str());
if ( skipvalidation == 0 ) if ( skipvalidation == 0 )
{ {
@@ -117,7 +123,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
retval = -2003; retval = -2003;
} }
} }
} else retval = -2002; } else retval = -2005;
} else retval = -2004; } else retval = -2004;
} }
return(retval); return(retval);
@@ -228,13 +234,6 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C
{ {
CTransaction txNewConst(mtx); SignatureData sigdata; CBasicKeyStore keystore; int64_t branchid = NSPV_BRANCHID; CTransaction txNewConst(mtx); SignatureData sigdata; CBasicKeyStore keystore; int64_t branchid = NSPV_BRANCHID;
keystore.AddKey(NSPV_key); keystore.AddKey(NSPV_key);
if ( 0 )
{
int32_t i;
for (i=0; i<scriptPubKey.size()+4; i++)
fprintf(stderr,"%02x",((uint8_t *)&scriptPubKey)[i]);
fprintf(stderr," scriptPubKey\n");
}
if ( nTime != 0 && nTime < KOMODO_SAPLING_ACTIVATION ) if ( nTime != 0 && nTime < KOMODO_SAPLING_ACTIVATION )
{ {
fprintf(stderr,"use legacy sig validation\n"); fprintf(stderr,"use legacy sig validation\n");
@@ -243,9 +242,9 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C
if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 ) if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 )
{ {
UpdateTransaction(mtx,vini,sigdata); UpdateTransaction(mtx,vini,sigdata);
// fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); //fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
return(true); return(true);
} // else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN); } //else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
return(false); return(false);
} }
@@ -301,7 +300,7 @@ std::string NSPV_signtx(int64_t &rewardsum,int64_t &interestsum,UniValue &retcod
UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about! UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about!
{ {
UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); uint8_t rmd160[128]; int64_t txfee = 10000; UniValue result(UniValue::VOBJ),retcodes(UniValue::VARR); std::vector<uint8_t> data; CScript scriptPubKey; uint8_t *ptr,rmd160[128]; int32_t len; int64_t txfee = 10000;
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
@@ -317,9 +316,25 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
} }
else if ( bitcoin_base58decode(rmd160,destaddr) != 25 ) else if ( bitcoin_base58decode(rmd160,destaddr) != 25 )
{ {
result.push_back(Pair("result","error")); if ( (len= is_hexstr(destaddr,0)) > 0 )
result.push_back(Pair("error","invalid destaddr")); {
return(result); len >>= 1;
data.resize(len);
decode_hex(&data[0],len,destaddr);
scriptPubKey = CScript() << data << OP_CHECKCRYPTOCONDITION;
}
else
{
result.push_back(Pair("result","error"));
result.push_back(Pair("error","invalid destaddr"));
return(result);
}
}
else
{
data.resize(20);
memcpy(&data[0],&rmd160[1],20);
scriptPubKey = (CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG);
} }
if ( NSPV_inforesult.height == 0 ) if ( NSPV_inforesult.height == 0 )
{ {
@@ -348,7 +363,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
return(result); return(result);
} }
printf("%s numutxos.%d balance %.8f\n",NSPV_utxosresult.coinaddr,NSPV_utxosresult.numutxos,(double)NSPV_utxosresult.total/COIN); printf("%s numutxos.%d balance %.8f\n",NSPV_utxosresult.coinaddr,NSPV_utxosresult.numutxos,(double)NSPV_utxosresult.total/COIN);
std::vector<uint8_t> data; CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0; CScript opret; std::string hex; struct NSPV_utxoresp used[NSPV_MAXVINS]; CMutableTransaction mtx; CTransaction tx; int64_t rewardsum=0,interestsum=0;
mtx.fOverwintered = true; mtx.fOverwintered = true;
mtx.nExpiryHeight = 0; mtx.nExpiryHeight = 0;
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
@@ -356,12 +371,10 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
mtx.nLockTime = (uint32_t)time(NULL) - 777; mtx.nLockTime = (uint32_t)time(NULL) - 777;
memset(used,0,sizeof(used)); memset(used,0,sizeof(used));
data.resize(20);
memcpy(&data[0],&rmd160[1],20);
if ( NSPV_addinputs(used,mtx,satoshis+txfee,64,NSPV_utxosresult.utxos,NSPV_utxosresult.numutxos) > 0 ) if ( NSPV_addinputs(used,mtx,satoshis+txfee,64,NSPV_utxosresult.utxos,NSPV_utxosresult.numutxos) > 0 )
{ {
mtx.vout.push_back(CTxOut(satoshis,CScript() << OP_DUP << OP_HASH160 << ParseHex(HexStr(data)) << OP_EQUALVERIFY << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(satoshis,scriptPubKey));
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
@@ -371,8 +384,11 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
hex = NSPV_signtx(rewardsum,interestsum,retcodes,mtx,txfee,opret,used); hex = NSPV_signtx(rewardsum,interestsum,retcodes,mtx,txfee,opret,used);
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
result.push_back(Pair("rewards",AmountFromValue(interestsum))); char numstr[64];
result.push_back(Pair("validated",AmountFromValue(rewardsum))); sprintf(numstr,"%.8f",(double)interestsum/COIN);
result.push_back(Pair("rewards",numstr));
sprintf(numstr,"%.8f",(double)rewardsum/COIN);
result.push_back(Pair("validated",numstr));
} }
if ( hex.size() > 0 ) if ( hex.size() > 0 )
{ {
@@ -406,4 +422,56 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
} }
} }
int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr)
{
char coinaddr[64]; int32_t CCflag = 0;
if ( ptr != 0 )
{
mtx.fOverwintered = true;
mtx.nExpiryHeight = 0;
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtx.nVersion = SAPLING_TX_VERSION;
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG);
if ( strcmp(ptr->U.coinaddr,coinaddr) != 0 )
{
NSPV_addressutxos(coinaddr,CCflag);
NSPV_utxosresp_purge(&ptr->U);
NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult);
}
fprintf(stderr,"%s numutxos.%d\n",ptr->U.coinaddr,ptr->U.numutxos);
memset(ptr->used,0,sizeof(ptr->used));
return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos));
} else return(0);
}
void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &outputs)
{
CAddressUnspentKey key; CAddressUnspentValue value; int32_t i,type; uint160 hashBytes; std::string addrstr(ptr->coinaddr);
if ( ptr->utxos != NULL && ptr->numutxos > 0 )
{
CBitcoinAddress address(addrstr);
if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 )
{
fprintf(stderr,"couldnt get indexkey\n");
return;
}
for (i = 0; i < ptr->numutxos; i ++)
{
key.type = type;
key.hashBytes = hashBytes;
key.txhash = ptr->utxos[i].txid;
key.index = ptr->utxos[i].vout;
value.satoshis = ptr->utxos[i].satoshis;
value.blockHeight = ptr->utxos[i].height;
outputs.push_back(std::make_pair(key, value));
}
}
}
void NSPV_CCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &outputs,char *coinaddr,bool ccflag)
{
NSPV_addressutxos(coinaddr,ccflag);
NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs);
}
#endif // KOMODO_NSPVWALLET_H #endif // KOMODO_NSPVWALLET_H

View File

@@ -1780,7 +1780,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
//fprintf(stderr,"already in mempool\n"); //fprintf(stderr,"already in mempool\n");
return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); return state.Invalid(false, REJECT_DUPLICATE, "already in mempool");
} }
//fprintf(stderr,"addmempool 0\n");
// Node operator can choose to reject tx by number of transparent inputs // Node operator can choose to reject tx by number of transparent inputs
static_assert(std::numeric_limits<size_t>::max() >= std::numeric_limits<int64_t>::max(), "size_t too small"); static_assert(std::numeric_limits<size_t>::max() >= std::numeric_limits<int64_t>::max(), "size_t too small");
size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0);
@@ -1794,6 +1794,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
return false; return false;
} }
} }
//fprintf(stderr,"addmempool 1\n");
auto verifier = libzcash::ProofVerifier::Strict(); auto verifier = libzcash::ProofVerifier::Strict();
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,chainActive.LastTip()->GetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,chainActive.LastTip()->GetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 )
@@ -1811,7 +1812,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
{ {
return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
} }
// Coinbase is only valid in a block, not as a loose transaction //fprintf(stderr,"addmempool 2\n");
// Coinbase is only valid in a block, not as a loose transaction
if (tx.IsCoinBase()) if (tx.IsCoinBase())
{ {
fprintf(stderr,"AcceptToMemoryPool coinbase as individual tx\n"); fprintf(stderr,"AcceptToMemoryPool coinbase as individual tx\n");
@@ -1833,6 +1835,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
//fprintf(stderr,"AcceptToMemoryPool reject non-final\n"); //fprintf(stderr,"AcceptToMemoryPool reject non-final\n");
return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); return state.DoS(0, false, REJECT_NONSTANDARD, "non-final");
} }
//fprintf(stderr,"addmempool 3\n");
// Check for conflicts with in-memory transactions // Check for conflicts with in-memory transactions
if (!fSkipExpiry) if (!fSkipExpiry)
@@ -1861,6 +1864,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
} }
} }
} }
//fprintf(stderr,"addmempool 4\n");
{ {
CCoinsView dummy; CCoinsView dummy;
@@ -1960,6 +1964,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
} }
} }
} }
//fprintf(stderr,"addmempool 5\n");
// Grab the branch ID we expect this transaction to commit to. We don't // Grab the branch ID we expect this transaction to commit to. We don't
// yet know if it does, but if the entry gets added to the mempool, then // yet know if it does, but if the entry gets added to the mempool, then
@@ -2022,6 +2027,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
LogPrint("mempool", errmsg.c_str()); LogPrint("mempool", errmsg.c_str());
return state.Error("AcceptToMemoryPool: " + errmsg); return state.Error("AcceptToMemoryPool: " + errmsg);
} }
//fprintf(stderr,"addmempool 6\n");
// Check against previous transactions // Check against previous transactions
// This is done last to help prevent CPU exhaustion denial-of-service attacks. // This is done last to help prevent CPU exhaustion denial-of-service attacks.
@@ -2047,6 +2053,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
flag = 1; flag = 1;
KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1; KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1;
} }
//fprintf(stderr,"addmempool 7\n");
if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
{ {
if ( flag != 0 ) if ( flag != 0 )
@@ -2220,6 +2227,18 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock)
{ {
memset(&hashBlock,0,sizeof(hashBlock)); memset(&hashBlock,0,sizeof(hashBlock));
if ( KOMODO_NSPV != 0 )
{
int64_t rewardsum = 0; int32_t i,retval,txheight = 0,vout = 0;
for (i=0; i<NSPV_U.U.numutxos; i++)
if ( NSPV_U.U.utxos[i].txid == hash )
{
txheight = NSPV_U.U.utxos[i].height;
break;
}
retval = NSPV_gettransaction(1,vout,hash,txheight,txOut,0,0,rewardsum);
return(retval != -1);
}
// need a GetTransaction without lock so the validation code for assets can run without deadlock // need a GetTransaction without lock so the validation code for assets can run without deadlock
{ {
//fprintf(stderr,"check mempool %s\n",hash.GetHex().c_str()); //fprintf(stderr,"check mempool %s\n",hash.GetHex().c_str());
@@ -2413,7 +2432,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW)
//uint64_t komodo_moneysupply(int32_t height); //uint64_t komodo_moneysupply(int32_t height);
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS+1];
extern uint32_t ASSETCHAINS_MAGIC; extern uint32_t ASSETCHAINS_MAGIC;
extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY;
extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
@@ -7060,6 +7079,7 @@ void static ProcessGetData(CNode* pfrom)
} }
} }
#include "komodo_nSPV_defs.h"
#include "komodo_nSPV.h" // shared defines, structs, serdes, purge functions #include "komodo_nSPV.h" // shared defines, structs, serdes, purge functions
#include "komodo_nSPV_fullnode.h" // nSPV fullnode handling of the getnSPV request messages #include "komodo_nSPV_fullnode.h" // nSPV fullnode handling of the getnSPV request messages
#include "komodo_nSPV_superlite.h" // nSPV superlite client, issuing requests and handling nSPV responses #include "komodo_nSPV_superlite.h" // nSPV superlite client, issuing requests and handling nSPV responses
@@ -8459,21 +8479,31 @@ extern "C" const char* getDataDir()
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight)
{ {
CMutableTransaction mtx; CMutableTransaction mtx;
if ( KOMODO_NSPV != 0 )
bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); {
if (isOverwintered) {
mtx.fOverwintered = true; mtx.fOverwintered = true;
mtx.nExpiryHeight = nHeight + expiryDelta; mtx.nExpiryHeight = 0;
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) { mtx.nVersion = SAPLING_TX_VERSION;
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; }
mtx.nVersion = SAPLING_TX_VERSION; else
} else { {
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
mtx.nVersion = OVERWINTER_TX_VERSION; if (isOverwintered)
mtx.nExpiryHeight = std::min( {
mtx.nExpiryHeight, mtx.fOverwintered = true;
static_cast<uint32_t>(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1)); mtx.nExpiryHeight = nHeight + expiryDelta;
if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING))
{
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtx.nVersion = SAPLING_TX_VERSION;
}
else
{
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nExpiryHeight = std::min(mtx.nExpiryHeight,static_cast<uint32_t>(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1));
}
} }
} }
return mtx; return mtx;

View File

@@ -665,7 +665,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{ {
static bool didinit = false; static bool didinit = false;
if ( !didinit && nHeight > 100 && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() ) if ( !didinit && nHeight > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
{ {
fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true; didinit = true;

View File

@@ -430,7 +430,7 @@ void CheckBurnTxSource(uint256 burntxid, UniValue &info) {
CTransaction burnTx; CTransaction burnTx;
uint256 blockHash; uint256 blockHash;
if (!GetTransaction(burntxid, burnTx, blockHash, true)) if (!myGetTransaction(burntxid, burnTx, blockHash))
throw std::runtime_error("Cannot find burn transaction"); throw std::runtime_error("Cannot find burn transaction");
if (blockHash.IsNull()) if (blockHash.IsNull())
@@ -854,6 +854,7 @@ UniValue importgatewayinfo(const UniValue& params, bool fHelp)
return(ImportGatewayInfo(txid)); return(ImportGatewayInfo(txid));
} }
UniValue importgatewaybind(const UniValue& params, bool fHelp) UniValue importgatewaybind(const UniValue& params, bool fHelp)
{ {
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
@@ -866,7 +867,7 @@ UniValue importgatewaybind(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 8) if ( fHelp || params.size() != 8)
throw runtime_error("use \'importgatewaybind coin orcletxid M N pubkeys pubtype p2shtype wiftype [taddr]\' to bind an import gateway\n"); throw runtime_error("use \'importgatewaybind coin orcletxid M N pubkeys pubtype p2shtype wiftype [taddr]\' to bind an import gateway\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
CCerror = ""; CCerror = "";
coin = params[0].get_str(); coin = params[0].get_str();
oracletxid = Parseuint256(params[1].get_str().c_str()); oracletxid = Parseuint256(params[1].get_str().c_str());
@@ -919,7 +920,7 @@ UniValue importgatewaydeposit(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 9) if ( fHelp || params.size() != 9)
throw runtime_error("use \'importgatewaydeposit bindtxid height coin burntxid nvout rawburntx rawproof destpub amount\' to import deposited coins\n"); throw runtime_error("use \'importgatewaydeposit bindtxid height coin burntxid nvout rawburntx rawproof destpub amount\' to import deposited coins\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
CCerror = ""; CCerror = "";
bindtxid = Parseuint256(params[0].get_str().c_str()); bindtxid = Parseuint256(params[0].get_str().c_str());
height = atoi(params[1].get_str().c_str()); height = atoi(params[1].get_str().c_str());
@@ -962,7 +963,7 @@ UniValue importgatewaywithdraw(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 4) if ( fHelp || params.size() != 4)
throw runtime_error("use \'importgatewaywithdraw bindtxid coin withdrawpub amount\' to burn imported coins and withdraw them on external chain\n"); throw runtime_error("use \'importgatewaywithdraw bindtxid coin withdrawpub amount\' to burn imported coins and withdraw them on external chain\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
CCerror = ""; CCerror = "";
bindtxid = Parseuint256(params[0].get_str().c_str()); bindtxid = Parseuint256(params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
@@ -997,7 +998,7 @@ UniValue importgatewaypartialsign(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("importgatewayspartialsign txidaddr refcoin hex\n"); throw runtime_error("importgatewayspartialsign txidaddr refcoin hex\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
parthex = params[2].get_str(); parthex = params[2].get_str();
@@ -1020,7 +1021,7 @@ UniValue importgatewaycompletesigning(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("importgatewaycompletesigning withdrawtxid coin hex\n"); throw runtime_error("importgatewaycompletesigning withdrawtxid coin hex\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); withdrawtxid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
txhex = params[2].get_str(); txhex = params[2].get_str();
@@ -1040,7 +1041,7 @@ UniValue importgatewaymarkdone(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("importgatewaymarkdone completesigningtx coin\n"); throw runtime_error("importgatewaymarkdone completesigningtx coin\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
completetxid = Parseuint256((char *)params[0].get_str().c_str()); completetxid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
hex = ImportGatewayMarkDone(0,completetxid,coin); hex = ImportGatewayMarkDone(0,completetxid,coin);
@@ -1059,7 +1060,7 @@ UniValue importgatewaypendingdeposits(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("importgatewaypendingdeposits bindtxid coin\n"); throw runtime_error("importgatewaypendingdeposits bindtxid coin\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
return(ImportGatewayPendingDeposits(bindtxid,coin)); return(ImportGatewayPendingDeposits(bindtxid,coin));
@@ -1071,7 +1072,7 @@ UniValue importgatewaypendingwithdraws(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("importgatewaypendingwithdraws bindtxid coin\n"); throw runtime_error("importgatewaypendingwithdraws bindtxid coin\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
return(ImportGatewayPendingWithdraws(bindtxid,coin)); return(ImportGatewayPendingWithdraws(bindtxid,coin));
@@ -1083,7 +1084,7 @@ UniValue importgatewayprocessed(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("importgatewayprocessed bindtxid coin\n"); throw runtime_error("importgatewayprocessed bindtxid coin\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
coin = params[1].get_str(); coin = params[1].get_str();
return(ImportGatewayProcessedWithdraws(bindtxid,coin)); return(ImportGatewayProcessedWithdraws(bindtxid,coin));
@@ -1096,7 +1097,7 @@ UniValue importgatewayexternaladdress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2) if ( fHelp || params.size() != 2)
throw runtime_error("importgatewayexternaladdress bindtxid pubkey\n"); throw runtime_error("importgatewayexternaladdress bindtxid pubkey\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
pubkey = ParseHex(params[1].get_str().c_str()); pubkey = ParseHex(params[1].get_str().c_str());
return(ImportGatewayExternalAddress(bindtxid,pubkey)); return(ImportGatewayExternalAddress(bindtxid,pubkey));
@@ -1109,7 +1110,7 @@ UniValue importgatewaydumpprivkey(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2) if ( fHelp || params.size() != 2)
throw runtime_error("importgatewaydumpprivkey bindtxid address\n"); throw runtime_error("importgatewaydumpprivkey bindtxid address\n");
if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 ) if ( ensure_CCrequirements(EVAL_IMPORTGATEWAY) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
std::string strAddress = params[1].get_str(); std::string strAddress = params[1].get_str();
CTxDestination dest = DecodeDestination(strAddress); CTxDestination dest = DecodeDestination(strAddress);
@@ -1156,7 +1157,7 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp)
{ {
UniValue item(UniValue::VOBJ); UniValue notaryarr(UniValue::VARR); std::vector<int8_t> NotarisationNotaries; UniValue item(UniValue::VOBJ); UniValue notaryarr(UniValue::VARR); std::vector<int8_t> NotarisationNotaries;
uint256 hash; CTransaction tx; uint256 hash; CTransaction tx;
if ( GetTransaction(n.first,tx,hash,false) ) if ( myGetTransaction(n.first,tx,hash) )
{ {
if ( is_STAKED(n.second.symbol) != 0 ) if ( is_STAKED(n.second.symbol) != 0 )
{ {

View File

@@ -222,11 +222,11 @@ UniValue getinfo(const UniValue& params, bool fHelp)
+ HelpExampleCli("getinfo", "") + HelpExampleCli("getinfo", "")
+ HelpExampleRpc("getinfo", "") + HelpExampleRpc("getinfo", "")
); );
//#ifdef ENABLE_WALLET //#ifdef ENABLE_WALLET
// LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
//#else //#else
LOCK(cs_main); LOCK(cs_main);
//#endif //#endif
proxyType proxy; proxyType proxy;
GetProxy(NET_IPV4, proxy); GetProxy(NET_IPV4, proxy);
@@ -243,50 +243,54 @@ UniValue getinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("prevMoMheight", prevMoMheight)); obj.push_back(Pair("prevMoMheight", prevMoMheight));
obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedhash", notarized_hash.ToString()));
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); if ( KOMODO_NSPV == 0 )
if ( txid_height > 0 ) {
obj.push_back(Pair("notarizedtxid_height", txid_height)); txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height);
else obj.push_back(Pair("notarizedtxid_height", "mempool")); if ( txid_height > 0 )
if ( ASSETCHAINS_SYMBOL[0] != 0 ) obj.push_back(Pair("notarizedtxid_height", txid_height));
obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); else obj.push_back(Pair("notarizedtxid_height", "mempool"));
obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); if ( ASSETCHAINS_SYMBOL[0] != 0 )
//fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height));
obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0));
//fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL));
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (pwalletMain) { if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM)));
obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance()
}
else
{
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); //
}
} }
else
{
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); //
}
}
#endif #endif
//fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL));
obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("blocks", (int)chainActive.Height()));
if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain )
longestchain = chainActive.Height(); longestchain = chainActive.Height();
//fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL));
obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("longestchain", longestchain));
if ( chainActive.LastTip() != 0 )
obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
}
if (pwalletMain && pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif
obj.push_back(Pair("sapling", ASSETCHAINS_SAPLING));
}
obj.push_back(Pair("timeoffset", GetTimeOffset())); obj.push_back(Pair("timeoffset", GetTimeOffset()));
if ( chainActive.LastTip() != 0 )
obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime));
obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
}
if (pwalletMain && pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("errors", GetWarnings("statusbar")));
if ( NOTARY_PUBKEY33[0] != 0 ) { if ( NOTARY_PUBKEY33[0] != 0 ) {
@@ -304,7 +308,6 @@ UniValue getinfo(const UniValue& params, bool fHelp)
if ( ASSETCHAINS_CC != 0 ) if ( ASSETCHAINS_CC != 0 )
obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC));
obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL));
obj.push_back(Pair("sapling", ASSETCHAINS_SAPLING));
obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT));
obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT));

View File

@@ -61,7 +61,7 @@ UniValue test_ac(const UniValue& params, bool fHelp)
if (fHelp || (params.size() != 4)) if (fHelp || (params.size() != 4))
throw runtime_error("incorrect params\n"); throw runtime_error("incorrect params\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0) if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
std::vector<unsigned char> pubkey1; std::vector<unsigned char> pubkey1;
std::vector<unsigned char> pubkey2; std::vector<unsigned char> pubkey2;
@@ -106,7 +106,7 @@ UniValue test_heirmarker(const UniValue& params, bool fHelp)
if (fHelp || (params.size() != 1)) if (fHelp || (params.size() != 1))
throw runtime_error("incorrect params\n"); throw runtime_error("incorrect params\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0) if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
uint256 fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); uint256 fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -137,7 +137,7 @@ UniValue test_burntx(const UniValue& params, bool fHelp)
if (fHelp || (params.size() != 1)) if (fHelp || (params.size() != 1))
throw runtime_error("incorrect params\n"); throw runtime_error("incorrect params\n");
if (ensure_CCrequirements(EVAL_TOKENS) < 0) if (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"); throw runtime_error(CC_REQUIREMENTS_MSG);
uint256 tokenid = Parseuint256((char *)params[0].get_str().c_str()); uint256 tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -230,7 +230,7 @@ UniValue test_pricesmarker(const UniValue& params, bool fHelp)
if (fHelp || (params.size() != 1)) if (fHelp || (params.size() != 1))
throw runtime_error("incorrect params\n"); throw runtime_error("incorrect params\n");
if (ensure_CCrequirements(EVAL_PRICES) < 0) if (ensure_CCrequirements(EVAL_PRICES) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
uint256 bettxid = Parseuint256((char *)params[0].get_str().c_str()); uint256 bettxid = Parseuint256((char *)params[0].get_str().c_str());

View File

@@ -385,7 +385,9 @@ bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript, std::vector<std::vec
bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript) const bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript) const
{ {
std::vector<std::vector<unsigned char>> vParams; std::vector<std::vector<unsigned char>> vParams;
return IsPayToCryptoCondition(pCCSubScript, vParams); if ( pCCSubScript != 0 )
return IsPayToCryptoCondition(pCCSubScript, vParams);
else return(false);
} }
bool CScript::IsPayToCryptoCondition() const bool CScript::IsPayToCryptoCondition() const

View File

@@ -35,6 +35,8 @@ using namespace std;
typedef vector<unsigned char> valtype; typedef vector<unsigned char> valtype;
extern uint8_t ASSETCHAINS_TXPOW; extern uint8_t ASSETCHAINS_TXPOW;
extern char NSPV_wifstr[],NSPV_pubkeystr[];
extern int32_t KOMODO_NSPV;
uint256 SIG_TXHASH; uint256 SIG_TXHASH;
TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {} TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
@@ -45,21 +47,35 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
try { try {
hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, consensusBranchId); hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, consensusBranchId);
} catch (logic_error ex) { } catch (logic_error ex) {
{
fprintf(stderr,"logic error\n");
return false; return false;
}
} }
SIG_TXHASH = hash; SIG_TXHASH = hash;
if (pprivKey) if ( KOMODO_NSPV != 0 )
key = DecodeSecret(NSPV_wifstr);
else if (pprivKey)
key = *pprivKey; key = *pprivKey;
else if (!keystore || !keystore->GetKey(address, key)) else if (!keystore || !keystore->GetKey(address, key))
{
fprintf(stderr,"keystore.%p error\n",keystore);
return false; return false;
}
//fprintf(stderr,"privkey (%s) for %s\n",NSPV_wifstr,EncodeDestination(key.GetPubKey().GetID()).c_str());
if (scriptCode.IsPayToCryptoCondition()) if (scriptCode.IsPayToCryptoCondition())
{ {
CC *cc = (CC *)extraData; CC *cc = (CC *)extraData;
// assume either 1of1 or 1of2. if the condition created by the // assume either 1of1 or 1of2. if the condition created by the
if (!cc || cc_signTreeSecp256k1Msg32(cc, key.begin(), hash.begin()) == 0) if (!cc || cc_signTreeSecp256k1Msg32(cc, key.begin(), hash.begin()) == 0)
{
fprintf(stderr,"CC tree error\n");
return false; return false;
}
vchSig = CCSigVec(cc); vchSig = CCSigVec(cc);
if ( KOMODO_NSPV != 0 )
memset((uint8_t *)key.begin(),0,32);
return true; return true;
} }
else else
@@ -67,7 +83,14 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
if ( ASSETCHAINS_TXPOW == 0 ) if ( ASSETCHAINS_TXPOW == 0 )
{ {
if (!key.Sign(hash, vchSig)) if (!key.Sign(hash, vchSig))
{
fprintf(stderr,"key.Sign error\n");
return false; return false;
}
else
{
//fprintf(stderr,"signed success %s\n",(char *)HexStr(vchSig).c_str());
}
} }
else else
{ {
@@ -77,7 +100,8 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
} }
vchSig.push_back((unsigned char)nHashType); vchSig.push_back((unsigned char)nHashType);
if ( KOMODO_NSPV != 0 )
memset((uint8_t *)key.begin(),0,32);
return true; return true;
} }
@@ -85,7 +109,10 @@ static bool Sign1(const CKeyID& address, const BaseSignatureCreator& creator, co
{ {
vector<unsigned char> vchSig; vector<unsigned char> vchSig;
if (!creator.CreateSig(vchSig, address, scriptCode, consensusBranchId)) if (!creator.CreateSig(vchSig, address, scriptCode, consensusBranchId))
{
fprintf(stderr,"Sign1 creatsig error\n");
return false; return false;
}
ret.push_back(vchSig); ret.push_back(vchSig);
return true; return true;
} }
@@ -337,7 +364,6 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
} }
CKeyID keyID; CKeyID keyID;
switch (whichTypeRet) switch (whichTypeRet)
{ {
case TX_NONSTANDARD: case TX_NONSTANDARD:
@@ -349,12 +375,18 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
case TX_PUBKEYHASH: case TX_PUBKEYHASH:
keyID = CKeyID(uint160(vSolutions[0])); keyID = CKeyID(uint160(vSolutions[0]));
if (!Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId)) if (!Sign1(keyID, creator, scriptPubKey, ret, consensusBranchId))
{
fprintf(stderr,"sign1 error\n");
return false; return false;
}
else else
{ {
CPubKey vch; if ( KOMODO_NSPV == 0 )
creator.KeyStore().GetPubKey(keyID, vch); {
ret.push_back(ToByteVector(vch)); CPubKey vch;
creator.KeyStore().GetPubKey(keyID, vch);
ret.push_back(ToByteVector(vch));
} else ret.push_back(ParseHex(NSPV_pubkeystr));
} }
return true; return true;
case TX_SCRIPTHASH: case TX_SCRIPTHASH:
@@ -411,7 +443,6 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu
} }
sigdata.scriptSig = PushAll(result); sigdata.scriptSig = PushAll(result);
// Test solution // Test solution
return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId); return solved && VerifyScript(sigdata.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker(), consensusBranchId);
} }

View File

@@ -5544,7 +5544,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("channelsaddress pubkey\n"); throw runtime_error("channelsaddress pubkey\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Channels",pubkey)); return(CCaddress(cp,(char *)"Channels",pubkey));
} }
@@ -5555,7 +5555,7 @@ UniValue cclibaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 2 ) if ( fHelp || params.size() > 2 )
throw runtime_error("cclibaddress [evalcode] [pubkey]\n"); throw runtime_error("cclibaddress [evalcode] [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() >= 1 ) if ( params.size() >= 1 )
{ {
evalcode = atoi(params[0].get_str().c_str()); evalcode = atoi(params[0].get_str().c_str());
@@ -5576,7 +5576,7 @@ UniValue cclibinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("cclibinfo\n"); throw runtime_error("cclibinfo\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
cp = CCinit(&C,evalcode); cp = CCinit(&C,evalcode);
return(CClib_info(cp)); return(CClib_info(cp));
} }
@@ -5591,7 +5591,7 @@ UniValue cclib(const UniValue& params, bool fHelp)
if ( ASSETCHAINS_CCLIB.size() == 0 ) if ( ASSETCHAINS_CCLIB.size() == 0 )
throw runtime_error("no -ac_cclib= specified\n"); throw runtime_error("no -ac_cclib= specified\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
method = (char *)params[0].get_str().c_str(); method = (char *)params[0].get_str().c_str();
@@ -5624,7 +5624,7 @@ UniValue payments_release(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentsrelease \"[%22createtxid%22,amount,(skipminimum)]\"\n"); throw runtime_error("paymentsrelease \"[%22createtxid%22,amount,(skipminimum)]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5637,7 +5637,7 @@ UniValue payments_fund(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentsfund \"[%22createtxid%22,amount(,useopret)]\"\n"); throw runtime_error("paymentsfund \"[%22createtxid%22,amount(,useopret)]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5650,7 +5650,7 @@ UniValue payments_merge(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentsmerge \"[%22createtxid%22]\"\n"); throw runtime_error("paymentsmerge \"[%22createtxid%22]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5663,7 +5663,7 @@ UniValue payments_txidopret(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentstxidopret \"[allocation,%22scriptPubKey%22(,%22destopret%22)]\"\n"); throw runtime_error("paymentstxidopret \"[allocation,%22scriptPubKey%22(,%22destopret%22)]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5676,7 +5676,7 @@ UniValue payments_create(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentscreate \"[lockedblocks,minamount,%22paytxid0%22,...,%22paytxidN%22]\"\n"); throw runtime_error("paymentscreate \"[lockedblocks,minamount,%22paytxid0%22,...,%22paytxidN%22]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5689,7 +5689,7 @@ UniValue payments_airdrop(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentsairdrop \"[lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludeAddress%22,...,%22excludeAddressN%22]\"\n"); throw runtime_error("paymentsairdrop \"[lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludeAddress%22,...,%22excludeAddressN%22]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5702,7 +5702,7 @@ UniValue payments_airdroptokens(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("payments_airdroptokens \"[%22tokenid%22,lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludePubKey%22,...,%22excludePubKeyN%22]\"\n"); throw runtime_error("payments_airdroptokens \"[%22tokenid%22,lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludePubKey%22,...,%22excludePubKeyN%22]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5715,7 +5715,7 @@ UniValue payments_info(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("paymentsinfo \"[%22createtxid%22]\"\n"); throw runtime_error("paymentsinfo \"[%22createtxid%22]\"\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5728,7 +5728,7 @@ UniValue payments_list(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 0 ) if ( fHelp || params.size() != 0 )
throw runtime_error("paymentslist\n"); throw runtime_error("paymentslist\n");
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 ) if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
@@ -5742,7 +5742,7 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("oraclesaddress [pubkey]\n"); throw runtime_error("oraclesaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Oracles",pubkey)); return(CCaddress(cp,(char *)"Oracles",pubkey));
@@ -5756,7 +5756,7 @@ UniValue pricesaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("pricesaddress [pubkey]\n"); throw runtime_error("pricesaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
result = CCaddress(cp,(char *)"Prices",pubkey); result = CCaddress(cp,(char *)"Prices",pubkey);
@@ -5778,7 +5778,7 @@ UniValue pegsaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("pegssaddress [pubkey]\n"); throw runtime_error("pegssaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Pegs",pubkey)); return(CCaddress(cp,(char *)"Pegs",pubkey));
@@ -5791,7 +5791,7 @@ UniValue marmaraaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("Marmaraaddress [pubkey]\n"); throw runtime_error("Marmaraaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Marmara",pubkey)); return(CCaddress(cp,(char *)"Marmara",pubkey));
@@ -5804,7 +5804,7 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("paymentsaddress [pubkey]\n"); throw runtime_error("paymentsaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Payments",pubkey)); return(CCaddress(cp,(char *)"Payments",pubkey));
@@ -5817,7 +5817,7 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("gatewaysaddress [pubkey]\n"); throw runtime_error("gatewaysaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Gateways",pubkey)); return(CCaddress(cp,(char *)"Gateways",pubkey));
@@ -5830,7 +5830,7 @@ UniValue heiraddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("heiraddress pubkey\n"); throw runtime_error("heiraddress pubkey\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Heir",pubkey)); return(CCaddress(cp,(char *)"Heir",pubkey));
} }
@@ -5842,7 +5842,7 @@ UniValue lottoaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("lottoaddress [pubkey]\n"); throw runtime_error("lottoaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Lotto",pubkey)); return(CCaddress(cp,(char *)"Lotto",pubkey));
@@ -5855,7 +5855,7 @@ UniValue FSMaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("FSMaddress [pubkey]\n"); throw runtime_error("FSMaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"FSM",pubkey)); return(CCaddress(cp,(char *)"FSM",pubkey));
@@ -5868,7 +5868,7 @@ UniValue auctionaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("auctionaddress [pubkey]\n"); throw runtime_error("auctionaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Auction",pubkey)); return(CCaddress(cp,(char *)"Auction",pubkey));
@@ -5881,7 +5881,7 @@ UniValue diceaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("diceaddress [pubkey]\n"); throw runtime_error("diceaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Dice",pubkey)); return(CCaddress(cp,(char *)"Dice",pubkey));
@@ -5909,7 +5909,7 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("rewardsaddress [pubkey]\n"); throw runtime_error("rewardsaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Rewards",pubkey)); return(CCaddress(cp,(char *)"Rewards",pubkey));
@@ -5922,7 +5922,7 @@ UniValue assetsaddress(const UniValue& params, bool fHelp)
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
throw runtime_error("assetsaddress [pubkey]\n"); throw runtime_error("assetsaddress [pubkey]\n");
if (ensure_CCrequirements(0) < 0) if (ensure_CCrequirements(0) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if (params.size() == 1) if (params.size() == 1)
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp, (char *)"Assets", pubkey)); return(CCaddress(cp, (char *)"Assets", pubkey));
@@ -5935,7 +5935,7 @@ UniValue tokenaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("tokenaddress [pubkey]\n"); throw runtime_error("tokenaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Tokens", pubkey)); return(CCaddress(cp,(char *)"Tokens", pubkey));
@@ -5948,7 +5948,7 @@ UniValue importgatewayaddress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("importgatewayddress [pubkey]\n"); throw runtime_error("importgatewayddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(0) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"ImportGateway", pubkey)); return(CCaddress(cp,(char *)"ImportGateway", pubkey));
@@ -5964,7 +5964,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp)
throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
perc = atof(params[0].get_str().c_str()) / 100.; perc = atof(params[0].get_str().c_str()) / 100.;
@@ -5984,7 +5984,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp)
throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n"); throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
memset(&batontxid,0,sizeof(batontxid)); memset(&batontxid,0,sizeof(batontxid));
@@ -6015,7 +6015,7 @@ UniValue marmara_issue(const UniValue& params, bool fHelp)
throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n"); throw runtime_error("marmaraissue receiverpk amount currency matures approvaltxid\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
receiverpub = ParseHex(params[0].get_str().c_str()); receiverpub = ParseHex(params[0].get_str().c_str());
@@ -6040,7 +6040,7 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp)
throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n"); throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
receiverpub = ParseHex(params[0].get_str().c_str()); receiverpub = ParseHex(params[0].get_str().c_str());
if (receiverpub.size()!= 33) if (receiverpub.size()!= 33)
{ {
@@ -6066,7 +6066,7 @@ UniValue marmara_info(const UniValue& params, bool fHelp)
throw runtime_error("marmarainfo firstheight lastheight minamount maxamount [currency issuerpk]\n"); throw runtime_error("marmarainfo firstheight lastheight minamount maxamount [currency issuerpk]\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
firstheight = atol(params[0].get_str().c_str()); firstheight = atol(params[0].get_str().c_str());
@@ -6098,7 +6098,7 @@ UniValue marmara_creditloop(const UniValue& params, bool fHelp)
throw runtime_error("marmaracreditloop txid\n"); throw runtime_error("marmaracreditloop txid\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6116,7 +6116,7 @@ UniValue marmara_settlement(const UniValue& params, bool fHelp)
throw runtime_error("marmarasettlement batontxid\n"); throw runtime_error("marmarasettlement batontxid\n");
} }
if ( ensure_CCrequirements(EVAL_MARMARA) < 0 ) if ( ensure_CCrequirements(EVAL_MARMARA) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
batontxid = Parseuint256((char *)params[0].get_str().c_str()); batontxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6145,7 +6145,7 @@ UniValue channelslist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("channelsinfo\n"); throw runtime_error("channelsinfo\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
return(ChannelsList()); return(ChannelsList());
@@ -6157,7 +6157,7 @@ UniValue channelsinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("channelsinfo [opentxid]\n"); throw runtime_error("channelsinfo [opentxid]\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
opentxid=zeroid; opentxid=zeroid;
@@ -6175,7 +6175,7 @@ UniValue channelsopen(const UniValue& params, bool fHelp)
if ( fHelp || params.size() < 3 || params.size() > 4) if ( fHelp || params.size() < 3 || params.size() > 4)
throw runtime_error("channelsopen destpubkey numpayments payment\n"); throw runtime_error("channelsopen destpubkey numpayments payment\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
destpub = ParseHex(params[0].get_str().c_str()); destpub = ParseHex(params[0].get_str().c_str());
@@ -6217,7 +6217,7 @@ UniValue channelspayment(const UniValue& params, bool fHelp)
if ( fHelp || params.size() < 2 || params.size() >3 ) if ( fHelp || params.size() < 2 || params.size() >3 )
throw runtime_error("channelspayment opentxid amount [secret]\n"); throw runtime_error("channelspayment opentxid amount [secret]\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
opentxid = Parseuint256((char *)params[0].get_str().c_str()); opentxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6248,7 +6248,7 @@ UniValue channelsclose(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("channelsclose opentxid\n"); throw runtime_error("channelsclose opentxid\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
opentxid = Parseuint256((char *)params[0].get_str().c_str()); opentxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6269,7 +6269,7 @@ UniValue channelsrefund(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("channelsrefund opentxid closetxid\n"); throw runtime_error("channelsrefund opentxid closetxid\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 ) if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
opentxid = Parseuint256((char *)params[0].get_str().c_str()); opentxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6290,7 +6290,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 6 || params.size() < 2 ) if ( fHelp || params.size() > 6 || params.size() < 2 )
throw runtime_error("rewardscreatefunding name amount APR mindays maxdays mindeposit\n"); throw runtime_error("rewardscreatefunding name amount APR mindays maxdays mindeposit\n");
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
// default to OOT params // default to OOT params
@@ -6359,7 +6359,7 @@ UniValue rewardslock(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("rewardslock name fundingtxid amount\n"); throw runtime_error("rewardslock name fundingtxid amount\n");
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -6389,7 +6389,7 @@ UniValue rewardsaddfunding(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("rewardsaddfunding name fundingtxid amount\n"); throw runtime_error("rewardsaddfunding name fundingtxid amount\n");
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -6424,7 +6424,7 @@ UniValue rewardsunlock(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 3 || params.size() < 2 ) if ( fHelp || params.size() > 3 || params.size() < 2 )
throw runtime_error("rewardsunlock name fundingtxid [txid]\n"); throw runtime_error("rewardsunlock name fundingtxid [txid]\n");
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -6452,7 +6452,7 @@ UniValue rewardslist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("rewardslist\n"); throw runtime_error("rewardslist\n");
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
return(RewardsList()); return(RewardsList());
@@ -6464,7 +6464,7 @@ UniValue rewardsinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("rewardsinfo fundingtxid\n"); throw runtime_error("rewardsinfo fundingtxid\n");
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 ) if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6476,7 +6476,7 @@ UniValue gatewayslist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("gatewayslist\n"); throw runtime_error("gatewayslist\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
return(GatewaysList()); return(GatewaysList());
@@ -6489,7 +6489,7 @@ UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2) if ( fHelp || params.size() != 2)
throw runtime_error("gatewaysexternaladdress bindtxid pubkey\n"); throw runtime_error("gatewaysexternaladdress bindtxid pubkey\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6504,7 +6504,7 @@ UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2) if ( fHelp || params.size() != 2)
throw runtime_error("gatewaysdumpprivkey bindtxid address\n"); throw runtime_error("gatewaysdumpprivkey bindtxid address\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
std::string strAddress = params[1].get_str(); std::string strAddress = params[1].get_str();
@@ -6529,7 +6529,7 @@ UniValue gatewaysinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("gatewaysinfo bindtxid\n"); throw runtime_error("gatewaysinfo bindtxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6544,7 +6544,7 @@ UniValue gatewaysbind(const UniValue& params, bool fHelp)
if ( fHelp || params.size() < 10 ) if ( fHelp || params.size() < 10 )
throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n"); throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6584,7 +6584,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 9 ) if ( fHelp || params.size() != 9 )
throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount\n"); throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6617,7 +6617,7 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 5 ) if ( fHelp || params.size() != 5 )
throw runtime_error("gatewaysclaim bindtxid coin deposittxid destpub amount\n"); throw runtime_error("gatewaysclaim bindtxid coin deposittxid destpub amount\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6643,7 +6643,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 4 ) if ( fHelp || params.size() != 4 )
throw runtime_error("gatewayswithdraw bindtxid coin withdrawpub amount\n"); throw runtime_error("gatewayswithdraw bindtxid coin withdrawpub amount\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6668,7 +6668,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("gatewayspartialsign txidaddr refcoin hex\n"); throw runtime_error("gatewayspartialsign txidaddr refcoin hex\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6690,7 +6690,7 @@ UniValue gatewayscompletesigning(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("gatewayscompletesigning withdrawtxid coin hex\n"); throw runtime_error("gatewayscompletesigning withdrawtxid coin hex\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); withdrawtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6712,7 +6712,7 @@ UniValue gatewaysmarkdone(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("gatewaysmarkdone completesigningtx coin\n"); throw runtime_error("gatewaysmarkdone completesigningtx coin\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
completetxid = Parseuint256((char *)params[0].get_str().c_str()); completetxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6733,7 +6733,7 @@ UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("gatewayspendingdeposits bindtxid coin\n"); throw runtime_error("gatewayspendingdeposits bindtxid coin\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6747,7 +6747,7 @@ UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("gatewayspendingwithdraws bindtxid coin\n"); throw runtime_error("gatewayspendingwithdraws bindtxid coin\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6761,7 +6761,7 @@ UniValue gatewaysprocessed(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("gatewaysprocessed bindtxid coin\n"); throw runtime_error("gatewaysprocessed bindtxid coin\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); bindtxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6774,7 +6774,7 @@ UniValue oracleslist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("oracleslist\n"); throw runtime_error("oracleslist\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
return(OraclesList()); return(OraclesList());
@@ -6786,7 +6786,7 @@ UniValue oraclesinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("oraclesinfo oracletxid\n"); throw runtime_error("oraclesinfo oracletxid\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6799,7 +6799,7 @@ UniValue oraclesfund(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("oraclesfund oracletxid\n"); throw runtime_error("oraclesfund oracletxid\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6819,7 +6819,7 @@ UniValue oraclesregister(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("oraclesregister oracletxid datafee\n"); throw runtime_error("oraclesregister oracletxid datafee\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6841,7 +6841,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("oraclessubscribe oracletxid publisher amount\n"); throw runtime_error("oraclessubscribe oracletxid publisher amount\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6863,7 +6863,7 @@ UniValue oraclessample(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("oraclessample oracletxid txid\n"); throw runtime_error("oraclessample oracletxid txid\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
oracletxid = Parseuint256((char *)params[0].get_str().c_str()); oracletxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6877,7 +6877,7 @@ UniValue oraclessamples(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("oraclessamples oracletxid batonaddress num\n"); throw runtime_error("oraclessamples oracletxid batonaddress num\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6892,7 +6892,7 @@ UniValue oraclesdata(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("oraclesdata oracletxid hexstr\n"); throw runtime_error("oraclesdata oracletxid hexstr\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
@@ -6913,7 +6913,7 @@ UniValue oraclescreate(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("oraclescreate name description format\n"); throw runtime_error("oraclescreate name description format\n");
if ( ensure_CCrequirements(EVAL_ORACLES) < 0 ) if ( ensure_CCrequirements(EVAL_ORACLES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = params[0].get_str(); name = params[0].get_str();
@@ -6950,7 +6950,7 @@ UniValue FSMcreate(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("FSMcreate name states\n"); throw runtime_error("FSMcreate name states\n");
if ( ensure_CCrequirements(EVAL_FSM) < 0 ) if ( ensure_CCrequirements(EVAL_FSM) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = params[0].get_str(); name = params[0].get_str();
@@ -6970,7 +6970,7 @@ UniValue FSMlist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("FSMlist\n"); throw runtime_error("FSMlist\n");
if ( ensure_CCrequirements(EVAL_FSM) < 0 ) if ( ensure_CCrequirements(EVAL_FSM) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
return(FSMList()); return(FSMList());
} }
@@ -6980,7 +6980,7 @@ UniValue FSMinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("FSMinfo fundingtxid\n"); throw runtime_error("FSMinfo fundingtxid\n");
if ( ensure_CCrequirements(EVAL_FSM) < 0 ) if ( ensure_CCrequirements(EVAL_FSM) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
FSMtxid = Parseuint256((char *)params[0].get_str().c_str()); FSMtxid = Parseuint256((char *)params[0].get_str().c_str());
return(FSMInfo(FSMtxid)); return(FSMInfo(FSMtxid));
} }
@@ -6991,7 +6991,7 @@ UniValue faucetinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 0 ) if ( fHelp || params.size() != 0 )
throw runtime_error("faucetinfo\n"); throw runtime_error("faucetinfo\n");
if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) if ( ensure_CCrequirements(EVAL_FAUCET) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
return(FaucetInfo()); return(FaucetInfo());
} }
@@ -7000,11 +7000,19 @@ UniValue faucetfund(const UniValue& params, bool fHelp)
UniValue result(UniValue::VOBJ); int64_t funds; std::string hex; UniValue result(UniValue::VOBJ); int64_t funds; std::string hex;
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("faucetfund amount\n"); throw runtime_error("faucetfund amount\n");
funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999;
if ( (0) && KOMODO_NSPV != 0 )
{
char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v;
cp = CCinit(&C,EVAL_FAUCET);
v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0));
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG);
return(NSPV_spend(coinaddr,(char *)HexStr(v.scriptPubKey.begin()+1,v.scriptPubKey.end()-1).c_str(),funds));
}
if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) if ( ensure_CCrequirements(EVAL_FAUCET) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999;
if (funds > 0) { if (funds > 0) {
hex = FaucetFund(0,(uint64_t) funds); hex = FaucetFund(0,(uint64_t) funds);
if ( hex.size() > 0 ) if ( hex.size() > 0 )
@@ -7022,7 +7030,7 @@ UniValue faucetget(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("faucetget\n"); throw runtime_error("faucetget\n");
if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) if ( ensure_CCrequirements(EVAL_FAUCET) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
hex = FaucetGet(0); hex = FaucetGet(0);
@@ -7051,7 +7059,7 @@ UniValue priceslist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 0 && params.size() != 1) if ( fHelp || params.size() != 0 && params.size() != 1)
throw runtime_error("priceslist [all|open|closed]\n"); throw runtime_error("priceslist [all|open|closed]\n");
if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) if ( ensure_CCrequirements(EVAL_PRICES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
uint32_t filter = 0; uint32_t filter = 0;
if (params.size() == 1) if (params.size() == 1)
filter = pricesGetParam(params[0]); filter = pricesGetParam(params[0]);
@@ -7066,7 +7074,7 @@ UniValue mypriceslist(const UniValue& params, bool fHelp)
if (fHelp || params.size() != 0 && params.size() != 1) if (fHelp || params.size() != 0 && params.size() != 1)
throw runtime_error("mypriceslist [all|open|closed]\n"); throw runtime_error("mypriceslist [all|open|closed]\n");
if (ensure_CCrequirements(EVAL_PRICES) < 0) if (ensure_CCrequirements(EVAL_PRICES) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
uint32_t filter = 0; uint32_t filter = 0;
if (params.size() == 1) if (params.size() == 1)
@@ -7082,7 +7090,7 @@ UniValue pricesinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 && params.size() != 2) if ( fHelp || params.size() != 1 && params.size() != 2)
throw runtime_error("pricesinfo bettxid [height]\n"); throw runtime_error("pricesinfo bettxid [height]\n");
if ( ensure_CCrequirements(EVAL_PRICES) < 0 ) if ( ensure_CCrequirements(EVAL_PRICES) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
bettxid = Parseuint256((char *)params[0].get_str().c_str()); bettxid = Parseuint256((char *)params[0].get_str().c_str());
height = 0; height = 0;
if (params.size() == 2) if (params.size() == 2)
@@ -7096,7 +7104,7 @@ UniValue dicefund(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 6 ) if ( fHelp || params.size() != 6 )
throw runtime_error("dicefund name funds minbet maxbet maxodds timeoutblocks\n"); throw runtime_error("dicefund name funds minbet maxbet maxodds timeoutblocks\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -7129,7 +7137,7 @@ UniValue diceaddfunds(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("diceaddfunds name fundingtxid amount\n"); throw runtime_error("diceaddfunds name fundingtxid amount\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -7157,7 +7165,7 @@ UniValue dicebet(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 4 ) if ( fHelp || params.size() != 4 )
throw runtime_error("dicebet name fundingtxid amount odds\n"); throw runtime_error("dicebet name fundingtxid amount odds\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -7189,7 +7197,7 @@ UniValue dicefinish(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("dicefinish name fundingtxid bettxid\n"); throw runtime_error("dicefinish name fundingtxid bettxid\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -7224,7 +7232,7 @@ UniValue dicestatus(const UniValue& params, bool fHelp)
if ( fHelp || (params.size() != 2 && params.size() != 3) ) if ( fHelp || (params.size() != 2 && params.size() != 3) )
throw runtime_error("dicestatus name fundingtxid bettxid\n"); throw runtime_error("dicestatus name fundingtxid bettxid\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str(); name = (char *)params[0].get_str().c_str();
@@ -7272,7 +7280,7 @@ UniValue dicelist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("dicelist\n"); throw runtime_error("dicelist\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
return(DiceList()); return(DiceList());
} }
@@ -7282,7 +7290,7 @@ UniValue diceinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("diceinfo fundingtxid\n"); throw runtime_error("diceinfo fundingtxid\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 ) if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
return(DiceInfo(fundingtxid)); return(DiceInfo(fundingtxid));
} }
@@ -7293,7 +7301,7 @@ UniValue tokenlist(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 0 ) if ( fHelp || params.size() > 0 )
throw runtime_error("tokenlist\n"); throw runtime_error("tokenlist\n");
if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) if ( 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
return(TokenList()); return(TokenList());
} }
@@ -7303,7 +7311,7 @@ UniValue tokeninfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("tokeninfo tokenid\n"); throw runtime_error("tokeninfo tokenid\n");
if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) if ( 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -7316,7 +7324,7 @@ UniValue tokenorders(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("tokenorders tokenid\n"); throw runtime_error("tokenorders tokenid\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
if (params.size() == 1) { if (params.size() == 1) {
@@ -7338,7 +7346,7 @@ UniValue mytokenorders(const UniValue& params, bool fHelp)
if (fHelp || params.size() > 2) if (fHelp || params.size() > 2)
throw runtime_error("mytokenorders [evalcode]\n"); throw runtime_error("mytokenorders [evalcode]\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -7357,7 +7365,7 @@ UniValue tokenbalance(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 2 ) if ( fHelp || params.size() > 2 )
throw runtime_error("tokenbalance tokenid [pubkey]\n"); throw runtime_error("tokenbalance tokenid [pubkey]\n");
if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) if ( 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
LOCK(cs_main); LOCK(cs_main);
@@ -7399,7 +7407,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 4 || params.size() < 2 ) if ( fHelp || params.size() > 4 || params.size() < 2 )
throw runtime_error("tokencreate name supply [description][data]\n"); throw runtime_error("tokencreate name supply [description][data]\n");
if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) if ( 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -7459,7 +7467,7 @@ UniValue tokentransfer(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3) if ( fHelp || params.size() != 3)
throw runtime_error("tokentransfer tokenid destpubkey amount\n"); throw runtime_error("tokentransfer tokenid destpubkey amount\n");
if ( ensure_CCrequirements(EVAL_TOKENS) < 0 ) if ( 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -7495,7 +7503,7 @@ UniValue tokenconvert(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 4 ) if ( fHelp || params.size() != 4 )
throw runtime_error("tokenconvert evalcode tokenid pubkey amount\n"); throw runtime_error("tokenconvert evalcode tokenid pubkey amount\n");
if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) if ( ensure_CCrequirements(EVAL_ASSETS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
evalcode = atoi(params[0].get_str().c_str()); evalcode = atoi(params[0].get_str().c_str());
@@ -7536,7 +7544,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("tokenbid numtokens tokenid price\n"); throw runtime_error("tokenbid numtokens tokenid price\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
//numtokens = atoi(params[0].get_str().c_str()); //numtokens = atoi(params[0].get_str().c_str());
@@ -7578,7 +7586,7 @@ UniValue tokencancelbid(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("tokencancelbid tokenid bidtxid\n"); throw runtime_error("tokencancelbid tokenid bidtxid\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -7603,7 +7611,7 @@ UniValue tokenfillbid(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("tokenfillbid tokenid bidtxid fillamount\n"); throw runtime_error("tokenfillbid tokenid bidtxid fillamount\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -7635,7 +7643,7 @@ UniValue tokenask(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("tokenask numtokens tokenid price\n"); throw runtime_error("tokenask numtokens tokenid price\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
//numtokens = atoi(params[0].get_str().c_str()); //numtokens = atoi(params[0].get_str().c_str());
@@ -7669,7 +7677,7 @@ UniValue tokenswapask(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 4 ) if ( fHelp || params.size() != 4 )
throw runtime_error("tokenswapask numtokens tokenid otherid price\n"); throw runtime_error("tokenswapask numtokens tokenid otherid price\n");
if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) if ( ensure_CCrequirements(EVAL_ASSETS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
//numtokens = atoi(params[0].get_str().c_str()); //numtokens = atoi(params[0].get_str().c_str());
@@ -7697,7 +7705,7 @@ UniValue tokencancelask(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("tokencancelask tokenid asktxid\n"); throw runtime_error("tokencancelask tokenid asktxid\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -7722,7 +7730,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 3 ) if ( fHelp || params.size() != 3 )
throw runtime_error("tokenfillask tokenid asktxid fillunits\n"); throw runtime_error("tokenfillask tokenid asktxid fillunits\n");
if (ensure_CCrequirements(EVAL_ASSETS) < 0 || ensure_CCrequirements(EVAL_TOKENS) < 0) 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"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -7762,7 +7770,7 @@ UniValue tokenfillswap(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 4 ) if ( fHelp || params.size() != 4 )
throw runtime_error("tokenfillswap tokenid otherid asktxid fillunits\n"); throw runtime_error("tokenfillswap tokenid otherid asktxid fillunits\n");
if ( ensure_CCrequirements(EVAL_ASSETS) < 0 ) if ( ensure_CCrequirements(EVAL_ASSETS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
tokenid = Parseuint256((char *)params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[0].get_str().c_str());
@@ -7843,7 +7851,7 @@ UniValue heirfund(const UniValue& params, bool fHelp)
if (fHelp || params.size() != 6 && params.size() != 7) if (fHelp || params.size() != 6 && params.size() != 7)
throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n"); throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0) if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -7917,7 +7925,7 @@ UniValue heiradd(const UniValue& params, bool fHelp)
if (fHelp || params.size() != 3) if (fHelp || params.size() != 3)
throw runtime_error("heiradd txfee funds fundingtxid\n"); throw runtime_error("heiradd txfee funds fundingtxid\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0) if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -7951,7 +7959,7 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
if (fHelp || params.size() != 3) if (fHelp || params.size() != 3)
throw runtime_error("heirclaim txfee funds fundingtxid\n"); throw runtime_error("heirclaim txfee funds fundingtxid\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0) if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -7976,7 +7984,7 @@ UniValue heirinfo(const UniValue& params, bool fHelp)
throw runtime_error("heirinfo fundingtxid\n"); throw runtime_error("heirinfo fundingtxid\n");
// if ( ensure_CCrequirements(EVAL_HEIR) < 0 ) // if ( ensure_CCrequirements(EVAL_HEIR) < 0 )
// throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); // throw runtime_error(CC_REQUIREMENTS_MSG);
fundingtxid = Parseuint256((char*)params[0].get_str().c_str()); fundingtxid = Parseuint256((char*)params[0].get_str().c_str());
return (HeirInfo(fundingtxid)); return (HeirInfo(fundingtxid));
@@ -7988,7 +7996,7 @@ UniValue heirlist(const UniValue& params, bool fHelp)
throw runtime_error("heirlist\n"); throw runtime_error("heirlist\n");
// if ( ensure_CCrequirements(EVAL_HEIR) < 0 ) // if ( ensure_CCrequirements(EVAL_HEIR) < 0 )
// throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); // throw runtime_error(CC_REQUIREMENTS_MSG);
return (HeirList()); return (HeirList());
} }
@@ -8001,7 +8009,7 @@ UniValue pegscreate(const UniValue& params, bool fHelp)
if ( fHelp || params.size()<3) if ( fHelp || params.size()<3)
throw runtime_error("pegscreate amount N bindtxid1 [bindtxid2 ...]\n"); throw runtime_error("pegscreate amount N bindtxid1 [bindtxid2 ...]\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) if ( ensure_CCrequirements(EVAL_PEGS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
amount = atof((char *)params[0].get_str().c_str()) * COIN + 0.00000000499999; amount = atof((char *)params[0].get_str().c_str()) * COIN + 0.00000000499999;
@@ -8031,7 +8039,7 @@ UniValue pegsfund(const UniValue& params, bool fHelp)
if ( fHelp || params.size()!=3) if ( fHelp || params.size()!=3)
throw runtime_error("pegsfund pegstxid tokenid amount\n"); throw runtime_error("pegsfund pegstxid tokenid amount\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) if ( ensure_CCrequirements(EVAL_PEGS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256(params[0].get_str().c_str()); pegstxid = Parseuint256(params[0].get_str().c_str());
@@ -8054,7 +8062,7 @@ UniValue pegsget(const UniValue& params, bool fHelp)
if ( fHelp || params.size()!=3) if ( fHelp || params.size()!=3)
throw runtime_error("pegsget pegstxid tokenid amount\n"); throw runtime_error("pegsget pegstxid tokenid amount\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) if ( ensure_CCrequirements(EVAL_PEGS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256(params[0].get_str().c_str()); pegstxid = Parseuint256(params[0].get_str().c_str());
@@ -8077,7 +8085,7 @@ UniValue pegsredeem(const UniValue& params, bool fHelp)
if ( fHelp || params.size()!=2) if ( fHelp || params.size()!=2)
throw runtime_error("pegsredem pegstxid tokenid\n"); throw runtime_error("pegsredem pegstxid tokenid\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) if ( ensure_CCrequirements(EVAL_PEGS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256(params[0].get_str().c_str()); pegstxid = Parseuint256(params[0].get_str().c_str());
@@ -8099,7 +8107,7 @@ UniValue pegsliquidate(const UniValue& params, bool fHelp)
if ( fHelp || params.size()!=3) if ( fHelp || params.size()!=3)
throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n"); throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) if ( ensure_CCrequirements(EVAL_PEGS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256(params[0].get_str().c_str()); pegstxid = Parseuint256(params[0].get_str().c_str());
@@ -8122,7 +8130,7 @@ UniValue pegsexchange(const UniValue& params, bool fHelp)
if ( fHelp || params.size()!=3) if ( fHelp || params.size()!=3)
throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n"); throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) if ( ensure_CCrequirements(EVAL_PEGS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256(params[0].get_str().c_str()); pegstxid = Parseuint256(params[0].get_str().c_str());
@@ -8145,7 +8153,7 @@ UniValue pegsaccounthistory(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("pegsaccounthistory pegstxid\n"); throw runtime_error("pegsaccounthistory pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); pegstxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -8159,7 +8167,7 @@ UniValue pegsaccountinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("pegsaccountinfo pegstxid\n"); throw runtime_error("pegsaccountinfo pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); pegstxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -8173,7 +8181,7 @@ UniValue pegsworstaccounts(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("pegsworstaccounts pegstxid\n"); throw runtime_error("pegsworstaccounts pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); pegstxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -8187,7 +8195,7 @@ UniValue pegsinfo(const UniValue& params, bool fHelp)
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("pegsinfo pegstxid\n"); throw runtime_error("pegsinfo pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain; const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); pegstxid = Parseuint256((char *)params[0].get_str().c_str());
@@ -8296,7 +8304,7 @@ UniValue opreturn_burn(const UniValue& params, bool fHelp)
throw runtime_error("amount to burn, hexstring to send\n"); throw runtime_error("amount to burn, hexstring to send\n");
struct CCcontract_info *cp, C; UniValue ret(UniValue::VOBJ); struct CCcontract_info *cp, C; UniValue ret(UniValue::VOBJ);
if (ensure_CCrequirements(EVAL_ORACLES) < 0) if (ensure_CCrequirements(EVAL_ORACLES) < 0)
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); throw runtime_error(CC_REQUIREMENTS_MSG);
cp = CCinit(&C, EVAL_ORACLES); cp = CCinit(&C, EVAL_ORACLES);
CAmount nAmount = AmountFromValue(params[0]); CAmount nAmount = AmountFromValue(params[0]);