From 05a37d87828cac23f8d0d514f8bcb8f1b7c1c0ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 Nov 2016 14:57:08 -0300 Subject: [PATCH] test --- src/komodo_gateway.h | 87 ++++++++++++++++++++++++---------------- src/wallet/rpcwallet.cpp | 11 ++--- 2 files changed, 58 insertions(+), 40 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index faea16680..27b3e3f17 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -112,7 +112,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char memcpy(pax->rmd160,rmd160,20); pax->height = height; if ( pax->marked == 0 ) - printf("ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d\n",symbol,dstr(fiatoshis),coinaddr,height); + printf("ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d total %.8f\n",symbol,dstr(fiatoshis),coinaddr,height,dstr(komodo_total())); else printf("MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d\n",pax->marked,symbol,dstr(fiatoshis),coinaddr,height); } else @@ -252,49 +252,66 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo=0; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; + uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,kmdheight,tokomodo=0; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; tokomodo = (komodo_is_issuer() == 0); if ( opretbuf[0] == 'D' ) { - if ( opretlen == 34 ) // any KMD tx + if ( opretlen == 38 ) // any KMD tx { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); + if ( kmdheight <= height ) { - for (i=0; i= checktoshis ) - { - if ( komodo_paxfind(&space,txid,vout) == 0 ) - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height); - } - } - else // short + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { for (i=0; i dest.(RQY5zAq49YYc8knVkBBpxuxbQa3xwhaw5z) komodoshis.7763390 + //6a22440245555240420f00000000003c8390ec7bac0c84d9ceb39b1f31564c983123b8e4 opretbuf[36] + //9b51f402d7f5afde938b96f0c69d4114f2033a7ebd4db11eee7f2b6a94f00bca + /*{ + "base" : "eur", + "rel" : "kmd", + "height" : 59480, + "timestamp" : 1478540309, + "price" : 7.76339000, + "invprice" : 0.12880971, + "basevolume" : 1.00000000, + "relvolume" : 7.76339000 + }*/ + if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 && shortflag == ASSETCHAINS_SHORTFLAG ) + { + if ( shortflag == 0 ) { - + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + if ( value >= checktoshis ) + { + if ( komodo_paxfind(&space,txid,vout) == 0 ) + komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight); + } + } + else // short + { + for (i=0; inHeight,(char *)base.c_str(),fiatoshis); + komodoshis = PAX_fiatdest(0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),chainActive.Tip()->nHeight,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); if (!destaddress.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); + printf("%02x",pubkey37[i]); printf(" ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu\n",chainActive.Tip()->nHeight,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)komodoshis); EnsureWalletIsUnlocked(); CWalletTx wtx; uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000; if ( fee < 10000 ) fee = 10000; - opretlen = komodo_opreturnscript(opretbuf,'D',pubkey33,33); + iguana_rwnum(1,&pubkey37[33],sizeof(height),&height); + opretlen = komodo_opreturnscript(opretbuf,'D',pubkey37,33); SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis); return wtx.GetHash().GetHex(); }