test
This commit is contained in:
@@ -454,6 +454,7 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
|
||||
}
|
||||
|
||||
extern uint8_t NOTARY_PUBKEY33[33];
|
||||
uint32_t Mining_start;
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||
|
||||
void static BitcoinMiner(CWallet *pwallet)
|
||||
@@ -503,7 +504,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
//
|
||||
// Create new block
|
||||
//
|
||||
uint32_t starttime = (uint32_t)time(NULL);
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
|
||||
@@ -527,8 +528,9 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
if ( komodo_chosennotary(¬aryid,pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 )
|
||||
{
|
||||
hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS);
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
//fprintf(stderr,"I am the chosen one for ht.%d\n",pindexPrev->nHeight+1);
|
||||
}
|
||||
} else Mining_start = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -565,8 +567,11 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
if (UintToArith256(pblock->GetHash()) > hashTarget) {
|
||||
return false;
|
||||
}
|
||||
/* if ( pblock->nBits == KOMODO_MINDIFF_NBITS && time(NULL) < starttime+50 )
|
||||
sleep(starttime+50-time(NULL));*/
|
||||
if ( Mining_start != 0 && time(NULL) < Mining_start+50 )
|
||||
{
|
||||
printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+50-time(NULL)));
|
||||
sleep(Mining_start+50-time(NULL));
|
||||
}
|
||||
|
||||
// Found a solution
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
|
||||
@@ -399,7 +399,9 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "wallet", "z_exportkey", &z_exportkey, true },
|
||||
{ "wallet", "z_importkey", &z_importkey, true },
|
||||
{ "wallet", "z_exportwallet", &z_exportwallet, true },
|
||||
{ "wallet", "z_importwallet", &z_importwallet, true }
|
||||
{ "wallet", "z_importwallet", &z_importwallet, true },
|
||||
|
||||
{ "wallet", "paxdeposit", &paxdeposit, true }
|
||||
#endif // ENABLE_WALLET
|
||||
};
|
||||
|
||||
|
||||
@@ -245,6 +245,7 @@ extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool
|
||||
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxprice(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxprices(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxdeposit(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value verifychain(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value getchaintips(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value invalidateblock(const json_spirit::Array& params, bool fHelp);
|
||||
|
||||
@@ -452,6 +452,35 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
||||
return wtx.GetHash().GetHex();
|
||||
}
|
||||
|
||||
uint64_t PAX_fiatdest(char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *base,int32_t fiatunits)
|
||||
|
||||
Value paxdeposit(const Array& params, bool fHelp)
|
||||
{
|
||||
uint64_t komodoshis = 0; char destaddr[64]; uint8_t pubkey33[33];
|
||||
bool fSubtractFeeFromAmount = false;
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return Value::null;
|
||||
if (fHelp || params.size() != 3)
|
||||
throw runtime_error("paxdeposit \"bitcoinaddress\" fiatunits \"base\" \n");
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
CBitcoinAddress address(params[0].get_str());
|
||||
if (!address.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
|
||||
int32_t fiatunits = AmountFromValue(params[1]);
|
||||
std:string dest,base = params[2].get_str();
|
||||
komodoshis = PAX_fiatdest(destaddr,pubkey33,(char *)params[0].get_str().c_str(),chainActive.Tip()->nHeight,(char *)base.c_str(),fiatunits);
|
||||
dest.copy(destaddr);
|
||||
CBitcoinAddress destaddress(dest);
|
||||
if (!destaddress.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address");
|
||||
printf("ht.%d srcaddr.(%s) %s fiatunits.%d -> dest.(%s) komodoshis.%llu\n",chainActive.Tip()->nHeight,(char *)params[0].get_str().c_str(),(char *)base.c_str(),fiatunits,destaddr,(long long)komodoshis);
|
||||
|
||||
EnsureWalletIsUnlocked();
|
||||
CWalletTx wtx;
|
||||
SendMoney(destaddress.Get(), komodoshis, fSubtractFeeFromAmount, wtx);
|
||||
return wtx.GetHash().GetHex();
|
||||
}
|
||||
|
||||
Value listaddressgroupings(const Array& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
|
||||
Reference in New Issue
Block a user