This commit is contained in:
blackjok3r
2019-05-06 12:08:53 +08:00
parent c7ab203920
commit 0f6fe03990
4 changed files with 18 additions and 16 deletions

View File

@@ -63,7 +63,8 @@ int32_t has_opret(const CTransaction &tx, uint8_t evalcode)
int i = 0;
for ( auto vout : tx.vout )
{
if ( vout.scriptPubKey[0] == OP_RETURN && vout.scriptPubKey[1] == evalcode )
//fprintf(stderr, "[txid.%s] 1.%i 2.%i 3.%i 4.%i\n",tx.GetHash().GetHex().c_str(), vout.scriptPubKey[0], vout.scriptPubKey[1], vout.scriptPubKey[2], vout.scriptPubKey[3]);
if ( vout.scriptPubKey[0] == OP_RETURN && vout.scriptPubKey[2] == evalcode )
return i;
i++;
}

View File

@@ -303,7 +303,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
pub2createtxid(temp);
createtxid = Parseuint256(temp);
}
//printf("createtxid.%s\n",createtxid.ToString().c_str());
printf("createtxid.%s\n",createtxid.ToString().c_str());
// use the createtxid to fetch the tx and all of the plans info.
if ( myGetTransaction(createtxid,plantx,blockhash) != 0 && plantx.vout.size() > 0 )
@@ -501,7 +501,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
{
mergeoffset = PAYMENTS_MERGEOFSET;
}
fprintf(stderr, "mergeoffset.%i\n", mergeoffset);
//fprintf(stderr, "mergeoffset.%i\n", mergeoffset);
// check the chain depth vs locked blocks requirement.
if ( !payments_lockedblocks(blockhash, lockedblocks+mergeoffset, blocksleft) )
return(eval->Invalid("vin not elegible"));
@@ -576,16 +576,16 @@ int64_t AddPaymentsInputs(bool fLockedBlocks,int8_t GetBalance,struct CCcontract
if ( (nValue= IsPaymentsvout(cp,vintx,vout,coinaddr,ccopret)) > PAYMENTS_TXFEE && nValue >= threshold && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{
int32_t tmpblocksleft = 0;
if ( (GetBalance == 0 && total != 0 && maxinputs != 0) || GetBalance == 4 )
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
nValue = it->second.satoshis;
if ( nValue < COIN )
blocksleft++; // count dust with unused variable.
if ( fLockedBlocks && !payments_lockedblocks(hashBlock, lockedblocks+(GetBalance == 4 ? PAYMENTS_MERGEOFSET : 0), tmpblocksleft) )
{
blocksleft_balance.push_back(std::make_pair(tmpblocksleft,nValue));
continue;
}
if ( (GetBalance == 0 && total != 0 && maxinputs != 0) || GetBalance == 4 )
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
nValue = it->second.satoshis;
if ( nValue < COIN )
blocksleft++; // count dust with unused variable.
totalinputs += nValue;
n++;
//fprintf(stderr,"iter.%d %s/v%d %s %.8f\n",iter,txid.GetHex().c_str(),vout,coinaddr,(double)nValue/COIN);
@@ -1021,24 +1021,25 @@ UniValue PaymentsMerge(struct CCcontract_info *cp,char *jsonstr)
else if ( (inputsum= AddPaymentsInputs(true,4,cp,mtx,txidpk,0,CC_MAXVINS,createtxid,lockedblocks,minrelease,blocksleft)) > 0 && mtx.vin.size() > 1 )
{
int32_t dust = blocksleft;
if ( mtx.vin.size() != dust+1 )
if ( mtx.vin.size() == dust+1 )
{
result.push_back(Pair("result","error"));
result.push_back(Pair("error","cannot merge only dust"));
}
else
{
{
// encode the checktxid into the end of the ccvout, along with 'M' to flag merge type tx.
opret = EncodePaymentsMergeOpRet(createtxid);
std::vector<std::vector<unsigned char>> vData = std::vector<std::vector<unsigned char>>();
if ( makeCCopret(opret, vData) )
mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,inputsum-PAYMENTS_TXFEE,Paymentspk,&vData));
mtx.vout.push_back(MakeCC1of2vout(EVAL_PAYMENTS,inputsum-PAYMENTS_TXFEE,Paymentspk,txidpk,&vData));
//mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,inputsum-PAYMENTS_TXFEE,txidpk,&vData));
GetCCaddress1of2(cp,destaddr,Paymentspk,txidpk);
CCaddr1of2set(cp,Paymentspk,txidpk,cp->CCpriv,destaddr);
rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,CScript());
if ( params != 0 )
free_json(params);
return(payments_rawtxresult(result,rawtx,1));
return(payments_rawtxresult(result,rawtx,0));
}
}
else

View File

@@ -38,7 +38,7 @@ static const int SPROUT_VALUE_VERSION = 1001400;
static const int SAPLING_VALUE_VERSION = 1010100;
extern int32_t ASSETCHAINS_LWMAPOS;
extern char ASSETCHAINS_SYMBOL[65];
//extern uint64_t ASSETCHAINS_NOTARY_PAY;
extern uint64_t ASSETCHAINS_NOTARY_PAY[];
struct CDiskBlockPos
{
@@ -547,7 +547,7 @@ public:
if ((s.GetType() & SER_DISK) && (nVersion >= SAPLING_VALUE_VERSION)) {
READWRITE(nSaplingValue);
}
if ( (s.GetType() & SER_DISK) && (is_STAKED(ASSETCHAINS_SYMBOL) != 0) )
if ( (s.GetType() & SER_DISK) && (is_STAKED(ASSETCHAINS_SYMBOL) != 0) && ASSETCHAINS_NOTARY_PAY[0] != 0 )
{
READWRITE(nNotaryPay);
READWRITE(segid);

View File

@@ -1,7 +1,7 @@
#ifndef KOMODO_NK_H
#define KOMODO_NK_H
#define ASSETCHAINS_N 77
#define ASSETCHAINS_K 3
#define ASSETCHAINS_N 96
#define ASSETCHAINS_K 5
#endif