Merge pull request #26 from jl777/dev

update dev
This commit is contained in:
ca333
2018-04-24 18:06:36 +02:00
committed by GitHub
22 changed files with 306 additions and 162 deletions

112
README.md
View File

@@ -1,38 +1,46 @@
## Komodo with Bitcore
This version of Komodo contains Bitcore support for komodo and all its assetchains.
## Komodod
This software is Komodo client, generally you will use this if you want to mine KMD or setup a full node.
It downloads and stores the entire history of Komodo transactions; depending on the speed of your computer and network connection, the synchronization process could take a day or more once the blockchain has reached a significant size.
## Development Resources
- Komodo Web: [https://komodoplatform.com/](https://komodoplatform.com/)
- Organization web: [https://www.supernet.org](https://www.supernet.org)
- Forum: [https://forum.supernet.org/](https://forum.supernet.org/)
- Mail: [info@supernet.org](mailto:info@supernet.org)
- Support & Guides: [https://support.supernet.org/support/home](https://support.supernet.org/support/home)
- Organization web: [https://komodoplatform.com/](https://komodoplatform.com/)
- Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/)
- Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com)
- Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home)
- Knowledgebase & How-to: [https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages](https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages)
- API references: [http://docs.supernet.org/](http://docs.supernet.org/) #Not up to date.
- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf)
- Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0)
## List of Komodo Platform Technologies
Delayed Proof of Work (dPoW) - Additional security layer.
zk-SNARKs - Komodo Platform's privacy technology
Jumblr - Decentralized tumbler for KMD and other cryptocurrencies
Assetchains - Easy way to fork Komodo coin
Pegged Assets - Chains that maintain a peg to fiat currencies
Peerchains - Scalability solution where sibling chains form a network of blockchains
More in depth covered [here](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0)
Also note you receive 5% APR on your holdings.
[See this article for more details](https://supernet.org/en/resources/articles/receive-free-coins-quaranteed-kmd-interest)
- Delayed Proof of Work (dPoW) - Additional security layer.
- zk-SNARKs - Komodo Platform's privacy technology
- Jumblr - Decentralized tumbler for KMD and other cryptocurrencies
- Assetchains - Easy way to fork Komodo coin
- Pegged Assets - Chains that maintain a peg to fiat currencies
- Peerchains - Scalability solution where sibling chains form a network of blockchains
- More in depth covered [here](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0)
- Also note you receive 5% APR on your holdings.
[See this article for more details](https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages/20480015/Claim+KMD+Interest+in+Agama)
## Tech Specification
Max Supply: 200 million KMD.
Block Time: 1M 2s
Block Reward: 3KMD
Mining Algorithm: Equihash
- Max Supply: 200 million KMD.
- Block Time: 1M 2s
- Block Reward: 3KMD
- Mining Algorithm: Equihash
## About this Project
Komodo is based on Zcash and has been by our innovative consensus algorithm called dPoW which utilizes Bitcoin's hashrate to store Komodo blockchain information into the Bitcoin blockchain. Other new and native Komodo features are the privacy technology called JUMBLR or our assetchain capabilities (one click plug and play blockchain solutions). More details are available under https://komodoplatform.com/.
## Getting started
Dependencies
------------
```
```shell
#The following packages are needed:
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-openssl-dev bsdmainutils automake curl
```
@@ -54,7 +62,7 @@ dPoW branch: autobuild into GUI installers, unix, osx, windows
beta branch: notary nodes, command line unix
dev branch: bleeding edge, possibly wont even compile, multiple updates per hour
```
```shell
git clone https://github.com/jl777/komodo
cd komodo
#you might want to: git checkout <branch>; git pull
@@ -64,7 +72,6 @@ cd komodo
#This can take some time.
```
**komodo is experimental and a work-in-progress.** Use at your own risk.
Deprecation Policy
@@ -76,11 +83,14 @@ time after this one year period. The automatic feature is based on block
height and can be explicitly disabled.
# to update an existing version, git checkout dPoW if not on that branch already
# to update an existing version, `git checkout dPoW` if not on that branch already
```shell
git pull
./zcutil/fetch-params.sh
./zcutil/build.sh -j8
To reset the blockchain, from ~/.komodo rm -rf blocks chainstate debug.log komodostate db.log
```
To reset the blockchain, from *~/.komodo* `rm -rf blocks chainstate debug.log komodostate db.log`
Create komodo.conf
------------------
@@ -105,7 +115,7 @@ addnode=89.248.166.91
Start mining
------------
```
```shell
#iguana documentation shows how to get the btcpubkey and wifstrs that need to be used
#bitcoin also need to be installed with txindex=1 and with rpc enabled
cd ~
@@ -136,59 +146,89 @@ Both komodod and komodo-cli recognize -ac_name=option so you can create fork fro
```
=======
**Zcash is unfinished and highly experimental.** Use at your own risk.
Where do I begin?
-----------------
We have a guide for joining the main Zcash network:
https://github.com/zcash/zcash/wiki/1.0-User-Guide
### Need Help?
* See the documentation at the [Zcash Wiki](https://github.com/zcash/zcash/wiki)
for help and more information.
* Ask for help on the [Zcash](https://forum.z.cash/) forum.
Participation in the Zcash project is subject to a
[Code of Conduct](code_of_conduct.md).
Building
--------
Build Zcash along with most dependencies from source by running
./zcutil/build.sh. Currently only Linux is officially supported.
`./zcutil/build.sh`. Currently only Linux is officially supported.
License
-------
For license information see the file [COPYING](COPYING).
NOTE TO EXCHANGES:
**NOTE TO EXCHANGES:**
https://bitcointalk.org/index.php?topic=1605144.msg17732151#msg17732151
There is a small chance that an outbound transaction will give an error due to mismatched values in wallet calculations. There is a -exchange option that you can run komodod with, but make sure to have the entire transaction history under the same -exchange mode. Otherwise you will get wallet conflicts.
To change modes:
a) backup all privkeys (launch komodod with -exportdir=<path> and dumpwallet)
b) start a totally new sync including wallet.dat, launch with same exportdir
c) stop it before it gets too far and import all the privkeys from a) using komodo-cli importwallet filename
**To change modes:**
a) backup all privkeys (launch komodod with `-exportdir=<path>` and `dumpwallet`)
b) start a totally new sync including `wallet.dat`, launch with same `exportdir`
c) stop it before it gets too far and import all the privkeys from a) using `komodo-cli importwallet filename`
d) resume sync till it gets to chaintip
For example:
```shell
./komodod -exportdir=/tmp &
./komodo-cli dumpwallet example
./komodo-cli stop
mv ~/.komodo ~/.komodo.old && mkdir ~/.komodo && cp ~/.komodo.old/komodo.conf ~/.komodo.old/peers.dat ~/.komodo
./komodod -exchange -exportdir=/tmp &
./komodo-cli importwallet /tmp/example
############## JUMBLR
komodod now has jumblr_deposit and jumblr_secret RPC calls.
```
## JUMBLR
komodod now has `jumblr_deposit` and `jumblr_secret` RPC calls.
Jumblr works like described previously where all the nodes with jumblr active synchronize their tx activity during the same block to maximize the mixing effect. However, unlike all other mixers/tumblers, you never give up control of your coins to anybody else. JUMBLR uses a one to many allocation of funds, ie. one deposit address and many secret addresses. You can always run multiple komodod daemons to get multiple active deposit addresses.
JUMBLR implements t -> z, z -> z and z -> t transactions to maximize privacy of the destination t (transparent) address. So while it is transparent, its first activity is funds coming from an untracable z address.
Which of the three stages is done is randomly selected at each turn. Also when there is more than one possible transaction at the selected stage, a random one is selected. This randomization prevents analyzing incoming z ->t transactions by its size to correlate it to the originating address.
jumblr_deposit <depositaddr> designates the deposit address as the jumblr deposit address for that session. You can select an address that already has funds in it and it will immediately start jumblr process. If there are no funds, it will wait until you send funds to it.
There are three sizes of a jumblr transaction: 10 KMD, 100 KMD and 1000 KMD. There is also a fixed interval of blocks where all jumblr nodes are active. Currently it is set to be 10, but this is subject to change. Only during every 10*10 blocks are the largest 1000 KMD transactions processed, so this concentrates all the large transactions every N*N blocks.
jumblr_secret <secretaddress> notifies JUMBLR where to send the final z -> t transactions. In order to allow larger accounts to obtain privacy, up to 777 secret addresses are supported. Whenever a z -> t stage is activated, a random secret address from the list of the then active secret addresses is selected.
Practical Advice:
`jumblr_deposit <depositaddr>` designates the deposit address as the jumblr deposit address for that session. You can select an address that already has funds in it and it will immediately start jumblr process. If there are no funds, it will wait until you send funds to it.
There are three sizes of a jumblr transaction: 10 KMD, 100 KMD and 1000 KMD. There is also a fixed interval of blocks where all jumblr nodes are active. Currently it is set to be 10, but this is subject to change. Only during every 10*10 blocks are the largest 1000 KMD transactions processed, so this concentrates all the large transactions every N*N blocks.
`jumblr_secret <secretaddress>` notifies JUMBLR where to send the final z -> t transactions. In order to allow larger accounts to obtain privacy, up to 777 secret addresses are supported. Whenever a z -> t stage is activated, a random secret address from the list of the then active secret addresses is selected.
#### Practical Advice:
Obtaining privacy used to be very difficult. JUMBLR makes it as simple as issuing two command line calls. Higher level layers can be added to help manage the addresses, ie. linking them at the passphrase level. Such matters are left to each implementation.
Once obtained, it is very easy to lose all the privacy. With a single errant transaction that combines some previously used address and the secretaddress, well, the secretaddress is no longer so private.
The advice is to setup a totally separate node!
This might seem a bit drastic, but if you want to maintain privacy, it is best to make it look like all the transactions are coming from a different node. The easiest way for most people to do this is to actually have a different node.
It can be a dedicated laptop (recommended) or a VPS (for smaller amounts) with a totally fresh komodod wallet. Generate an address on this wallet and use that as the jumblr_secret address on your main node. As the JUMBLR operates funds will teleport into your secret node's address. If you are careful and never use the same IP address for both your nodes, you will be able to maintain very good privacy.
It can be a dedicated laptop (recommended) or a VPS (for smaller amounts) with a totally fresh komodod wallet. Generate an address on this wallet and use that as the jumblr_secret address on your main node. As the JUMBLR operates funds will teleport into your secret node's address. If you are careful and never use the same IP address for both your nodes, you will be able to maintain very good privacy.
Of course, don't send emails that link the two accounts together! Dont use secret address funds for home delivery purchases! Etc. There are many ways to lose the privacy, just think about what linkages can be dont at the IP and blockchain level and that should be a useful preparation.
What if you have 100,000 KMD and you dont want others to know you are such a whale?
Instead of generating 1 secret address, generate 100 and make a script file with:
```shell
./komodo-cli jumblr_secret <addr0>
./komodo-cli jumblr_secret <addr1>
...
./komodo-cli jumblr_secret <addr99>
```
And make sure to delete all traces of this when the JUMBLR is finished. You will end up with 100 addresses that have an average of 1000 KMD each. So as long as you are careful and dont do a 10,000 KMD transaction (that will link 10 of your secret addresses together), you can appear as 100 different people each with 1000 KMD.

View File

@@ -202,7 +202,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
{
std::string host = GetArg("-rpcconnect", "127.0.0.1");
int port = GetArg("-rpcport", BaseParams().RPCPort());
BITCOIND_PORT = port;
BITCOIND_RPCPORT = port;
// Obtain event base
raii_event_base base = obtain_event_base();

View File

@@ -79,7 +79,7 @@ void *chainparams_commandline(void *ptr);
#include "komodo_defs.h"
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern uint16_t ASSETCHAINS_PORT;
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAIN_INIT;
extern uint32_t ASSETCHAINS_MAGIC;
extern uint64_t ASSETCHAINS_SUPPLY;
@@ -209,7 +209,7 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat
void *chainparams_commandline(void *ptr)
{
CChainParams::CCheckpointData checkpointData;
while ( ASSETCHAINS_PORT == 0 )
while ( ASSETCHAINS_P2PPORT == 0 )
{
#ifdef _WIN32
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
@@ -217,15 +217,17 @@ void *chainparams_commandline(void *ptr)
sleep(1);
#endif
}
//fprintf(stderr,">>>>>>>> port.%u\n",ASSETCHAINS_PORT);
//fprintf(stderr,">>>>>>>> port.%u\n",ASSETCHAINS_P2PPORT);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
mainParams.SetDefaultPort(ASSETCHAINS_PORT);
mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT);
if ( ASSETCHAINS_RPCPORT == 0 )
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
mainParams.pchMessageStart[0] = ASSETCHAINS_MAGIC & 0xff;
mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff;
mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff;
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: port.%u/%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
checkpointData = //(Checkpoints::CCheckpointData)
{

View File

@@ -11,7 +11,7 @@
#include "chainparams.h"
static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
void EnforceNodeDeprecation(int nHeight, bool forceLogging) {

View File

@@ -22,6 +22,7 @@ public:
MOCK_CONST_METHOD0(GetRejectReason, std::string());
};
int32_t futureblock;
TEST(CheckBlock, VersionTooLow) {
auto verifier = libzcash::ProofVerifier::Strict();
@@ -30,7 +31,7 @@ TEST(CheckBlock, VersionTooLow) {
MockCValidationState state;
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "version-too-low", false)).Times(1);
EXPECT_FALSE(CheckBlock(0,0,block, state, verifier, false, false));
EXPECT_FALSE(CheckBlock(&futureblock,0,0,block, state, verifier, false, false));
}
@@ -230,4 +231,4 @@ TEST(ContextualCheckBlock, BlockOverwinterRulesRejectSproutTx) {
// Revert to default
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT);
}
}

View File

@@ -504,7 +504,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32];
memset(&hash,0,sizeof(hash));
sprintf(params,"[%d]",height);
if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,BITCOIND_PORT)) != 0 )
if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,BITCOIND_RPCPORT)) != 0 )
{
if ( (result= cJSON_Parse(jsonstr)) != 0 )
{
@@ -1035,7 +1035,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
cmptime -= 16000;
if ( (int64_t)tx.nLockTime < cmptime-3600 )
{
if ( tx.nLockTime != 1477258935 || dispflag != 0 )
if ( tx.nLockTime != 1477258935 && dispflag != 0 )
{
fprintf(stderr,"komodo_validate_interest.%d reject.%d [%d] locktime %u cmp2.%u\n",dispflag,txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,cmptime);
}

View File

@@ -51,13 +51,13 @@ std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY;
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096];
uint16_t ASSETCHAINS_PORT;
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
uint32_t ASSETCHAINS_MAGIC = 2387029918;
uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10;
uint32_t KOMODO_INITDONE;
char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_PORT = 7771;
char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;
uint64_t PENDING_KOMODO_TX;
extern int32_t KOMODO_LOADINGBLOCKS;

View File

@@ -83,7 +83,7 @@ char *jumblr_importaddress(char *address)
{
char params[1024];
sprintf(params,"[\"%s\", \"%s\", false]",address,address);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"importaddress",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"importaddress",params,BITCOIND_RPCPORT));
}
char *jumblr_validateaddress(char *addr)
@@ -91,7 +91,7 @@ char *jumblr_validateaddress(char *addr)
char params[1024];
sprintf(params,"[\"%s\"]",addr);
printf("validateaddress.%s\n",params);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"validateaddress",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"validateaddress",params,BITCOIND_RPCPORT));
}
int32_t Jumblr_secretaddrfind(char *searchaddr)
@@ -222,28 +222,28 @@ char *jumblr_zgetnewaddress()
{
char params[1024];
sprintf(params,"[]");
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getnewaddress",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getnewaddress",params,BITCOIND_RPCPORT));
}
char *jumblr_zlistoperationids()
{
char params[1024];
sprintf(params,"[]");
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listoperationids",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listoperationids",params,BITCOIND_RPCPORT));
}
char *jumblr_zgetoperationresult(char *opid)
{
char params[1024];
sprintf(params,"[[\"%s\"]]",opid);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getoperationresult",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getoperationresult",params,BITCOIND_RPCPORT));
}
char *jumblr_zgetoperationstatus(char *opid)
{
char params[1024];
sprintf(params,"[[\"%s\"]]",opid);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getoperationstatus",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getoperationstatus",params,BITCOIND_RPCPORT));
}
char *jumblr_sendt_to_z(char *taddr,char *zaddr,double amount)
@@ -253,7 +253,7 @@ char *jumblr_sendt_to_z(char *taddr,char *zaddr,double amount)
return(clonestr((char *)"{\"error\":\"illegal address in t to z\"}"));
sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",taddr,zaddr,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE);
printf("t -> z: %s\n",params);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_RPCPORT));
}
char *jumblr_sendz_to_z(char *zaddrS,char *zaddrD,double amount)
@@ -264,7 +264,7 @@ char *jumblr_sendz_to_z(char *zaddrS,char *zaddrD,double amount)
//sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddrS,zaddrD,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE);
sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddrS,zaddrD,amount-fee-JUMBLR_TXFEE,JUMBLR_TXFEE);
printf("z -> z: %s\n",params);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_RPCPORT));
}
char *jumblr_sendz_to_t(char *zaddr,char *taddr,double amount)
@@ -274,56 +274,56 @@ char *jumblr_sendz_to_t(char *zaddr,char *taddr,double amount)
return(clonestr((char *)"{\"error\":\"illegal address in z to t\"}"));
sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddr,taddr,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE);
printf("z -> t: %s\n",params);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_RPCPORT));
}
char *jumblr_zlistaddresses()
{
char params[1024];
sprintf(params,"[]");
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listaddresses",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listaddresses",params,BITCOIND_RPCPORT));
}
char *jumblr_zlistreceivedbyaddress(char *addr)
{
char params[1024];
sprintf(params,"[\"%s\", 1]",addr);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listreceivedbyaddress",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listreceivedbyaddress",params,BITCOIND_RPCPORT));
}
char *jumblr_getreceivedbyaddress(char *addr)
{
char params[1024];
sprintf(params,"[\"%s\", 1]",addr);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"getreceivedbyaddress",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"getreceivedbyaddress",params,BITCOIND_RPCPORT));
}
char *jumblr_importprivkey(char *wifstr)
{
char params[1024];
sprintf(params,"[\"%s\", \"\", false]",wifstr);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"importprivkey",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"importprivkey",params,BITCOIND_RPCPORT));
}
char *jumblr_zgetbalance(char *addr)
{
char params[1024];
sprintf(params,"[\"%s\", 1]",addr);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getbalance",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getbalance",params,BITCOIND_RPCPORT));
}
char *jumblr_listunspent(char *coinaddr)
{
char params[1024];
sprintf(params,"[1, 99999999, [\"%s\"]]",coinaddr);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"listunspent",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"listunspent",params,BITCOIND_RPCPORT));
}
char *jumblr_gettransaction(char *txidstr)
{
char params[1024];
sprintf(params,"[\"%s\", 1]",txidstr);
return(jumblr_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,BITCOIND_PORT));
return(jumblr_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,BITCOIND_RPCPORT));
}
int32_t jumblr_numvins(bits256 txid)

View File

@@ -1263,7 +1263,7 @@ void iguana_initQ(queue_t *Q,char *name)
free(item);
}
uint16_t komodo_userpass(char *username,char *password,FILE *fp)
uint16_t _komodo_userpass(char *username,char *password,FILE *fp)
{
char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0;
rpcuser = rpcpassword = 0;
@@ -1280,7 +1280,7 @@ uint16_t komodo_userpass(char *username,char *password,FILE *fp)
else if ( (str= strstr(line,(char *)"rpcport")) != 0 )
{
port = atoi(parse_conf_line(str,(char *)"rpcport"));
//printf("rpcport.%u in file\n",port);
//fprintf(stderr,"rpcport.%u in file\n",port);
}
}
if ( rpcuser != 0 && rpcpassword != 0 )
@@ -1333,11 +1333,11 @@ void komodo_statefname(char *fname,char *symbol,char *str)
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname);
}
void komodo_configfile(char *symbol,uint16_t port)
void komodo_configfile(char *symbol,uint16_t rpcport)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
if ( symbol != 0 && port != 0 )
if ( symbol != 0 && rpcport != 0 )
{
r = (uint32_t)time(NULL);
r2 = OS_milliseconds();
@@ -1354,7 +1354,7 @@ void komodo_configfile(char *symbol,uint16_t port)
sprintf(&password[i*2],"%02x",buf2[i]);
password[i*2] = 0;
sprintf(buf,"%s.conf",symbol);
BITCOIND_PORT = port;
BITCOIND_RPCPORT = rpcport;
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
#else
@@ -1365,7 +1365,7 @@ void komodo_configfile(char *symbol,uint16_t port)
#ifndef FROM_CLI
if ( (fp= fopen(fname,"wb")) != 0 )
{
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=256\nrpcallowip=127.0.0.1\n",crc,password,port);
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=256\nrpcallowip=127.0.0.1\n",crc,password,rpcport);
fclose(fp);
printf("Created (%s)\n",fname);
} else printf("Couldnt create (%s)\n",fname);
@@ -1373,7 +1373,7 @@ void komodo_configfile(char *symbol,uint16_t port)
}
else
{
komodo_userpass(myusername,mypassword,fp);
_komodo_userpass(myusername,mypassword,fp);
mapArgs["-rpcpassword"] = mypassword;
mapArgs["-rpcusername"] = myusername;
//fprintf(stderr,"myusername.(%s)\n",myusername);
@@ -1396,7 +1396,7 @@ void komodo_configfile(char *symbol,uint16_t port)
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
if ( (kmdport= komodo_userpass(username,password,fp)) != 0 )
if ( (kmdport= _komodo_userpass(username,password,fp)) != 0 )
KMD_PORT = kmdport;
sprintf(KMDUSERPASS,"%s:%s",username,password);
fclose(fp);
@@ -1420,12 +1420,11 @@ uint16_t komodo_userpass(char *userpass,char *symbol)
komodo_statefname(fname,symbol,confname);
if ( (fp= fopen(fname,"rb")) != 0 )
{
port = komodo_userpass(username,password,fp);
port = _komodo_userpass(username,password,fp);
sprintf(userpass,"%s:%s",username,password);
if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 )
strcpy(ASSETCHAINS_USERPASS,userpass);
fclose(fp);
return((int32_t)strlen(userpass));
}
return(port);
}
@@ -1503,7 +1502,7 @@ char *argv0names[] =
void komodo_args(char *argv0)
{
extern int64_t MAX_MONEY;
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; int32_t i,baseid,len,n,extralen = 0;
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0;
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 )
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
@@ -1581,7 +1580,7 @@ void komodo_args(char *argv0)
addn = GetArg("-seednode","");
if ( strlen(addn.c_str()) > 0 )
ASSETCHAINS_SEED = 1;
strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1);
strncpy(ASSETCHAINS_SYMBOL,name.c_str(),64);
if ( (baseid= komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 )
MAX_MONEY = komodo_maxallowed(baseid);
else if ( ASSETCHAINS_REWARD == 0 )
@@ -1589,7 +1588,7 @@ void komodo_args(char *argv0)
else MAX_MONEY = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY);
MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN;
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 )
{
fprintf(stderr,"waiting for datadir\n");
@@ -1604,11 +1603,14 @@ void komodo_args(char *argv0)
{
int32_t komodo_baseid(char *origbase);
extern int COINBASE_MATURITY;
komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1);
komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL);
if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 )
ASSETCHAINS_RPCPORT = port;
else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1);
COINBASE_MATURITY = 1;
//fprintf(stderr,"ASSETCHAINS_PORT %s %u (%s)\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_USERPASS);
//fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_RPCPORT);
}
if ( ASSETCHAINS_RPCPORT == 0 )
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
//ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
//komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());
iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
@@ -1619,7 +1621,7 @@ void komodo_args(char *argv0)
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");
fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146");
fclose(fp);
//printf("created (%s)\n",fname);
} else printf("error creating (%s)\n",fname);
@@ -1628,7 +1630,8 @@ void komodo_args(char *argv0)
else
{
char fname[512],username[512],password[4096]; int32_t iter; FILE *fp;
ASSETCHAINS_PORT = 8777;
ASSETCHAINS_P2PPORT = 7770;
ASSETCHAINS_RPCPORT = 7771;
for (iter=0; iter<2; iter++)
{
strcpy(fname,GetDataDir().string().c_str());
@@ -1653,7 +1656,7 @@ void komodo_args(char *argv0)
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
komodo_userpass(username,password,fp);
_komodo_userpass(username,password,fp);
sprintf(iter == 0 ? KMDUSERPASS : BTCUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
@@ -1662,8 +1665,11 @@ void komodo_args(char *argv0)
break;
}
}
BITCOIND_PORT = GetArg("-rpcport", BaseParams().RPCPort());
//fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT);
//fprintf(stderr,"(%s) port.%u chain params initialized\n",ASSETCHAINS_SYMBOL,BITCOIND_RPCPORT);
} else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort());
}
void komodo_nameset(char *symbol,char *dest,char *source)

View File

@@ -1294,10 +1294,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
COutPoint outpoint = tx.vin[i].prevout;
if (pool.mapNextTx.count(outpoint))
{
static uint32_t counter;
//static uint32_t counter;
// Disable replacement feature for now
//if ( counter++ < 100 )
fprintf(stderr,"Disable replacement feature for now\n");
//fprintf(stderr,"Disable replacement feature for now\n");
return false;
}
}
@@ -1665,7 +1665,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo
if (filein.IsNull())
{
//fprintf(stderr,"readblockfromdisk err A\n");
return false;//error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
}
// Read block
@@ -2583,11 +2583,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
}
auto verifier = libzcash::ProofVerifier::Strict();
auto disabledVerifier = libzcash::ProofVerifier::Disabled();
int32_t futureblock;
// Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in
if (!CheckBlock(pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck))
if (!CheckBlock(&futureblock,pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck) || futureblock != 0 )
{
fprintf(stderr,"checkblock failure in connectblock\n");
//fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock);
return false;
}
@@ -3317,8 +3317,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
pindexOldTip->phashBlock->GetHex(), pindexOldTip->nHeight, pindexOldTip->nChainWork.GetHex()) + "\n" +
"- " + strprintf(_("New tip: %s, height %d, work %s"),
pindexMostWork->phashBlock->GetHex(), pindexMostWork->nHeight, pindexMostWork->nChainWork.GetHex()) + "\n" +
"- " + strprintf(_("Fork point: %s, height %d"),
pindexFork->phashBlock->GetHex(), pindexFork->nHeight) + "\n\n" +
"- " + strprintf(_("Fork point: %s %s, height %d"),
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->nHeight) + "\n\n" +
_("Please help, human!");
LogPrintf("*** %s\n", msg);
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
@@ -3740,7 +3740,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
return true;
}
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
{
// Check timestamp
if ( 0 )
@@ -3758,9 +3758,26 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
fprintf(stderr," <- chainTip\n");
}
}
*futureblockp = 0;
if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60)
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
else if ( ASSETCHAINS_STAKED != 0 && pindex != 0 && pindex->pprev != 0 && pindex->nTime < pindex->pprev->nTime )
{
CBlockIndex *tipindex;
fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime());
if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetAdjustedTime() + 60 + 5 )
{
//fprintf(stderr,"it is the next block, let's wait for %d seconds\n",GetAdjustedTime() + 60 - blockhdr.GetBlockTime());
while ( blockhdr.GetBlockTime() > GetAdjustedTime() + 60 )
sleep(1);
//fprintf(stderr,"now its valid\n");
}
else
{
if (blockhdr.GetBlockTime() < GetAdjustedTime() + 600)
*futureblockp = 1;
return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
}
}
if ( ASSETCHAINS_STAKED != 0 && pindex != 0 && pindex->pprev != 0 && pindex->nTime <= pindex->pprev->nTime )
{
fprintf(stderr,"ht.%d %u vs ht.%d %u, is not monotonic\n",pindex->nHeight,pindex->nTime,pindex->pprev->nHeight,pindex->pprev->nTime);
return state.Invalid(error("CheckBlockHeader(): block timestamp needs to always increase"),REJECT_INVALID, "time-too-new");
@@ -3785,7 +3802,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime);
int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height);
bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
libzcash::ProofVerifier& verifier,
bool fCheckPOW, bool fCheckMerkleRoot)
{
@@ -3795,10 +3812,11 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
// Check that the header is valid (particularly PoW). This is mostly
// redundant with the call in AcceptBlockHeader.
if (!CheckBlockHeader(height,pindex,block,state,fCheckPOW))
if (!CheckBlockHeader(futureblockp,height,pindex,block,state,fCheckPOW))
{
//fprintf(stderr,"checkblockheader error PoW.%d\n",fCheckPOW);
return false;
if ( *futureblockp == 0 )
return false;
//else fprintf(stderr,"checkblockheader PoW.%d got futureblock\n",fCheckPOW);
}
if ( fCheckPOW )
{
@@ -3852,7 +3870,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
// Check transactions
BOOST_FOREACH(const CTransaction& tx, block.vtx)
{
if ( komodo_validate_interest(tx,height == 0 ? komodo_block2height((CBlock *)&block) : height,block.nTime,1) < 0 )
if ( komodo_validate_interest(tx,height == 0 ? komodo_block2height((CBlock *)&block) : height,block.nTime,0) < 0 )
return error("CheckBlock: komodo_validate_interest failed");
if (!CheckTransaction(tx, state, verifier))
return error("CheckBlock: CheckTransaction failed");
@@ -3974,10 +3992,15 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
return true;
}
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex)
//static uint256 komodo_requestedhash;
//static int32_t komodo_requestedcount;
bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex)
{
static uint256 zero;
const CChainParams& chainparams = Params();
AssertLockHeld(cs_main);
// Check for duplicate
uint256 hash = block.GetHash();
BlockMap::iterator miSelf = mapBlockIndex.find(hash);
@@ -3990,54 +4013,86 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
*ppindex = pindex;
if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK )
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
/*if ( pindex != 0 && hash == komodo_requestedhash )
{
fprintf(stderr,"AddToBlockIndex A komodo_requestedhash %s\n",komodo_requestedhash.ToString().c_str());
memset(&komodo_requestedhash,0,sizeof(komodo_requestedhash));
komodo_requestedcount = 0;
}*/
//if ( pindex == 0 )
// fprintf(stderr,"accepthdr %s already known but no pindex\n",hash.ToString().c_str());
return true;
}
if (!CheckBlockHeader(*ppindex!=0?(*ppindex)->nHeight:0,*ppindex, block, state,0))
if (!CheckBlockHeader(futureblockp,*ppindex!=0?(*ppindex)->nHeight:0,*ppindex, block, state,0))
{
//fprintf(stderr,"CheckBlockHeader failed\n");
return false;
if ( *futureblockp == 0 )
return false;
//else fprintf(stderr,"AcceptBlockHeader: CheckBlockHeader got future block\n");
}
// Get prev block index
CBlockIndex* pindexPrev = NULL;
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
if (hash != chainparams.GetConsensus().hashGenesisBlock)
{
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
if (mi == mapBlockIndex.end())
{
return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
//fprintf(stderr,"AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str());
/*if ( komodo_requestedhash == zero )
{
komodo_requestedhash = block.hashPrevBlock;
komodo_requestedcount = 0;
}*/
return(false);
//return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
}
pindexPrev = (*mi).second;
if (pindexPrev == 0 || (pindexPrev->nStatus & BLOCK_FAILED_MASK) )
if (pindexPrev == 0 )
{
/*fprintf(stderr,"AcceptBlockHeader failed no pindexPrev %s\n",block.hashPrevBlock.ToString().c_str());
if ( komodo_requestedhash == zero )
{
komodo_requestedhash = block.hashPrevBlock;
komodo_requestedcount = 0;
}*/
return(false);
}
if ( (pindexPrev->nStatus & BLOCK_FAILED_MASK) )
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
}
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
{
//fprintf(stderr,"ContextualCheckBlockHeader failed\n");
//fprintf(stderr,"AcceptBlockHeader ContextualCheckBlockHeader failed\n");
return false;
}
if (pindex == NULL)
{
if ( (pindex= AddToBlockIndex(block)) == 0 )
{
//fprintf(stderr,"couldnt add to block index\n");
fprintf(stderr,"AcceptBlockHeader couldnt add to block index\n");
}
}
if (ppindex)
*ppindex = pindex;
/*if ( pindex != 0 && hash == komodo_requestedhash )
{
fprintf(stderr,"AddToBlockIndex komodo_requestedhash %s\n",komodo_requestedhash.ToString().c_str());
memset(&komodo_requestedhash,0,sizeof(komodo_requestedhash));
komodo_requestedcount = 0;
}*/
return true;
}
bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp)
bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp)
{
const CChainParams& chainparams = Params();
AssertLockHeld(cs_main);
CBlockIndex *&pindex = *ppindex;
if (!AcceptBlockHeader(block, state, &pindex))
if (!AcceptBlockHeader(futureblockp,block, state, &pindex))
{
//fprintf(stderr,"AcceptBlockHeader rejected\n");
return false;
if ( *futureblockp == 0 )
return false;
//else fprintf(stderr,"AcceptBlock AcceptBlockHeader got future block\n");
}
if ( pindex == 0 )
{
@@ -4069,14 +4124,16 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
// See method docstring for why this is always disabled
auto verifier = libzcash::ProofVerifier::Disabled();
if ((!CheckBlock(pindex->nHeight,pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev))
if ((!CheckBlock(futureblockp,pindex->nHeight,pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev))
{
if (state.IsInvalid() && !state.CorruptionPossible()) {
pindex->nStatus |= BLOCK_FAILED_VALID;
setDirtyBlockIndex.insert(pindex);
}
//fprintf(stderr,"CheckBlock or ContextualCheckBlock failed\n");
return false;
if ( *futureblockp == 0 )
{
if (state.IsInvalid() && !state.CorruptionPossible()) {
pindex->nStatus |= BLOCK_FAILED_VALID;
setDirtyBlockIndex.insert(pindex);
}
return false;
} else fprintf(stderr,"CheckBlock or ContextualCheckBlock got futureblock\n");
}
int nHeight = pindex->nHeight;
@@ -4100,8 +4157,9 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
if (fCheckForPruning)
FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files
return true;
if ( *futureblockp == 0 )
return true;
else return false;
}
static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams)
@@ -4129,19 +4187,28 @@ CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash)
miSelf->second = AddToBlockIndex(*pblock);
//fprintf(stderr,"Block header %s is already known, but without pindex -> ensured %p\n",hash.ToString().c_str(),miSelf->second);
}
/*if ( hash != chainparams.GetConsensus().hashGenesisBlock )
{
miSelf = mapBlockIndex.find(pblock->hashPrevBlock);
if ( miSelf == mapBlockIndex.end() )
{
miSelf->second = InsertBlockIndex(pblock->hashPrevBlock);
fprintf(stderr,"autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str());
}
}*/
}
}
bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
{
// Preliminary checks
bool checked; uint256 hash;
bool checked; uint256 hash; int32_t futureblock=0;
auto verifier = libzcash::ProofVerifier::Disabled();
hash = pblock->GetHash();
//fprintf(stderr,"process newblock %s\n",hash.ToString().c_str());
//fprintf(stderr,"process newblock %s\n",hash.ToString().c_str());
if ( chainActive.Tip() != 0 )
komodo_currentheight_set(chainActive.Tip()->nHeight);
checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);
checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);
{
LOCK(cs_main);
bool fRequested = MarkBlockAsReceived(hash);
@@ -4151,7 +4218,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
checked = 0;
fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner && ASSETCHAINS_STAKED == 0);
}
if (!checked)
if (!checked && futureblock == 0)
{
if ( pfrom != 0 )
{
@@ -4165,17 +4232,17 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
// without the komodo_ensure call, it is quite possible to get a non-error but null pindex returned from AcceptBlockHeader. In a 2 node network, it will be a long time before that block is reprocessed. Even though restarting makes it rescan, it seems much better to keep the nodes in sync
komodo_ensure(pblock,hash);
}
bool ret = AcceptBlock(*pblock, state, &pindex, fRequested, dbp);
bool ret = AcceptBlock(&futureblock,*pblock, state, &pindex, fRequested, dbp);
if (pindex && pfrom) {
mapBlockSource[pindex->GetBlockHash()] = pfrom->GetId();
}
CheckBlockIndex();
if (!ret)
if (!ret && futureblock == 0)
return error("%s: AcceptBlock FAILED", __func__);
//else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev);
}
if (!ActivateBestChain(state, pblock))
if (futureblock == 0 && !ActivateBestChain(state, pblock))
return error("%s: ActivateBestChain failed", __func__);
return true;
@@ -4198,7 +4265,8 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
//fprintf(stderr,"TestBlockValidity failure A checkPOW.%d\n",fCheckPOW);
return false;
}
if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
int32_t futureblock;
if (!CheckBlock(&futureblock,indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
{
//fprintf(stderr,"TestBlockValidity failure B checkPOW.%d\n",fCheckPOW);
return false;
@@ -4214,7 +4282,8 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
return false;
}
assert(state.IsValid());
if ( futureblock != 0 )
return(false);
return true;
}
@@ -4608,7 +4677,8 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
if (!ReadBlockFromDisk(block, pindex,0))
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 1: verify block validity
if (nCheckLevel >= 1 && !CheckBlock(pindex->nHeight,pindex,block, state, verifier,0))
int32_t futureblock;
if (nCheckLevel >= 1 && !CheckBlock(&futureblock,pindex->nHeight,pindex,block, state, verifier,0) )
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 2: verify undo validity
if (nCheckLevel >= 2 && pindex) {
@@ -5837,7 +5907,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vector<CBlock> vHeaders;
int nLimit = MAX_HEADERS_RESULTS;
LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id);
if ( pfrom->lasthdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pfrom->lasthdrsreq != (int32_t)(pindex ? pindex->nHeight : -1) )
//if ( pfrom->lasthdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pfrom->lasthdrsreq != (int32_t)(pindex ? pindex->nHeight : -1) )// no need to ever suppress this
{
pfrom->lasthdrsreq = (int32_t)(pindex ? pindex->nHeight : -1);
for (; pindex; pindex = chainActive.Next(pindex))
@@ -5848,12 +5918,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
pfrom->PushMessage("headers", vHeaders);
}
else if ( NOTARY_PUBKEY33[0] != 0 )
/*else if ( NOTARY_PUBKEY33[0] != 0 )
{
static uint32_t counter;
if ( counter++ < 3 )
fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->nHeight : -1),pfrom->lasthdrsreq);
}
}*/
}
@@ -6017,12 +6087,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
Misbehaving(pfrom->GetId(), 20);
return error("non-continuous headers sequence");
}
int32_t futureblock;
//fprintf(stderr,"headers msg nCount.%d\n",(int32_t)nCount);
if (!AcceptBlockHeader(header, state, &pindexLast)) {
if (!AcceptBlockHeader(&futureblock,header, state, &pindexLast)) {
int nDoS;
if (state.IsInvalid(nDoS))
{
if (nDoS > 0)
if (nDoS > 0 && futureblock == 0)
Misbehaving(pfrom->GetId(), nDoS/nDoS);
return error("invalid header received");
}
@@ -6653,6 +6724,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
//
// Message: getdata (blocks)
//
static uint256 zero;
vector<CInv> vGetData;
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
vector<CBlockIndex*> vToDownload;
@@ -6671,7 +6743,21 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
}
}
}
/*CBlockIndex *pindex;
if ( komodo_requestedhash != zero && komodo_requestedcount < 16 && (pindex= mapBlockIndex[komodo_requestedhash]) != 0 )
{
LogPrint("net","komodo_requestedhash.%d request %s to nodeid.%d\n",komodo_requestedcount,komodo_requestedhash.ToString().c_str(),pto->GetId());
fprintf(stderr,"komodo_requestedhash.%d request %s to nodeid.%d\n",komodo_requestedcount,komodo_requestedhash.ToString().c_str(),pto->GetId());
vGetData.push_back(CInv(MSG_BLOCK, komodo_requestedhash));
MarkBlockAsInFlight(pto->GetId(), komodo_requestedhash, consensusParams, pindex);
komodo_requestedcount++;
if ( komodo_requestedcount > 16 )
{
memset(&komodo_requestedhash,0,sizeof(komodo_requestedhash));
komodo_requestedcount = 0;
}
}*/
//
// Message: getdata (non-blocks)
//

View File

@@ -796,8 +796,8 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false,bool fCheckPOW = false);
/** Context-independent validity checks */
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex,const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true);
bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true);
bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
libzcash::ProofVerifier& verifier,
bool fCheckPOW = true, bool fCheckMerkleRoot = true);
@@ -815,8 +815,8 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
* - The only caller of AcceptBlock verifies JoinSplit proofs elsewhere.
* If dbp is non-NULL, the file is known to already reside on disk
*/
bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex **pindex, bool fRequested, CDiskBlockPos* dbp);
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL);
bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, CBlockIndex **pindex, bool fRequested, CDiskBlockPos* dbp);
bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL);

View File

@@ -212,7 +212,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight))
continue;
if ( komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
{
//fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime);
continue;
@@ -463,7 +463,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 )
{
pblock->nTime = pindexPrev->nTime + 60;
while ( pblock->GetBlockTime() > GetAdjustedTime() + 60 )
while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 )
sleep(1);
//fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60));
}

View File

@@ -53,7 +53,7 @@ void TxConfirmStats::ClearCurrent(unsigned int nBlockHeight)
unsigned int TxConfirmStats::FindBucketIndex(double val)
{
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
auto it = bucketMap.lower_bound(val);
if ( it != bucketMap.end() )
{

View File

@@ -123,7 +123,7 @@ CBlockIndex *komodo_chainactive(int32_t height);
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
extern int32_t KOMODO_CHOSEN_ONE;
extern uint64_t ASSETCHAINS_STAKED;
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
#define KOMODO_ELECTION_GAP 2000
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);

View File

@@ -264,7 +264,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (wtx.IsCoinBase())
{
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
if ( ASSETCHAINS_SYMBOL[0] == 0 )
COINBASE_MATURITY = _COINBASE_MATURITY;
quint32 numBlocksToMaturity = COINBASE_MATURITY + 1;

View File

@@ -50,10 +50,10 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp);
uint32_t komodo_chainactive_timestamp();
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE;
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
#define KOMODO_VERSION "0.1.1"
extern uint16_t ASSETCHAINS_PORT;
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAINS_CC;
extern uint32_t ASSETCHAINS_MAGIC;
extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY;
@@ -155,10 +155,12 @@ UniValue getinfo(const UniValue& params, bool fHelp)
}
if ( ASSETCHAINS_CC != 0 )
obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC));
obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL));
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
obj.push_back(Pair("name", ASSETCHAINS_SYMBOL));
obj.push_back(Pair("port", ASSETCHAINS_PORT));
//obj.push_back(Pair("name", ASSETCHAINS_SYMBOL));
obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT));
obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT));
obj.push_back(Pair("magic", (int)ASSETCHAINS_MAGIC));
if ( ASSETCHAINS_SUPPLY != 0 )
obj.push_back(Pair("premine", ASSETCHAINS_SUPPLY));

View File

@@ -238,7 +238,7 @@ UniValue help(const UniValue& params, bool fHelp)
return tableRPC.help(strCommand);
}
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
UniValue stop(const UniValue& params, bool fHelp)
{

View File

@@ -315,7 +315,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
{
// Remove transactions spending a coinbase which are now immature
extern char ASSETCHAINS_SYMBOL[];
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
if ( ASSETCHAINS_SYMBOL[0] == 0 )
COINBASE_MATURITY = _COINBASE_MATURITY;
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
@@ -401,15 +401,20 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
}
}
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
void CTxMemPool::removeExpired(unsigned int nBlockHeight)
{
CBlockIndex *tipindex;
// Remove expired txs from the mempool
LOCK(cs);
list<CTransaction> transactionsToRemove;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++)
{
const CTransaction& tx = it->GetTx();
if (IsExpiredTx(tx, nBlockHeight)) {
tipindex = chainActive.Tip();
if (IsExpiredTx(tx, nBlockHeight) || (tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,1)) < 0)
{
transactionsToRemove.push_back(tx);
}
}

View File

@@ -644,9 +644,8 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
}
// If datadir is changed in .conf file:
ClearDatadirCache();
extern uint16_t BITCOIND_PORT;
BITCOIND_PORT = GetArg("-rpcport",BaseParams().RPCPort());
//fprintf(stderr,"from conf file %s RPC %u, used to be %u\n",ASSETCHAINS_SYMBOL,BITCOIND_PORT,BITCOIND_PORT);
extern uint16_t BITCOIND_RPCPORT;
BITCOIND_RPCPORT = GetArg("-rpcport",BaseParams().RPCPort());
}
#ifndef _WIN32

View File

@@ -257,4 +257,7 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
}
}
#define KOMODO_ASSETCHAIN_MAXLEN 65
#endif // BITCOIN_UTIL_H

View File

@@ -12,8 +12,8 @@
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint64_t ASSETCHAINS_SUPPLY;
uint16_t BITCOIND_PORT = 7771;
uint16_t ASSETCHAINS_PORT;
uint16_t BITCOIND_RPCPORT = 7771;
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
uint32_t ASSETCHAINS_MAGIC = 2387029918;

View File

@@ -10,7 +10,7 @@
#include "komodo_defs.h"
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint16_t BITCOIND_PORT = 7771;
uint16_t BITCOIND_RPCPORT = 7771;
uint32_t ASSETCHAINS_CC = 0;
using namespace libzcash;