Browse Source

test

pull/4/head
jl777 8 years ago
parent
commit
aa114a6095
  1. 9
      src/komodo.h
  2. 35
      src/komodo_gateway.h
  3. 3
      src/komodo_pax.h
  4. 4
      src/komodo_structs.h
  5. 11
      src/komodo_utils.h
  6. 2
      src/miner.cpp
  7. 5
      src/rpcblockchain.cpp
  8. 3
      src/wallet/rpcwallet.cpp

9
src/komodo.h

@ -17,13 +17,14 @@
#define H_KOMODO_H
// Todo:
// 1. net balance limiter, wait for notarized
// 2. verify: reorgs
// verify: reorgs
// non komodod (non-hardfork) todo:
// a. automate notarization fee payouts
// b. automated distribution of test REVS snapshot
#define KOMODO_ASSETCHAINS_WAITNOTARIZE
#include <stdint.h>
#include <stdio.h>
#include <pthread.h>
@ -512,7 +513,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
numvalid = bitweight(signedmask);
if ( height == 79633 )
notarized = 1;
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries>>1)) )
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) )
{
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
notarized = 1;
@ -563,7 +564,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
}
}
if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1) )
if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) )
{
memset(&txhash,0,sizeof(txhash));
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0);

35
src/komodo_gateway.h

@ -15,9 +15,10 @@
// paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse
int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base)
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base)
{
int32_t baseid; struct komodo_state *sp;
int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed;
*available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0;
if ( (baseid= komodo_baseid(base)) >= 0 )
{
if ( (sp= komodo_stateptrget(base)) != 0 )
@ -27,7 +28,11 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,
*withdrawn = sp->withdrawn;
*approved = sp->approved;
*redeemed = sp->redeemed;
printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed));
netliability = (sp->deposited - sp->withdrawn) - sp->shorted;
maxallowed = komodo_maxallowed(baseid);
if ( netliability < maxallowed )
*available = (maxallowed - netliability);
//printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed));
return(0);
} else printf("pax_fiatstatus cant get basesp.%s\n",base);
} else printf("pax_fiatstatus illegal base.%s\n",base);
@ -360,9 +365,17 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
HASH_ITER(hh,PAX,pax,tmp)
{
//printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
if ( strcmp(symbol,"KMD") == 0 && (pax->approved == 0 || pax->validated == 0) )
if ( strcmp(symbol,"KMD") == 0 && pax->approved == 0 )
continue;
if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 )
else if ( strcmp(symbol,"KMD") != 0 )
{
#ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE
struct komodo_state *kmdsp = komodo_stateptrget("KMD");
if ( kmdsp != 0 && kmdsp->notarized_height >= pax->height ) // assumes same chain as notarize
pax->validated = kmdsp->notarized_height;
#endif
}
if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 )
continue;
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
@ -629,6 +642,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],'A',kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]);
komodo_paxmark(height,txids[i],vouts[i],'W',height);
komodo_paxmark(height,txids[i],vouts[i],'A',height);
if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 )
{
basesp->approved += srcvalues[i];
@ -674,9 +689,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
}
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0);
if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 )
{
}
komodo_paxmark(height,txids[i],vouts[i],'D',height);
komodo_paxmark(height,txids[i],vouts[i],'I',height);
if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 )
{
pax->type = opretbuf[0];
@ -696,8 +710,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
continue;
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0);
if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 )
;
komodo_paxmark(height,txids[i],vouts[i],'W',height);
komodo_paxmark(height,txids[i],vouts[i],'A',height);
komodo_paxmark(height,txids[i],vouts[i],'X',height);
if ( (pax= komodo_paxfind(txids[i],vouts[i],'X')) != 0 )
{
pax->type = opretbuf[0];

3
src/komodo_pax.h

@ -309,7 +309,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba
{
if ( relid == MAX_CURRENCIES )
{
kmdbtc = pvals[MAX_CURRENCIES];
if ( (kmdbtc= pvals[MAX_CURRENCIES]) < 25000 )
kmdbtc = 25000;
btcusd = pvals[MAX_CURRENCIES + 1];
if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 )
{

4
src/komodo_structs.h

@ -23,7 +23,7 @@
#endif*/
#define GENESIS_NBITS 0x1f00ffff
#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 13)
#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 11)
#define KOMODO_MAXBLOCKS 5000000
#define KOMODO_EVENT_RATIFY 'P'
@ -71,7 +71,7 @@ struct komodo_state
uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID;
int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT;
uint32_t SAVEDTIMESTAMP;
uint64_t deposited,issued,withdrawn,approved,redeemed;
uint64_t deposited,issued,withdrawn,approved,redeemed,shorted;
struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS;
struct komodo_event **Komodo_events; int32_t Komodo_numevents;
uint32_t RTbufs[64][3]; uint64_t RTmask;

11
src/komodo_utils.h

@ -785,6 +785,17 @@ char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD",
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"KMD" };
uint64_t komodo_maxallowed(int32_t baseid)
{
uint64_t mult,val = (uint64_t)10000 * COIN;
if ( baseid < 0 || baseid >= 32 )
return(0);
if ( baseid < 10 )
val *= 10;
mult = MINDENOMS[baseid] / MIND;
return(mult * val);
}
int32_t komodo_baseid(char *origbase)
{
int32_t i; char base[64];

2
src/miner.cpp

@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
}
#define ASSETCHAINS_MINHEIGHT 100
#define ROUNDROBIN_DELAY 60
#define ROUNDROBIN_DELAY 59
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE;
extern char ASSETCHAINS_SYMBOL[16];
extern std::string NOTARY_PUBKEY;

5
src/rpcblockchain.cpp

@ -481,12 +481,12 @@ Value notaries(const Array& params, bool fHelp)
}
int32_t komodo_pending_withdraws(char *opretstr);
int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
extern char CURRENCIES[][8];
Value paxpending(const Array& params, bool fHelp)
{
Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t deposited,issued,withdrawn,approved,redeemed;
Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t available,deposited,issued,withdrawn,approved,redeemed;
if ( fHelp || params.size() != 0 )
throw runtime_error("paxpending needs no args\n");
LOCK(cs_main);
@ -500,6 +500,7 @@ Value paxpending(const Array& params, bool fHelp)
{
if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 )
{
item.push_back(Pair("available", ValueFromAmount(available)));
item.push_back(Pair("deposited", ValueFromAmount(deposited)));
item.push_back(Pair("issued", ValueFromAmount(issued)));
item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn)));

3
src/wallet/rpcwallet.cpp

@ -482,6 +482,7 @@ extern char ASSETCHAINS_SYMBOL[16];
int32_t komodo_is_issuer();
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t komodo_isrealtime(int32_t *kmdheightp);
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
Value paxdeposit(const Array& params, bool fHelp)
{
@ -501,6 +502,8 @@ Value paxdeposit(const Array& params, bool fHelp)
std::string base = params[2].get_str();
std::string dest;
height = chainActive.Tip()->nHeight;
if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) != 0 || available < fiatoshis )
throw runtime_error("paxdeposit no available inventory");
komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis);
dest.append(destaddr);
CBitcoinAddress destaddress(CRYPTO777_KMDADDR);

Loading…
Cancel
Save