@@ -1,35 +1,35 @@
|
||||
source pubkey.txt
|
||||
echo $pubkey
|
||||
|
||||
./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 &
|
||||
./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 &
|
||||
./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 &
|
||||
|
||||
@@ -58,8 +58,18 @@ public:
|
||||
|
||||
#include "uint256.h"
|
||||
#include "arith_uint256.h"
|
||||
|
||||
int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks
|
||||
|
||||
#include "komodo_globals.h"
|
||||
#include "komodo_utils.h"
|
||||
#include "cJSON.c"
|
||||
#include "komodo_notary.h"
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static bool AppInitRPC(int argc, char* argv[])
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
// Tell the main threads to shutdown.
|
||||
while (!fShutdown)
|
||||
{
|
||||
MilliSleep(2000);
|
||||
MilliSleep(10000);
|
||||
if ( komodo_is_issuer() != 0 )
|
||||
komodo_gateway_iteration(ASSETCHAINS_SYMBOL);
|
||||
else komodo_iteration((char *)"EUR");
|
||||
|
||||
@@ -400,7 +400,14 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr
|
||||
interest = komodo_interest(nHeight,value,tx.nLockTime,tiptime);
|
||||
#ifdef KOMODO_ENABLE_INTEREST
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 )
|
||||
{
|
||||
if ( interest != 0 )
|
||||
{
|
||||
printf("nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime);
|
||||
fprintf(stderr,"nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime);
|
||||
}
|
||||
nResult += interest;
|
||||
}
|
||||
#endif
|
||||
(*interestp) += interest;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#ifndef BITCOIN_COINS_H
|
||||
#define BITCOIN_COINS_H
|
||||
|
||||
#define KOMODO_ENABLE_INTEREST //enabling this is a hardfork, activate with new RR method
|
||||
|
||||
#include "compressor.h"
|
||||
#include "memusage.h"
|
||||
#include "serialize.h"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
echo aud; fiat/aud $1 $2 $3 $4
|
||||
echo bgn; fiat/bgn $1 $2 $3 $4
|
||||
echo cad; fiat/cad $1 $2 $3 $4
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
./komodo-cli -ac_name=-USD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=AUD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=BGN $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=BRL $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=CAD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=CHF $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=CNY $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=CZK $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=DKK $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=EUR $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=GBP $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=HKD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=HRK $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=HUF $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=IDR $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=ILS $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=INR $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=JPY $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=KRW $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=MXN $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=MYR $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=NOK $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=NZD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=PHP $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=PLN $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=RON $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=RUB $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=SEK $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=SGD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=THB $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=TRY $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=USD $1 $2 $3 $4
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=ZAR $1 $2 $3 $4
|
||||
|
||||
31
src/komodo.h
31
src/komodo.h
@@ -16,26 +16,27 @@
|
||||
#ifndef H_KOMODO_H
|
||||
#define H_KOMODO_H
|
||||
|
||||
// Todo: handle reorg: clear all entries above reorged height
|
||||
// smooth consensus price
|
||||
//
|
||||
// Todo:
|
||||
// 1. error check fiat redeem amounts
|
||||
// 2. net balance limiter
|
||||
// 3. new RR algo
|
||||
// 4. verify: interest payment, ratification, reorgs
|
||||
// 5. automate notarization fee payouts
|
||||
// 6. automated distribution of test REVS snapshot
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <ctype.h>
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout);
|
||||
void komodo_init(int32_t height);
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||
char *komodo_issuemethod(char *method,char *params,uint16_t port);
|
||||
|
||||
#define GENESIS_NBITS 0x1f00ffff
|
||||
#define KOMODO_MINRATIFY 7
|
||||
|
||||
int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks
|
||||
|
||||
#include "komodo_globals.h"
|
||||
#include "komodo_utils.h"
|
||||
//queue_t DepositsQ,PendingsQ;
|
||||
|
||||
#include "cJSON.c"
|
||||
#include "komodo_bitcoind.h"
|
||||
@@ -349,7 +350,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
static int32_t hwmheight;
|
||||
uint64_t signedmask,voutmask;
|
||||
uint8_t scriptbuf[4096],pubkeys[64][33]; uint256 kmdtxid,btctxid,txhash;
|
||||
int32_t i,j,k,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count;
|
||||
int32_t i,j,k,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count;
|
||||
komodo_init(pindex->nHeight);
|
||||
if ( pindex->nHeight > hwmheight )
|
||||
hwmheight = pindex->nHeight;
|
||||
@@ -358,15 +359,16 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight);
|
||||
// reset komodostate
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
CURRENT_HEIGHT = chainActive.Tip()->nHeight;
|
||||
if ( komodo_is_issuer() != 0 )
|
||||
{
|
||||
while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME )
|
||||
{
|
||||
fprintf(stderr,"komodo_connect.(%s) waiting for realtime RT.%u now.%u\n",ASSETCHAINS_SYMBOL,KOMODO_REALTIME,(uint32_t)time(NULL));
|
||||
sleep(3);
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||
KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
height = pindex->nHeight;
|
||||
@@ -391,6 +393,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
#endif
|
||||
// signedmask is needed here!
|
||||
notaryid = komodo_voutupdate(notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue);
|
||||
if ( i == 0 && j == 0 && komodo_chosennotary(&nid,height,scriptbuf + 1) >= 0 )
|
||||
{
|
||||
if ( height < sizeof(Minerids)/sizeof(*Minerids) )
|
||||
Minerids[height] = nid;
|
||||
}
|
||||
if ( 0 && i > 0 )
|
||||
{
|
||||
for (k=0; k<len; k++)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <curl/easy.h>
|
||||
#endif
|
||||
|
||||
#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7775",0,(char *)(cmdstr),0)
|
||||
#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr))
|
||||
|
||||
struct MemoryStruct { char *memory; size_t size; };
|
||||
struct return_string { char *ptr; size_t len; };
|
||||
@@ -377,6 +377,7 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
||||
{
|
||||
//int32_t i; uint256 hash;
|
||||
komodo_init(pindex->nHeight);
|
||||
Minerids[pindex->nHeight] = -2;
|
||||
//hash = block.GetHash();
|
||||
//for (i=0; i<32; i++)
|
||||
// printf("%02x",((uint8_t *)&hash)[i]);
|
||||
@@ -446,6 +447,49 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
||||
}
|
||||
}
|
||||
|
||||
int8_t komodo_minerid(int32_t height)
|
||||
{
|
||||
static uint32_t depth;
|
||||
int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33];
|
||||
if ( depth == 0 && height <= CURRENT_HEIGHT )//chainActive.Tip()->nHeight )
|
||||
{
|
||||
if ( (pindex= chainActive[height]) != 0 )
|
||||
{
|
||||
depth++;
|
||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||
komodo_chosennotary(¬aryid,height,pubkey33);
|
||||
depth--;
|
||||
return(notaryid);
|
||||
}
|
||||
}
|
||||
return(-2);
|
||||
}
|
||||
|
||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
|
||||
{
|
||||
int32_t i,notaryid;
|
||||
komodo_chosennotary(¬aryid,height,pubkey33);
|
||||
if ( height >= 34000 && notaryid >= 0 )
|
||||
{
|
||||
for (i=1; i<64; i++)
|
||||
{
|
||||
if ( Minerids[height-i] == -2 )
|
||||
{
|
||||
Minerids[height-i] = komodo_minerid(height-i);
|
||||
if ( Minerids[height - i] == -2 )
|
||||
{
|
||||
//fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,CURRENT_HEIGHT);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if ( Minerids[height-i] == notaryid )
|
||||
return(-1);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
|
||||
{
|
||||
int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary;
|
||||
|
||||
@@ -20,7 +20,7 @@ struct pax_transaction
|
||||
UT_hash_handle hh;
|
||||
uint256 txid;
|
||||
uint64_t komodoshis,fiatoshis;
|
||||
int32_t marked,height;
|
||||
int32_t marked,height,otherheight;
|
||||
uint16_t vout;
|
||||
char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag;
|
||||
} *PAX;
|
||||
@@ -28,27 +28,6 @@ struct pax_transaction
|
||||
uint64_t komodo_paxtotal()
|
||||
{
|
||||
struct pax_transaction *pax,*tmp; uint64_t total = 0;
|
||||
/*pthread_mutex_lock(&komodo_mutex);
|
||||
tmp = 0;
|
||||
if ( PAX != 0 )
|
||||
{
|
||||
pax = (struct pax_transaction *)PAX->hh.next;
|
||||
while ( pax != 0 && pax != tmp && n++ < 1000000 )
|
||||
{
|
||||
printf("PAX.[%p %p] pax.%p marked.%d fiat %.8f KMD %.8f\n",PAX->hh.next,PAX->hh.prev,pax,pax->marked,dstr(pax->fiatoshis),dstr(pax->komodoshis));
|
||||
if ( pax->marked == 0 )
|
||||
{
|
||||
if ( komodo_is_issuer() != 0 )
|
||||
total += pax->fiatoshis;
|
||||
else total += pax->komodoshis;
|
||||
}
|
||||
tmp = pax;
|
||||
pax = (struct pax_transaction *)pax->hh.next;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
if ( n >= 1000000 )
|
||||
printf("komodo_paxtotal n.%d iterations?\n",n);*/
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
{
|
||||
if ( pax->marked == 0 )
|
||||
@@ -97,7 +76,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp
|
||||
return(pax);
|
||||
}
|
||||
|
||||
void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height) // assetchain context
|
||||
void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context
|
||||
{
|
||||
struct pax_transaction *pax; int32_t addflag = 0;
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
@@ -108,9 +87,13 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char
|
||||
pax->txid = txid;
|
||||
pax->vout = vout;
|
||||
HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax);
|
||||
//int32_t i; for (i=0; i<32; i++)
|
||||
// printf("%02x",((uint8_t *)&txid)[i]);
|
||||
//printf(" v.%d [%s] ht.%d create pax.%p\n",vout,ASSETCHAINS_SYMBOL,height,pax);
|
||||
addflag = 1;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
int32_t i; for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&txid)[i]);
|
||||
printf(" v.%d [%s] kht.%d ht.%d create pax.%p\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
if ( coinaddr != 0 )
|
||||
@@ -122,18 +105,22 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char
|
||||
pax->fiatoshis = fiatoshis;
|
||||
memcpy(pax->rmd160,rmd160,20);
|
||||
pax->height = height;
|
||||
pax->otherheight = otherheight;
|
||||
if ( pax->marked == 0 )
|
||||
printf("[%s] %p ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d total %.8f\n",ASSETCHAINS_SYMBOL,pax,symbol,dstr(fiatoshis),coinaddr,height,dstr(komodo_paxtotal()));
|
||||
else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height);
|
||||
{
|
||||
if ( addflag != 0 )
|
||||
printf("[%s] addflag.%d ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal()));
|
||||
}
|
||||
//else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight);
|
||||
}
|
||||
else
|
||||
{
|
||||
pax->marked = height;
|
||||
printf("pax.%p MARK DEPOSIT ht.%d\n",pax,height);
|
||||
printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen)
|
||||
int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo)
|
||||
{
|
||||
int32_t i,n=0,j,len;
|
||||
if ( opretbuf[opretlen-5] == '-' )
|
||||
@@ -141,7 +128,7 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin
|
||||
else *shortflagp = 0;
|
||||
for (i=0; i<4; i++)
|
||||
base[i] = opretbuf[opretlen-4+i];
|
||||
if ( (strcmp(base,"KMD") == 0 && ASSETCHAINS_SYMBOL[0] == 0) || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag
|
||||
{
|
||||
opretbuf++, opretlen--;
|
||||
for (n=len=0; n<opretlen/34; n++)
|
||||
@@ -154,16 +141,31 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin
|
||||
vouts[n] = opretbuf[len++];
|
||||
vouts[n] = (opretbuf[len++] << 8) | vouts[n];
|
||||
//printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen);
|
||||
if ( iskomodo != 0 )
|
||||
{
|
||||
uint64_t fiatoshis; int32_t height,otherheight,shortflag; char symbol[16];
|
||||
len += iguana_rwnum(0,&opretbuf[len],sizeof(fiatoshis),&fiatoshis);
|
||||
len += iguana_rwnum(0,&opretbuf[len],sizeof(height),&height);
|
||||
len += iguana_rwnum(0,&opretbuf[len],sizeof(otherheight),&otherheight);
|
||||
if ( opretbuf[len] == '-' )
|
||||
shortflag = 1, len++;
|
||||
else shortflag = 0;
|
||||
for (i=0; opretbuf[len+i]!=0&&i<3; i++)
|
||||
symbol[i] = opretbuf[len+i];
|
||||
symbol[i] = 0;
|
||||
printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d short.%d\n",symbol,dstr(fiatoshis),height,otherheight,shortflag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol)
|
||||
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *base,int32_t tokomodo)
|
||||
{
|
||||
struct pax_transaction *pax,*tmp; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1;
|
||||
struct pax_transaction *pax,*tmp; char symbol[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1;
|
||||
strcpy(symbol,base);
|
||||
PENDING_KOMODO_TX = 0;
|
||||
if ( strcmp(symbol,"KMD") != 0 )
|
||||
if ( tokomodo == 0 )
|
||||
opcode = 'I';
|
||||
else opcode = 'X';
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
@@ -173,7 +175,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("pax.%p marked.%d %.8f -> %.8f\n",pax,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
||||
txNew->vout.resize(numvouts+1);
|
||||
txNew->vout[numvouts].nValue = pax->fiatoshis;
|
||||
txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis;
|
||||
txNew->vout[numvouts].scriptPubKey.resize(25);
|
||||
script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0];
|
||||
*script++ = 0x76;
|
||||
@@ -189,10 +191,22 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *
|
||||
}
|
||||
data[len++] = pax->vout & 0xff;
|
||||
data[len++] = (pax->vout >> 8) & 0xff;
|
||||
if ( strcmp(symbol,"KMD") != 0 )
|
||||
if ( tokomodo == 0 )
|
||||
PENDING_KOMODO_TX += pax->fiatoshis;
|
||||
else PENDING_KOMODO_TX += pax->komodoshis;
|
||||
//printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX));
|
||||
else
|
||||
{
|
||||
//[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.10000000,"fiat":"EUR","kmdheight":57930,"height":153,"KMD":0.78329000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5","rmd160":"306c507eea639e7220b3069ed9f49f3bc97eaca1"}]
|
||||
len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis);
|
||||
len += iguana_rwnum(1,&data[len],sizeof(pax->height),&pax->height);
|
||||
len += iguana_rwnum(1,&data[len],sizeof(pax->otherheight),&pax->otherheight);
|
||||
if ( pax->shortflag != 0 )
|
||||
data[len++] = '-';
|
||||
for (i=0; pax->symbol[i]!=0&&i<3; i++)
|
||||
data[len++] = pax->symbol[i];
|
||||
data[len++] = 0;
|
||||
PENDING_KOMODO_TX += pax->komodoshis;
|
||||
printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX));
|
||||
}
|
||||
if ( numvouts++ >= 64 )
|
||||
break;
|
||||
}
|
||||
@@ -200,6 +214,8 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *
|
||||
{
|
||||
if ( shortflag != 0 )
|
||||
data[len++] = '-';
|
||||
if ( tokomodo != 0 )
|
||||
strcpy(symbol,(char *)"KMD");
|
||||
for (i=0; symbol[i]!=0; i++)
|
||||
data[len++] = symbol[i];
|
||||
data[len++] = 0;
|
||||
@@ -209,8 +225,10 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *
|
||||
txNew->vout[numvouts].scriptPubKey.resize(opretlen);
|
||||
script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0];
|
||||
memcpy(script,opret,opretlen);
|
||||
printf("total numvouts.%d %.8f opretlen.%d\n",numvouts,dstr(PENDING_KOMODO_TX),opretlen);
|
||||
printf("MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,ASSETCHAINS_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
||||
@@ -221,9 +239,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
if ( n <= 2 || script[0] != 0x6a )
|
||||
return(0);
|
||||
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
|
||||
//printf("checkdeposit n.%d [%02x] [%c] %d vs %d\n",n,script[0],script[offset],script[offset],'I');
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
//for (i=0; i<opretlen; i++)
|
||||
// printf("%02x",script[i]);
|
||||
//printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X');
|
||||
opcode = 'X';
|
||||
strcpy(symbol,"KMD");
|
||||
}
|
||||
@@ -234,7 +254,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
}
|
||||
if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() )
|
||||
{
|
||||
if ( (num= komodo_issued_opreturn(&shortflag,base,txids,vouts,&script[offset],opretlen)) > 0 )
|
||||
if ( (num= komodo_issued_opreturn(&shortflag,base,txids,vouts,&script[offset],opretlen,opcode == 'X')) > 0 )
|
||||
{
|
||||
for (i=1; i<n-1; i++)
|
||||
{
|
||||
@@ -245,29 +265,40 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
if ( pax->marked != 0 )
|
||||
errs++;
|
||||
else matched++;
|
||||
//printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue));
|
||||
if ( opcode == 'X' )
|
||||
printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = block.GetHash();
|
||||
//for (j=0; j<32; j++)
|
||||
// printf("%02x",((uint8_t *)&hash)[j]);
|
||||
//printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i);
|
||||
if ( opcode == 'X' )
|
||||
{
|
||||
for (j=0; j<32; j++)
|
||||
printf("%02x",((uint8_t *)&hash)[j]);
|
||||
printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i);
|
||||
// validate amount!
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//for (j=0; j<32; j++)
|
||||
// printf("%02x",((uint8_t *)&txids[i-1])[j]);
|
||||
//printf(" cant paxfind txid\n");
|
||||
if ( opcode == 'X' )
|
||||
{
|
||||
matched++;
|
||||
for (j=0; j<32; j++)
|
||||
printf("%02x",((uint8_t *)&txids[i-1])[j]);
|
||||
printf(" cant paxfind txid\n");
|
||||
// validate amount!
|
||||
} else if ( opcode == 'I' )
|
||||
matched++;
|
||||
}
|
||||
komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height);
|
||||
}
|
||||
if ( matched != num )
|
||||
{
|
||||
//printf("matched.%d vs num.%d\n",matched,num);
|
||||
// can easily happen depending on order of loading
|
||||
if ( height > 60000 )
|
||||
return(-1);
|
||||
printf("WARNING: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num);
|
||||
}
|
||||
}
|
||||
//printf("opretlen.%d num.%d\n",opretlen,num);
|
||||
@@ -317,7 +348,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
if ( komodo_paxfind(&space,txid,vout) == 0 )
|
||||
{
|
||||
komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight);
|
||||
komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight,height);
|
||||
} else printf("duplicate deposit\n");
|
||||
}
|
||||
}
|
||||
@@ -339,7 +370,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase
|
||||
{
|
||||
if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen)) > 0 && shortflag == ASSETCHAINS_SHORTFLAG )
|
||||
if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen,0)) > 0 && shortflag == ASSETCHAINS_SHORTFLAG )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
@@ -347,7 +378,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
// printf("%02x",((uint8_t *)&txids[i])[j]);
|
||||
if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 )
|
||||
{
|
||||
komodo_gateway_deposit(0,0,0,0,0,0,txids[i],vouts[i],height);
|
||||
komodo_gateway_deposit(0,0,0,0,0,0,txids[i],vouts[i],height,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -473,7 +504,7 @@ void komodo_gateway_iteration(char *symbol)
|
||||
char *retstr; int32_t i,kmdheight; cJSON *infoobj,*result; uint256 zero; uint16_t port = 7771;
|
||||
if ( KMDHEIGHT <= 0 )
|
||||
KMDHEIGHT = 1;
|
||||
KOMODO_REALTIME = 0;
|
||||
//KOMODO_REALTIME = 0;
|
||||
if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 )
|
||||
{
|
||||
if ( (infoobj= cJSON_Parse(retstr)) != 0 )
|
||||
@@ -513,10 +544,9 @@ void komodo_gateway_iteration(char *symbol)
|
||||
|
||||
void komodo_iteration(char *symbol)
|
||||
{
|
||||
char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height; uint256 txid; uint8_t rmd160[20],addrtype;
|
||||
char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height,fiatheight; uint256 txid; uint8_t rmd160[20],addrtype;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
//[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.78329000,"fiat":"EUR","height":57930,"KMD":0.10000000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5"}]
|
||||
sprintf(cmd,"{\"agent\":\"dpow\",\"method\":\"pending\",\"fiat\":\"%s\"}",symbol);
|
||||
if ( (retstr= issue_curl(cmd)) != 0 )
|
||||
{
|
||||
@@ -529,22 +559,23 @@ void komodo_iteration(char *symbol)
|
||||
item = jitem(array,i);
|
||||
coinaddr = jstr(item,(char *)"address");
|
||||
value = jdouble(item,(char *)"KMD") * COIN;
|
||||
base = jstr(item,(char *)"fiat");
|
||||
shortflag = juint(item,(char *)"short");
|
||||
vout = jint(item,(char *)"prev_vout");
|
||||
height = jint(item,(char *)"height");
|
||||
base = jstr(item,(char *)"fiat");
|
||||
height = jint(item,(char *)"kmdheight");
|
||||
fiatheight = jint(item,(char *)"height");
|
||||
txidstr = jstr(item,(char *)"prev_hash");
|
||||
if ( coinaddr != 0 && base != 0 && value > 0 && height > 0 )
|
||||
{
|
||||
fiatoshis = jdouble(item,base) * COIN;
|
||||
decode_hex((uint8_t *)&txid,sizeof(txid),txidstr);
|
||||
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
|
||||
komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height);
|
||||
komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height,fiatheight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("retstr.(%s)\n",retstr);
|
||||
//printf("retstr.(%s)\n",retstr);
|
||||
free(retstr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,18 @@
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout);
|
||||
void komodo_init(int32_t height);
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||
char *komodo_issuemethod(char *method,char *params,uint16_t port);
|
||||
void komodo_init(int32_t height);
|
||||
void komodo_assetchain_pubkeys(char *jsonstr);
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||
|
||||
int COINBASE_MATURITY = 100;
|
||||
|
||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
|
||||
std::string NOTARY_PUBKEY;
|
||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,CURRENT_HEIGHT,ASSETCHAINS_SEED;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
|
||||
uint8_t NOTARY_PUBKEY33[33];
|
||||
|
||||
int32_t ASSETCHAINS_SHORTFLAG;
|
||||
|
||||
@@ -52,7 +52,7 @@ const char *Notaries_genesis[][2] =
|
||||
{ "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" },
|
||||
};
|
||||
|
||||
#define KOMODO_ELECTION_GAP 1000
|
||||
#define KOMODO_ELECTION_GAP 2000
|
||||
#define KOMODO_PUBKEYS_HEIGHT(height) ((int32_t)(((((height)+KOMODO_ELECTION_GAP*.5)/KOMODO_ELECTION_GAP) + 1) * KOMODO_ELECTION_GAP))
|
||||
|
||||
struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; } *NUTXOS;
|
||||
@@ -138,11 +138,11 @@ void komodo_notarysinit(int32_t height,uint8_t pubkeys[64][33],int32_t num)
|
||||
memcpy(kp->pubkey,pubkeys[k],33);
|
||||
kp->notaryid = k;
|
||||
HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp);
|
||||
if ( height > 10000 )
|
||||
//if ( height > 10000 )
|
||||
{
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkeys[k][i]);
|
||||
printf(" notarypubs.[%d]\n",k);
|
||||
printf(" notarypubs.[%d] ht.%d\n",k,height);
|
||||
}
|
||||
}
|
||||
N.numnotaries = num;
|
||||
@@ -224,13 +224,13 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n
|
||||
|
||||
void komodo_init(int32_t height)
|
||||
{
|
||||
static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33];
|
||||
if ( height > didinit )
|
||||
static int didinit; uint256 zero; int32_t i,k,n; uint8_t pubkeys[64][33];
|
||||
if ( didinit == 0 )
|
||||
{
|
||||
if ( didinit == 0 )
|
||||
pthread_mutex_init(&komodo_mutex,NULL);
|
||||
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||
if ( height >= 0 )
|
||||
{
|
||||
pthread_mutex_init(&komodo_mutex,NULL);
|
||||
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||
n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis));
|
||||
for (k=0; k<n; k++)
|
||||
{
|
||||
@@ -239,8 +239,44 @@ void komodo_init(int32_t height)
|
||||
decode_hex(pubkeys[k],33,(char *)Notaries_genesis[k][1]);
|
||||
}
|
||||
komodo_notarysinit(0,pubkeys,k);
|
||||
memset(&zero,0,sizeof(zero));
|
||||
}
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0);
|
||||
memset(&zero,0,sizeof(zero));
|
||||
for (i=0; i<sizeof(Minerids); i++)
|
||||
Minerids[i] = -2;
|
||||
didinit = 1;
|
||||
}
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0);
|
||||
}
|
||||
|
||||
void komodo_assetchain_pubkeys(char *jsonstr)
|
||||
{
|
||||
cJSON *array; int32_t i,n; uint8_t pubkeys[64][33]; char *hexstr;
|
||||
memset(pubkeys,0,sizeof(pubkeys));
|
||||
if ( (array= cJSON_Parse(jsonstr)) != 0 )
|
||||
{
|
||||
if ( (n= cJSON_GetArraySize(array)) > 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
if ( (hexstr= jstri(array,i)) != 0 && is_hexstr(hexstr,0) == 66 )
|
||||
{
|
||||
decode_hex(pubkeys[i],33,hexstr);
|
||||
fprintf(stderr,"i.%d of n.%d pubkey.(%s)\n",i,n,hexstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"illegal hexstr.(%s) i.%d of n.%d\n",hexstr,i,n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == n )
|
||||
{
|
||||
komodo_init(-1);
|
||||
komodo_notarysinit(0,pubkeys,n);
|
||||
printf("initialize pubkeys[%d]\n",n);
|
||||
} else fprintf(stderr,"komodo_assetchain_pubkeys i.%d vs n.%d\n",i,n);
|
||||
} else fprintf(stderr,"assetchain pubkeys n.%d\n",n);
|
||||
}
|
||||
//else if ( jsonstr != 0 )
|
||||
// fprintf(stderr,"assetchain pubkeys couldnt parse.(%s)\n",jsonstr);
|
||||
}
|
||||
|
||||
@@ -851,11 +851,13 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
||||
{
|
||||
int32_t adjust,i = 0;
|
||||
//printf("decode.(%s)\n",hex);
|
||||
if ( is_hexstr(hex,n) == 0 )
|
||||
if ( is_hexstr(hex,n) <= 0 )
|
||||
{
|
||||
memset(bytes,0,n);
|
||||
return(n);
|
||||
}
|
||||
if ( hex[n-1] == '\n' || hex[n-1] == '\r' )
|
||||
hex[--n] = 0;
|
||||
if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) )
|
||||
{
|
||||
if ( n > 0 )
|
||||
@@ -1354,9 +1356,12 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES])
|
||||
printf("ports\n");
|
||||
}
|
||||
|
||||
char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\"";
|
||||
|
||||
|
||||
void komodo_args()
|
||||
{
|
||||
std::string name; char *dirname; int32_t i,len;
|
||||
std::string name,addn; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,len;
|
||||
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
|
||||
NOTARY_PUBKEY = GetArg("-pubkey", "");
|
||||
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
|
||||
@@ -1365,6 +1370,9 @@ void komodo_args()
|
||||
if ( name.c_str()[0] != 0 )
|
||||
{
|
||||
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
|
||||
addn = GetArg("-seednode","");
|
||||
if ( strlen(addn.c_str()) > 0 )
|
||||
ASSETCHAINS_SEED = 1;
|
||||
strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1);
|
||||
ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,&ASSETCHAINS_SHORTFLAG);
|
||||
//fprintf(stderr,"after args: %c%s port.%u magic.%08x supply.%u\n",ASSETCHAINS_SHORTFLAG!=0?'-':'+',ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_MAGIC,(int32_t)ASSETCHAINS_SUPPLY);
|
||||
@@ -1379,9 +1387,22 @@ void komodo_args()
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
extern int COINBASE_MATURITY;
|
||||
komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1);
|
||||
if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 )
|
||||
//if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 )
|
||||
COINBASE_MATURITY = 1;
|
||||
}
|
||||
ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
|
||||
komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());
|
||||
iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
|
||||
for (i=0; i<4; i++)
|
||||
sprintf(&magicstr[i<<1],"%02x",magic[i]);
|
||||
magicstr[8] = 0;
|
||||
sprintf(fname,"gen%s",ASSETCHAINS_SYMBOL);
|
||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||
{
|
||||
fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,"78.47.196.146");
|
||||
fclose(fp);
|
||||
//printf("created (%s)\n",fname);
|
||||
} else printf("error creating (%s)\n",fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
21
src/main.cpp
21
src/main.cpp
@@ -551,7 +551,6 @@ CBlockTreeDB *pblocktree = NULL;
|
||||
// Komodo globals
|
||||
|
||||
#define KOMODO_TESTNET_EXPIRATION 100000
|
||||
#define KOMODO_ENABLE_INTEREST //enabling this is a hardfork
|
||||
#define KOMODO_PAX
|
||||
#define KOMODO_ZCASH
|
||||
#include "komodo.h"
|
||||
@@ -1179,7 +1178,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
view.GetBestBlock();
|
||||
|
||||
nValueIn = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime);
|
||||
|
||||
if ( interest != 0 )
|
||||
fprintf(stderr,"add interest %.8f\n",(double)interest/COIN);
|
||||
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
|
||||
view.SetBackend(dummy);
|
||||
}
|
||||
@@ -3312,12 +3312,15 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
|
||||
}
|
||||
|
||||
|
||||
bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
|
||||
bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
|
||||
{
|
||||
// Preliminary checks
|
||||
extern int32_t CURRENT_HEIGHT;
|
||||
bool checked;
|
||||
if ( chainActive.Tip() != 0 )
|
||||
CURRENT_HEIGHT = chainActive.Tip()->nHeight;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
checked = CheckBlock(komodo_block2height(pblock),0,*pblock, state);
|
||||
checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state);
|
||||
else checked = CheckBlock(0,0,*pblock, state);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
@@ -3882,7 +3885,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
// process in case the block isn't known yet
|
||||
if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) {
|
||||
CValidationState state;
|
||||
if (ProcessNewBlock(state, NULL, &block, true, dbp))
|
||||
if (ProcessNewBlock(0,state, NULL, &block, true, dbp))
|
||||
nLoaded++;
|
||||
if (state.IsError())
|
||||
break;
|
||||
@@ -3904,7 +3907,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
||||
head.ToString());
|
||||
CValidationState dummy;
|
||||
if (ProcessNewBlock(dummy, NULL, &block, true, &it->second))
|
||||
if (ProcessNewBlock(0,dummy, NULL, &block, true, &it->second))
|
||||
{
|
||||
nLoaded++;
|
||||
queue.push_back(block.GetHash());
|
||||
@@ -4896,7 +4899,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
int nDoS;
|
||||
if (state.IsInvalid(nDoS)) {
|
||||
if (nDoS > 0)
|
||||
Misbehaving(pfrom->GetId(), nDoS);
|
||||
Misbehaving(pfrom->GetId(), nDoS/nDoS);
|
||||
return error("invalid header received");
|
||||
}
|
||||
}
|
||||
@@ -4932,7 +4935,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
// Such an unrequested block may still be processed, subject to the
|
||||
// conditions in AcceptBlock().
|
||||
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload();
|
||||
ProcessNewBlock(state, pfrom, &block, forceProcessing, NULL);
|
||||
ProcessNewBlock(0,state, pfrom, &block, forceProcessing, NULL);
|
||||
int nDoS;
|
||||
if (state.IsInvalid(nDoS)) {
|
||||
pfrom->PushMessage("reject", strCommand, state.GetRejectCode(),
|
||||
@@ -5285,7 +5288,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintExceptionContinue(&e, "ProcessMessages()");
|
||||
//PrintExceptionContinue(&e, "ProcessMessages()");
|
||||
}
|
||||
}
|
||||
catch (const boost::thread_interrupted&) {
|
||||
|
||||
@@ -167,7 +167,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals);
|
||||
* @param[out] dbp If pblock is stored to disk (or already there), this will be set to its location.
|
||||
* @return True if state.IsValid()
|
||||
*/
|
||||
bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp);
|
||||
bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp);
|
||||
/** Check whether enough disk space is available for an incoming block */
|
||||
bool CheckDiskSpace(uint64_t nAdditionalBytes = 0);
|
||||
/** Open a block file (blk?????.dat) */
|
||||
|
||||
108
src/miner.cpp
108
src/miner.cpp
@@ -102,7 +102,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
||||
int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize);
|
||||
uint64_t komodo_paxtotal();
|
||||
int32_t komodo_is_issuer();
|
||||
void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol);
|
||||
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo);
|
||||
extern int32_t KOMODO_INITDONE,ASSETCHAINS_SHORTFLAG,KOMODO_REALTIME;
|
||||
extern char ASSETCHAINS_SYMBOL[16];
|
||||
|
||||
@@ -114,20 +114,24 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
if(!pblocktemplate.get())
|
||||
return NULL;
|
||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME);
|
||||
while ( mempool.GetTotalTxSize() <= 0 )
|
||||
//fprintf(stderr,"create new block %d\n",chainActive.Tip()->nHeight);
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 )
|
||||
{
|
||||
deposits = komodo_paxtotal();
|
||||
if ( KOMODO_INITDONE == 0 || time(NULL) < KOMODO_INITDONE+60 || KOMODO_REALTIME == 0 )
|
||||
continue;
|
||||
if ( deposits != 0 )
|
||||
break;
|
||||
sleep(10);
|
||||
fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME);
|
||||
while ( mempool.GetTotalTxSize() <= 0 )
|
||||
{
|
||||
deposits = komodo_paxtotal();
|
||||
if ( KOMODO_INITDONE == 0 || KOMODO_REALTIME == 0 )
|
||||
{
|
||||
//fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN);
|
||||
}
|
||||
else if ( deposits != 0 )
|
||||
break;
|
||||
sleep(10);
|
||||
}
|
||||
if ( 0 && deposits != 0 )
|
||||
printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize());
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize());
|
||||
|
||||
// -regtest only: allow overriding block.nVersion with
|
||||
// -blockversion=N to test forking scenarios
|
||||
if (Params().MineBlocksOnDemand())
|
||||
@@ -364,21 +368,23 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
int32_t i,opretlen; uint8_t opret[256],*ptr;
|
||||
if ( (opretlen= komodo_pax_opreturn(opret,sizeof(opret))) > 0 )
|
||||
if ( komodo_gateway_deposits(&txNew,0,(char *)"EUR",1) == 0 )
|
||||
{
|
||||
txNew.vout.resize(2);
|
||||
txNew.vout[1].scriptPubKey.resize(opretlen);
|
||||
ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data();
|
||||
for (i=0; i<opretlen; i++)
|
||||
ptr[i] = opret[i];
|
||||
txNew.vout[1].nValue = 0;
|
||||
//fprintf(stderr,"opretlen.%d\n",opretlen);
|
||||
if ( (opretlen= komodo_pax_opreturn(opret,sizeof(opret))) > 0 )
|
||||
{
|
||||
txNew.vout.resize(2);
|
||||
txNew.vout[1].scriptPubKey.resize(opretlen);
|
||||
ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data();
|
||||
for (i=0; i<opretlen; i++)
|
||||
ptr[i] = opret[i];
|
||||
txNew.vout[1].nValue = 0;
|
||||
//fprintf(stderr,"opretlen.%d\n",opretlen);
|
||||
}
|
||||
}
|
||||
komodo_gateway_deposits(&txNew,0,(char *)"EUR");
|
||||
}
|
||||
else if ( komodo_is_issuer() != 0 )
|
||||
{
|
||||
komodo_gateway_deposits(&txNew,0,ASSETCHAINS_SYMBOL);
|
||||
komodo_gateway_deposits(&txNew,0,ASSETCHAINS_SYMBOL,0);
|
||||
fprintf(stderr,"txNew numvouts.%d\n",(int32_t)txNew.vout.size());
|
||||
}
|
||||
pblock->vtx[0] = txNew;
|
||||
@@ -433,11 +439,13 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
||||
//
|
||||
// Internal miner
|
||||
//
|
||||
extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
|
||||
#define ROUNDROBIN_DELAY 45
|
||||
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern uint8_t NOTARY_PUBKEY33[33];
|
||||
uint32_t Mining_start,Mining_height;
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]);
|
||||
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||
{
|
||||
@@ -466,7 +474,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||
{
|
||||
LogPrintf("%s\n", pblock->ToString());
|
||||
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));
|
||||
LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.Tip()->nHeight+1);
|
||||
|
||||
// Found a solution
|
||||
{
|
||||
@@ -487,7 +495,7 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
|
||||
|
||||
// Process this block the same as if we had received it from another node
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlock(state, NULL, pblock, true, NULL))
|
||||
if (!ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
return error("ZcashMiner: ProcessNewBlock, block not accepted");
|
||||
|
||||
minedBlocks.increment();
|
||||
@@ -495,6 +503,8 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
|
||||
void static BitcoinMiner(CWallet *pwallet)
|
||||
{
|
||||
LogPrintf("ZcashMiner started\n");
|
||||
@@ -508,12 +518,12 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
|
||||
unsigned int n = chainparams.EquihashN();
|
||||
unsigned int k = chainparams.EquihashK();
|
||||
extern int32_t ASSETCHAIN_INIT,KOMODO_INITDONE; extern uint8_t NOTARY_PUBKEY33[33];
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||
int32_t notaryid = -1;
|
||||
while ( ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0 )
|
||||
{
|
||||
sleep(1);
|
||||
if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
|
||||
break;
|
||||
}
|
||||
komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33);
|
||||
|
||||
@@ -539,6 +549,8 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
{
|
||||
if (chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 )
|
||||
break;
|
||||
// Busy-wait for the network to come online so we don't waste time mining
|
||||
// on an obsolete chain. In regtest mode we expect to fly solo.
|
||||
//fprintf(stderr,"Wait for peers...\n");
|
||||
@@ -556,14 +568,18 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
} while (true);
|
||||
//fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
// fprintf(stderr,"%s create new block\n",ASSETCHAINS_SYMBOL);
|
||||
//
|
||||
// Create new block
|
||||
//
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
if ( Mining_height != pindexPrev->nHeight+1 )
|
||||
{
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height);
|
||||
|
||||
unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
|
||||
if (!pblocktemplate.get())
|
||||
@@ -577,20 +593,19 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
//
|
||||
// Search
|
||||
//
|
||||
int32_t notaryid; uint32_t savebits; int64_t nStart = GetTime();
|
||||
uint32_t savebits; int64_t nStart = GetTime();
|
||||
savebits = pblock->nBits;
|
||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_chosennotary(¬aryid,pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_is_special(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 %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);
|
||||
//fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);
|
||||
} else Mining_start = 0;
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
while (true)
|
||||
{
|
||||
//fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
||||
// Hash state
|
||||
KOMODO_CHOSEN_ONE = 0;
|
||||
crypto_generichash_blake2b_state state;
|
||||
EhInitialiseState(n, k, state);
|
||||
// I = the block header minus nonce and solution.
|
||||
@@ -619,10 +634,11 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
// printf("missed target\n");
|
||||
return false;
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+20 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY )
|
||||
{
|
||||
printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+20-time(NULL)));
|
||||
sleep(Mining_start+20-time(NULL));
|
||||
printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL)));
|
||||
sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL));
|
||||
KOMODO_CHOSEN_ONE = 1;
|
||||
}
|
||||
// Found a solution
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
@@ -633,6 +649,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
std::lock_guard<std::mutex> lock{m_cs};
|
||||
cancelSolver = false;
|
||||
}
|
||||
KOMODO_CHOSEN_ONE = 0;
|
||||
int32_t i; uint256 hash = pblock->GetHash();
|
||||
for (i=0; i<32; i++)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
@@ -704,9 +721,8 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
// Regtest mode doesn't require peers
|
||||
if (vNodes.empty() && chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("no nodes, break\n");
|
||||
break;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 )
|
||||
break;
|
||||
}
|
||||
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
||||
{
|
||||
@@ -716,14 +732,14 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
}
|
||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("timeout, break\n");
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
// printf("timeout, break\n");
|
||||
break;
|
||||
}
|
||||
if ( pindexPrev != chainActive.Tip() )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("Tip advanced, break\n");
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
// printf("Tip advanced, break\n");
|
||||
break;
|
||||
}
|
||||
// Update nNonce and nTime
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifdef HAVE_GETADDRINFO_A
|
||||
#undef HAVE_GETADDRINFO_A
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETADDRINFO_A
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
46
src/pow.cpp
46
src/pow.cpp
@@ -105,6 +105,9 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
||||
}
|
||||
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]);
|
||||
extern int32_t KOMODO_CHOSEN_ONE,CURRENT_HEIGHT;
|
||||
extern int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks
|
||||
|
||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
||||
{
|
||||
@@ -112,6 +115,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
arith_uint256 bnTarget;
|
||||
|
||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||
if ( height == 0 )
|
||||
height = CURRENT_HEIGHT + 1;
|
||||
if ( height > 34000 ) // 0 -> non-special notary
|
||||
{
|
||||
special = komodo_chosennotary(¬aryid,height,pubkey33);
|
||||
@@ -119,33 +124,42 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
{
|
||||
if ( pubkey33[i] != 0 )
|
||||
nonz++;
|
||||
//fprintf(stderr,"%02x",pubkey33[i]);
|
||||
}
|
||||
//fprintf(stderr," height.%d special.%d nonz.%d\n",height,special,nonz);
|
||||
if ( nonz == 0 )
|
||||
return(true); // will come back via different path with pubkey set
|
||||
if ( special > 0 ) // special notary id == (height % numnotaries)
|
||||
if ( height > 60000 )
|
||||
{
|
||||
if (UintToArith256(hash) <= bnTarget) // accept normal diff
|
||||
return true;
|
||||
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
flag = 1;
|
||||
} //else bnTarget /= 8;
|
||||
if ( notaryid >= 0 )
|
||||
{
|
||||
if ( (height < 70000 && (special != 0 || komodo_is_special(height,pubkey33) > 0)) ||
|
||||
(height >= 70000 && komodo_is_special(height,pubkey33) > 0) )
|
||||
{
|
||||
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( special > 0 ) // special notary id == (height % numnotaries)
|
||||
{
|
||||
if (UintToArith256(hash) <= bnTarget) // accept normal diff
|
||||
return true;
|
||||
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check range
|
||||
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit))
|
||||
return error("CheckProofOfWork(): nBits below minimum work");
|
||||
// Check proof of work matches claimed amount
|
||||
if (UintToArith256(hash) > bnTarget)
|
||||
if ( UintToArith256(hash) > bnTarget )
|
||||
{
|
||||
//for (i=0; i<33; i++)
|
||||
// printf("%02x",pubkey33[i]);
|
||||
//printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35));
|
||||
return error("CheckProofOfWork(): hash doesn't match nBits");
|
||||
}
|
||||
if ( flag != 0 )
|
||||
{
|
||||
for (i=0; i<33; i++)
|
||||
fprintf(stderr,"%02x",pubkey33[i]);
|
||||
fprintf(stderr," <- Round Robin ht.%d for notary.%d special.%d\n",height,notaryid,special);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,13 @@ JSDescription JSDescription::Randomized(
|
||||
const uint256& anchor,
|
||||
boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
|
||||
boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
|
||||
#ifdef __APPLE__
|
||||
boost::array<uint64_t, ZC_NUM_JS_INPUTS>& inputMap,
|
||||
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS>& outputMap,
|
||||
#else
|
||||
boost::array<size_t, ZC_NUM_JS_INPUTS>& inputMap,
|
||||
boost::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap,
|
||||
#endif
|
||||
CAmount vpub_old,
|
||||
CAmount vpub_new,
|
||||
bool computeProof,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
@@ -86,8 +87,13 @@ public:
|
||||
const uint256& rt,
|
||||
boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
|
||||
boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
|
||||
#ifdef __APPLE__
|
||||
boost::array<uint64_t, ZC_NUM_JS_INPUTS>& inputMap,
|
||||
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS>& outputMap,
|
||||
#else
|
||||
boost::array<size_t, ZC_NUM_JS_INPUTS>& inputMap,
|
||||
boost::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap,
|
||||
#endif
|
||||
CAmount vpub_old,
|
||||
CAmount vpub_new,
|
||||
bool computeProof = true, // Set to false in some tests
|
||||
|
||||
2
src/revs
Executable file
2
src/revs
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=REVS $1 $2 $3 $4
|
||||
@@ -394,7 +394,10 @@ Value notaries(const Array& params, bool fHelp)
|
||||
throw runtime_error("notaries height\n");
|
||||
LOCK(cs_main);
|
||||
int32_t height = atoi(params[0].get_str().c_str());
|
||||
if ( height < 0 || height > chainActive.Height()+2000 )
|
||||
if ( height < 0 )
|
||||
height = 0;
|
||||
//fprintf(stderr,"notaries as of height.%d\n",height);
|
||||
if ( height > chainActive.Height()+20000 )
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||
else
|
||||
{
|
||||
@@ -404,22 +407,24 @@ Value notaries(const Array& params, bool fHelp)
|
||||
{
|
||||
Object item;
|
||||
std::string btcaddress,kmdaddress,hex;
|
||||
bitcoin_address(btcaddr,0,pubkeys[i],33);
|
||||
m = (int32_t)strlen(btcaddr);
|
||||
btcaddress.resize(m);
|
||||
ptr = (char *)btcaddress.data();
|
||||
memcpy(ptr,btcaddr,n);
|
||||
bitcoin_address(kmdaddr,60,pubkeys[i],33);
|
||||
m = (int32_t)strlen(kmdaddr);
|
||||
kmdaddress.resize(m);
|
||||
ptr = (char *)kmdaddress.data();
|
||||
memcpy(ptr,kmdaddr,m);
|
||||
hex.resize(66);
|
||||
hexstr = (char *)hex.data();
|
||||
for (j=0; j<33; j++)
|
||||
sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]);
|
||||
item.push_back(Pair("pubkey", hex));
|
||||
|
||||
bitcoin_address(btcaddr,0,pubkeys[i],33);
|
||||
m = (int32_t)strlen(btcaddr);
|
||||
btcaddress.resize(m);
|
||||
ptr = (char *)btcaddress.data();
|
||||
memcpy(ptr,btcaddr,m);
|
||||
item.push_back(Pair("BTCaddress", btcaddress));
|
||||
|
||||
bitcoin_address(kmdaddr,60,pubkeys[i],33);
|
||||
m = (int32_t)strlen(kmdaddr);
|
||||
kmdaddress.resize(m);
|
||||
ptr = (char *)kmdaddress.data();
|
||||
memcpy(ptr,kmdaddr,m);
|
||||
item.push_back(Pair("KMDaddress", kmdaddress));
|
||||
a.push_back(item);
|
||||
}
|
||||
@@ -444,7 +449,9 @@ Value paxprice(const Array& params, bool fHelp)
|
||||
ret.push_back(Pair("base", base));
|
||||
ret.push_back(Pair("rel", rel));
|
||||
ret.push_back(Pair("height", height));
|
||||
ret.push_back(Pair("seed", seed));
|
||||
char seedstr[32];
|
||||
sprintf(seedstr,"%llu",(long long)seed);
|
||||
ret.push_back(Pair("seed", seedstr));
|
||||
if ( height < 0 || height > chainActive.Height() )
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||
else
|
||||
|
||||
@@ -207,7 +207,7 @@ Value generate(const Array& params, bool fHelp)
|
||||
}
|
||||
endloop:
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlock(state, NULL, pblock, true, NULL))
|
||||
if (!ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
|
||||
minedBlocks.increment();
|
||||
++nHeight;
|
||||
@@ -716,7 +716,7 @@ Value submitblock(const Array& params, bool fHelp)
|
||||
CValidationState state;
|
||||
submitblock_StateCatcher sc(block.GetHash());
|
||||
RegisterValidationInterface(&sc);
|
||||
bool fAccepted = ProcessNewBlock(state, NULL, &block, true, NULL);
|
||||
bool fAccepted = ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL);
|
||||
UnregisterValidationInterface(&sc);
|
||||
if (fBlockPresent)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "zcash/IncrementalMerkleTree.hpp"
|
||||
#include "sodium.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
@@ -873,8 +875,13 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit(
|
||||
{info.vjsin[0], info.vjsin[1]};
|
||||
boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS> outputs
|
||||
{info.vjsout[0], info.vjsout[1]};
|
||||
#ifdef __APPLE__
|
||||
boost::array<uint64_t, ZC_NUM_JS_INPUTS> inputMap;
|
||||
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> outputMap;
|
||||
#else
|
||||
boost::array<size_t, ZC_NUM_JS_INPUTS> inputMap;
|
||||
boost::array<size_t, ZC_NUM_JS_OUTPUTS> outputMap;
|
||||
#endif
|
||||
JSDescription jsdesc = JSDescription::Randomized(
|
||||
*pzcashParams,
|
||||
joinSplitPubKey_,
|
||||
|
||||
@@ -513,7 +513,7 @@ Value paxdeposit(const Array& params, bool fHelp)
|
||||
Value paxwithdraw(const Array& params, bool fHelp)
|
||||
{
|
||||
extern int32_t KMDHEIGHT,KOMODO_REALTIME;
|
||||
CWalletTx wtx; std::string dest; int32_t height; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false;
|
||||
CWalletTx wtx; std::string dest; int32_t kmdheight; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
return(0);
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
@@ -527,20 +527,20 @@ Value paxwithdraw(const Array& params, bool fHelp)
|
||||
if (!address.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
|
||||
int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN;
|
||||
komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),KMDHEIGHT,ASSETCHAINS_SYMBOL,fiatoshis);
|
||||
kmdheight = KMDHEIGHT;
|
||||
komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),kmdheight,ASSETCHAINS_SYMBOL,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",pubkey37[i]);
|
||||
height = KMDHEIGHT;
|
||||
printf(" ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),ASSETCHAINS_SYMBOL,(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed);
|
||||
printf(" kmdheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",kmdheight,(char *)params[0].get_str().c_str(),ASSETCHAINS_SYMBOL,(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed);
|
||||
EnsureWalletIsUnlocked();
|
||||
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000;
|
||||
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000;
|
||||
if ( fee < 10000 )
|
||||
fee = 10000;
|
||||
iguana_rwnum(1,&pubkey37[33],sizeof(height),&height);
|
||||
iguana_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight);
|
||||
opretlen = komodo_opreturnscript(opretbuf,'W',pubkey37,37);
|
||||
SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis);
|
||||
return wtx.GetHash().GetHex();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "utilmoneystr.h"
|
||||
#include "zcash/Note.hpp"
|
||||
#include "crypter.h"
|
||||
|
||||
#include "coins.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
@@ -2399,12 +2399,18 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
|
||||
if(!out.fSpendable)
|
||||
continue;
|
||||
nValueRet += out.tx->vout[out.i].nValue;
|
||||
interest = komodo_interest(chainActive.Tip()->nHeight,out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime);
|
||||
interest = komodo_interest(chainActive.Tip()->nHeight+1,out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime);
|
||||
#ifdef KOMODO_ENABLE_INTEREST
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && txheight >= 60000 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip()->nHeight+1 >= 60000 )
|
||||
{
|
||||
if ( interest != 0 )
|
||||
{
|
||||
printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,out.tx->nLockTime,chainActive.Tip()->nTime);
|
||||
fprintf(stderr,"nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,out.tx->nLockTime,chainActive.Tip()->nTime);
|
||||
}
|
||||
nValueRet += interest;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr,"interest %llu from %llu lock.%u tip.%u\n",(long long)interest,(long long)out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime);
|
||||
setCoinsRet.insert(make_pair(out.tx, out.i));
|
||||
}
|
||||
return (nValueRet >= nTargetValue);
|
||||
|
||||
@@ -160,7 +160,11 @@ public:
|
||||
// Transaction hash
|
||||
uint256 hash;
|
||||
// Index into CTransaction.vjoinsplit
|
||||
#ifdef __APPLE__
|
||||
uint64_t js;
|
||||
#else
|
||||
size_t js;
|
||||
#endif
|
||||
// Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS
|
||||
uint8_t n;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user