@@ -48,7 +48,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
int32_t i,flag,utxovout,n,err = 0;
|
int32_t i,flag,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, *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;
|
||||||
CPubKey unspendablepk /*, tokensunspendablepk*/;
|
CPubKey unspendablepk /*, tokensunspendablepk*/;
|
||||||
struct CCcontract_info *cpTokens, tokensC;
|
struct CCcontract_info *cpTokens, tokensC;
|
||||||
globalpk = GetUnspendable(cp,0);
|
globalpk = GetUnspendable(cp,0);
|
||||||
@@ -75,7 +75,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
othercond = MakeCCcond1(cp->evalcode, unspendablepk);
|
othercond = MakeCCcond1(cp->evalcode, unspendablepk);
|
||||||
GetCCaddress1of2(cp,CC1of2CCaddr,unspendablepk,unspendablepk);
|
GetCCaddress1of2(cp,CC1of2CCaddr,unspendablepk,unspendablepk);
|
||||||
|
|
||||||
//printf("evalcode.%d (%s)\n",cp->evalcode,unspendable);
|
//fprintf(stderr,"evalcode.%d (%s)\n",cp->evalcode,unspendable);
|
||||||
|
|
||||||
// tokens support:
|
// tokens support:
|
||||||
// to spend from dual/three-eval mypk vout
|
// to spend from dual/three-eval mypk vout
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
|
|||||||
nValue = it->second.satoshis;
|
nValue = it->second.satoshis;
|
||||||
totalinputs += nValue;
|
totalinputs += nValue;
|
||||||
n++;
|
n++;
|
||||||
|
//fprintf(stderr,"iter.%d %s/v%d %s %.8f\n",iter,txid.GetHex().c_str(),vout,coinaddr,(double)nValue/COIN);
|
||||||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) )
|
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) )
|
||||||
break;
|
break;
|
||||||
} //else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN);
|
} //else fprintf(stderr,"nValue %.8f vs threshold %.8f\n",(double)nValue/COIN,(double)threshold/COIN);
|
||||||
@@ -263,7 +264,7 @@ cJSON *payments_reparse(int32_t *nump,char *jsonstr)
|
|||||||
}
|
}
|
||||||
newstr[j] = 0;
|
newstr[j] = 0;
|
||||||
params = cJSON_Parse(newstr);
|
params = cJSON_Parse(newstr);
|
||||||
if ( 1 && params != 0 )
|
if ( 0 && params != 0 )
|
||||||
printf("new.(%s) -> %s\n",newstr,jprint(params,0));
|
printf("new.(%s) -> %s\n",newstr,jprint(params,0));
|
||||||
free(newstr);
|
free(newstr);
|
||||||
*nump = cJSON_GetArraySize(params);
|
*nump = cJSON_GetArraySize(params);
|
||||||
@@ -294,8 +295,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
{
|
{
|
||||||
int32_t latestheight,nextheight = komodo_nextheight();
|
int32_t latestheight,nextheight = komodo_nextheight();
|
||||||
CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock;
|
CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); uint256 createtxid,hashBlock;
|
||||||
CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector<uint256> txidoprets; std::string rawtx;
|
CTransaction tx,txO; CPubKey mypk,txidpk,Paymentspk; int32_t i,n,m,numoprets=0,lockedblocks,minrelease,totalallocations,checkallocations=0,allocation; int64_t inputsum,amount,CCchange=0; CTxOut vout; CScript onlyopret; char txidaddr[64],destaddr[64]; std::vector<uint256> txidoprets;
|
||||||
fprintf(stderr,"jsonstr.(%s)\n",jsonstr);
|
|
||||||
cJSON *params = payments_reparse(&n,jsonstr);
|
cJSON *params = payments_reparse(&n,jsonstr);
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
Paymentspk = GetUnspendable(cp,0);
|
Paymentspk = GetUnspendable(cp,0);
|
||||||
@@ -324,7 +324,8 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
}
|
}
|
||||||
txidpk = CCtxidaddr(txidaddr,createtxid);
|
txidpk = CCtxidaddr(txidaddr,createtxid);
|
||||||
mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,0,Paymentspk,txidpk));
|
mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,0,Paymentspk,txidpk));
|
||||||
for (i=0; i<txidoprets.size(); i++)
|
m = txidoprets.size();
|
||||||
|
for (i=0; i<m; i++)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> scriptPubKey,opret;
|
std::vector<uint8_t> scriptPubKey,opret;
|
||||||
vout.nValue = 0;
|
vout.nValue = 0;
|
||||||
@@ -343,7 +344,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
} else break;
|
} else break;
|
||||||
mtx.vout.push_back(vout);
|
mtx.vout.push_back(vout);
|
||||||
}
|
}
|
||||||
if ( i != txidoprets.size() )
|
if ( i != m )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("result","error"));
|
result.push_back(Pair("result","error"));
|
||||||
result.push_back(Pair("error","invalid txidoprets[i]"));
|
result.push_back(Pair("error","invalid txidoprets[i]"));
|
||||||
@@ -371,14 +372,14 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
|
|||||||
free_json(params);
|
free_json(params);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
for (i=0; i<txidoprets.size(); i++)
|
for (i=0; i<m; i++)
|
||||||
{
|
{
|
||||||
mtx.vout[i+1].nValue *= amount;
|
mtx.vout[i+1].nValue *= amount;
|
||||||
mtx.vout[i+1].nValue /= totalallocations;
|
mtx.vout[i+1].nValue /= totalallocations;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"addinputs %.8f\n",(double)amount/COIN);
|
|
||||||
if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount )
|
if ( (inputsum= AddPaymentsInputs(cp,mtx,txidpk,amount+PAYMENTS_TXFEE,60,createtxid,latestheight)) >= amount )
|
||||||
{
|
{
|
||||||
|
std::string rawtx;
|
||||||
if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE )
|
if ( (CCchange= (inputsum - amount)) >= PAYMENTS_TXFEE )
|
||||||
mtx.vout[0].nValue = CCchange;
|
mtx.vout[0].nValue = CCchange;
|
||||||
mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG));
|
mtx.vout.push_back(CTxOut(0,CScript() << ParseHex(HexStr(txidpk)) << OP_CHECKSIG));
|
||||||
|
|||||||
Reference in New Issue
Block a user