Test
This commit is contained in:
@@ -121,6 +121,7 @@ int32_t komodo_baseid(char *origbase);
|
|||||||
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
|
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
|
||||||
uint64_t komodo_commission(const CBlock *block);
|
uint64_t komodo_commission(const CBlock *block);
|
||||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig);
|
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig);
|
||||||
|
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33);
|
||||||
|
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||||
{
|
{
|
||||||
@@ -478,12 +479,19 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
}
|
}
|
||||||
pblock->nSolution.clear();
|
pblock->nSolution.clear();
|
||||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
pblock->nTime = pindexPrev->nTime + 65;
|
CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
||||||
//while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 )
|
if ( pblock->nTime < pindexPrev->nTime+60 )
|
||||||
// sleep(1);
|
pblock->nTime = pindexPrev->nTime + 65;
|
||||||
//fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60));
|
if ( (siglen= komodo_notaryvin(txNotary,NOTARY_PUBKEY33)) > 0 )
|
||||||
|
{
|
||||||
|
CAmount txfees = 0;
|
||||||
|
pblock->vtx.push_back(txNotary);
|
||||||
|
pblocktemplate->vTxFees.push_back(txfees);
|
||||||
|
pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary));
|
||||||
|
nFees += txfees;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4465,6 +4465,74 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
|||||||
extern std::string NOTARY_PUBKEY;
|
extern std::string NOTARY_PUBKEY;
|
||||||
uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 hash,int32_t n,uint32_t blocktime,uint32_t prevtime,char *destaddr);
|
uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 hash,int32_t n,uint32_t blocktime,uint32_t prevtime,char *destaddr);
|
||||||
|
|
||||||
|
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33)
|
||||||
|
{
|
||||||
|
set<CBitcoinAddress> setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector<COutput> vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow;
|
||||||
|
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||||
|
assert(pwalletMain != NULL);
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
utxovalue = 0;
|
||||||
|
memset(&utxotxid,0,sizeof(utxotxid));
|
||||||
|
memset(&utxovout,0,sizeof(utxovout));
|
||||||
|
memset(utxosig,0,sizeof(utxosig));
|
||||||
|
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
||||||
|
BOOST_FOREACH(const COutput& out, vecOutputs)
|
||||||
|
{
|
||||||
|
if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth )
|
||||||
|
continue;
|
||||||
|
if ( setAddress.size() )
|
||||||
|
{
|
||||||
|
CTxDestination address;
|
||||||
|
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
||||||
|
continue;
|
||||||
|
if (!setAddress.count(address))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||||
|
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
|
||||||
|
CTxDestination address;
|
||||||
|
if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
||||||
|
{
|
||||||
|
//entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
|
||||||
|
//if (pwalletMain->mapAddressBook.count(address))
|
||||||
|
// entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name));
|
||||||
|
}
|
||||||
|
script = (uint8_t *)out.tx->vout[out.i].scriptPubKey.data();
|
||||||
|
if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 )
|
||||||
|
continue;
|
||||||
|
utxovalue = (uint64_t)nValue;
|
||||||
|
decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str());
|
||||||
|
utxovout = out.i;
|
||||||
|
|
||||||
|
bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid;
|
||||||
|
auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());
|
||||||
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
|
txNew.vin.resize(1);
|
||||||
|
txNew.vout.resize(1);
|
||||||
|
txfee = 0;
|
||||||
|
for (i=0; i<32; i++)
|
||||||
|
((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i];
|
||||||
|
txNew.vin[0].prevout.hash = revtxid;
|
||||||
|
txNew.vin[0].prevout.n = utxovout;
|
||||||
|
txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
||||||
|
txNew.vout[0].nValue = utxovalue - txfee;
|
||||||
|
CTransaction txNewConst(txNew);
|
||||||
|
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId);
|
||||||
|
if (!signSuccess)
|
||||||
|
fprintf(stderr,"notaryvin failed to create signature\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateTransaction(txNew,0,sigdata);
|
||||||
|
ptr = (uint8_t *)sigdata.scriptSig.data();
|
||||||
|
siglen = sigdata.scriptSig.size();
|
||||||
|
for (i=0; i<siglen; i++)
|
||||||
|
utxosig[i] = ptr[i], fprintf(stderr,"%02x",ptr[i]);
|
||||||
|
fprintf(stderr," siglen.%d notaryvin\n",siglen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(siglen);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
||||||
{
|
{
|
||||||
set<CBitcoinAddress> setAddress; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector<COutput> vecOutputs; uint32_t eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow;
|
set<CBitcoinAddress> setAddress; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector<COutput> vecOutputs; uint32_t eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow;
|
||||||
|
|||||||
Reference in New Issue
Block a user