diff --git a/src/komodo.h b/src/komodo.h index 42cad2481..d4b6932ce 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -328,7 +328,7 @@ int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) // with more than 13 pay2pubkey outputs -> ratify // if all outputs to notary -> notary utxo // if txi == 0 && 2 outputs and 2nd OP_RETURN, len == 32*2+4 -> notarized, 1st byte 'P' -> pricefeed -// OP_RETURN: 'D' -> deposit +// OP_RETURN: 'D' -> deposit, 'W' -> withdraw void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c7c52c4bc..22e0c315f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -13,20 +13,21 @@ * * ******************************************************************************/ -// convert paxdeposit into new coins in the next block +// create list of approved deposits, validate all deposits against this list, prevent double deposit +// need to tag deposits with OP_RETURN, ie link with originating txid/vout // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen) { uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,tokomodo=0; char base[4],coinaddr[64],destaddr[64]; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; //printf("komodo_opreturn[%c]: ht.%d %.8f opretlen.%d\n",opretbuf[0],height,dstr(value),opretlen); - if ( opretbuf[0] == 'D' ) +#ifdef KOMODO_ISSUER + tokomodo = 1; +#endif + if ( opretbuf[0] == ((tokomodo != 0) ? 'D' : 'W') ) { if ( opretlen == 34 ) { -#ifdef KOMODO_ISSUER - tokomodo = 1; -#endif memset(base,0,sizeof(base)); PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); if ( fiatoshis < 0 ) @@ -42,9 +43,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf(" checkpubkey check %.8f v %.8f dest.(%s)\n",dstr(checktoshis),dstr(value),destaddr); typestr = "deposit"; #ifdef KOMODO_ISSUER - if ( strncmp(KOMODO_SOURCE,base,strlen(base)) == 0 && value >= checktoshis*.9999 ) + if ( strncmp(KOMODO_SOURCE,base,strlen(base)) == 0 && ((tokomodo == 0 && value >= checktoshis*.9999) || (tokomodo != 0 && value <= checktoshis/.9999)) ) { - printf("START %s MINER!\n",KOMODO_SOURCE); + printf("START %s MINER! %.8f\n",KOMODO_SOURCE,dstr(fiatoshis)); KOMODO_DEPOSIT = fiatoshis; KOMODO_SCRIPTPUBKEY[0] = 0x76; KOMODO_SCRIPTPUBKEY[1] = 0xa9; diff --git a/src/main.cpp b/src/main.cpp index e5fcc4736..28393810f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1415,8 +1415,8 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) CAmount nSubsidy = 3 * COIN; if ( nHeight == 1 ) return(100000000 * COIN); // ICO allocation - else if ( komodo_moneysupply(nHeight) < MAX_MONEY ) - return(3 * COIN); + //else if ( komodo_moneysupply(nHeight) < MAX_MONEY ) + // return(3 * COIN); else return(0); /* // Mining slow start diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e245fad37..e934bfa66 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -500,7 +500,7 @@ Value paxdeposit(const Array& params, bool fHelp) if ( fee < 10000 ) fee = 10000; opretlen = komodo_opreturnscript(opretbuf,'D',pubkey33,33); - SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis); + SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis); return wtx.GetHash().GetHex(); }