From e0711243be9a647c7415c35034a79b07450369da Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Apr 2018 10:42:11 +0300 Subject: [PATCH 001/157] Return error instead of assert of prevhash is not best hash --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index f4a7eed43..08e161a19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2455,6 +2455,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); + if ( hashPrevBlock != view.GetBestBlock() ) + { + fprintf(stderr,"ConnectBlock(): hashPrevBlock != view.GetBestBlock()\n"); + return state.DoS(1, error("ConnectBlock(): hashPrevBlock != view.GetBestBlock()"), + REJECT_INVALID, "hashPrevBlock-not-bestblock"); + } assert(hashPrevBlock == view.GetBestBlock()); // Special case for the genesis block, skipping connection of its transactions From 9764030cd4d1201b9b3e1d390d318bc94b7971c1 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 21 Apr 2018 18:52:52 +0200 Subject: [PATCH 002/157] update librustzcash update librustzcash - experimental! --- depends/packages/librustzcash.mk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk index bfd8fef1e..3628bc48e 100644 --- a/depends/packages/librustzcash.mk +++ b/depends/packages/librustzcash.mk @@ -3,10 +3,9 @@ $(package)_version=0.1 $(package)_download_path=https://github.com/zcash/$(package)/archive/ $(package)_file_name=$(package)-$($(package)_git_commit).tar.gz $(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=a5760a90d4a1045c8944204f29fa2a3cf2f800afee400f88bf89bbfe2cce1279 -$(package)_git_commit=91348647a86201a9482ad4ad68398152dc3d635e -$(package)_dependencies=rust - +$(package)_sha256_hash=b63ba98d569d332764f27706038c04d03ac7e2c836dc15dc4eaa24b04b8c7f4a +$(package)_git_commit=6cc1813ae3bb1e42224fd8ca0a8977b95c576738 +$(package)_dependencies=rust $(rust_crates) ifeq ($(host_os),mingw32) define $(package)_build_cmds From 696460ce86a3567e7a951ac6e4090a5e66dc2823 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 21 Apr 2018 19:42:22 +0200 Subject: [PATCH 003/157] revert librustzcash update --- depends/packages/librustzcash.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk index 3628bc48e..20126776a 100644 --- a/depends/packages/librustzcash.mk +++ b/depends/packages/librustzcash.mk @@ -3,9 +3,9 @@ $(package)_version=0.1 $(package)_download_path=https://github.com/zcash/$(package)/archive/ $(package)_file_name=$(package)-$($(package)_git_commit).tar.gz $(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=b63ba98d569d332764f27706038c04d03ac7e2c836dc15dc4eaa24b04b8c7f4a -$(package)_git_commit=6cc1813ae3bb1e42224fd8ca0a8977b95c576738 -$(package)_dependencies=rust $(rust_crates) +$(package)_sha256_hash=a5760a90d4a1045c8944204f29fa2a3cf2f800afee400f88bf89bbfe2cce1279 +$(package)_git_commit=91348647a86201a9482ad4ad68398152dc3d635e +$(package)_dependencies=rust ifeq ($(host_os),mingw32) define $(package)_build_cmds From 3b2762ebc888986a21368d178afc00ca6557fd09 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 23 Apr 2018 10:59:16 +0300 Subject: [PATCH 004/157] Revert half the windows redundant header fix --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 08e161a19..bd684a6fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5564,7 +5564,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vector 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) ) { pfrom->lasthdrsreq = (int32_t)(pindex ? pindex->nHeight : -1); for (; pindex; pindex = chainActive.Next(pindex)) @@ -5575,12 +5575,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); - } + }*/ } From 460945fc9ee458e90c381840f53597255b591c28 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 15:03:02 +0300 Subject: [PATCH 005/157] Max future mined time -> 10 seconds --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 01817c759..7af581439 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -487,8 +487,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { pblock->nTime = pindexPrev->nTime + 60; - 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)); - while ( pblock->GetBlockTime() > GetAdjustedTime() + 60 ) + //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)); + while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) sleep(1); } pblock->nSolution.clear(); From 4a953920259963a621f5924a7da859b0fe25e5bd Mon Sep 17 00:00:00 2001 From: SHossain Date: Tue, 24 Apr 2018 13:08:32 +0100 Subject: [PATCH 006/157] Update README.md --- README.md | 110 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 74425bd3c..d39f83675 100644 --- a/README.md +++ b/README.md @@ -3,36 +3,43 @@ Komodo 1.0.15 ## 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 +61,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 ; git pull @@ -64,7 +71,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 +82,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 +114,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 +145,88 @@ 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= 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=` 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 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 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 ` 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 ` 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 ./komodo-cli jumblr_secret ... ./komodo-cli jumblr_secret +``` 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. From 12121008ff08179059c067496ae6de698780bbad Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 15:38:49 +0300 Subject: [PATCH 007/157] Add validate_interest expiration to mempool removeExpired --- src/txmempool.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 2dc9a4642..58cea060b 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -261,15 +261,20 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list } } +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 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); } } From 1d1c75f4f0f30c42fc44607e1b3fdf290585c5a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 21:57:30 +0300 Subject: [PATCH 008/157] Futureblock flag --- src/main.cpp | 6 +++++- src/main.h | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bd684a6fd..4f57483de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2449,9 +2449,13 @@ 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)) //!fJustCheck, !fJustCheck)) + if (!CheckBlock(&futureblock,pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck) || futureblock != 0 ) + { + //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); return false; + } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); diff --git a/src/main.h b/src/main.h index cb10e0168..5c7f5835c 100644 --- a/src/main.h +++ b/src/main.h @@ -450,8 +450,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); @@ -469,8 +469,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); From 3ae9dcb4c364a02c12db60abf89cf3c578da277b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:01:53 +0300 Subject: [PATCH 009/157] More future block --- src/main.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4f57483de..08669438e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3492,7 +3492,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 ) @@ -3510,9 +3510,30 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl fprintf(stderr," <- chainTip\n"); } } + *futureblockp = 0; if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) + { + 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; + LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); + } + } + /*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 ) + else*/ + 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"); @@ -3567,7 +3588,7 @@ int32_t komodo_reverify_blockcheck(CValidationState& state,int32_t height,CBlock return(0); } -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) { @@ -3746,7 +3767,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn return true; } -bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex) +bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex) { const CChainParams& chainparams = Params(); AssertLockHeld(cs_main); @@ -3796,7 +3817,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc 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); From af58b81e17be85d4ebf369083dc5a3d015a0d60e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:05:50 +0300 Subject: [PATCH 010/157] More --- src/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 08669438e..994f774dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3595,12 +3595,14 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C uint8_t pubkey33[33]; // These are checks that are independent of context. - // Check that the header is valid (particularly PoW). This is mostly - // redundant with the call in AcceptBlockHeader. - if (!CheckBlockHeader(height,pindex,block,state,fCheckPOW)) + // Check that the header is valid (particularly PoW). This is mostly redundant with the call in AcceptBlockHeader. + if (!CheckBlockHeader(futureblockp,height,pindex,block,state,fCheckPOW)) { - //fprintf(stderr,"checkblockheader error PoW.%d\n",fCheckPOW); - return false; + if ( *futureblockp == 0 ) + { + LogPrintf("CheckBlock header error"); + return false; + } } if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) ) return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution"); From 09a409ea91f985656192469f8070be7716425e97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:10:01 +0300 Subject: [PATCH 011/157] Accept block future block changes --- src/main.cpp | 98 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 24 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 994f774dd..002320365 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3771,51 +3771,93 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn 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); CBlockIndex *pindex = NULL; - if (miSelf != mapBlockIndex.end()) { + if (miSelf != mapBlockIndex.end()) + { // Block header is already known. pindex = miSelf->second; if (ppindex) *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 ) + { + LogPrintf("AcceptBlockHeader CheckBlockHeader error"); + return false; + } } // 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; + }*/ + LogPrintf("AcceptBlockHeader hashPrevBlock %s not found",block.hashPrevBlock.ToString().c_str()); + 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; + }*/ + LogPrintf("AcceptBlockHeader hashPrevBlock %s no pindexPrev",block.hashPrevBlock.ToString().c_str()); + 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"); + LogPrintf("AcceptBlockHeader ContextualCheckBlockHeader failed"); 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; } @@ -3825,14 +3867,17 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C 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 ) + { + LogPrintf("AcceptBlock AcceptBlockHeader error"); + return false; + } } if ( pindex == 0 ) { - //fprintf(stderr,"unexpected AcceptBlock error null pindex\n"); + LogPrintf("AcceptBlock null pindex error"); return false; } //fprintf(stderr,"acceptblockheader passed\n"); @@ -3846,10 +3891,11 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // blocks which are too close in height to the tip. Apply this test // regardless of whether pruning is enabled; it should generally be safe to // not process unrequested blocks. - bool fTooFarAhead = (pindex->nHeight > int(chainActive.Height() + MIN_BLOCKS_TO_KEEP)); + bool fTooFarAhead = (pindex->nHeight > int(chainActive.Height() + BLOCK_DOWNLOAD_WINDOW)); //MIN_BLOCKS_TO_KEEP)); // TODO: deal better with return value and error conditions for duplicate // and unrequested blocks. + //fprintf(stderr,"Accept %s flags already.%d requested.%d morework.%d farahead.%d\n",pindex->GetBlockHash().ToString().c_str(),fAlreadyHave,fRequested,fHasMoreWork,fTooFarAhead); if (fAlreadyHave) return true; if (!fRequested) { // If we didn't ask for it: if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned @@ -3859,18 +3905,20 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // 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); + if ( *futureblockp == 0 ) + { + if (state.IsInvalid() && !state.CorruptionPossible()) { + pindex->nStatus |= BLOCK_FAILED_VALID; + setDirtyBlockIndex.insert(pindex); + } + LogPrintf("AcceptBlock CheckBlock or ContextualCheckBlock error"); + return false; } - fprintf(stderr,"CheckBlock or ContextualCheckBlock failed\n"); - return false; } int nHeight = pindex->nHeight; - // Write block to history file try { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); @@ -3890,8 +3938,10 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if (fCheckForPruning) FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files - - return true; + if ( *futureblockp == 0 ) + return true; + LogPrintf("AcceptBlock block from future error"); + return false; } static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams) From d81711c3989f0d1dae99c22efaf38e0f48a35794 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:12:58 +0300 Subject: [PATCH 012/157] komodo_ensure, process/testblock --- src/main.cpp | 69 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 002320365..e05b074ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3958,21 +3958,49 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned void komodo_currentheight_set(int32_t height); -bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) +CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) +{ + CBlockIndex *pindex; + BlockMap::iterator miSelf = mapBlockIndex.find(hash); + if ( miSelf != mapBlockIndex.end() ) + { + if ( (pindex= miSelf->second) == 0 ) // create pindex so first Accept block doesnt fail + { + 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; + 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()); if ( chainActive.Tip() != 0 ) komodo_currentheight_set(chainActive.Tip()->nHeight); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0); - else 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(pblock->GetHash()); + bool fRequested = MarkBlockAsReceived(hash); fRequested |= fForceProcessing; - if (!checked) + if ( checked != 0 && komodo_checkPOW(from_miner && ASSETCHAINS_STAKED == 0,pblock,height) < 0 ) + { + checked = 0; + fprintf(stderr,"passed checkblock but failed checkPOW.%d\n",from_miner && ASSETCHAINS_STAKED == 0); + } + if (!checked && futureblock == 0) { if ( pfrom != 0 ) { @@ -3980,19 +4008,23 @@ bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBloc } return error("%s: CheckBlock FAILED", __func__); } - // Store to disk CBlockIndex *pindex = NULL; - bool ret = AcceptBlock(*pblock, state, &pindex, fRequested, dbp); + { + // 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(&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; @@ -4009,30 +4041,31 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex indexDummy.nHeight = pindexPrev->nHeight + 1; // JoinSplit proofs are verified in ConnectBlock auto verifier = libzcash::ProofVerifier::Disabled(); - // NOTE: CheckBlockHeader is called by CheckBlock if (!ContextualCheckBlockHeader(block, state, pindexPrev)) { - fprintf(stderr,"TestBlockValidity failure A\n"); + //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\n"); + //fprintf(stderr,"TestBlockValidity failure B checkPOW.%d\n",fCheckPOW); return false; } if (!ContextualCheckBlock(block, state, pindexPrev)) { - //fprintf(stderr,"TestBlockValidity failure C\n"); + //fprintf(stderr,"TestBlockValidity failure C checkPOW.%d\n",fCheckPOW); return false; } if (!ConnectBlock(block, state, &indexDummy, viewNew, true,fCheckPOW)) { - fprintf(stderr,"TestBlockValidity failure D\n"); + //fprintf(stderr,"TestBlockValidity failure D checkPOW.%d\n",fCheckPOW); return false; } assert(state.IsValid()); - + if ( futureblock != 0 ) + return(false); return true; } From ed5ef86613b684e68f79c923e258c8e44edcc29a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:15:42 +0300 Subject: [PATCH 013/157] komodo_POW --- src/main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e05b074ac..b04a2f074 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3592,7 +3592,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C libzcash::ProofVerifier& verifier, bool fCheckPOW, bool fCheckMerkleRoot) { - uint8_t pubkey33[33]; + uint8_t pubkey33[33]; uint256 hash; // These are checks that are independent of context. // Check that the header is valid (particularly PoW). This is mostly redundant with the call in AcceptBlockHeader. @@ -3604,11 +3604,26 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C return false; } } - if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) ) + if ( fCheckPOW ) + { + //if ( !CheckEquihashSolution(&block, Params()) ) + // return state.DoS(100, error("CheckBlock: Equihash solution invalid"),REJECT_INVALID, "invalid-solution"); + komodo_block2pubkey33(pubkey33,(CBlock *)&block); + if ( !CheckProofOfWork(height,pubkey33,hash,block.nBits,Params().GetConsensus(),block.nTime) ) + { + int32_t z; for (z=31; z>=0; z--) + fprintf(stderr,"%02x",((uint8_t *)&hash)[z]); + fprintf(stderr," failed hash ht.%d\n",height); + return state.DoS(50, error("CheckBlock: proof of work failed"),REJECT_INVALID, "high-hash"); + } + if ( komodo_checkPOW(1,(CBlock *)&block,height) < 0 ) // checks Equihash + return state.DoS(100, error("CheckBlock: failed slow_checkPOW"),REJECT_INVALID, "failed-slow_checkPOW"); + } + /*if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) ) return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution"); komodo_block2pubkey33(pubkey33,(CBlock *)&block); if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime) ) - return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash"); + return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash");*/ // Check the merkle root. if (fCheckMerkleRoot) { bool mutated; From b2b5381f521463467954abd33f842e2ee29f620a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:16:49 +0300 Subject: [PATCH 014/157] Add hash --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b04a2f074..a32f1d492 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3594,7 +3594,8 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { uint8_t pubkey33[33]; uint256 hash; // These are checks that are independent of context. - + hash = block.GetHash(); + // Check that the header is valid (particularly PoW). This is mostly redundant with the call in AcceptBlockHeader. if (!CheckBlockHeader(futureblockp,height,pindex,block,state,fCheckPOW)) { From 6bf62671eb8043b043a489f69eff109d1b4ddd58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:18:34 +0300 Subject: [PATCH 015/157] komodo_checkPOW functions --- src/komodo_bitcoind.h | 310 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 310 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3d569577f..37fc87150 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1031,3 +1031,313 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ return(0); } + +/* + komodo_checkPOW (fast) is called early in the process and should only refer to data immediately available. it is a filter to prevent bad blocks from going into the local DB. The more blocks we can filter out at this stage, the less junk in the local DB that will just get purged later on. + + komodo_checkPOW (slow) is called right before connecting blocks so all prior blocks can be assumed to be there and all checks must pass + + commission must be in coinbase.vout[1] and must be >= 10000 sats + PoS stake must be without txfee and in the last tx in the block at vout[0] + PoW mining on PoS chain must solve a harder diff that adjusts, but never less than KOMODO_POWMINMULT + */ +#define KOMODO_POWMINMULT 16 + +uint64_t komodo_commission(const CBlock *pblock) +{ + int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; + txn_count = pblock->vtx.size(); + for (i=0; ivtx[i].vout.size(); + for (j=0; jvtx[i].vout[j].nValue; + } + } + //fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN)); + commission = ((total * ASSETCHAINS_COMMISSION) / COIN); + if ( commission < 10000 ) + commission = 0; + return(commission); +} + +uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr) +{ + CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN; + txtime = komodo_txtime(&value,txid,vout,address); + if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) + return(0); + if ( (minage= nHeight*3) > 6000 ) + minage = 6000; + if ( blocktime < prevtime+57 ) + blocktime = prevtime+57; + if ( blocktime > txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) + { + vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); + segid = ((nHeight + addrhash.uints[0]) & 0x3f); + pasthash = pindex->GetBlockHash(); + memcpy(hashbuf,&pasthash,sizeof(pasthash)); + memcpy(&hashbuf[sizeof(pasthash)],&addrhash,sizeof(addrhash)); + vcalc_sha256(0,(uint8_t *)&hash,hashbuf,(int32_t)sizeof(uint256)*2); + //fprintf(stderr,"(%s) vs. (%s) %s %.8f txtime.%u\n",address,destaddr,hash.ToString().c_str(),dstr(value),txtime); + for (iter=0; iter<3600; iter++) + { + diff = (iter + blocktime - txtime - minage); + if ( diff > 3600*24 ) + break; + coinage = (value * diff) * ((diff >> 16) + 1); + hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); + if ( hashval <= bnTarget ) + { + winner = 1; + if ( validateflag == 0 ) + { + blocktime += iter; + blocktime += segid * 2; + } + break; + } + if ( validateflag != 0 ) + { + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," vs target "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d gap.%d %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,(int32_t)(blocktime - prevtime),dstr(value),(int32_t)diff); + break; + } + } + //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); + if ( 0 ) + { + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," vs "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,dstr(value),(int32_t)diff); + } + } + if ( nHeight < 2 ) + return(blocktime); + return(blocktime * winner); +} + +arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) +{ + CBlockIndex *pindex; arith_uint256 bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,ht,percPoS,diff,val; + *percPoSp = percPoS = 0; + if ( height < 3 ) + return(target); + sum = arith_uint256(0); + ave = sum; + for (i=n=0; i<100; i++) + { + ht = height - 100 + i; + if ( (pindex= komodo_chainactive(ht)) != 0 ) + { + bnTarget.SetCompact(pindex->nBits,&fNegative,&fOverflow); + bnTarget = (bnTarget / arith_uint256(KOMODO_POWMINMULT)); + hashval = UintToArith256(pindex->GetBlockHash()); + if ( hashval <= bnTarget ) // PoW is never as easy as PoS/64, some PoS will be counted as PoW + { + fprintf(stderr,"1"); + sum += hashval; + n++; + } + else + { + percPoS++; + fprintf(stderr,"0"); + } + if ( (i % 10) == 9 ) + fprintf(stderr," %d, ",percPoS); + } + } + fprintf(stderr," -> %d%% percPoS ht.%d\n",percPoS,height); + *percPoSp = percPoS; + target = (target / arith_uint256(KOMODO_POWMINMULT)); + if ( n > 0 ) + { + ave = (sum / arith_uint256(n)); + if ( ave > target ) + ave = target; + } else return(target); + if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget + { + bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256((goalperc) * (goalperc)); + /*if ( height > 1165 ) + { + if ( height > 1180 ) + { + if ( height > 1230 ) + bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256((goalperc) * (goalperc)); + else bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc); + } + else bnTarget = (ave * arith_uint256(goalperc * goalperc)) / arith_uint256(2 * (percPoS + goalperc) * (percPoS + goalperc)); + } else bnTarget = (ave * arith_uint256(goalperc)) / arith_uint256(percPoS + goalperc);*/ + if ( 1 ) + { + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); + fprintf(stderr," increase diff -> "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," floor diff "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&target)[i]); + fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); + } + } + else if ( percPoS > goalperc ) // decrease PoW diff -> raise bnTarget + { + bnTarget = ((ave * arith_uint256(goalperc)) + (target * arith_uint256(percPoS))) / arith_uint256(percPoS + goalperc); + if ( 1 ) + { + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); + fprintf(stderr," decrease diff -> "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," floor diff "); + for (i=31; i>=24; i--) + fprintf(stderr,"%02x",((uint8_t *)&target)[i]); + fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); + } + } + else bnTarget = ave; // recent ave is perfect + return(bnTarget); +} + +int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget) +{ + CBlockIndex *previndex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,txn_count,eligible,isPoS = 0; uint64_t value; CTxDestination voutaddress; + txn_count = pblock->vtx.size(); + if ( txn_count > 1 ) + { + if ( prevtime == 0 ) + { + if ( (previndex= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) + prevtime = (uint32_t)previndex->nTime; + } + txid = pblock->vtx[txn_count-1].vin[0].prevout.hash; + vout = pblock->vtx[txn_count-1].vin[0].prevout.n; + if ( prevtime != 0 ) + { + eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime,(char *)""); + if ( eligible == 0 || eligible > pblock->nTime ) + { + fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); + } else isPoS = 1; + } + else if ( slowflag == 0 ) // maybe previous block is not seen yet, do the best approx + { + txtime = komodo_txtime(&value,txid,vout,destaddr); + if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) + { + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[txn_count-1].vout[0].nValue == value ) + isPoS = 1; // close enough for a pre-filter + else fprintf(stderr,"komodo_is_PoSblock ht.%d (%s) != (%s) or %.8f != %.8f\n",height,destaddr,voutaddr,dstr(value),dstr(pblock->vtx[txn_count-1].vout[0].nValue)); + } else fprintf(stderr,"komodo_is_PoSblock ht.%d couldnt extract voutaddress\n",height); + } else return(-1); + } + return(isPoS); +} + +int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) +{ + uint256 hash; arith_uint256 bnTarget,bhash; bool fNegative,fOverflow; uint8_t *script,pubkey33[33],pubkeys[64][33]; int32_t i,possible,PoSperc,is_PoSblock=0,n,failed = 0,notaryid = -1; int64_t checktoshis,value; CBlockIndex *pprev; + if ( !CheckEquihashSolution(pblock, Params()) ) + { + fprintf(stderr,"komodo_checkPOW slowflag.%d ht.%d CheckEquihashSolution failed\n",slowflag,height); + return(-1); + } + hash = pblock->GetHash(); + bnTarget.SetCompact(pblock->nBits,&fNegative,&fOverflow); + bhash = UintToArith256(hash); + possible = komodo_block2pubkey33(pubkey33,pblock); + //fprintf(stderr,"height.%d slowflag.%d possible.%d cmp.%d\n",height,slowflag,possible,bhash > bnTarget); + if ( height == 0 ) + { + if ( slowflag != 0 ) + return(0); + if ( (pprev= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) + height = pprev->nHeight + 1; + if ( height == 0 ) + return(0); + } + if ( (ASSETCHAINS_SYMBOL[0] != 0 || height > 792000) && bhash > bnTarget ) + { + failed = 1; + if ( height > 0 && ASSETCHAINS_SYMBOL[0] == 0 ) // for the fast case + { + if ( (n= komodo_notaries(pubkeys,height,pblock->nTime)) > 0 ) + { + for (i=0; i= 2 ) // must PoS or have at least 16x better PoW + { + if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget)) == 0 ) + { + if ( ASSETCHAINS_STAKED == 100 && height > 100 ) // only PoS allowed! + return(-1); + else + { + if ( slowflag != 0 ) + bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + else bnTarget = (bnTarget / arith_uint256(KOMODO_POWMINMULT)); // lower bound + if ( bhash > bnTarget ) + { + for (i=31; i>=16; i--) + fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]); + fprintf(stderr," > "); + for (i=31; i>=16; i--) + fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); + fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED); + return(-1); + } + } + } else if ( is_PoSblock < 0 ) + return(-1); + } + if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) + { + checktoshis = komodo_commission(pblock); + if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) + return(-1); + else if ( checktoshis != 0 ) + { + script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + return(-1); + if ( pblock->vtx[0].vout[1].nValue != checktoshis ) + { + fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + return(-1); + } + } + } + //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); + if ( failed != 0 && possible == 0 && notaryid < 0 ) + return(-1); + else return(0); +} + + From 753b841f99650264f556516fa556ebf06823670e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:31:28 +0300 Subject: [PATCH 016/157] Move POW code around --- src/komodo_bitcoind.h | 6 +- src/komodo_gateway.h | 147 ------------------------------------------ src/main.cpp | 10 +-- 3 files changed, 11 insertions(+), 152 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 37fc87150..a7142de10 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -659,7 +659,7 @@ int32_t komodo_block2height(CBlock *block) return(height); } -void komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block) +int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block) { int32_t n; if ( KOMODO_LOADINGBLOCKS == 0 ) @@ -675,8 +675,12 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block) //komodo_init(0); n = block->vtx[0].vout[0].scriptPubKey.size(); if ( n == 35 ) + { memcpy(pubkey33,ptr+1,33); + return(1); + } } + return(0); } int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 72f36a21c..0f3baf50f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -650,153 +650,6 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) void komodo_passport_iteration(); -uint64_t komodo_commission(const CBlock &block) -{ - int32_t i,j,n=0,txn_count; uint64_t total = 0; - txn_count = block.vtx.size(); - for (i=0; i %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN)); - return((total * ASSETCHAINS_COMMISSION) / COIN); -} - -uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr) -{ - CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN; - txtime = komodo_txtime(&value,txid,vout,address); - if ( value == 0 || txtime == 0 ) - return(0); - if ( (minage= nHeight*3) > 6000 ) - minage = 6000; - if ( blocktime > txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) - { - vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); - segid = ((nHeight + addrhash.uints[0]) & 0x3f); - pasthash = pindex->GetBlockHash(); - memcpy(hashbuf,&pasthash,sizeof(pasthash)); - memcpy(&hashbuf[sizeof(pasthash)],&addrhash,sizeof(addrhash)); - vcalc_sha256(0,(uint8_t *)&hash,hashbuf,(int32_t)sizeof(uint256)*2); - //fprintf(stderr,"(%s) vs. (%s) %s %.8f txtime.%u\n",address,destaddr,hash.ToString().c_str(),dstr(value),txtime); - for (iter=0; iter<3600; iter++) - { - diff = (iter + blocktime - txtime - minage); - if ( diff > 3600*24 ) - break; - coinage = (value * diff) * ((diff >> 16) + 1); - hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); - if ( hashval <= bnTarget ) - { - winner = 1; - if ( validateflag == 0 ) - { - blocktime += iter; - blocktime += segid * 2; - } - break; - } - if ( validateflag != 0 ) - { - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs target "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d gap.%d %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,(int32_t)(blocktime - prevtime),dstr(value),(int32_t)diff); - break; - } - } - //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 0 ) - { - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u %.8f diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,dstr(value),(int32_t)diff); - } - } - if ( nHeight < 2 ) - return(blocktime); - return(blocktime * winner); -} - -#define KOMODO_POWMINMULT 16 -arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) -{ - CBlockIndex *pindex; arith_uint256 bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,ht,percPoS,diff; - *percPoSp = percPoS = 0; - sum = arith_uint256(0); - ave = sum; - for (i=n=0; i<100; i++) - { - ht = height - 100 + i; - if ( (pindex= komodo_chainactive(ht)) != 0 ) - { - bnTarget.SetCompact(pindex->nBits,&fNegative,&fOverflow); - bnTarget = (bnTarget / arith_uint256(KOMODO_POWMINMULT)); - hashval = UintToArith256(pindex->GetBlockHash()); - if ( hashval <= bnTarget ) // PoW is never as easy as PoS/64, some PoS will be counted as PoW - { - sum += hashval; - n++; - } else percPoS++; - } - } - *percPoSp = percPoS; - target = (target / arith_uint256(KOMODO_POWMINMULT)); - if ( n > 0 ) - { - ave = (sum / arith_uint256(n)); - if ( ave > target ) - ave = target; - } else return(target); - if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget - { - bnTarget = (ave * arith_uint256(goalperc)) / arith_uint256(percPoS + goalperc); - if ( 1 ) - { - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); - fprintf(stderr," increase diff -> "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," floor diff "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&target)[i]); - fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); - } - } - else if ( percPoS > goalperc ) // decrease PoW diff -> raise bnTarget - { - bnTarget = ((ave * arith_uint256(goalperc)) + (target * arith_uint256(percPoS))) / arith_uint256(percPoS + goalperc); - if ( 1 ) - { - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); - fprintf(stderr," decrease diff -> "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," floor diff "); - for (i=31; i>=24; i--) - fprintf(stderr,"%02x",((uint8_t *)&target)[i]); - fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); - } - } - else bnTarget = ave; // recent ave is perfect - return(bnTarget); -} - int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; diff --git a/src/main.cpp b/src/main.cpp index a32f1d492..b4f8ae091 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,7 +55,7 @@ CCriticalSection cs_main; extern uint8_t NOTARY_PUBKEY33[33]; extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN; int32_t KOMODO_NEWBLOCKS; -void komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); +int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); BlockMap mapBlockIndex; CChain chainActive; @@ -4473,7 +4473,8 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth if (!ReadBlockFromDisk(block, pindex)) 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) { @@ -5870,9 +5871,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("non-continuous headers sequence"); } - if (!AcceptBlockHeader(header, state, &pindexLast)) { + int32_t futureblock; + if (!AcceptBlockHeader(&futureblock,header, state, &pindexLast)) { int nDoS; - if (state.IsInvalid(nDoS)) + if (state.IsInvalid(nDoS) && futureblock == 0) { if (nDoS > 0) Misbehaving(pfrom->GetId(), nDoS/nDoS); From bab6d6ab0c9abe69abb267d8098eb17cc31dd53e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:32:56 +0300 Subject: [PATCH 017/157] Update check deposit code --- src/komodo_gateway.h | 57 ++------------------------------------------ 1 file changed, 2 insertions(+), 55 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0f3baf50f..ab114e892 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -707,7 +707,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( overflow != 0 || total > COIN/10 ) { - //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= activation ) return(-1); } @@ -720,65 +720,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } else { - if ( ASSETCHAINS_STAKED != 0 && height >= 2 ) - { - arith_uint256 bnTarget,hashval; int32_t PoSperc; bool fNegative,fOverflow; CBlockIndex *previndex; uint32_t eligible,isPoS = 0; - bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); - if ( txn_count > 1 ) - { - if ( prevtime == 0 ) - { - if ( (previndex= mapBlockIndex[block.hashPrevBlock]) != 0 ) - prevtime = (uint32_t)previndex->nTime; - } - eligible = komodo_stake(1,bnTarget,height,block.vtx[txn_count-1].vin[0].prevout.hash,block.vtx[txn_count-1].vin[0].prevout.n,block.nTime,prevtime,(char *)""); - if ( eligible == 0 || eligible > block.nTime ) - { - fprintf(stderr,"PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)block.nTime,(int32_t)(eligible - block.nTime)); - } else isPoS = 1; - } - if ( isPoS == 0 && height > 100 ) - { - if ( ASSETCHAINS_STAKED == 100 ) - { - fprintf(stderr,"ht.%d 100%% PoS after height 100 rule violated for -ac_staking=100\n",height); - return(-1); - } - // check PoW - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); - hashval = UintToArith256(block.GetHash()); - if ( hashval > bnTarget ) - { - /*for (i=31; i>=0; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," > "); - for (i=31; i>=0; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED);*/ - return(-1); - } - } - } - if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && block.vtx[0].vout.size() > 1 ) - { - script = (uint8_t *)block.vtx[0].vout[1].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) - return(-1); - if ( (checktoshis = komodo_commission(block)) != 0 ) - { - if ( block.vtx[0].vout[1].nValue != checktoshis ) - { - fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue)); - return(-1); - } else return(0); - } - } if ( overflow != 0 || total > 0 ) return(-1); } return(0); } -/* + /* //fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE); offset += komodo_scriptitemlen(&opretlen,&script[offset]); //printf("offset.%d opretlen.%d [%02x %02x %02x %02x]\n",offset,opretlen,script[0],script[1],script[2],script[3]); From b8d0ed28eacf064ae1c40ad1c213699fa252e795 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:37:06 +0300 Subject: [PATCH 018/157] Fix --- src/main.cpp | 2 +- src/miner.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b4f8ae091..a0fdd7c7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2608,7 +2608,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && block.vtx[0].vout.size() > 1 ) { uint64_t checktoshis; - if ( (checktoshis = komodo_commission(block)) != 0 ) + if ( (checktoshis= komodo_commission((const CBlock *)&block)) != 0 ) { if ( block.vtx[0].vout.size() == 2 && block.vtx[0].vout[1].nValue == checktoshis ) blockReward += checktoshis; diff --git a/src/miner.cpp b/src/miner.cpp index 7af581439..b79a1dccd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -119,7 +119,7 @@ int32_t komodo_is_issuer(); int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); int32_t komodo_isrealtime(int32_t *kmdheightp); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); -uint64_t komodo_commission(const CBlock &block); +uint64_t komodo_commission(const CBlock *block); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) @@ -454,7 +454,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) }*/ pblock->vtx[0] = txNew; - if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission(pblocktemplate->block)) != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock *)pblocktemplate->block)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From b04e28042ddca99fcc3fb8081f14f3fdd795dc38 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:38:24 +0300 Subject: [PATCH 019/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b79a1dccd..f29f18ccf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -454,7 +454,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) }*/ pblock->vtx[0] = txNew; - if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock *)pblocktemplate->block)) != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock *)&pblocktemplate->block)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From 70c6301c924bd7b332b501ac9782037cc2676eb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 22:58:35 +0300 Subject: [PATCH 020/157] Syntax --- src/main.cpp | 6 +++--- src/main.h | 2 +- src/miner.cpp | 2 +- src/rpcmining.cpp | 4 ++-- src/test/miner_tests.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a0fdd7c7b..537fbfae9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4809,7 +4809,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(0,state, NULL, &block, true, dbp)) + if (ProcessNewBlock(0,0,state, NULL, &block, true, dbp)) nLoaded++; if (state.IsError()) break; @@ -4831,7 +4831,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(0,dummy, NULL, &block, true, &it->second)) + if (ProcessNewBlock(0,0,dummy, NULL, &block, true, &it->second)) { nLoaded++; queue.push_back(block.GetHash()); @@ -5917,7 +5917,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(0,state, pfrom, &block, forceProcessing, NULL); + ProcessNewBlock(0,0,state, pfrom, &block, forceProcessing, NULL); int nDoS; if (state.IsInvalid(nDoS)) { pfrom->PushMessage("reject", strCommand, state.GetRejectCode(), diff --git a/src/main.h b/src/main.h index 5c7f5835c..0f1ad0d03 100644 --- a/src/main.h +++ b/src/main.h @@ -183,7 +183,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(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp); +bool ProcessNewBlock(int32_t from_miner,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) */ diff --git a/src/miner.cpp b/src/miner.cpp index f29f18ccf..8a56b72d1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -655,7 +655,7 @@ static bool ProcessBlockFound(CBlock* pblock) // Process this block the same as if we had received it from another node CValidationState state; - if (!ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL)) + if (!ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL)) return error("KomodoMiner: ProcessNewBlock, block not accepted"); TrackMinedBlock(pblock->GetHash()); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index d141c42c4..4bc37041a 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -267,7 +267,7 @@ UniValue generate(const UniValue& params, bool fHelp) } endloop: CValidationState state; - if (!ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL)) + if (!ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL)) throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted"); ++nHeight; blockHashes.push_back(pblock->GetHash().GetHex()); @@ -807,7 +807,7 @@ UniValue submitblock(const UniValue& params, bool fHelp) CValidationState state; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); - bool fAccepted = ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL); + bool fAccepted = ProcessNewBlock(1,0,chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL); UnregisterValidationInterface(&sc); if (fBlockPresent) { diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 9b8674f04..7866d3ac1 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) CValidationState state; - if (ProcessNewBlock(state, NULL, pblock, true, NULL) && state.IsValid()) { + if (ProcessNewBlock(1,0,state, NULL, pblock, true, NULL) && state.IsValid()) { goto foundit; } @@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) */ CValidationState state; - BOOST_CHECK(ProcessNewBlock(state, NULL, pblock, true, NULL)); + BOOST_CHECK(ProcessNewBlock(1,0,state, NULL, pblock, true, NULL)); BOOST_CHECK_MESSAGE(state.IsValid(), state.GetRejectReason()); pblock->hashPrevBlock = pblock->GetHash(); From 8a1b1894bca4c730457434ef8e1a3a801b93ffc7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 23:01:03 +0300 Subject: [PATCH 021/157] Test --- src/rpcmining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 4bc37041a..aea5694f2 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -807,7 +807,7 @@ UniValue submitblock(const UniValue& params, bool fHelp) CValidationState state; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); - bool fAccepted = ProcessNewBlock(1,0,chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL); + bool fAccepted = ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL); UnregisterValidationInterface(&sc); if (fBlockPresent) { From c1029e9df4e32c84e744a0a532b8a3edcf591e52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 23:07:12 +0300 Subject: [PATCH 022/157] Test --- src/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.h b/src/main.h index 0f1ad0d03..4035de136 100644 --- a/src/main.h +++ b/src/main.h @@ -183,7 +183,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(int32_t from_miner,int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp); +bool ProcessNewBlock(bool from_miner,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) */ From 9ffe5e947bd34404ca94930a30bac7339a757acf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 23:15:57 +0300 Subject: [PATCH 023/157] Latest pindex autocrat --- src/main.cpp | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 537fbfae9..71988b129 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3526,7 +3526,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, { if (blockhdr.GetBlockTime() < GetAdjustedTime() + 600) *futureblockp = 1; - LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + LogPrintf("CheckBlockHeader block from future %d error\n",blockhdr.GetBlockTime() - GetAdjustedTime()); return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); } } @@ -3601,7 +3601,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { if ( *futureblockp == 0 ) { - LogPrintf("CheckBlock header error"); + LogPrintf("CheckBlock header error\n"); return false; } } @@ -3817,7 +3817,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat { if ( *futureblockp == 0 ) { - LogPrintf("AcceptBlockHeader CheckBlockHeader error"); + LogPrintf("AcceptBlockHeader CheckBlockHeader error\n"); return false; } } @@ -3834,7 +3834,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat komodo_requestedhash = block.hashPrevBlock; komodo_requestedcount = 0; }*/ - LogPrintf("AcceptBlockHeader hashPrevBlock %s not found",block.hashPrevBlock.ToString().c_str()); + LogPrintf("AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str()); return(false); //return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk"); } @@ -3847,7 +3847,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat komodo_requestedhash = block.hashPrevBlock; komodo_requestedcount = 0; }*/ - LogPrintf("AcceptBlockHeader hashPrevBlock %s no pindexPrev",block.hashPrevBlock.ToString().c_str()); + LogPrintf("AcceptBlockHeader hashPrevBlock %s no pindexPrev\n",block.hashPrevBlock.ToString().c_str()); return(false); } if ( (pindexPrev->nStatus & BLOCK_FAILED_MASK) ) @@ -3856,7 +3856,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat if (!ContextualCheckBlockHeader(block, state, pindexPrev)) { //fprintf(stderr,"AcceptBlockHeader ContextualCheckBlockHeader failed\n"); - LogPrintf("AcceptBlockHeader ContextualCheckBlockHeader failed"); + LogPrintf("AcceptBlockHeader ContextualCheckBlockHeader failed\n"); return false; } if (pindex == NULL) @@ -3887,14 +3887,18 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C { if ( *futureblockp == 0 ) { - LogPrintf("AcceptBlock AcceptBlockHeader error"); + LogPrintf("AcceptBlock AcceptBlockHeader error\n"); return false; } } if ( pindex == 0 ) { - LogPrintf("AcceptBlock null pindex error"); - return false; + *ppindex = pindex = AddToBlockIndex(block); + if ( pindex == 0 ) + { + LogPrintf("AcceptBlock null pindex error\n"); + return false; + } } //fprintf(stderr,"acceptblockheader passed\n"); // Try to process all requested blocks that we don't have, but only @@ -3929,7 +3933,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C pindex->nStatus |= BLOCK_FAILED_VALID; setDirtyBlockIndex.insert(pindex); } - LogPrintf("AcceptBlock CheckBlock or ContextualCheckBlock error"); + LogPrintf("AcceptBlock CheckBlock or ContextualCheckBlock error\n"); return false; } } @@ -3956,7 +3960,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files if ( *futureblockp == 0 ) return true; - LogPrintf("AcceptBlock block from future error"); + LogPrintf("AcceptBlock block from future error\n"); return false; } @@ -3985,15 +3989,15 @@ 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()); - } - }*/ + if ( hash != Params().GetConsensus().hashGenesisBlock ) + { + miSelf = mapBlockIndex.find(pblock->hashPrevBlock); + if ( miSelf == mapBlockIndex.end() ) + { + miSelf->second = InsertBlockIndex(pblock->hashPrevBlock); + LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); + } + } } } From e0ed9dca91c48fa07e24fab56e0def411f9d8b85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 23:18:08 +0300 Subject: [PATCH 024/157] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 71988b129..9f5d23ff9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4233,7 +4233,7 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly) while ( fread(ignore,1,incr,file) == incr ) fprintf(stderr,"."); free(ignore); - fprintf(stderr,"blk.%d loaded %ld bytes set fpos.%ld loading.%d\n",(int)pos.nFile,(long)ftell(file),(long)fpos,KOMODO_LOADINGBLOCKS); + //fprintf(stderr,"blk.%d loaded %ld bytes set fpos.%ld loading.%d\n",(int)pos.nFile,(long)ftell(file),(long)fpos,KOMODO_LOADINGBLOCKS); } } fseek(file,fpos,SEEK_SET); From 12c4543d51ebacaae60824a54f394d091f3ec565 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 23:50:45 +0300 Subject: [PATCH 025/157] Fix komodo_ensure --- src/main.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9f5d23ff9..63afcc656 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3893,12 +3893,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } if ( pindex == 0 ) { - *ppindex = pindex = AddToBlockIndex(block); - if ( pindex == 0 ) - { - LogPrintf("AcceptBlock null pindex error\n"); - return false; - } + LogPrintf("AcceptBlock null pindex error\n"); + return false; } //fprintf(stderr,"acceptblockheader passed\n"); // Try to process all requested blocks that we don't have, but only @@ -3980,25 +3976,42 @@ void komodo_currentheight_set(int32_t height); CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) { - CBlockIndex *pindex; + CBlockIndex *pindex=0,*previndex=0; BlockMap::iterator miSelf = mapBlockIndex.find(hash); - if ( miSelf != mapBlockIndex.end() ) + if ( miSelf == mapBlockIndex.end() ) { - if ( (pindex= miSelf->second) == 0 ) // create pindex so first Accept block doesnt fail + pindex = InsertBlockIndex(hash); + LogPrintf("autocreate pindex %s\n",hash.ToString().c_str()); + } + if ( (miSelf= mapBlockIndex.find(hash)) != mapBlockIndex.end() ) + { + if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail { - 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 ( pindex == 0 ) + pindex = AddToBlockIndex(*pblock); + if ( pindex != 0 ) + { + miSelf->second = pindex; + LogPrintf("Block header %s is already known, but without pindex -> ensured %p\n",hash.ToString().c_str(),miSelf->second); + } else LogPrintf("komodo_ensure unexpected null pindex\n"); } if ( hash != Params().GetConsensus().hashGenesisBlock ) { miSelf = mapBlockIndex.find(pblock->hashPrevBlock); if ( miSelf == mapBlockIndex.end() ) + previndex = InsertBlockIndex(pblock->hashPrevBlock); + if ( (miSelf= mapBlockIndex.find(pblock->hashPrevBlock)) != mapBlockIndex.end() ) { - miSelf->second = InsertBlockIndex(pblock->hashPrevBlock); - LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); - } + if ( previndex == 0 ) + previndex = InsertBlockIndex(pblock->hashPrevBlock); + if ( previndex != 0 ) + { + miSelf->second = previndex; + LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); + } else LogPrintf("komodo_ensure unexpected null previndex\n"); + } else LogPrintf("komodo_ensure unexpected null miprev\n"); } - } + } else LogPrintf("komodo_ensure unexpected error creating pindex %s\n",hash.ToString().c_str()); } bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) From 223fbb65cb19d61e5facac30cdba280dd8f72aee Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 23:56:42 +0300 Subject: [PATCH 026/157] Fix komodo_ensure --- src/komodo_gateway.h | 2 +- src/main.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ab114e892..ce51746f7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1772,7 +1772,7 @@ void komodo_passport_iteration() if ( expired == 0 && KOMODO_PASSPORT_INITDONE == 0 ) { KOMODO_PASSPORT_INITDONE = 1; - printf("done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + printf("READY for RPC calls at %u! done PASSPORT %s refid.%d\n",(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid); } } diff --git a/src/main.cpp b/src/main.cpp index 63afcc656..214831fe7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4002,13 +4002,16 @@ CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) previndex = InsertBlockIndex(pblock->hashPrevBlock); if ( (miSelf= mapBlockIndex.find(pblock->hashPrevBlock)) != mapBlockIndex.end() ) { - if ( previndex == 0 ) - previndex = InsertBlockIndex(pblock->hashPrevBlock); - if ( previndex != 0 ) + if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail { - miSelf->second = previndex; - LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); - } else LogPrintf("komodo_ensure unexpected null previndex\n"); + if ( previndex == 0 ) + previndex = InsertBlockIndex(pblock->hashPrevBlock); + if ( previndex != 0 ) + { + miSelf->second = previndex; + LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); + } else LogPrintf("komodo_ensure unexpected null previndex\n"); + } } else LogPrintf("komodo_ensure unexpected null miprev\n"); } } else LogPrintf("komodo_ensure unexpected error creating pindex %s\n",hash.ToString().c_str()); From 6b619d6edfe755d53ba8e1a1a97474610597b37d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 00:20:58 +0300 Subject: [PATCH 027/157] Test --- src/main.cpp | 65 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 214831fe7..0653c6d59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3977,44 +3977,45 @@ void komodo_currentheight_set(int32_t height); CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) { CBlockIndex *pindex=0,*previndex=0; + if ( (pindex= mapBlockIndex[hash]) == 0 ) + pindex = InsertBlockIndex(hash); BlockMap::iterator miSelf = mapBlockIndex.find(hash); if ( miSelf == mapBlockIndex.end() ) { - pindex = InsertBlockIndex(hash); - LogPrintf("autocreate pindex %s\n",hash.ToString().c_str()); + LogPrintf("komodo_ensure unexpected missing hash %s\n",hash.ToString().c_str()); + return(0); } - if ( (miSelf= mapBlockIndex.find(hash)) != mapBlockIndex.end() ) + if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail { - if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail + if ( pindex == 0 ) + pindex = AddToBlockIndex(*pblock); + if ( pindex != 0 ) { - if ( pindex == 0 ) - pindex = AddToBlockIndex(*pblock); - if ( pindex != 0 ) - { - miSelf->second = pindex; - LogPrintf("Block header %s is already known, but without pindex -> ensured %p\n",hash.ToString().c_str(),miSelf->second); - } else LogPrintf("komodo_ensure unexpected null pindex\n"); - } - if ( hash != Params().GetConsensus().hashGenesisBlock ) - { - miSelf = mapBlockIndex.find(pblock->hashPrevBlock); - if ( miSelf == mapBlockIndex.end() ) - previndex = InsertBlockIndex(pblock->hashPrevBlock); - if ( (miSelf= mapBlockIndex.find(pblock->hashPrevBlock)) != mapBlockIndex.end() ) - { - if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail - { - if ( previndex == 0 ) - previndex = InsertBlockIndex(pblock->hashPrevBlock); - if ( previndex != 0 ) - { - miSelf->second = previndex; - LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); - } else LogPrintf("komodo_ensure unexpected null previndex\n"); - } - } else LogPrintf("komodo_ensure unexpected null miprev\n"); - } - } else LogPrintf("komodo_ensure unexpected error creating pindex %s\n",hash.ToString().c_str()); + miSelf->second = pindex; + LogPrintf("Block header %s is already known, but without pindex -> ensured %p\n",hash.ToString().c_str(),miSelf->second); + } else LogPrintf("komodo_ensure unexpected null pindex\n"); + } + /*if ( hash != Params().GetConsensus().hashGenesisBlock ) + { + miSelf = mapBlockIndex.find(pblock->hashPrevBlock); + if ( miSelf == mapBlockIndex.end() ) + previndex = InsertBlockIndex(pblock->hashPrevBlock); + if ( (miSelf= mapBlockIndex.find(pblock->hashPrevBlock)) != mapBlockIndex.end() ) + { + if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail + { + if ( previndex == 0 ) + previndex = InsertBlockIndex(pblock->hashPrevBlock); + if ( previndex != 0 ) + { + miSelf->second = previndex; + LogPrintf("autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); + } else LogPrintf("komodo_ensure unexpected null previndex\n"); + } + } else LogPrintf("komodo_ensure unexpected null miprev\n"); + } + }*/ + return(pindex); } bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) From 6fa7fd0c164fb6023fd8804275faadf97b95c664 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 00:35:20 +0300 Subject: [PATCH 028/157] Test --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0653c6d59..0fea9553a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3978,7 +3978,13 @@ CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) { CBlockIndex *pindex=0,*previndex=0; if ( (pindex= mapBlockIndex[hash]) == 0 ) - pindex = InsertBlockIndex(hash); + { + pindex = new CBlockIndex(); + if (!pindex) + throw runtime_error("komodo_ensure: new CBlockIndex failed"); + mi = mapBlockIndex.insert(make_pair(hash, pindexN)).first; + pindex->phashBlock = &((*mi).first); + } BlockMap::iterator miSelf = mapBlockIndex.find(hash); if ( miSelf == mapBlockIndex.end() ) { @@ -3988,7 +3994,10 @@ CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) if ( miSelf->second == 0 ) // create pindex so first Accept block doesnt fail { if ( pindex == 0 ) + { pindex = AddToBlockIndex(*pblock); + fprintf(stderr,"ensure call addtoblockindex, got %p\n",pindex); + } if ( pindex != 0 ) { miSelf->second = pindex; From 4cbd837c0b0b5343afbd32929384e279c379d2e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 00:40:07 +0300 Subject: [PATCH 029/157] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0fea9553a..a606d9c0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3982,7 +3982,7 @@ CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) pindex = new CBlockIndex(); if (!pindex) throw runtime_error("komodo_ensure: new CBlockIndex failed"); - mi = mapBlockIndex.insert(make_pair(hash, pindexN)).first; + mi = mapBlockIndex.insert(make_pair(hash, pindex)).first; pindex->phashBlock = &((*mi).first); } BlockMap::iterator miSelf = mapBlockIndex.find(hash); From 9a26ff906cd46925036ba9e44131207d4edf232a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 00:42:36 +0300 Subject: [PATCH 030/157] Test --- src/main.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a606d9c0b..182a2cfee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3982,7 +3982,7 @@ CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) pindex = new CBlockIndex(); if (!pindex) throw runtime_error("komodo_ensure: new CBlockIndex failed"); - mi = mapBlockIndex.insert(make_pair(hash, pindex)).first; + BlockMap::iterator mi = mapBlockIndex.insert(make_pair(hash, pindex)).first; pindex->phashBlock = &((*mi).first); } BlockMap::iterator miSelf = mapBlockIndex.find(hash); @@ -5732,12 +5732,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->PushMessage("headers", vHeaders); } - /*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); - }*/ } From cfd2492e38ea8b874a231c0cc1042f966e774a29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 00:49:55 +0300 Subject: [PATCH 031/157] Skip ensure --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 182a2cfee..95d15c8c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4056,6 +4056,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; + if ( 0 ) { // 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); From 537cfef7d9d0801802684e5c6714b2fa780ef461 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 00:59:58 +0300 Subject: [PATCH 032/157] +error --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 95d15c8c8..3351e77c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,7 +1603,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos) 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 From d60fb8fa36d569313217f930cf403bfe0b15dcd3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 01:10:52 +0300 Subject: [PATCH 033/157] Test --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3351e77c7..3f568df7c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3798,7 +3798,8 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat if (miSelf != mapBlockIndex.end()) { // Block header is already known. - pindex = miSelf->second; + if ( (pindex= miSelf->second) == 0 ) + pindex = AddToBlockIndex(block); if (ppindex) *ppindex = pindex; if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK ) From 695ffea8de213eeeea7fbf42bc5583e4826e6c10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 01:30:28 +0300 Subject: [PATCH 034/157] +ensure --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3f568df7c..e28f9a4c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4057,7 +4057,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; - if ( 0 ) + if ( 1 ) { // 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); From ab158faa6de1016a703ea4fb1ecdb09e8a72e672 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 01:49:01 +0300 Subject: [PATCH 035/157] Simplify ensure --- src/main.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e28f9a4c0..3563dc253 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3976,6 +3976,32 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned void komodo_currentheight_set(int32_t height); CBlockIndex *komodo_ensure(CBlock *pblock,uint256 hash) +{ + CBlockIndex *pindex; + BlockMap::iterator miSelf = mapBlockIndex.find(hash); + if ( miSelf != mapBlockIndex.end() ) + { + if ( (pindex= miSelf->second) == 0 ) // create pindex so first Accept block doesnt fail + { + 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 != Params().GetConsensus().hashGenesisBlock ) + { + miSelf = mapBlockIndex.find(pblock->hashPrevBlock); + if ( miSelf != mapBlockIndex.end() ) + { + if ( miSelf->second == 0 ) + { + miSelf->second = InsertBlockIndex(pblock->hashPrevBlock); + fprintf(stderr,"autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); + } + } + } + } +} + +CBlockIndex *oldkomodo_ensure(CBlock *pblock,uint256 hash) { CBlockIndex *pindex=0,*previndex=0; if ( (pindex= mapBlockIndex[hash]) == 0 ) @@ -4057,7 +4083,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; - if ( 1 ) + if ( 0 ) { // 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); From 27113a317e430deea764e880e6c947470adc4d03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 02:30:59 +0300 Subject: [PATCH 036/157] Miself update --- src/main.cpp | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3563dc253..95ecb37b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3799,19 +3799,11 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat { // Block header is already known. if ( (pindex= miSelf->second) == 0 ) - pindex = AddToBlockIndex(block); + miSelf->second = pindex = AddToBlockIndex(block); if (ppindex) *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(futureblockp,*ppindex!=0?(*ppindex)->nHeight:0,*ppindex, block, state,0)) @@ -3829,12 +3821,6 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock); if (mi == mapBlockIndex.end()) { - //fprintf(stderr,"AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str()); - /*if ( komodo_requestedhash == zero ) - { - komodo_requestedhash = block.hashPrevBlock; - komodo_requestedcount = 0; - }*/ LogPrintf("AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str()); return(false); //return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk"); @@ -3842,12 +3828,6 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat pindexPrev = (*mi).second; 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; - }*/ LogPrintf("AcceptBlockHeader hashPrevBlock %s no pindexPrev\n",block.hashPrevBlock.ToString().c_str()); return(false); } @@ -3862,19 +3842,16 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat } if (pindex == NULL) { - if ( (pindex= AddToBlockIndex(block)) == 0 ) + if ( (pindex= AddToBlockIndex(block)) != 0 ) { + miSelf = mapBlockIndex.find(hash); + if (miSelf != mapBlockIndex.end()) + miSelf->second = pindex; //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; } From 8771059f5b11291e3a609eb180488fb9f795456b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 02:32:54 +0300 Subject: [PATCH 037/157] Mi->second = index --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 95ecb37b6..8ab156077 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3336,7 +3336,8 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) pindexBestHeader = pindexNew; setDirtyBlockIndex.insert(pindexNew); - + mi->second = pindexNew; + return pindexNew; } From 9376e387dbacefe086f60e9f9a8bd57648fe6cbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 02:47:30 +0300 Subject: [PATCH 038/157] +ensure --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8ab156077..c7192673d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4061,7 +4061,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; - if ( 0 ) + if ( 1 ) { // 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); From 6cc888dd992bd9c3ebd2043dd63c61896f78b1f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 02:55:40 +0300 Subject: [PATCH 039/157] Set second --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c7192673d..af92dc85a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3312,8 +3312,10 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) uint256 hash = block.GetHash(); BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end()) - return it->second; - + { + if ( it->second != 0 ) + return it->second; + } // Construct new block index object CBlockIndex* pindexNew = new CBlockIndex(block); assert(pindexNew); From c9fbb1a741f9504a65da07d25ac3d4981e05736f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 03:00:53 +0300 Subject: [PATCH 040/157] Sync addtoblockindex --- src/main.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index af92dc85a..3a7bcdeba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3311,10 +3311,20 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) // Check for duplicate uint256 hash = block.GetHash(); BlockMap::iterator it = mapBlockIndex.find(hash); + BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock); if (it != mapBlockIndex.end()) { - if ( it->second != 0 ) + if ( it->second != 0 ) // vNodes.size() >= KOMODO_LIMITED_NETWORKSIZE, change behavior to allow komodo_ensure to work + { + // this is the strange case where somehow the hash is in the mapBlockIndex via as yet undetermined process, but the pindex for the hash is not there. Theoretically it is due to processing the block headers, but I have seen it get this case without having received it from the block headers or anywhere else... jl777 + //fprintf(stderr,"addtoblockindex already there %p\n",it->second); return it->second; + } + if ( miPrev != mapBlockIndex.end() && (*miPrev).second == 0 ) + { + //fprintf(stderr,"edge case of both block and prevblock in the strange state\n"); + return(0); // return here to avoid the state of pindex->nHeight not set and pprev NULL + } } // Construct new block index object CBlockIndex* pindexNew = new CBlockIndex(block); @@ -3325,11 +3335,11 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) pindexNew->nSequenceId = 0; BlockMap::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; pindexNew->phashBlock = &((*mi).first); - BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock); if (miPrev != mapBlockIndex.end()) { - pindexNew->pprev = (*miPrev).second; - pindexNew->nHeight = pindexNew->pprev->nHeight + 1; + if ( (pindexNew->pprev= (*miPrev).second) != 0 ) + pindexNew->nHeight = pindexNew->pprev->nHeight + 1; + else fprintf(stderr,"unexpected null pprev %s\n",hash.ToString().c_str()); pindexNew->BuildSkip(); } pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + GetBlockProof(*pindexNew); @@ -3338,8 +3348,8 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) pindexBestHeader = pindexNew; setDirtyBlockIndex.insert(pindexNew); + //fprintf(stderr,"added to block index %s %p\n",hash.ToString().c_str(),pindexNew); mi->second = pindexNew; - return pindexNew; } From 4add33cf7e98c0559cf1d5e75094e2ac16128db2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 29 Apr 2018 10:05:50 +0300 Subject: [PATCH 041/157] Restore LOCK cs_main in getinfo --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 079354a7b..0a413d52c 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -92,7 +92,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) //#ifdef ENABLE_WALLET // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); //#else -// LOCK(cs_main); + LOCK(cs_main); //#endif proxyType proxy; From 61a186ae07eb079e668f6eeefc8b31edff280d2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 29 Apr 2018 12:28:12 +0300 Subject: [PATCH 042/157] Create copy of fiat into ac so we can deprecate usage of fiat/* --- src/ac/axo | 2 ++ src/ac/beer | 2 ++ src/ac/bet | 2 ++ src/ac/bntn | 2 ++ src/ac/bots | 2 ++ src/ac/btch | 2 ++ src/ac/ceal | 2 ++ src/ac/chain | 2 ++ src/ac/coqui | 2 ++ src/ac/crypto | 2 ++ src/ac/dex | 2 ++ src/ac/etomic | 2 ++ src/ac/hodl | 2 ++ src/ac/jumblr | 2 ++ src/ac/kv | 2 ++ src/ac/mesh | 2 ++ src/ac/mgw | 2 ++ src/ac/mnz | 2 ++ src/ac/mshark | 2 ++ src/ac/ninja | 2 ++ src/ac/oot | 2 ++ src/ac/pangea | 2 ++ src/ac/pizza | 2 ++ src/ac/prlpay | 2 ++ src/ac/revs | 2 ++ src/ac/supernet | 2 ++ src/ac/vote2018 | 2 ++ src/ac/wlc | 2 ++ 28 files changed, 56 insertions(+) create mode 100755 src/ac/axo create mode 100755 src/ac/beer create mode 100755 src/ac/bet create mode 100755 src/ac/bntn create mode 100755 src/ac/bots create mode 100755 src/ac/btch create mode 100755 src/ac/ceal create mode 100755 src/ac/chain create mode 100755 src/ac/coqui create mode 100755 src/ac/crypto create mode 100755 src/ac/dex create mode 100755 src/ac/etomic create mode 100755 src/ac/hodl create mode 100755 src/ac/jumblr create mode 100755 src/ac/kv create mode 100755 src/ac/mesh create mode 100755 src/ac/mgw create mode 100755 src/ac/mnz create mode 100755 src/ac/mshark create mode 100755 src/ac/ninja create mode 100755 src/ac/oot create mode 100755 src/ac/pangea create mode 100755 src/ac/pizza create mode 100755 src/ac/prlpay create mode 100755 src/ac/revs create mode 100755 src/ac/supernet create mode 100755 src/ac/vote2018 create mode 100755 src/ac/wlc diff --git a/src/ac/axo b/src/ac/axo new file mode 100755 index 000000000..18d38cac0 --- /dev/null +++ b/src/ac/axo @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=AXO $1 $2 $3 $4 $5 $6 diff --git a/src/ac/beer b/src/ac/beer new file mode 100755 index 000000000..34317bb93 --- /dev/null +++ b/src/ac/beer @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BEER $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bet b/src/ac/bet new file mode 100755 index 000000000..ed99ce59f --- /dev/null +++ b/src/ac/bet @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BET $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bntn b/src/ac/bntn new file mode 100755 index 000000000..7ae6f4e8d --- /dev/null +++ b/src/ac/bntn @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bots b/src/ac/bots new file mode 100755 index 000000000..15c0fc288 --- /dev/null +++ b/src/ac/bots @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BOTS $1 $2 $3 $4 $5 $6 diff --git a/src/ac/btch b/src/ac/btch new file mode 100755 index 000000000..6a57ea8d1 --- /dev/null +++ b/src/ac/btch @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BTCH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ceal b/src/ac/ceal new file mode 100755 index 000000000..0cbeba67b --- /dev/null +++ b/src/ac/ceal @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CEAL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/chain b/src/ac/chain new file mode 100755 index 000000000..c55d30fbd --- /dev/null +++ b/src/ac/chain @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CHAIN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/coqui b/src/ac/coqui new file mode 100755 index 000000000..d4fcb63d5 --- /dev/null +++ b/src/ac/coqui @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=COQUI $1 $2 $3 $4 $5 $6 diff --git a/src/ac/crypto b/src/ac/crypto new file mode 100755 index 000000000..5a3d46188 --- /dev/null +++ b/src/ac/crypto @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 $5 $6 diff --git a/src/ac/dex b/src/ac/dex new file mode 100755 index 000000000..67331201a --- /dev/null +++ b/src/ac/dex @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=DEX $1 $2 $3 $4 $5 $6 diff --git a/src/ac/etomic b/src/ac/etomic new file mode 100755 index 000000000..76eb0191c --- /dev/null +++ b/src/ac/etomic @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ETOMIC $1 $2 $3 $4 $5 $6 diff --git a/src/ac/hodl b/src/ac/hodl new file mode 100755 index 000000000..a5430db59 --- /dev/null +++ b/src/ac/hodl @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=HODL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/jumblr b/src/ac/jumblr new file mode 100755 index 000000000..2969c5009 --- /dev/null +++ b/src/ac/jumblr @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 $5 $6 diff --git a/src/ac/kv b/src/ac/kv new file mode 100755 index 000000000..997fccb33 --- /dev/null +++ b/src/ac/kv @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=KV $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mesh b/src/ac/mesh new file mode 100755 index 000000000..19b359509 --- /dev/null +++ b/src/ac/mesh @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MESH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mgw b/src/ac/mgw new file mode 100755 index 000000000..9afa86b7a --- /dev/null +++ b/src/ac/mgw @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MGW $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mnz b/src/ac/mnz new file mode 100755 index 000000000..f4e1f3501 --- /dev/null +++ b/src/ac/mnz @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MNZ $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mshark b/src/ac/mshark new file mode 100755 index 000000000..1f0c950c6 --- /dev/null +++ b/src/ac/mshark @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MSHARK $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ninja b/src/ac/ninja new file mode 100755 index 000000000..f7722abb0 --- /dev/null +++ b/src/ac/ninja @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=NINJA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/oot b/src/ac/oot new file mode 100755 index 000000000..4c7c6b683 --- /dev/null +++ b/src/ac/oot @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=OOT $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pangea b/src/ac/pangea new file mode 100755 index 000000000..9920189ea --- /dev/null +++ b/src/ac/pangea @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pizza b/src/ac/pizza new file mode 100755 index 000000000..d8400d9d3 --- /dev/null +++ b/src/ac/pizza @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PIZZA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/prlpay b/src/ac/prlpay new file mode 100755 index 000000000..3d1063d13 --- /dev/null +++ b/src/ac/prlpay @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PRLPAY $1 $2 $3 $4 $5 $6 diff --git a/src/ac/revs b/src/ac/revs new file mode 100755 index 000000000..b898eb5dc --- /dev/null +++ b/src/ac/revs @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=REVS $1 $2 $3 $4 $5 $6 diff --git a/src/ac/supernet b/src/ac/supernet new file mode 100755 index 000000000..d841ffa0e --- /dev/null +++ b/src/ac/supernet @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 $5 $6 diff --git a/src/ac/vote2018 b/src/ac/vote2018 new file mode 100755 index 000000000..4e385d76f --- /dev/null +++ b/src/ac/vote2018 @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=VOTE2018 $1 $2 $3 $4 $5 $6 diff --git a/src/ac/wlc b/src/ac/wlc new file mode 100755 index 000000000..ef7c47b90 --- /dev/null +++ b/src/ac/wlc @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6 From 6494f040c52173fe6e05382437bd4e43750594af Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 29 Apr 2018 14:59:20 +0300 Subject: [PATCH 043/157] Redundant calls to dpow KMD --- src/dpowassets | 6 ++++-- src/komodo_notary.h | 12 ++++++------ src/miner.cpp | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/dpowassets b/src/dpowassets index 14bb39912..f00ade7f6 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -2,9 +2,10 @@ set -x source pubkey.txt echo $pubkey +sleep 3 +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" - -curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SUPERNET\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DEX\",\"pubkey\":\"$pubkey\"}" @@ -32,4 +33,5 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3c81f5115..25a03f83b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -142,7 +142,7 @@ const char *Notaries_elected1[][2] = {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, @@ -152,7 +152,7 @@ const char *Notaries_elected1[][2] = {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, - {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, + {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, @@ -162,7 +162,7 @@ const char *Notaries_elected1[][2] = {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, @@ -172,7 +172,7 @@ const char *Notaries_elected1[][2] = {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, - {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, + {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, @@ -182,7 +182,7 @@ const char *Notaries_elected1[][2] = {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, + {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, @@ -192,7 +192,7 @@ const char *Notaries_elected1[][2] = {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, diff --git a/src/miner.cpp b/src/miner.cpp index 59d1b8a11..aece99e38 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -845,8 +845,8 @@ void static BitcoinMiner() for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) break; - if ( externalflag == 0 && i != 66 ) - printf("VIOLATION at %d\n",i); + if ( externalflag == 0 && i != 66 && mids[i] >= 0 ) + printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); for (j=gpucount=0; j<65; j++) { if ( mids[j] >= 0 || notaryid == 34 ) From e4a383e340e1bf1ef0dc8e57d5a4c5b49f1f8d9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 00:36:12 +0300 Subject: [PATCH 044/157] Add notary 3 to recent miners print --- src/miner.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index aece99e38..71537bce9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -840,7 +840,7 @@ void static BitcoinMiner() if ( i == 33 ) externalflag = 1; else externalflag = 0; - if ( NOTARY_PUBKEY33[0] != 0 && (notaryid < 3 || notaryid == 34 || notaryid == 51 || notaryid == 52) ) + if ( NOTARY_PUBKEY33[0] != 0 ) { for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) @@ -849,9 +849,12 @@ void static BitcoinMiner() printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); for (j=gpucount=0; j<65; j++) { - if ( mids[j] >= 0 || notaryid == 34 ) - fprintf(stderr,"%d ",mids[j]); - else fprintf(stderr,"GPU "); + if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + { + if ( mids[j] >= 0 ) + fprintf(stderr,"%d ",mids[j]); + else fprintf(stderr,"GPU "); + } if ( mids[j] == -1 ) gpucount++; } From 2c7ba74d0eeb8a26547ce5ab1fd767505bc2a0f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 00:38:30 +0300 Subject: [PATCH 045/157] Fix --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 71537bce9..dace45ee4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -868,7 +868,8 @@ void static BitcoinMiner() roundrobin_delay += ((delta * i) / 64) - delta; //fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64); } - fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); + if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); } for (j=0; j<65; j++) if ( mids[j] == notaryid ) From 4fff8a632e7c4b80c7609fd2ea07fb106f579383 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 00:44:45 +0300 Subject: [PATCH 046/157] Add 56 and 57 for miners display --- src/miner.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index dace45ee4..b57144dbc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -831,6 +831,9 @@ void static BitcoinMiner() j = 65; if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { + int32_t dispflag = 0; + if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) { @@ -849,7 +852,7 @@ void static BitcoinMiner() printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); for (j=gpucount=0; j<65; j++) { - if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + if ( dispflag != 0 ) { if ( mids[j] >= 0 ) fprintf(stderr,"%d ",mids[j]); @@ -868,7 +871,7 @@ void static BitcoinMiner() roundrobin_delay += ((delta * i) / 64) - delta; //fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64); } - if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + if ( dispflag != 0 ) fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); } for (j=0; j<65; j++) From 8f2def7895ff75504a7c2b2800c21c5d3eb7979f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 11:49:03 +0300 Subject: [PATCH 047/157] Update display notary --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b57144dbc..445ea2dad 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -832,7 +832,7 @@ void static BitcoinMiner() if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) &¬aryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) From ea5071d27f11dc3cfa692794bd97b8e35c51c69b Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 1 May 2018 15:13:47 +0700 Subject: [PATCH 048/157] Reorder assetchain params for better readability --- src/assetchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 517687097..61eca28e0 100755 --- a/src/assetchains +++ b/src/assetchains @@ -21,7 +21,7 @@ function komodo_asset () supply=" " fi - $komodo_binary -pubkey=$pubkey -ac_name=$1 $supply -addnode=$seed_ip $gen $args & + $komodo_binary -ac_name=$1 $gen $supply $args -pubkey=$pubkey -addnode=$seed_ip & sleep $delay } From 8fc79ac9fb8808bbd3b88d70979a351983006733 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 13:18:19 +0300 Subject: [PATCH 049/157] Reduce miner created latency --- src/komodo.h | 3 ++- src/miner.cpp | 44 +++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 74c6e2010..5b2872946 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -680,7 +680,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); + if ( matched != 0 ) + printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); diff --git a/src/miner.cpp b/src/miner.cpp index 445ea2dad..8400e2a17 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -476,23 +476,25 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) UpdateTime(pblock, Params().GetConsensus(), pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); } + pblock->nSolution.clear(); + pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { pblock->nTime = pindexPrev->nTime + 60; - while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) - sleep(1); + //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)); } - pblock->nSolution.clear(); - pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - - CValidationState state; - if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) + else { - //static uint32_t counter; - //if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) - // fprintf(stderr,"warning: miner testblockvalidity failed\n"); - return(0); + CValidationState state; + if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) + { + //static uint32_t counter; + //if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) + // fprintf(stderr,"warning: miner testblockvalidity failed\n"); + return(0); + } } } @@ -788,7 +790,7 @@ void static BitcoinMiner() static uint32_t counter; if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) fprintf(stderr,"created illegal block, retry\n"); - sleep(3); + sleep(1); continue; } unique_ptr pblocktemplate(ptr); @@ -953,15 +955,6 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ - CValidationState state; - if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false)) - { - h = UintToArith256(B.GetHash()); - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&h)[z]); - fprintf(stderr," Invalid block mined, try again\n"); - return(false); - } if ( ASSETCHAINS_STAKED == 0 ) { if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) @@ -993,6 +986,15 @@ void static BitcoinMiner() fprintf(stderr," mined block!\n"); } } + CValidationState state; + if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false)) + { + h = UintToArith256(B.GetHash()); + for (z=31; z>=0; z--) + fprintf(stderr,"%02x",((uint8_t *)&h)[z]); + fprintf(stderr," Invalid block mined, try again\n"); + return(false); + } KOMODO_CHOSEN_ONE = 1; // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); From 82f1287731de001fc7807444291c81a2188e35c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 13:53:11 +0300 Subject: [PATCH 050/157] -prints --- src/komodo_events.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index c7e17ed54..53e72ae95 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -41,9 +41,9 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; - if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 800000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) + if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 814000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { - if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 800000 && counter++ < 10 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 814000 && counter++ < 10 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); } else if ( strcmp(symbol,coin) == 0 ) From 4f61808ffcfe1f2b3e248c30105fe2a48e0205d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 16:25:54 +0300 Subject: [PATCH 051/157] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ab27a998f..511a7413c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3766,7 +3766,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) { CBlockIndex *tipindex; - fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime()); + //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()); From eb1ba5a0fe930b05292f0164f53519db05fcbe8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 07:18:05 +0300 Subject: [PATCH 052/157] improve miner to reduce out of order timestamps --- src/dpowassets | 3 --- src/miner.cpp | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/dpowassets b/src/dpowassets index f00ade7f6..a144eab28 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -3,7 +3,6 @@ set -x source pubkey.txt echo $pubkey sleep 3 -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" @@ -33,5 +32,3 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" - diff --git a/src/miner.cpp b/src/miner.cpp index 8400e2a17..c46ade13d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) @@ -834,7 +834,7 @@ void static BitcoinMiner() if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) &¬aryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) ||notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 || notaryid == 62 ) dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) @@ -955,9 +955,19 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ + if ( B.nTime > GetAdjustedTime() ) + { + printf("need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); + while ( GetAdjustedTime() < B.nTime ) + sleep(1); + } if ( ASSETCHAINS_STAKED == 0 ) { - if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) + if ( NOTARY_PUBKEY33[0] != 0 ) + { + MilliSleep((rand() % 2700) + 1000); + } + /*if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) { //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+roundrobin_delay-time(NULL))); //int32_t nseconds = Mining_start+roundrobin_delay-time(NULL); @@ -968,13 +978,12 @@ void static BitcoinMiner() else if ( ASSETCHAINS_SYMBOL[0] != 0 ) { sleep(rand() % 30); - } + }*/ } else { if ( NOTARY_PUBKEY33[0] != 0 ) { - printf("need to wait %d seconds to submit staked block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) sleep(1); } From 97e9d76edcaf99a53897b0208fa0df9c3964d848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 07:19:10 +0300 Subject: [PATCH 053/157] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c46ade13d..e46756fa9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) @@ -957,7 +957,7 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( B.nTime > GetAdjustedTime() ) { - printf("need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); + fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) sleep(1); } From 6181f7d5bb090278859d7bc8c12f719828c20cc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 07:22:41 +0300 Subject: [PATCH 054/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e46756fa9..dfb12565d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -955,7 +955,7 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ - if ( B.nTime > GetAdjustedTime() ) + if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) From 4cc387ec2c414606e723915990c4591413f50425 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 08:44:03 +0300 Subject: [PATCH 055/157] Detect new block during wait --- src/miner.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index dfb12565d..2f7c3b1c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -959,7 +959,14 @@ void static BitcoinMiner() { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) + { sleep(1); + if ( chainActive.Tip()->nHeight >= Mining_height ) + { + fprintf(stderr,"new block arrived\n"); + return(false); + } + } } if ( ASSETCHAINS_STAKED == 0 ) { From 9bf6c59e33245d27895a04b6160a3b8e000d478b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 09:05:00 +0300 Subject: [PATCH 056/157] PoS mining latency fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 2f7c3b1c9..99e1dac83 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -421,7 +421,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); - while ( GetAdjustedTime()+30 < pblock->nTime ) + while ( 0 && GetAdjustedTime()+30 < pblock->nTime ) { sleep(30); fprintf(stderr,"%d ",(int32_t)(pblock->nTime - GetAdjustedTime())); From b92a8cd4bf62c46466b4508bafde3b675b881c93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 09:34:51 +0300 Subject: [PATCH 057/157] Block PoS miner, need to cache first timestamp --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 99e1dac83..2f7c3b1c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -421,7 +421,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); - while ( 0 && GetAdjustedTime()+30 < pblock->nTime ) + while ( GetAdjustedTime()+30 < pblock->nTime ) { sleep(30); fprintf(stderr,"%d ",(int32_t)(pblock->nTime - GetAdjustedTime())); From e7018d1da8dcc3e2b1a0240b0503d6899e283b84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 13:13:47 +0300 Subject: [PATCH 058/157] Exemption for TXSCL* --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5b2872946..ec1bc8013 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -615,7 +615,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr memset(&MoMoMdata,0,sizeof(MoMoMdata)); if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) notarized = 1; - if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("SCALE",ccdata.symbol,5) == 0 ) + if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 ) notarized = 1; if ( 0 && opretlen != 149 ) printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); From 98ec2dc219b153e0365a5d1b911ec8b97b510cd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 14:20:34 +0300 Subject: [PATCH 059/157] Add 1 second to timestamp to reduce diff growth --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 2f7c3b1c9..ac1116b4e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -480,7 +480,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { - pblock->nTime = pindexPrev->nTime + 60; + pblock->nTime = pindexPrev->nTime + 61; //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)); From be381f22ffe1b3748d1e6953a2f8a1e16b713fe0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 16:18:00 +0300 Subject: [PATCH 060/157] 65 seconds to slow down diff --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ac1116b4e..a62f39846 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -480,7 +480,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { - pblock->nTime = pindexPrev->nTime + 61; + pblock->nTime = pindexPrev->nTime + 65; //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)); From fb38b77469996d6f7e87121f3d96bf3929a309da Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 4 May 2018 17:39:21 +0300 Subject: [PATCH 061/157] Monthly cap --- src/komodo_interest.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 23ed985ca..8fd6becea 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -80,13 +80,15 @@ uint64_t komodo_moneysupply(int32_t height) } #endif -uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) +uint64_t _komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes; uint64_t interest = 0; if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= 60 ) { if ( minutes > 365 * 24 * 60 ) minutes = 365 * 24 * 60; + if ( txheight >= 1000000 && minutes > 31 * 24 * 60 ) + minutes = 31 * 24 * 60; minutes -= 59; interest = ((nValue / 10512000) * minutes); } @@ -97,7 +99,7 @@ uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime, { uint64_t interest = 0; if ( txheight < KOMODO_ENDOFERA && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) //komodo_moneysupply(txheight) < MAX_MONEY && - interest = _komodo_interestnew(nValue,nLockTime,tiptime); + interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); return(interest); } @@ -151,21 +153,21 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else if ( txheight < 1000000 ) { interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) printf("pathA current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } else if ( txheight < 1000000 ) { numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) printf("pathB current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } else { @@ -187,11 +189,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); //fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) fprintf(stderr,"pathC current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); From 57023d5b91caf5062ca9d1dcedf843edb95f4aa0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 4 May 2018 17:45:09 +0300 Subject: [PATCH 062/157] Monthly cap on active user reward --- src/komodo_interest.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 07b12cfe1..581592566 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -80,13 +80,15 @@ uint64_t komodo_moneysupply(int32_t height) } #endif -uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) +uint64_t _komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes; uint64_t interest = 0; if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= 60 ) { if ( minutes > 365 * 24 * 60 ) minutes = 365 * 24 * 60; + if ( txheight >= 1000000 && minutes > 31 * 24 * 60 ) + minutes = 31 * 24 * 60; minutes -= 59; interest = ((nValue / 10512000) * minutes); } @@ -97,7 +99,7 @@ uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime, { uint64_t interest = 0; if ( txheight < KOMODO_ENDOFERA && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) //komodo_moneysupply(txheight) < MAX_MONEY && - interest = _komodo_interestnew(nValue,nLockTime,tiptime); + interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); return(interest); } @@ -151,21 +153,21 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else if ( txheight < 1000000 ) { interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) printf("pathA current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } else if ( txheight < 1000000 ) { numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) printf("pathB current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } else { @@ -187,11 +189,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); //fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) fprintf(stderr,"pathC current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); From 38215324fe75fb4b9ae97e2ddbbc52408ae4e120 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 6 May 2018 20:08:56 +0300 Subject: [PATCH 063/157] Skip interest check for AC --- src/txmempool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index dd985f500..5fa19fb5f 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -413,7 +413,7 @@ void CTxMemPool::removeExpired(unsigned int nBlockHeight) { const CTransaction& tx = it->GetTx(); tipindex = chainActive.Tip(); - if (IsExpiredTx(tx, nBlockHeight) || (tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0) + if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0) { transactionsToRemove.push_back(tx); } From f839d3f52eda30d63b1a6161e601d88d6d24be19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 13:07:44 +0300 Subject: [PATCH 064/157] Fix --- src/txmempool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 5fa19fb5f..7a5110aa8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -402,6 +402,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list } int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); +extern char ASSETCHAINS_SYMBOL[]; void CTxMemPool::removeExpired(unsigned int nBlockHeight) { From 496f1fd267f31640680b2e5c2d8faeca5611d849 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 13:57:43 +0300 Subject: [PATCH 065/157] Test --- src/miner.cpp | 18 ++++++++--- src/wallet/rpcwallet.cpp | 68 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index a62f39846..e7062270a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -121,6 +121,7 @@ int32_t komodo_baseid(char *origbase); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); uint64_t komodo_commission(const CBlock *block); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); +int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { @@ -478,12 +479,19 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } pblock->nSolution.clear(); pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) { - pblock->nTime = pindexPrev->nTime + 65; - //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)); + CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); + if ( pblock->nTime < pindexPrev->nTime+60 ) + pblock->nTime = pindexPrev->nTime + 65; + if ( (siglen= komodo_notaryvin(txNotary,NOTARY_PUBKEY33)) > 0 ) + { + CAmount txfees = 0; + pblock->vtx.push_back(txNotary); + pblocktemplate->vTxFees.push_back(txfees); + pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); + nFees += txfees; + } } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 627ffe550..0ea12f63b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4465,6 +4465,74 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); extern std::string NOTARY_PUBKEY; uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 hash,int32_t n,uint32_t blocktime,uint32_t prevtime,char *destaddr); +int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) +{ + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + assert(pwalletMain != NULL); + LOCK2(cs_main, pwalletMain->cs_wallet); + utxovalue = 0; + memset(&utxotxid,0,sizeof(utxotxid)); + memset(&utxovout,0,sizeof(utxovout)); + memset(utxosig,0,sizeof(utxosig)); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) + continue; + if ( setAddress.size() ) + { + CTxDestination address; + if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + continue; + if (!setAddress.count(address)) + continue; + } + CAmount nValue = out.tx->vout[out.i].nValue; + const CScript& pk = out.tx->vout[out.i].scriptPubKey; + CTxDestination address; + if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + { + //entry.push_back(Pair("address", CBitcoinAddress(address).ToString())); + //if (pwalletMain->mapAddressBook.count(address)) + // entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); + } + script = (uint8_t *)out.tx->vout[out.i].scriptPubKey.data(); + if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 ) + continue; + utxovalue = (uint64_t)nValue; + decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxovout = out.i; + + bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; + auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); + const CKeyStore& keystore = *pwalletMain; + txNew.vin.resize(1); + txNew.vout.resize(1); + txfee = 0; + for (i=0; i<32; i++) + ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = revtxid; + txNew.vin[0].prevout.n = utxovout; + txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].nValue = utxovalue - txfee; + CTransaction txNewConst(txNew); + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); + if (!signSuccess) + fprintf(stderr,"notaryvin failed to create signature\n"); + else + { + UpdateTransaction(txNew,0,sigdata); + ptr = (uint8_t *)sigdata.scriptSig.data(); + siglen = sigdata.scriptSig.size(); + for (i=0; i setAddress; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; From a893e994999d2dee18802d7e158d192deedb179a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 13:59:44 +0300 Subject: [PATCH 066/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e7062270a..6063e2ea0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -484,7 +484,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) pblock->nTime = pindexPrev->nTime + 65; - if ( (siglen= komodo_notaryvin(txNotary,NOTARY_PUBKEY33)) > 0 ) + if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; pblock->vtx.push_back(txNotary); From 469e1de39f5dd8cdcc3c3b275efb38a3fa937e96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 14:04:18 +0300 Subject: [PATCH 067/157] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0ea12f63b..9abf741ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4468,7 +4468,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; - bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + bnTarget.SetCompact(KOMODO_MINDIFF_NBITS, &fNegative, &fOverflow); assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; From f8fb4922dafa66ba988ae7c76f216f13df7bb860 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 14:14:12 +0300 Subject: [PATCH 068/157] Test --- src/miner.cpp | 3 ++- src/wallet/rpcwallet.cpp | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6063e2ea0..e113571dd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - } + fprintf(stderr,"add notaryvin\n"); + } else fprintf(stderr,"error adding notaryvin\n"); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9abf741ff..fef435f1e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4467,8 +4467,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { - set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 bnTarget; bool fNegative,fOverflow; - bnTarget.SetCompact(KOMODO_MINDIFF_NBITS, &fNegative, &fOverflow); + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; From 39fefa6be968ca9da5a87e4171a4151cb3184837 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 14:34:20 +0300 Subject: [PATCH 069/157] Test --- src/wallet/rpcwallet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fef435f1e..f08368ba8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4488,6 +4488,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } CAmount nValue = out.tx->vout[out.i].nValue; + if ( nValue != 10000 ) + continue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; CTxDestination address; if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) @@ -4508,7 +4510,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) const CKeyStore& keystore = *pwalletMain; txNew.vin.resize(1); txNew.vout.resize(1); - txfee = 0; + txfee = utxovalue / 2;; for (i=0; i<32; i++) ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = revtxid; From c4eb1abbfcd68204d673dbb607686e36bbfcd3bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:12:34 +0300 Subject: [PATCH 070/157] Test --- src/wallet/rpcwallet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f08368ba8..e4a4f71e9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4500,10 +4500,14 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) } script = (uint8_t *)out.tx->vout[out.i].scriptPubKey.data(); if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 ) + { + fprintf(stderr,"scriptsize.%d [0] %02x\n",(int32_t)out.tx->vout[out.i].scriptPubKey.size(),script[0]); continue; + } utxovalue = (uint64_t)nValue; decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); utxovout = out.i; + fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue) bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From 0b18f1230c928223382963266c6c17c42028c821 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:16:20 +0300 Subject: [PATCH 071/157] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e4a4f71e9..7b2ebe31b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4507,7 +4507,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) utxovalue = (uint64_t)nValue; decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); utxovout = out.i; - fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue) + fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From ff1ee86e6ad9c22868cbff6a1ca525cc0101085a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:31:23 +0300 Subject: [PATCH 072/157] Test --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7b2ebe31b..499484b01 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4507,6 +4507,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) utxovalue = (uint64_t)nValue; decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); utxovout = out.i; + best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; @@ -4533,6 +4534,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) for (i=0; i Date: Mon, 7 May 2018 15:47:18 +0300 Subject: [PATCH 073/157] test --- src/coins.cpp | 1 + src/komodo_gateway.h | 13 ++++++++++--- src/main.cpp | 3 ++- src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 15 ++++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index bb40af9cc..ba55d174e 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -462,6 +462,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = AccessCoins(prevout.hash); if (!coins || !coins->IsAvailable(prevout.n)) { + fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str()); return false; } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7eb5d9ab8..dcb5d2483 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -683,18 +683,21 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } n = block.vtx[0].vout.size(); - script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); + //script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); //if ( n <= 2 || script[0] != 0x6a ) { - int64_t val,prevtotal = 0; int32_t overflow = 0; + int64_t val,strangeout=0,prevtotal = 0; int32_t overflow = 0; total = 0; for (i=1; i= MAX_MONEY ) { overflow = 1; break; } + if ( script[0] != 0x6a && val == 0 ) + strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) { @@ -719,10 +722,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } + if ( height > 800000 && strangeout != 0 ) + { + fprintf(stderr,"ht.%d strangout.%d\n",height,strangeout); + } } else { - if ( overflow != 0 || total > 0 ) + if ( overflow != 0 || total > 0 || strangeout != 0 ) return(-1); } return(0); diff --git a/src/main.cpp b/src/main.cpp index 511a7413c..cdb0b3f3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2684,9 +2684,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!tx.IsCoinBase()) { if (!view.HaveInputs(tx)) + { return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); - + } // are the JoinSplit's requirements met? if (!view.HaveJoinSplitRequirements(tx)) return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), diff --git a/src/miner.cpp b/src/miner.cpp index e113571dd..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - fprintf(stderr,"add notaryvin\n"); + //fprintf(stderr,"add notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 499484b01..673cca17a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4505,10 +4505,11 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); + //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); @@ -4516,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - for (i=0; i<32; i++) - ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; + //for (i=0; i<32; i++) + // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; @@ -4532,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 15:51:39 +0300 Subject: [PATCH 074/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dcb5d2483..e7048fd1f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -686,7 +686,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim //script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); //if ( n <= 2 || script[0] != 0x6a ) { - int64_t val,strangeout=0,prevtotal = 0; int32_t overflow = 0; + int64_t val,prevtotal = 0; int32_t strangeout=0,overflow = 0; total = 0; for (i=1; i Date: Mon, 7 May 2018 15:53:05 +0300 Subject: [PATCH 075/157] Test --- src/coins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coins.cpp b/src/coins.cpp index ba55d174e..42939ccac 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -462,7 +462,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = AccessCoins(prevout.hash); if (!coins || !coins->IsAvailable(prevout.n)) { - fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str()); + fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str(),prevout.n); return false; } } From 05f8c237675b028acaa94ba64af7cbf292be4706 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:07:04 +0300 Subject: [PATCH 076/157] Test --- src/komodo_events.h | 2 +- src/miner.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 53e72ae95..d3eab4902 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -48,7 +48,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig } else if ( strcmp(symbol,coin) == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 && verified != 0 ) + if ( 0 && NOTARY_PUBKEY33[0] != 0 && verified != 0 ) fprintf(stderr,"validated [%s] ht.%d notarized %d\n",coin,height,notarizedheight); memset(&N,0,sizeof(N)); N.blockhash = notarized_hash; diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..5c99f9537 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -893,6 +893,7 @@ void static BitcoinMiner() } else fprintf(stderr,"no nonz pubkeys\n"); if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > KOMODO_LASTMINED+64) ) { + pblock->nBits = KOMODO_MINDIFF_NBITS; HASHTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } //else fprintf(stderr,"duplicate at j.%d\n",j); From d6e4204114e2b8b4e8bdc68ffc91d276bebc07ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:10:45 +0300 Subject: [PATCH 077/157] Test --- src/miner.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5c99f9537..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -893,7 +893,6 @@ void static BitcoinMiner() } else fprintf(stderr,"no nonz pubkeys\n"); if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > KOMODO_LASTMINED+64) ) { - pblock->nBits = KOMODO_MINDIFF_NBITS; HASHTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } //else fprintf(stderr,"duplicate at j.%d\n",j); From 5ea06d80dee8a5d405c8d97730e37b3c85529d4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:11:07 +0300 Subject: [PATCH 078/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..0899f4396 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65; + pblock->nTime = pindexPrev->nTime + 65/2; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From 79e1814e1ce4311a4293281b70283ef66bd8530c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:11:30 +0300 Subject: [PATCH 079/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0899f4396..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65/2; + pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From bce6dbb37cba42550528b76ea95f3a2c03496e43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:20:13 +0300 Subject: [PATCH 080/157] Test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index bd2410616..817dcc1fe 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -202,7 +202,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int fprintf(stderr," hash vs "); for (i=31; i>=0; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," ht.%d special.%d notaryid.%d mod.%d error\n",height,special,notaryid,(height % 35)); + fprintf(stderr," ht.%d special.%d special2.%d flag.%d notaryid.%d mod.%d error\n",height,special,special2,flag,notaryid,(height % 35)); for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey33[i]); fprintf(stderr," <- pubkey\n"); From ff2277af4e685bf8b41c9093d11831792d58c9a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:25:44 +0300 Subject: [PATCH 081/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..0899f4396 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65; + pblock->nTime = pindexPrev->nTime + 65/2; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From f4eece4ae1d90343fb2264f65022c04b7f634069 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:26:03 +0300 Subject: [PATCH 082/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0899f4396..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65/2; + pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From e6a3570c42061be10166275e0f6ad8fbfe14d9e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 16:48:04 +0300 Subject: [PATCH 083/157] Test --- src/wallet/rpcwallet.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 673cca17a..8d1f0386e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4505,8 +4505,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); - utxotxid = out.tx->GetHash(); + decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + //utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); @@ -4517,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - //for (i=0; i<32; i++) - // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = utxotxid; //revtxid; + for (i=0; i<32; i++) + ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; From 6d04359865351b51983a757e842c4485a08cacf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:00:35 +0300 Subject: [PATCH 084/157] Test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8d1f0386e..fca98ef53 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:07:38 +0300 Subject: [PATCH 085/157] Test --- src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f8414cb19..07f5081e4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - //fprintf(stderr,"add notaryvin\n"); + fprintf(stderr,"added notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fca98ef53..c39b24b0b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4509,7 +4509,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) //utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); + fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From 0eb15e9463cc7ef0a158909133ad1979fb4e75d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:08:28 +0300 Subject: [PATCH 086/157] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c39b24b0b..730d592cf 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4509,7 +4509,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) //utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.c_str(),utxovout,(long long)utxovalue); + fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); From 1500012776d73a4c13382bcac2c0c37442697f03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:13:49 +0300 Subject: [PATCH 087/157] Test --- src/wallet/rpcwallet.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 730d592cf..58c19f4cd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4467,7 +4467,10 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { - set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid,revtxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; + bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; + auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); + const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); utxovalue = 0; @@ -4505,15 +4508,12 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); - //utxotxid = out.tx->GetHash(); + //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue); + //fprintf(stderr,"check %s/v%d %llu\n",(char *)utxotxid.GetHex().c_str(),utxovout,(long long)utxovalue); - bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; - auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - const CKeyStore& keystore = *pwalletMain; txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; @@ -4534,7 +4534,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:26:20 +0300 Subject: [PATCH 088/157] Test --- src/wallet/rpcwallet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 58c19f4cd..8894cefe5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4517,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - for (i=0; i<32; i++) - ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; + //for (i=0; i<32; i++) + // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; @@ -4534,7 +4534,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:39:01 +0300 Subject: [PATCH 089/157] Test --- src/komodo_gateway.h | 6 +++--- src/miner.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e7048fd1f..5a660ab33 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -696,7 +696,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim overflow = 1; break; } - if ( script[0] != 0x6a && val == 0 ) + if ( script[0] != 0x6a && val < 5000 ) strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) @@ -722,9 +722,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } - if ( height > 800000 && strangeout != 0 ) + if ( strangeout != 0 ) { - fprintf(stderr,"ht.%d strangout.%d\n",height,strangeout); + fprintf(stderr,">>>>>>>>>>>>> ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); } } else diff --git a/src/miner.cpp b/src/miner.cpp index 07f5081e4..eda55daa3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -482,8 +482,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 ) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); - if ( pblock->nTime < pindexPrev->nTime+60 ) - pblock->nTime = pindexPrev->nTime + 65; + if ( pblock->nTime < pindexPrev->nTime+65 ) + pblock->nTime = pindexPrev->nTime + 58;//65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - fprintf(stderr,"added notaryvin\n"); + //fprintf(stderr,"added notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8894cefe5..53ae9ddd7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4467,7 +4467,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { - set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid,revtxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; + set setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow; bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); const CKeyStore& keystore = *pwalletMain; @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 17:39:31 +0300 Subject: [PATCH 090/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index eda55daa3..466968e1b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -483,7 +483,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( pblock->nTime < pindexPrev->nTime+65 ) - pblock->nTime = pindexPrev->nTime + 58;//65; + pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { CAmount txfees = 0; From 56c6c06b3980d26aa428c3c538a4c42ea5c1d0e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 17:48:32 +0300 Subject: [PATCH 091/157] Test --- src/komodo_gateway.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5a660ab33..e190b3986 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -696,7 +696,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim overflow = 1; break; } - if ( script[0] != 0x6a && val < 5000 ) + if ( i > 1 && script[0] != 0x6a && val < 5000 ) strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53ae9ddd7..47d8010c9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 19:08:15 +0300 Subject: [PATCH 092/157] Test --- src/miner.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 466968e1b..aed085639 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -492,7 +492,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; //fprintf(stderr,"added notaryvin\n"); - } else fprintf(stderr,"error adding notaryvin\n"); + } + else + { + fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); + return(0); + } } else { From db4b45a62b8e68b6cc9f0e09b87e775ab915fd7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 19:08:49 +0300 Subject: [PATCH 093/157] Test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 47d8010c9..53ae9ddd7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4533,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i Date: Mon, 7 May 2018 19:14:54 +0300 Subject: [PATCH 094/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index aed085639..f94ff1d04 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -309,7 +309,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize) + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx { //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); continue; From 97d58e8c23400e51a1354cbf64518f78383f08f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 20:41:56 +0300 Subject: [PATCH 095/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e190b3986..238447a42 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -724,7 +724,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } if ( strangeout != 0 ) { - fprintf(stderr,">>>>>>>>>>>>> ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); } } else From 6ff3cabc314232f30addf6dbbde08a1f7d5d482a Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:50:42 +0100 Subject: [PATCH 096/157] removed VOTE2018 --- src/assetchains | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 517687097..b54987942 100755 --- a/src/assetchains +++ b/src/assetchains @@ -47,7 +47,6 @@ komodo_asset MNZ 257142858 komodo_asset AXO 200000000 komodo_asset ETOMIC 100000000 komodo_asset BTCH 20998641 -komodo_asset VOTE2018 600000000 komodo_asset PIZZA 100000000 komodo_asset BEER 100000000 komodo_asset NINJA 100000000 From b79d1ecda5e35daa08c00e53cf1cd95028b155eb Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:52:13 +0100 Subject: [PATCH 097/157] removed VOTE2018 --- src/assetchains.old | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index c025e0430..d41b64766 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -24,7 +24,6 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=VOTE2018 -ac_supply=600000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 & From 872338fa62f10bd4c664405736c75e675ce69014 Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:53:50 +0100 Subject: [PATCH 098/157] removed VOTE2018 --- src/assetchains_stop | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains_stop b/src/assetchains_stop index 29e1ab325..ba314e1c9 100644 --- a/src/assetchains_stop +++ b/src/assetchains_stop @@ -30,7 +30,6 @@ komodo_stop MNZ komodo_stop AXO komodo_stop ETOMIC komodo_stop BTCH -komodo_stop VOTE2018 komodo_stop PIZZA komodo_stop BEER komodo_stop NINJA From 3611134826b08ded4aec2a15a3e602a3451fa64c Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 7 May 2018 21:54:50 +0100 Subject: [PATCH 099/157] delete vote2018 --- src/fiat/vote2018 | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 src/fiat/vote2018 diff --git a/src/fiat/vote2018 b/src/fiat/vote2018 deleted file mode 100755 index 4e385d76f..000000000 --- a/src/fiat/vote2018 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=VOTE2018 $1 $2 $3 $4 $5 $6 From 9e44b3ce6f37a31f211068c9ceb7935fc8139edb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:01:57 +0300 Subject: [PATCH 100/157] Test --- src/komodo_gateway.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 238447a42..e51d0a115 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txid,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -680,6 +680,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } } + if ( i == 0 ) + { + txid = block.vtx[txn_count-1].vin[0].prevout.hash; + if ( GetTransaction(txid,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) + notmatched = 1; + } } } n = block.vtx[0].vout.size(); @@ -722,9 +728,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } - if ( strangeout != 0 ) + if ( strangeout != 0 || notmatched != 0 ) { - fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d <<<<<<<<<\n",height,strangeout); + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); } } else From dd249664314b576aa78bb25415b8388a206287e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:07:05 +0300 Subject: [PATCH 101/157] Test --- src/komodo_gateway.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e51d0a115..b91e4af86 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txid,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -668,6 +668,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { for (i=0; i Date: Tue, 8 May 2018 12:07:29 +0300 Subject: [PATCH 102/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b91e4af86..27cee3a23 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -670,7 +670,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( i == 0 ) { - if ( block.vtx[txn_count-1].vin.size() == 1 && block.vtx[txn_count-1].vout.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) + if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) notmatched = 1; } n = block.vtx[i].vin.size(); From 51f0e5008de36c8a9016cda45ff20d3cf10d4fec Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:17:48 +0300 Subject: [PATCH 103/157] Test --- src/komodo_gateway.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 27cee3a23..6660a4932 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -730,6 +730,16 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( strangeout != 0 || notmatched != 0 ) { fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); + if ( height > 1000000 && strangeout != 0 ) + return(-1); + } + else + { + script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); + n = komodo_electednotary(&num,script+1,height,0); + fprintf(stderr,">>>>>>>>>>>>> matched ht.%d notmatched.%d n.%d <<<<<<<<<\n",height,notmatched,n); + if ( height > 1000000 ) + return(-1 * (n >= 0)); } } else From 9c72a5cbb77fdb4e2f4e35db97519c807e7cbabb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 12:23:58 +0300 Subject: [PATCH 104/157] Test --- src/komodo_gateway.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6660a4932..18dabfb1d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -729,17 +729,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } if ( strangeout != 0 || notmatched != 0 ) { - fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); + if ( strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); if ( height > 1000000 && strangeout != 0 ) return(-1); } else { script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); - n = komodo_electednotary(&num,script+1,height,0); - fprintf(stderr,">>>>>>>>>>>>> matched ht.%d notmatched.%d n.%d <<<<<<<<<\n",height,notmatched,n); - if ( height > 1000000 ) - return(-1 * (n >= 0)); + return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); } } else From 99e304630768bb9aa7203928eb5a53fc6758644e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:02:57 +0300 Subject: [PATCH 105/157] Test --- src/miner.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f94ff1d04..6d0b29b33 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -984,22 +984,11 @@ void static BitcoinMiner() } if ( ASSETCHAINS_STAKED == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( NOTARY_PUBKEY33[0] != 0 && notaryid >= 0 ) { - MilliSleep((rand() % 2700) + 1000); + if ( (i= ((Mining_height + notaryid) % 64) / 8) > 0 ) + MilliSleep((rand() % (i * 1000)) + 500); } - /*if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) - { - //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+roundrobin_delay-time(NULL))); - //int32_t nseconds = Mining_start+roundrobin_delay-time(NULL); - //if ( nseconds > 0 ) - // sleep(nseconds); - MilliSleep((rand() % 1700) + 1); - } - else if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - sleep(rand() % 30); - }*/ } else { From 26810a265b43af78699edf351afb6aa34c789c77 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:03:43 +0300 Subject: [PATCH 106/157] Test --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6d0b29b33..de6024caf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -986,8 +986,9 @@ void static BitcoinMiner() { if ( NOTARY_PUBKEY33[0] != 0 && notaryid >= 0 ) { - if ( (i= ((Mining_height + notaryid) % 64) / 8) > 0 ) - MilliSleep((rand() % (i * 1000)) + 500); + int32_t r; + if ( (r= ((Mining_height + notaryid) % 64) / 8) > 0 ) + MilliSleep((rand() % (r * 1000)) + 500); } } else From 596b05baf216a0aface873c8be011030419b2ff2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:05:21 +0300 Subject: [PATCH 107/157] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index de6024caf..2632e71dc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -972,7 +972,7 @@ void static BitcoinMiner() if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); - while ( GetAdjustedTime() < B.nTime ) + while ( GetAdjustedTime() < B.nTime-2 ) { sleep(1); if ( chainActive.Tip()->nHeight >= Mining_height ) @@ -988,7 +988,7 @@ void static BitcoinMiner() { int32_t r; if ( (r= ((Mining_height + notaryid) % 64) / 8) > 0 ) - MilliSleep((rand() % (r * 1000)) + 500); + MilliSleep((rand() % (r * 1000)) + 1000); } } else From bed8cd1f4978e5241bcaee85d878567ede481f61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:38:51 +0300 Subject: [PATCH 108/157] Test --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 3 ++- src/wallet/rpcwallet.cpp | 14 +------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2174a8d80..8ca20d329 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1084,12 +1084,12 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh { CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN; txtime = komodo_txtime(&value,txid,vout,address); + if ( blocktime < prevtime+57 ) + blocktime = prevtime+57; if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) return(0); if ( (minage= nHeight*3) > 6000 ) minage = 6000; - if ( blocktime < prevtime+57 ) - blocktime = prevtime+57; if ( blocktime > txtime+minage && (pindex= komodo_chainactive(nHeight>200?nHeight-200:1)) != 0 ) { vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); diff --git a/src/miner.cpp b/src/miner.cpp index 2632e71dc..1fe8c511e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -419,7 +419,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + printf("PoS ht.%d t%u\n",(int32_t)pblock->nHeight,blocktime); + if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53ae9ddd7..702466c74 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4574,23 +4574,11 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt //if (pwalletMain->mapAddressBook.count(address)) // entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); } - /*entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end()))); - if (pk.IsPayToScriptHash()) - { - CTxDestination address; - if (ExtractDestination(pk, address)) { - const CScriptID& hash = boost::get(address); - CScript redeemScript; - if (pwalletMain->GetCScript(hash, redeemScript)) - entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()))); - } - } - entry.push_back(Pair("amount",ValueFromAmount(nValue)));*/ //BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *tipindex; if ( (tipindex= chainActive.Tip()) != 0 ) { - eligible = komodo_stake(0,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,*blocktimep,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()); + eligible = komodo_stake(0,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,0,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()); if ( eligible > 0 ) { if ( eligible != komodo_stake(1,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,eligible,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()) ) From 9703f8a03d894ee8af0d1d565d398c6915aa7d40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:43:08 +0300 Subject: [PATCH 109/157] Test --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1fe8c511e..c2ba5e78e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -419,8 +419,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - printf("PoS ht.%d t%u\n",(int32_t)pblock->nHeight,blocktime); - if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); + if ( 0 && GetAdjustedTime() < pblock->nTime ) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) @@ -985,10 +985,10 @@ void static BitcoinMiner() } if ( ASSETCHAINS_STAKED == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 && notaryid >= 0 ) + if ( NOTARY_PUBKEY33[0] != 0 ) { int32_t r; - if ( (r= ((Mining_height + notaryid) % 64) / 8) > 0 ) + if ( (r= ((Mining_height + NOTARY_PUBKEY33[16]) % 64) / 8) > 0 ) MilliSleep((rand() % (r * 1000)) + 1000); } } From ba1587fd3772dd50e3fee95a760e1df513d334a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 18:55:16 +0300 Subject: [PATCH 110/157] Test --- src/miner.cpp | 2 ++ src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c2ba5e78e..a33085820 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,6 +414,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; + if ( GetAdjustedTime() < pblock->nTime-30 ) + return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 702466c74..4cc79cfdb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4625,7 +4625,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i Date: Tue, 8 May 2018 19:00:21 +0300 Subject: [PATCH 111/157] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a33085820..9c84f5f28 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,7 +414,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; - if ( GetAdjustedTime() < pblock->nTime-30 ) + if ( GetAdjustedTime() < blocktime-30 ) return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); From de230f5e7579d59480440e73e5adf89697b4f1da Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 19:05:38 +0300 Subject: [PATCH 112/157] Test --- src/miner.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9c84f5f28..264a6e2d4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,25 +414,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( (siglen= komodo_staked(txStaked,pblock->nBits,&blocktime,&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CAmount txfees = 0; - if ( GetAdjustedTime() < blocktime-30 ) + if ( GetAdjustedTime() < blocktime-13 ) return(0); pblock->vtx.push_back(txStaked); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); - if ( 0 && GetAdjustedTime() < pblock->nTime ) - { - fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); - while ( GetAdjustedTime()+30 < pblock->nTime ) - { - sleep(30); - fprintf(stderr,"%d ",(int32_t)(pblock->nTime - GetAdjustedTime())); - } - fprintf(stderr,"finished waiting\n"); - //sleep(pblock->nTime - GetAdjustedTime()); - } + //printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } From 0afe191c041089f1dfc6cff7ef1115d7394e2405 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 19:11:58 +0300 Subject: [PATCH 113/157] Test --- src/komodo_gateway.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 18dabfb1d..c6441977c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -743,7 +743,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { if ( overflow != 0 || total > 0 || strangeout != 0 ) + { + if ( strangeout != 0 ) + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); return(-1); + } } return(0); } From 58d3618754005afc3ed81095cb7d6278e82578bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 20:18:34 +0300 Subject: [PATCH 114/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c6441977c..8daa0d32a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -734,7 +734,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > 1000000 && strangeout != 0 ) return(-1); } - else + else if ( height > 814000 ) { script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); From f4dfe2744283b5a393e722c8c52922259f08342c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 22:44:52 +0300 Subject: [PATCH 115/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8daa0d32a..8b310c56d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -668,7 +668,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { for (i=0; i 1 ) { if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) notmatched = 1; From 751df7814f0813e43249366286e09d61d9a9dacd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 22:51:57 +0300 Subject: [PATCH 116/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8b310c56d..b0ebac4c4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -668,7 +668,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { for (i=0; i 1 ) + if ( i == 0 && txn_count > 1 && block.vtx[txn_count-1].vout[0].nValue == 5000 ) { if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) notmatched = 1; From 2e12bbce39dc92c519f5e363d7526d87b1234ce7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 May 2018 23:08:00 +0300 Subject: [PATCH 117/157] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b0ebac4c4..018baa675 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -668,7 +668,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { for (i=0; i 1 && block.vtx[txn_count-1].vout[0].nValue == 5000 ) + if ( i == 0 && txn_count > 1 && block.vtx[txn_count-1].vout.size() > 0 && block.vtx[txn_count-1].vout[0].nValue == 5000 ) { if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) notmatched = 1; From b9b415654fd706e3a31d820db4f80c985bd33e3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 May 2018 09:36:27 +0300 Subject: [PATCH 118/157] Restore possibility of negative timestamps for PoS --- src/main.cpp | 5 ----- src/rpcrawtransaction.cpp | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cdb0b3f3e..31528442f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3783,11 +3783,6 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, 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"); - } // Check block version if (height > 0 && blockhdr.nVersion < MIN_BLOCK_VERSION) return state.DoS(100, error("CheckBlockHeader(): block version too low"),REJECT_INVALID, "version-too-low"); diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 8c88abe43..8130ba0a5 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -138,6 +138,8 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); in.push_back(Pair("vout", (int64_t)txin.prevout.n)); + + UniValue o(UniValue::VOBJ); o.push_back(Pair("asm", txin.scriptSig.ToString())); o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); From 1d03bae255c2fa185289a089d162126ff2e937e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 May 2018 09:55:43 +0300 Subject: [PATCH 119/157] Display vin address in tx son --- src/rpcrawtransaction.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 8130ba0a5..db830b388 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -138,8 +138,14 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); in.push_back(Pair("vout", (int64_t)txin.prevout.n)); - - + { + uint256 hash; CTransaction tx; CTxDestination address; + if (GetTransaction(txin.prevout.hash,tx,hash,false)) + { + if (ExtractDestination(tx.scriptPubKey, address)) + in.push_back(Pair("address", address.ToString())); + } + } UniValue o(UniValue::VOBJ); o.push_back(Pair("asm", txin.scriptSig.ToString())); o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); From c1ec8014fab2f915c0333a6b9fc7e45877bc5abe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 May 2018 09:58:52 +0300 Subject: [PATCH 120/157] Test --- src/rpcrawtransaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index db830b388..8b722e931 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -142,8 +142,8 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& uint256 hash; CTransaction tx; CTxDestination address; if (GetTransaction(txin.prevout.hash,tx,hash,false)) { - if (ExtractDestination(tx.scriptPubKey, address)) - in.push_back(Pair("address", address.ToString())); + if (ExtractDestination(tx.vout[txin.prevout.n].scriptPubKey, address)) + in.push_back(Pair("address", CBitcoinAddress(address).ToString())); } } UniValue o(UniValue::VOBJ); From bd070d8bcec0d2b42e561085e629357fa304f43e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 12:55:14 +0300 Subject: [PATCH 121/157] Prevent relaying expired tx --- src/komodo_bitcoind.h | 6 +++--- src/komodo_defs.h | 1 + src/komodo_interest.h | 4 ++-- src/wallet/wallet.cpp | 13 ++++++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8ca20d329..c434e33a3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1033,16 +1033,16 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ { if ( txheight < 247205 ) cmptime -= 16000; - if ( (int64_t)tx.nLockTime < cmptime-3600 ) + if ( (int64_t)tx.nLockTime < cmptime-KOMODO_MAXMEMPOOLTIME ) { 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); + fprintf(stderr,"komodo_validate_interest.%d reject.%d [%d] locktime %u cmp2.%u\n",dispflag,txheight,(int32_t)(tx.nLockTime - (cmptime-KOMODO_MAXMEMPOOLTIME)),(uint32_t)tx.nLockTime,cmptime); } return(-1); } if ( 0 && dispflag != 0 ) - fprintf(stderr,"validateinterest.%d accept.%d [%d] locktime %u cmp2.%u\n",dispflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)tx.nLockTime,cmptime); + fprintf(stderr,"validateinterest.%d accept.%d [%d] locktime %u cmp2.%u\n",dispflag,(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-KOMODO_MAXMEMPOOLTIME)),(int32_t)tx.nLockTime,cmptime); } } return(0); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 3f8b498fa..a1b219e80 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -6,5 +6,6 @@ #define ROUNDROBIN_DELAY 61 #define KOMODO_ASSETCHAIN_MAXLEN 65 #define KOMODO_LIMITED_NETWORKSIZE 4 +#define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus #endif diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 8fd6becea..3141532fa 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -83,13 +83,13 @@ uint64_t komodo_moneysupply(int32_t height) uint64_t _komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes; uint64_t interest = 0; - if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= 60 ) + if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= (KOMODO_MAXMEMPOOLTIME/60) ) { if ( minutes > 365 * 24 * 60 ) minutes = 365 * 24 * 60; if ( txheight >= 1000000 && minutes > 31 * 24 * 60 ) minutes = 31 * 24 * 60; - minutes -= 59; + minutes -= ((KOMODO_MAXMEMPOOLTIME/60) - 1); interest = ((nValue / 10512000) * minutes); } return(interest); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 77a27c69a..49b3e0c26 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1887,7 +1887,9 @@ bool CWalletTx::RelayWalletTransaction() assert(pwallet->GetBroadcastTransactions()); if (!IsCoinBase()) { - if (GetDepthInMainChain() == 0) { + if (GetDepthInMainChain() == 0) + { + // if tx is expired, dont relay LogPrintf("Relaying wtx %s\n", GetHash().ToString()); RelayTransaction((CTransaction)*this); return true; @@ -2102,12 +2104,21 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) LOCK(cs_wallet); // Sort them in chronological order multimap mapSorted; + uint32_t now = (uint32_t)time(NULL); BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: if (wtx.nTimeReceived > nTime) continue; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-KOMODO_MAXMEMPOOLTIME ) + { + LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", GetHash().ToString(),(uint32_t)wtx.nLockTime,now); + continue; + } + } mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted) From a5b7fef44b5b4cd93ed2aefd4bd82e8516593383 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 12:56:52 +0300 Subject: [PATCH 122/157] Test --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 49b3e0c26..550cba683 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2115,7 +2115,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) { if ( wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-KOMODO_MAXMEMPOOLTIME ) { - LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", GetHash().ToString(),(uint32_t)wtx.nLockTime,now); + LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now); continue; } } From 0d664409909a25a1b1ee4caa141f4fe2d4fdc5d1 Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 10 May 2018 11:58:13 +0200 Subject: [PATCH 123/157] update libgmp using our own CDN --- depends/packages/libgmp.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/libgmp.mk b/depends/packages/libgmp.mk index f06e4a6c4..d8e41573a 100644 --- a/depends/packages/libgmp.mk +++ b/depends/packages/libgmp.mk @@ -18,7 +18,7 @@ $(package)_dependencies= $(package)_config_opts=--enable-cxx --disable-shared else $(package)_version=6.1.1 -$(package)_download_path=https://gmplib.org/download/gmp/ +$(package)_download_path=https://supernetorg.bintray.com/misc $(package)_file_name=gmp-$($(package)_version).tar.bz2 $(package)_sha256_hash=a8109865f2893f1373b0a8ed5ff7429de8db696fc451b1036bd7bdf95bbeffd6 $(package)_dependencies= From be5f41cd904c437702a004074e7547491c3a6d24 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 13:00:24 +0300 Subject: [PATCH 124/157] Prevent rebroadcast of expired tx --- src/wallet/wallet.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index eadf7f36d..e4f13e749 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2102,12 +2102,21 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) LOCK(cs_wallet); // Sort them in chronological order multimap mapSorted; + uint32_t now = (uint32_t)time(NULL); BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: if (wtx.nTimeReceived > nTime) continue; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-KOMODO_MAXMEMPOOLTIME ) + { + LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now); + continue; + } + } mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted) From e39069257675a3cb7d73fd59f5ea1f01133ea03f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 13:08:25 +0300 Subject: [PATCH 125/157] Display invalidateblock, reconsiderblock, resendwallettransactions --- src/rpcserver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 4eb2270fb..86a7aed86 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -358,12 +358,12 @@ static const CRPCCommand vRPCCommands[] = { "util", "jumblr_pause", &jumblr_pause, true }, { "util", "jumblr_resume", &jumblr_resume, true }, + { "util", "invalidateblock", &invalidateblock, true }, + { "util", "reconsiderblock", &reconsiderblock, true }, /* Not shown in help */ - { "hidden", "invalidateblock", &invalidateblock, true }, - { "hidden", "reconsiderblock", &reconsiderblock, true }, { "hidden", "setmocktime", &setmocktime, true }, #ifdef ENABLE_WALLET - { "hidden", "resendwallettransactions", &resendwallettransactions, true}, + { "wallet", "resendwallettransactions", &resendwallettransactions, true}, #endif #ifdef ENABLE_WALLET From 4017d7c4f58fdab25e0d5fee9c06472b37eb5131 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 13:13:49 +0300 Subject: [PATCH 126/157] Change libgmp path to supernetorg --- depends/packages/libgmp.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/libgmp.mk b/depends/packages/libgmp.mk index f06e4a6c4..d8e41573a 100644 --- a/depends/packages/libgmp.mk +++ b/depends/packages/libgmp.mk @@ -18,7 +18,7 @@ $(package)_dependencies= $(package)_config_opts=--enable-cxx --disable-shared else $(package)_version=6.1.1 -$(package)_download_path=https://gmplib.org/download/gmp/ +$(package)_download_path=https://supernetorg.bintray.com/misc $(package)_file_name=gmp-$($(package)_version).tar.bz2 $(package)_sha256_hash=a8109865f2893f1373b0a8ed5ff7429de8db696fc451b1036bd7bdf95bbeffd6 $(package)_dependencies= From d014b5bd1c3665e2a399797d1efc913399b6ded5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 13:14:42 +0300 Subject: [PATCH 127/157] Change url for gmplib --- depends/packages/libgmp.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/depends/packages/libgmp.mk b/depends/packages/libgmp.mk index f06e4a6c4..496a2751e 100644 --- a/depends/packages/libgmp.mk +++ b/depends/packages/libgmp.mk @@ -18,7 +18,8 @@ $(package)_dependencies= $(package)_config_opts=--enable-cxx --disable-shared else $(package)_version=6.1.1 -$(package)_download_path=https://gmplib.org/download/gmp/ +$(package)_download_path=https://supernetorg.bintray.com/misc + $(package)_file_name=gmp-$($(package)_version).tar.bz2 $(package)_sha256_hash=a8109865f2893f1373b0a8ed5ff7429de8db696fc451b1036bd7bdf95bbeffd6 $(package)_dependencies= From cfc16d5ca461a709e8898e5f03c0b98db0f56c2a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 May 2018 17:52:55 +0300 Subject: [PATCH 128/157] KOMODO_MAXMEMPOOLTIME --- src/komodo_defs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index db792c44e..6cd297c49 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -5,5 +5,6 @@ #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 61 #define KOMODO_ASSETCHAIN_MAXLEN 65 +#define KOMODO_MAXMEMPOOLTIME 3600 #endif From 87ae91727714cfaf30415fedbd0954573d9faec3 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Fri, 11 May 2018 11:38:31 +0700 Subject: [PATCH 129/157] Remove vote2018 from `fiat-cli` --- src/fiat-cli | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fiat-cli b/src/fiat-cli index ce2e7a51d..76f219c83 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -22,7 +22,6 @@ echo etomic; fiat/etomic $1 $2 $3 $4 echo btch; fiat/btch $1 $2 $3 $4 echo pizza; fiat/pizza $1 $2 $3 $4 echo beer; fiat/beer $1 $2 $3 $4 -echo vote2018; fiat/vote2018 $1 $2 $3 $4 echo ninja; fiat/ninja $1 $2 $3 $4 echo oot; fiat/oot $1 $2 $3 $4 echo bntn; fiat/bntn $1 $2 $3 $4 From 7be54a7fa36d2594eef8e3b9e657f2045b153ffa Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Fri, 11 May 2018 11:59:49 +0700 Subject: [PATCH 130/157] Remove VOTE2018 from `dpowassets` --- src/dpowassets | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dpowassets b/src/dpowassets index a144eab28..c2ede0884 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -27,7 +27,6 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ETOMIC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BTCH\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHAIN\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"VOTE2018\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NINJA\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" From ae3f3fea6c0b98a3278151d96a32ceef63a03417 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 May 2018 16:28:52 +0300 Subject: [PATCH 131/157] +GAME sanitize listunspent interest calc --- src/dpowassets | 4 +++- src/rest.cpp | 1 - src/rpcblockchain.cpp | 2 -- src/rpcrawtransaction.cpp | 8 ++++---- src/wallet/rpcwallet.cpp | 10 ++++------ 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/dpowassets b/src/dpowassets index a144eab28..642881532 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -22,7 +22,6 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CEAL\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MESH\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MNZ\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AXO\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ETOMIC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BTCH\",\"pubkey\":\"$pubkey\"}" @@ -32,3 +31,6 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" + +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" diff --git a/src/rest.cpp b/src/rest.cpp index 44d1de533..8e2e4d1e6 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -563,7 +563,6 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart) utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer)); utxo.push_back(Pair("height", (int32_t)coin.nHeight)); utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue))); - //utxo.push_back(Pair("interest", ValueFromAmount(komodo_interest(coin.out.nValue,coin.nLockTime,chainActive.Tip()->nTime)))); // include the script in a json output UniValue o(UniValue::VOBJ); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index d9cc072e5..3774f1bb5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -752,12 +752,10 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp) #define KOMODO_KVDURATION 1440 #define KOMODO_KVBINARY 2 extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); -//uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n); int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width); int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); int32_t komodo_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip); diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 8b722e931..018361513 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -57,7 +57,6 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud out.push_back(Pair("addresses", a)); } - UniValue TxJoinSplitToJSON(const CTransaction& tx) { UniValue vjoinsplit(UniValue::VARR); for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) { @@ -115,7 +114,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) { return vjoinsplit; } -uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); +uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, int nHeight = 0, int nConfirmations = 0, int nBlockTime = 0) { @@ -176,9 +175,10 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& const CTxOut& txout = tx.vout[i]; UniValue out(UniValue::VOBJ); out.push_back(Pair("value", ValueFromAmount(txout.nValue))); - if ( pindex != 0 && tx.nLockTime > 500000000 && (tipindex= chainActive.Tip()) != 0 ) + if ( pindex != 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.Tip()) != 0 ) { - interest = komodo_interest(pindex->nHeight,txout.nValue,tx.nLockTime,tipindex->nTime); + int64_t interest; int32_t txheight; uint32_t locktime; + interest = komodo_accrued_interest(&txheight,&locktime,txout.hash,i,0,txout.nValue,(int32_t)tipindex->nHeight); out.push_back(Pair("interest", ValueFromAmount(interest))); } out.push_back(Pair("valueZat", txout.nValue)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4cc79cfdb..b96064221 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -76,7 +76,6 @@ void EnsureWalletIsUnlocked() } uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); -uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) { @@ -2562,8 +2561,6 @@ UniValue resendwallettransactions(const UniValue& params, bool fHelp) return result; } -uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); - UniValue listunspent(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -2678,8 +2675,8 @@ UniValue listunspent(const UniValue& params, bool fHelp) uint64_t interest; uint32_t locktime; int32_t txheight; if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) { - komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight); - interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime); + interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight); + //interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); } //fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight); @@ -2708,7 +2705,8 @@ uint64_t komodo_interestsum() CBlockIndex *tipindex,*pindex = it->second; if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 ) { - interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); + interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight); + //interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime); sum += interest; } } From 316a563c50026029dfc1c2b8bb235ffed26926a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 May 2018 16:34:25 +0300 Subject: [PATCH 132/157] Test --- src/rpcrawtransaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 018361513..123e0bbb9 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -178,7 +178,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& if ( pindex != 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.Tip()) != 0 ) { int64_t interest; int32_t txheight; uint32_t locktime; - interest = komodo_accrued_interest(&txheight,&locktime,txout.hash,i,0,txout.nValue,(int32_t)tipindex->nHeight); + interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->nHeight); out.push_back(Pair("interest", ValueFromAmount(interest))); } out.push_back(Pair("valueZat", txout.nValue)); From 09511571afa3d7e19075abb7610e0cfed6793b96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 May 2018 16:36:21 +0300 Subject: [PATCH 133/157] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b96064221..c87f6b2dd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2691,7 +2691,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) uint64_t komodo_interestsum() { - uint64_t interest,sum = 0; + uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime; vector vecOutputs; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); From a7322d7720e139d33e2dc5b81217af354be339d0 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 12 May 2018 12:51:39 +0300 Subject: [PATCH 134/157] rename zcash to komodo in cli examples --- src/amount.cpp | 2 +- src/rpcblockchain.cpp | 14 ++-- src/rpcmining.cpp | 8 +-- src/rpcmisc.cpp | 32 ++++----- src/rpcnet.cpp | 2 +- src/rpcrawtransaction.cpp | 12 ++-- src/wallet/rpcdump.cpp | 28 ++++---- src/wallet/rpcwallet.cpp | 136 +++++++++++++++++++------------------- 8 files changed, 117 insertions(+), 117 deletions(-) diff --git a/src/amount.cpp b/src/amount.cpp index f658c4a28..4e32ff45b 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -7,7 +7,7 @@ #include "tinyformat.h" -const std::string CURRENCY_UNIT = "ZEC"; +const std::string CURRENCY_UNIT = "KMD"; CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize) { diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index de3f55077..93feb57c6 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -626,7 +626,7 @@ UniValue height_MoM(const UniValue& params, bool fHelp) ret.push_back(Pair("kmdendi",kmdendi)); } } else ret.push_back(Pair("error",(char *)"no MoM for height")); - + return ret; } @@ -654,7 +654,7 @@ UniValue txMoMproof(const UniValue& params, bool fHelp) if (!depth) throw runtime_error("notarisation not found"); - + // index of block in MoM leaves nIndex = notarisedHeight - blockIndex->nHeight; } @@ -709,7 +709,7 @@ UniValue txMoMproof(const UniValue& params, bool fHelp) } // Check the proof - if (MoM != CBlock::CheckMerkleBranch(hash, branch, nIndex)) + if (MoM != CBlock::CheckMerkleBranch(hash, branch, nIndex)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Failed validating MoM"); // Encode and return @@ -808,14 +808,14 @@ UniValue notaries(const UniValue& params, bool fHelp) 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); @@ -963,8 +963,8 @@ UniValue gettxout(const UniValue& params, bool fHelp) " \"hex\" : \"hex\", (string) \n" " \"reqSigs\" : n, (numeric) Number of required signatures\n" " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" - " \"addresses\" : [ (array of string) array of Zcash addresses\n" - " \"zcashaddress\" (string) Zcash address\n" + " \"addresses\" : [ (array of string) array of Komodo addresses\n" + " \"komodoaddress\" (string) Komodo address\n" " ,...\n" " ]\n" " },\n" diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index aea5694f2..bd9c45f5d 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -182,7 +182,7 @@ UniValue generate(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Wallet disabled and -mineraddress not set"); } #else - throw JSONRPCError(RPC_METHOD_NOT_FOUND, "zcashd compiled without wallet and -mineraddress not set"); + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "komodod compiled without wallet and -mineraddress not set"); #endif } if (!Params().MineBlocksOnDemand()) @@ -304,7 +304,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Wallet disabled and -mineraddress not set"); } #else - throw JSONRPCError(RPC_METHOD_NOT_FOUND, "zcashd compiled without wallet and -mineraddress not set"); + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "komodod compiled without wallet and -mineraddress not set"); #endif } if (Params().MineBlocksOnDemand()) @@ -506,7 +506,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Wallet disabled and -mineraddress not set"); } #else - throw JSONRPCError(RPC_METHOD_NOT_FOUND, "zcashd compiled without wallet and -mineraddress not set"); + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "komodod compiled without wallet and -mineraddress not set"); #endif } @@ -563,7 +563,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) - throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!"); + throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); //if (IsInitialBlockDownload()) // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index cf7967cb7..682298485 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -66,7 +66,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) " \"version\": xxxxx, (numeric) the server version\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" - " \"balance\": xxxxxxx, (numeric) the total Zcash balance of the wallet\n" + " \"balance\": xxxxxxx, (numeric) the total Komodo balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" @@ -254,14 +254,14 @@ UniValue validateaddress(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( - "validateaddress \"zcashaddress\"\n" - "\nReturn information about the given Zcash address.\n" + "validateaddress \"komodoaddress\"\n" + "\nReturn information about the given Komodo address.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to validate\n" + "1. \"komodoaddress\" (string, required) The Komodo address to validate\n" "\nResult:\n" "{\n" " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" - " \"address\" : \"zcashaddress\", (string) The Zcash address validated\n" + " \"address\" : \"komodoaddress\", (string) The Komodo address validated\n" " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" " \"ismine\" : true|false, (boolean) If the address is yours or not\n" " \"isscript\" : true|false, (boolean) If the key is a script\n" @@ -270,8 +270,8 @@ UniValue validateaddress(const UniValue& params, bool fHelp) " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" "}\n" "\nExamples:\n" - + HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") - + HelpExampleRpc("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + + HelpExampleCli("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") + + HelpExampleRpc("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") ); #ifdef ENABLE_WALLET @@ -445,9 +445,9 @@ UniValue createmultisig(const UniValue& params, bool fHelp) "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" - "2. \"keys\" (string, required) A json array of keys which are Zcash addresses or hex-encoded public keys\n" + "2. \"keys\" (string, required) A json array of keys which are Komodo addresses or hex-encoded public keys\n" " [\n" - " \"key\" (string) Zcash address or hex-encoded public key\n" + " \"key\" (string) Komodo address or hex-encoded public key\n" " ,...\n" " ]\n" @@ -459,9 +459,9 @@ UniValue createmultisig(const UniValue& params, bool fHelp) "\nExamples:\n" "\nCreate a multisig address from 2 addresses\n" - + HelpExampleCli("createmultisig", "2 \"[\\\"t16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"t171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + + HelpExampleCli("createmultisig", "2 \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("createmultisig", "2, \"[\\\"t16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"t171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + HelpExampleRpc("createmultisig", "2, \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") ; throw runtime_error(msg); } @@ -482,10 +482,10 @@ UniValue verifymessage(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 3) throw runtime_error( - "verifymessage \"zcashaddress\" \"signature\" \"message\"\n" + "verifymessage \"komodoaddress\" \"signature\" \"message\"\n" "\nVerify a signed message\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to use for the signature.\n" + "1. \"komodoaddress\" (string, required) The Komodo address to use for the signature.\n" "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" "3. \"message\" (string, required) The message that was signed.\n" "\nResult:\n" @@ -494,11 +494,11 @@ UniValue verifymessage(const UniValue& params, bool fHelp) "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" - + HelpExampleCli("signmessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"my message\"") + + + HelpExampleCli("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"my message\"") + "\nVerify the signature\n" - + HelpExampleCli("verifymessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"signature\" \"my message\"") + + + HelpExampleCli("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"signature\" \"my message\"") + "\nAs json rpc\n" - + HelpExampleRpc("verifymessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", \"signature\", \"my message\"") + + HelpExampleRpc("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"signature\", \"my message\"") ); LOCK(cs_main); diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index a7a4bf051..79f2b0cdd 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -291,7 +291,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) " \"connected\" : true|false, (boolean) If connected\n" " \"addresses\" : [\n" " {\n" - " \"address\" : \"192.168.0.201:8233\", (string) The Zcash server host and port\n" + " \"address\" : \"192.168.0.201:8233\", (string) The Komodo server host and port\n" " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n" " }\n" " ,...\n" diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index e918df2c9..7bfe1269a 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -233,7 +233,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp) " \"reqSigs\" : n, (numeric) The required sigs\n" " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" " \"addresses\" : [ (json array of string)\n" - " \"zcashaddress\" (string) Zcash address\n" + " \"komodoaddress\" (string) Komodo address\n" " ,...\n" " ]\n" " }\n" @@ -488,7 +488,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) " ]\n" "2. \"addresses\" (string, required) a json object with addresses as keys and amounts as values\n" " {\n" - " \"address\": x.xxx (numeric, required) The key is the Zcash address, the value is the " + CURRENCY_UNIT + " amount\n" + " \"address\": x.xxx (numeric, required) The key is the Komodo address, the value is the " + CURRENCY_UNIT + " amount\n" " ,...\n" " }\n" @@ -509,7 +509,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) int nextBlockHeight = chainActive.Height() + 1; CMutableTransaction rawTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); - + if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { rawTx.nExpiryHeight = nextBlockHeight + expiryDelta; if (rawTx.nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD){ @@ -539,7 +539,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) BOOST_FOREACH(const string& name_, addrList) { CBitcoinAddress address(name_); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Zcash address: ")+name_); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Komodo address: ")+name_); if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+name_); @@ -595,7 +595,7 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp) " \"reqSigs\" : n, (numeric) The required sigs\n" " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" " \"addresses\" : [ (json array of string)\n" - " \"t12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) zcash address\n" + " \"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" (string) komodo address\n" " ,...\n" " ]\n" " }\n" @@ -665,7 +665,7 @@ UniValue decodescript(const UniValue& params, bool fHelp) " \"type\":\"type\", (string) The output type\n" " \"reqSigs\": n, (numeric) The required signatures\n" " \"addresses\": [ (json array of string)\n" - " \"address\" (string) Zcash address\n" + " \"address\" (string) Komodo address\n" " ,...\n" " ],\n" " \"p2sh\",\"address\" (string) script address\n" diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 33dc90bb3..15caad846 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -64,7 +64,7 @@ std::string DecodeDumpString(const std::string &str) { for (unsigned int pos = 0; pos < str.length(); pos++) { unsigned char c = str[pos]; if (c == '%' && pos+2 < str.length()) { - c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) | + c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) | ((str[pos+2]>>6)*9+((str[pos+2]-'0')&15)); pos += 2; } @@ -77,13 +77,13 @@ UniValue importprivkey(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + if (fHelp || params.size() < 1 || params.size() > 3) throw runtime_error( - "importprivkey \"zcashprivkey\" ( \"label\" rescan )\n" + "importprivkey \"komodoprivkey\" ( \"label\" rescan )\n" "\nAdds a private key (as returned by dumpprivkey) to your wallet.\n" "\nArguments:\n" - "1. \"zcashprivkey\" (string, required) The private key (see dumpprivkey)\n" + "1. \"komodoprivkey\" (string, required) The private key (see dumpprivkey)\n" "2. \"label\" (string, optional, default=\"\") An optional label\n" "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" "\nNote: This call can take minutes to complete if rescan is true.\n" @@ -152,7 +152,7 @@ UniValue importaddress(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + if (fHelp || params.size() < 1 || params.size() > 3) throw runtime_error( "importaddress \"address\" ( \"label\" rescan )\n" @@ -248,7 +248,7 @@ UniValue importwallet(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + if (fHelp || params.size() != 1) throw runtime_error( "importwallet \"filename\"\n" @@ -385,14 +385,14 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + if (fHelp || params.size() != 1) throw runtime_error( - "dumpprivkey \"zcashaddress\"\n" - "\nReveals the private key corresponding to 'zcashaddress'.\n" + "dumpprivkey \"komodoaddress\"\n" + "\nReveals the private key corresponding to 'komodoaddress'.\n" "Then the importprivkey can be used with this output\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The zcash address for the private key\n" + "1. \"komodoaddress\" (string, required) The komodo address for the private key\n" "\nResult:\n" "\"key\" (string) The private key\n" "\nExamples:\n" @@ -424,13 +424,13 @@ UniValue z_exportwallet(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + if (fHelp || params.size() != 1) throw runtime_error( "z_exportwallet \"filename\"\n" "\nExports all wallet keys, for taddr and zaddr, in a human-readable format. Overwriting an existing file is not permitted.\n" "\nArguments:\n" - "1. \"filename\" (string, required) The filename, saved in folder set by zcashd -exportdir option\n" + "1. \"filename\" (string, required) The filename, saved in folder set by komodod -exportdir option\n" "\nResult:\n" "\"path\" (string) The full path of the destination file\n" "\nExamples:\n" @@ -451,7 +451,7 @@ UniValue dumpwallet(const UniValue& params, bool fHelp) "dumpwallet \"filename\"\n" "\nDumps taddr wallet keys in a human-readable format. Overwriting an existing file is not permitted.\n" "\nArguments:\n" - "1. \"filename\" (string, required) The filename, saved in folder set by zcashd -exportdir option\n" + "1. \"filename\" (string, required) The filename, saved in folder set by komodod -exportdir option\n" "\nResult:\n" "\"path\" (string) The full path of the destination file\n" "\nExamples:\n" @@ -475,7 +475,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys) throw JSONRPCError(RPC_INTERNAL_ERROR, e.what()); } if (exportdir.empty()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Cannot export wallet until the zcashd -exportdir option has been set"); + throw JSONRPCError(RPC_WALLET_ERROR, "Cannot export wallet until the komodod -exportdir option has been set"); } std::string unclean = params[0].get_str(); std::string clean = SanitizeFilename(unclean); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 347c15f2d..ecc2b5d40 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -126,7 +126,7 @@ UniValue getnewaddress(const UniValue& params, bool fHelp) "\nArguments:\n" "1. \"account\" (string, optional) DEPRECATED. If provided, it MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" - "\"zcashaddress\" (string) The new Zcash address\n" + "\"komodoaddress\" (string) The new Komodo address\n" "\nExamples:\n" + HelpExampleCli("getnewaddress", "") + HelpExampleRpc("getnewaddress", "") @@ -203,7 +203,7 @@ UniValue getaccountaddress(const UniValue& params, bool fHelp) "\nArguments:\n" "1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" - "\"zcashaddress\" (string) The account Zcash address\n" + "\"komodoaddress\" (string) The account Komodo address\n" "\nExamples:\n" + HelpExampleCli("getaccountaddress", "") + HelpExampleCli("getaccountaddress", "\"\"") @@ -265,14 +265,14 @@ UniValue setaccount(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "setaccount \"zcashaddress\" \"account\"\n" + "setaccount \"komodoaddress\" \"account\"\n" "\nDEPRECATED. Sets the account associated with the given address.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to be associated with an account.\n" + "1. \"komodoaddress\" (string, required) The Komodo address to be associated with an account.\n" "2. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nExamples:\n" - + HelpExampleCli("setaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"tabby\"") - + HelpExampleRpc("setaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", \"tabby\"") + + HelpExampleCli("setaccount", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"tabby\"") + + HelpExampleRpc("setaccount", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"tabby\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -311,15 +311,15 @@ UniValue getaccount(const UniValue& params, bool fHelp) if (fHelp || params.size() != 1) throw runtime_error( - "getaccount \"zcashaddress\"\n" + "getaccount \"komodoaddress\"\n" "\nDEPRECATED. Returns the account associated with the given address.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address for account lookup.\n" + "1. \"komodoaddress\" (string, required) The Komodo address for account lookup.\n" "\nResult:\n" "\"accountname\" (string) the account address\n" "\nExamples:\n" - + HelpExampleCli("getaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") - + HelpExampleRpc("getaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") + + HelpExampleCli("getaccount", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\"") + + HelpExampleRpc("getaccount", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -349,7 +349,7 @@ UniValue getaddressesbyaccount(const UniValue& params, bool fHelp) "1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" "[ (json array of string)\n" - " \"zcashaddress\" (string) a Zcash address associated with the given account\n" + " \"komodoaddress\" (string) a Komodo address associated with the given account\n" " ,...\n" "]\n" "\nExamples:\n" @@ -425,11 +425,11 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2 || params.size() > 5) throw runtime_error( - "sendtoaddress \"zcashaddress\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n" + "sendtoaddress \"komodoaddress\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n" "\nSend an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001\n" + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to send to.\n" + "1. \"komodoaddress\" (string, required) The Komodo address to send to.\n" "2. \"amount\" (numeric, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n" "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" " This is not part of the transaction, just kept in your wallet.\n" @@ -437,14 +437,14 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) " to which you're sending the transaction. This is not part of the \n" " transaction, just kept in your wallet.\n" "5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" - " The recipient will receive less Zcash than you enter in the amount field.\n" + " The recipient will receive less Komodo than you enter in the amount field.\n" "\nResult:\n" "\"transactionid\" (string) The transaction id.\n" "\nExamples:\n" - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"donation\" \"seans outpost\"") - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true") - + HelpExampleRpc("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.1, \"donation\", \"seans outpost\"") + + HelpExampleCli("sendtoaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" 0.1") + + HelpExampleCli("sendtoaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" 0.1 \"donation\" \"seans outpost\"") + + HelpExampleCli("sendtoaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" 0.1 \"\" \"\" true") + + HelpExampleRpc("sendtoaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\", 0.1, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -712,7 +712,7 @@ UniValue listaddressgroupings(const UniValue& params, bool fHelp) "[\n" " [\n" " [\n" - " \"zcashaddress\", (string) The zcash address\n" + " \"komodoaddress\", (string) The komodo address\n" " amount, (numeric) The amount in " + CURRENCY_UNIT + "\n" " \"account\" (string, optional) The account (DEPRECATED)\n" " ]\n" @@ -755,11 +755,11 @@ UniValue signmessage(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error( - "signmessage \"zcashaddress\" \"message\"\n" + "signmessage \"komodoaddress\" \"message\"\n" "\nSign a message with the private key of an address" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to use for the private key.\n" + "1. \"komodoaddress\" (string, required) The Komodo address to use for the private key.\n" "2. \"message\" (string, required) The message to create a signature of.\n" "\nResult:\n" "\"signature\" (string) The signature of the message encoded in base 64\n" @@ -767,11 +767,11 @@ UniValue signmessage(const UniValue& params, bool fHelp) "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" - + HelpExampleCli("signmessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"my message\"") + + + HelpExampleCli("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"my message\"") + "\nVerify the signature\n" - + HelpExampleCli("verifymessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"signature\" \"my message\"") + + + HelpExampleCli("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"signature\" \"my message\"") + "\nAs json rpc\n" - + HelpExampleRpc("signmessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", \"my message\"") + + HelpExampleRpc("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"my message\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -811,22 +811,22 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "getreceivedbyaddress \"zcashaddress\" ( minconf )\n" - "\nReturns the total amount received by the given Zcash address in transactions with at least minconf confirmations.\n" + "getreceivedbyaddress \"komodoaddress\" ( minconf )\n" + "\nReturns the total amount received by the given Komodo address in transactions with at least minconf confirmations.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address for transactions.\n" + "1. \"komodoaddress\" (string, required) The Komodo address for transactions.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received at this address.\n" "\nExamples:\n" "\nThe amount from transactions with at least 1 confirmation\n" - + HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") + + + HelpExampleCli("getreceivedbyaddress", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\"") + "\nThe amount including unconfirmed transactions, zero confirmations\n" - + HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" 0") + + + HelpExampleCli("getreceivedbyaddress", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" 0") + "\nThe amount with at least 6 confirmations, very safe\n" - + HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" 6") + + + HelpExampleCli("getreceivedbyaddress", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" 6") + "\nAs a json rpc call\n" - + HelpExampleRpc("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", 6") + + HelpExampleRpc("getreceivedbyaddress", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", 6") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1119,13 +1119,13 @@ UniValue sendfrom(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3 || params.size() > 6) throw runtime_error( - "sendfrom \"fromaccount\" \"tozcashaddress\" amount ( minconf \"comment\" \"comment-to\" )\n" - "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a Zcash address.\n" + "sendfrom \"fromaccount\" \"tokomodoaddress\" amount ( minconf \"comment\" \"comment-to\" )\n" + "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a Komodo address.\n" "The amount is a real and is rounded to the nearest 0.00000001." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" - "2. \"tozcashaddress\" (string, required) The Zcash address to send funds to.\n" + "2. \"tokomodoaddress\" (string, required) The Komodo address to send funds to.\n" "3. amount (numeric, required) The amount in " + CURRENCY_UNIT + " (transaction fee is added on top).\n" "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" "5. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" @@ -1137,11 +1137,11 @@ UniValue sendfrom(const UniValue& params, bool fHelp) "\"transactionid\" (string) The transaction id.\n" "\nExamples:\n" "\nSend 0.01 " + CURRENCY_UNIT + " from the default account to the address, must have at least 1 confirmation\n" - + HelpExampleCli("sendfrom", "\"\" \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01") + + + HelpExampleCli("sendfrom", "\"\" \"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" 0.01") + "\nSend 0.01 from the tabby account to the given address, funds must have at least 6 confirmations\n" - + HelpExampleCli("sendfrom", "\"tabby\" \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01 6 \"donation\" \"seans outpost\"") + + + HelpExampleCli("sendfrom", "\"tabby\" \"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" 0.01 6 \"donation\" \"seans outpost\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("sendfrom", "\"tabby\", \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.01, 6, \"donation\", \"seans outpost\"") + + HelpExampleRpc("sendfrom", "\"tabby\", \"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\", 0.01, 6, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1191,14 +1191,14 @@ UniValue sendmany(const UniValue& params, bool fHelp) "1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "2. \"amounts\" (string, required) A json object with addresses and amounts\n" " {\n" - " \"address\":amount (numeric) The Zcash address is the key, the numeric amount in " + CURRENCY_UNIT + " is the value\n" + " \"address\":amount (numeric) The Komodo address is the key, the numeric amount in " + CURRENCY_UNIT + " is the value\n" " ,...\n" " }\n" "3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n" "4. \"comment\" (string, optional) A comment\n" "5. subtractfeefromamount (string, optional) A json array with addresses.\n" " The fee will be equally deducted from the amount of each selected address.\n" - " Those recipients will receive less Zcash than you enter in their corresponding amount field.\n" + " Those recipients will receive less Komodo than you enter in their corresponding amount field.\n" " If no addresses are specified here, the sender pays the fee.\n" " [\n" " \"address\" (string) Subtract fee from this address\n" @@ -1209,13 +1209,13 @@ UniValue sendmany(const UniValue& params, bool fHelp) " the number of addresses.\n" "\nExamples:\n" "\nSend two amounts to two different addresses:\n" - + HelpExampleCli("sendmany", "\"\" \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") + + + HelpExampleCli("sendmany", "\"\" \"{\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\":0.01,\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\":0.02}\"") + "\nSend two amounts to two different addresses setting the confirmation and comment:\n" - + HelpExampleCli("sendmany", "\"\" \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 6 \"testing\"") + + + HelpExampleCli("sendmany", "\"\" \"{\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\":0.01,\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\":0.02}\" 6 \"testing\"") + "\nSend two amounts to two different addresses, subtract fee from amount:\n" - + HelpExampleCli("sendmany", "\"\" \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 1 \"\" \"[\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\",\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") + + + HelpExampleCli("sendmany", "\"\" \"{\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\":0.01,\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\":0.02}\" 1 \"\" \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("sendmany", "\"\", \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\", 6, \"testing\"") + + HelpExampleRpc("sendmany", "\"\", \"{\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\":0.01,\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\":0.02}\", 6, \"testing\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1306,21 +1306,21 @@ UniValue addmultisigaddress(const UniValue& params, bool fHelp) "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" - "2. \"keysobject\" (string, required) A json array of Zcash addresses or hex-encoded public keys\n" + "2. \"keysobject\" (string, required) A json array of Komodo addresses or hex-encoded public keys\n" " [\n" - " \"address\" (string) Zcash address or hex-encoded public key\n" + " \"address\" (string) Komodo address or hex-encoded public key\n" " ...,\n" " ]\n" "3. \"account\" (string, optional) DEPRECATED. If provided, MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" - "\"zcashaddress\" (string) A Zcash address associated with the keys.\n" + "\"komodoaddress\" (string) A Komodo address associated with the keys.\n" "\nExamples:\n" "\nAdd a multisig address from 2 addresses\n" - + HelpExampleCli("addmultisigaddress", "2 \"[\\\"t16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"t171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + + HelpExampleCli("addmultisigaddress", "2 \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + "\nAs json rpc call\n" - + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"t16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"t171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") ; throw runtime_error(msg); } @@ -1669,7 +1669,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp) " {\n" " \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. \n" " It will be \"\" for the default account.\n" - " \"address\":\"zcashaddress\", (string) The Zcash address of the transaction. Not present for \n" + " \"address\":\"komodoaddress\", (string) The Komodo address of the transaction. Not present for \n" " move transactions (category = move).\n" " \"category\":\"send|receive|move\", (string) The transaction category. 'move' is a local (off blockchain)\n" " transaction between accounts, and not associated with an address,\n" @@ -1869,7 +1869,7 @@ UniValue listsinceblock(const UniValue& params, bool fHelp) "{\n" " \"transactions\": [\n" " \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. Will be \"\" for the default account.\n" - " \"address\":\"zcashaddress\", (string) The Zcash address of the transaction. Not present for move transactions (category = move).\n" + " \"address\":\"komodoaddress\", (string) The Komodo address of the transaction. Not present for move transactions (category = move).\n" " \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the 'move' category for moves \n" " outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" @@ -1968,7 +1968,7 @@ UniValue gettransaction(const UniValue& params, bool fHelp) " \"details\" : [\n" " {\n" " \"account\" : \"accountname\", (string) DEPRECATED. The account name involved in the transaction, can be \"\" for the default account.\n" - " \"address\" : \"zcashaddress\", (string) The Zcash address involved in the transaction\n" + " \"address\" : \"komodoaddress\", (string) The Komodo address involved in the transaction\n" " \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n" " \"amount\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n" " \"vout\" : n, (numeric) the vout value\n" @@ -2128,7 +2128,7 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp) throw runtime_error( "walletpassphrase \"passphrase\" timeout\n" "\nStores the wallet decryption key in memory for 'timeout' seconds.\n" - "This is needed prior to performing transactions related to private keys such as sending Zcash\n" + "This is needed prior to performing transactions related to private keys such as sending Komodo\n" "\nArguments:\n" "1. \"passphrase\" (string, required) The wallet passphrase\n" "2. timeout (numeric, required) The time to keep the decryption key in seconds.\n" @@ -2242,7 +2242,7 @@ UniValue walletlock(const UniValue& params, bool fHelp) "\nSet the passphrase for 2 minutes to perform a transaction\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + "\nPerform a send (requires passphrase set)\n" - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") + + + HelpExampleCli("sendtoaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" 1.0") + "\nClear the passphrase since we are done before 2 minutes is up\n" + HelpExampleCli("walletlock", "") + "\nAs json rpc call\n" @@ -2293,10 +2293,10 @@ UniValue encryptwallet(const UniValue& params, bool fHelp) "\nExamples:\n" "\nEncrypt you wallet\n" + HelpExampleCli("encryptwallet", "\"my pass phrase\"") + - "\nNow set the passphrase to use the wallet, such as for signing or sending Zcash\n" + "\nNow set the passphrase to use the wallet, such as for signing or sending Komodo\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\"") + "\nNow we can so something like sign\n" - + HelpExampleCli("signmessage", "\"zcashaddress\" \"test message\"") + + + HelpExampleCli("signmessage", "\"komodoaddress\" \"test message\"") + "\nNow lock the wallet again by removing the passphrase\n" + HelpExampleCli("walletlock", "") + "\nAs a json rpc call\n" @@ -2344,7 +2344,7 @@ UniValue lockunspent(const UniValue& params, bool fHelp) "lockunspent unlock [{\"txid\":\"txid\",\"vout\":n},...]\n" "\nUpdates list of temporarily unspendable outputs.\n" "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" - "A locked transaction output will not be chosen by automatic coin selection, when spending Zcash.\n" + "A locked transaction output will not be chosen by automatic coin selection, when spending Komodo.\n" "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n" "is always cleared (by virtue of process exit) when a node stops or fails.\n" "Also see the listunspent call\n" @@ -2579,9 +2579,9 @@ UniValue listunspent(const UniValue& params, bool fHelp) "\nArguments:\n" "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n" "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n" - "3. \"addresses\" (string) A json array of Zcash addresses to filter\n" + "3. \"addresses\" (string) A json array of Komodo addresses to filter\n" " [\n" - " \"address\" (string) Zcash address\n" + " \"address\" (string) Komodo address\n" " ,...\n" " ]\n" "\nResult\n" @@ -2590,7 +2590,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) " \"txid\" : \"txid\", (string) the transaction id \n" " \"vout\" : n, (numeric) the vout value\n" " \"generated\" : true|false (boolean) true if txout is a coinbase transaction output\n" - " \"address\" : \"address\", (string) the Zcash address\n" + " \"address\" : \"address\", (string) the Komodo address\n" " \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n" " \"scriptPubKey\" : \"key\", (string) the script key\n" " \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n" @@ -3230,7 +3230,7 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp) "\nReturns a new zaddr for receiving payments.\n" "\nArguments:\n" "\nResult:\n" - "\"zcashaddress\" (string) The new zaddr\n" + "\"komodoaddress\" (string) The new zaddr\n" "\nExamples:\n" + HelpExampleCli("z_getnewaddress", "") + HelpExampleRpc("z_getnewaddress", "") @@ -3669,8 +3669,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) "\nResult:\n" "\"operationid\" (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "\nExamples:\n" - + HelpExampleCli("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" '[{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]'") - + HelpExampleRpc("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", [{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]") + + HelpExampleCli("z_sendmany", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" '[{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]'") + + HelpExampleRpc("z_sendmany", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\", [{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3828,7 +3828,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); bool isShielded = !fromTaddr || zaddrRecipients.size() > 0; if (contextualTx.nVersion == 1 && isShielded) { - contextualTx.nVersion = 2; // Tx format should support vjoinsplits + contextualTx.nVersion = 2; // Tx format should support vjoinsplits } if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { contextualTx.nExpiryHeight = nextBlockHeight + expiryDelta; @@ -3889,8 +3889,8 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("z_shieldcoinbase", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") - + HelpExampleRpc("z_shieldcoinbase", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleCli("z_shieldcoinbase", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\" \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleRpc("z_shieldcoinbase", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\", \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4023,7 +4023,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); if (contextualTx.nVersion == 1) { - contextualTx.nVersion = 2; // Tx format should support vjoinsplits + contextualTx.nVersion = 2; // Tx format should support vjoinsplits } if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { contextualTx.nExpiryHeight = nextBlockHeight + expiryDelta; @@ -4107,8 +4107,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("z_mergetoaddress", "'[\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") - + HelpExampleRpc("z_mergetoaddress", "[\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleCli("z_mergetoaddress", "'[\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") + + HelpExampleRpc("z_mergetoaddress", "[\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); if (!fEnableMergeToAddress) { From 39c15c681f35d536076962c252a9e94a0f72bf1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 May 2018 16:53:59 +0300 Subject: [PATCH 135/157] -GAME for now --- src/dpowassets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dpowassets b/src/dpowassets index 642881532..b8e2583e8 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -33,4 +33,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" +#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" From 221cc791c35aa1a8d3b3927a34ce97f5e60b8562 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 15 May 2018 22:45:16 +0300 Subject: [PATCH 136/157] Change notary sig to CRYPTO output --- src/komodo_defs.h | 1 + src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index a1b219e80..1d7351638 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -7,5 +7,6 @@ #define KOMODO_ASSETCHAIN_MAXLEN 65 #define KOMODO_LIMITED_NETWORKSIZE 4 #define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus +#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c87f6b2dd..174b9a99a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4519,7 +4519,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; - txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; CTransaction txNewConst(txNew); signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); From f5446e44b75598e6ad0043b9597ac356c551b70e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 May 2018 16:56:44 +0300 Subject: [PATCH 137/157] Enable zmergetoaddress by default --- src/komodo_gateway.h | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 018baa675..7b642746a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -729,7 +729,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } if ( strangeout != 0 || notmatched != 0 ) { - if ( strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) + if ( 0 && strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); if ( height > 1000000 && strangeout != 0 ) return(-1); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 174b9a99a..fa2937005 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4067,7 +4067,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - auto fEnableMergeToAddress = fExperimentalMode && GetBoolArg("-zmergetoaddress", false); + auto fEnableMergeToAddress = true; //fExperimentalMode && GetBoolArg("-zmergetoaddress", false); std::string strDisabledMsg = ""; if (!fEnableMergeToAddress) { strDisabledMsg = "\nWARNING: z_mergetoaddress is DISABLED but can be enabled as an experimental feature.\n"; From 833115ea41708022e7caf9749a47ceb58d30f161 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 19 May 2018 02:27:58 +0200 Subject: [PATCH 138/157] add DSEC --- src/ac/dsec | 2 ++ src/assetchains | 1 + src/assetchains.old | 1 + src/assetchains_stop | 1 + src/dpowassets | 1 + src/fiat-cli | 1 + src/fiat/dsec | 2 ++ 7 files changed, 9 insertions(+) create mode 100644 src/ac/dsec create mode 100644 src/fiat/dsec diff --git a/src/ac/dsec b/src/ac/dsec new file mode 100644 index 000000000..a050ca94f --- /dev/null +++ b/src/ac/dsec @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=DSEC $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains b/src/assetchains index 2a883726d..a8ab28155 100755 --- a/src/assetchains +++ b/src/assetchains @@ -54,3 +54,4 @@ komodo_asset OOT 216000000 komodo_asset BNTN 500000000 komodo_asset CHAIN 999999 komodo_asset PRLPAY 500000000 +komodo_asset DSEC 7000000 diff --git a/src/assetchains.old b/src/assetchains.old index d41b64766..4e56fe639 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -31,6 +31,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 & ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & +./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & #sleep $delay #./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & diff --git a/src/assetchains_stop b/src/assetchains_stop index ba314e1c9..e55231b1a 100644 --- a/src/assetchains_stop +++ b/src/assetchains_stop @@ -37,3 +37,4 @@ komodo_stop OOT komodo_stop BNTN komodo_stop CHAIN komodo_stop PRLPAY +komodo_stop DSEC diff --git a/src/dpowassets b/src/dpowassets index 5076a385c..537b116e4 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -30,6 +30,7 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" #curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat-cli b/src/fiat-cli index 76f219c83..463906cf2 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -27,3 +27,4 @@ echo oot; fiat/oot $1 $2 $3 $4 echo bntn; fiat/bntn $1 $2 $3 $4 echo chain; fiat/chain $1 $2 $3 $4 echo prlpay; fiat/prlpay $1 $2 $3 $4 +echo dsec; fiat/dsec $1 $2 $3 $4 diff --git a/src/fiat/dsec b/src/fiat/dsec new file mode 100644 index 000000000..a050ca94f --- /dev/null +++ b/src/fiat/dsec @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=DSEC $1 $2 $3 $4 $5 $6 From db83a2c0c3f6dc3c7050677ff86f76889f30e605 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 19 May 2018 00:56:25 -0700 Subject: [PATCH 139/157] Try Hush regtest params This fails with: $ ./komodod -regtest Assertion failed: (consensus.hashGenesisBlock == uint256S("0x0379ff1530af893f2f2e61146db6e900dd828dc8254215b9de23df2dba06664f")), function CRegTestParams, file chainparams.cpp, line 540. Abort trap: 6 (core dumped) From https://github.com/MyHush/hush/pull/106/commits/1d8c55ecc297e9d6574d9eeb55d7eebb9546838b --- src/chainparams.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index df258d782..1482189d5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -532,11 +532,13 @@ public: BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; nEquihashK = K; - genesis.nTime = 1296688602; + genesis.nTime = 1519568466; genesis.nBits = KOMODO_MINDIFF_NBITS; - genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000021"); - genesis.nSolution = ParseHex("0f2a976db4c4263da10fd5d38eb1790469cf19bdb4bf93450e09a72fdff17a3454326399"); + genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000016"); + genesis.nSolution = ParseHex("0d1d1ef025037da781252f695ff279c12d492c5ed53e565c8ecdc044ede53cea96cff5fc"); consensus.hashGenesisBlock = genesis.GetHash(); + assert(consensus.hashGenesisBlock == uint256S("0x0379ff1530af893f2f2e61146db6e900dd828dc8254215b9de23df2dba06664f")); + nDefaultPort = 17779; nPruneAfterHeight = 1000; From a34f39e9b2e5ab759a520c441ecc3c6fe2b91e29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 May 2018 15:49:34 +0300 Subject: [PATCH 140/157] Dont overwrite sp->MoM with null --- src/komodo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ec1bc8013..9af2eed71 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,8 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; - sp->MoM = MoM; - sp->MoMdepth = MoMdepth; + if ( bits256_nonz(MoM) != 0 && MoMdepth > 0 ) + { + sp->MoM = MoM; + sp->MoMdepth = MoMdepth; + } komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); From 1b15c32d18fadeb0f92c2fcf3388f8e35b2e1be5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 May 2018 16:41:38 +0300 Subject: [PATCH 141/157] syntax --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 9af2eed71..36c7c2ef3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,7 +695,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; - if ( bits256_nonz(MoM) != 0 && MoMdepth > 0 ) + if ( MoM != zero && MoMdepth > 0 ) { sp->MoM = MoM; sp->MoMdepth = MoMdepth; From cadcb27a614470a0e5d92ebf49bbd424f32dd989 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Sat, 19 May 2018 16:50:17 +0300 Subject: [PATCH 142/157] Chmod fix --- src/ac/dsec | 0 src/assetchains_stop | 0 src/fiat/dsec | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/ac/dsec mode change 100644 => 100755 src/assetchains_stop mode change 100644 => 100755 src/fiat/dsec diff --git a/src/ac/dsec b/src/ac/dsec old mode 100644 new mode 100755 diff --git a/src/assetchains_stop b/src/assetchains_stop old mode 100644 new mode 100755 diff --git a/src/fiat/dsec b/src/fiat/dsec old mode 100644 new mode 100755 From b860fdec0d479784b095032a3b7aa9a5bfe13800 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 May 2018 18:48:33 +0300 Subject: [PATCH 143/157] Enable GAME --- src/dpowassets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dpowassets b/src/dpowassets index 537b116e4..f148bda05 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -33,4 +33,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" -#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" From b78c39beb269037b923de33314b86673b8068c95 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 19 May 2018 08:51:45 -0700 Subject: [PATCH 144/157] Convert to using CreateGenesisBlock() like Zcash upstream --- src/chainparams.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1482189d5..0c45e1961 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -532,12 +532,15 @@ public: BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; nEquihashK = K; - genesis.nTime = 1519568466; - genesis.nBits = KOMODO_MINDIFF_NBITS; - genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000016"); - genesis.nSolution = ParseHex("0d1d1ef025037da781252f695ff279c12d492c5ed53e565c8ecdc044ede53cea96cff5fc"); + genesis = CreateGenesisBlock( + 1519568466, + uint256S("0x0000000000000000000000000000000000000000000000000000000000000016"), + ParseHex("0d1d1ef025037da781252f695ff279c12d492c5ed53e565c8ecdc044ede53cea96cff5fc"), + KOMODO_MINDIFF_NBITS, 4, 0); + consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x0379ff1530af893f2f2e61146db6e900dd828dc8254215b9de23df2dba06664f")); + //TODO: assert merkle root nDefaultPort = 17779; nPruneAfterHeight = 1000; From 373afcb4990ea009acbde64b85971f0b83c95c77 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 19 May 2018 10:05:53 -0700 Subject: [PATCH 145/157] Use correct regtest genesis block hash komodod now starts up and dies with InvalidChainFound, I think due to checkpoints: call komodo_args.(./src/komodod) NOTARY_PUBKEY.() initialized at 1526749522 finished loading blocks Assertion failed: (tip), function InvalidChainFound, file main.cpp, line 1942. --- src/chainparams.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 0c45e1961..7fd9ba9ad 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -532,14 +532,17 @@ public: BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; nEquihashK = K; + // #define KOMODO_MINDIFF_NBITS 0x200f0f0f genesis = CreateGenesisBlock( - 1519568466, - uint256S("0x0000000000000000000000000000000000000000000000000000000000000016"), - ParseHex("0d1d1ef025037da781252f695ff279c12d492c5ed53e565c8ecdc044ede53cea96cff5fc"), + 1296688602, + uint256S("0x000000000000000000000000000000000000000000000000000000000000002f"), + ParseHex("1d64134e87a42ad5f12196da1452cb56b1f22a438fabd776ee8fca71ce1fb9b7fcc6f5ec"), KOMODO_MINDIFF_NBITS, 4, 0); consensus.hashGenesisBlock = genesis.GetHash(); - assert(consensus.hashGenesisBlock == uint256S("0x0379ff1530af893f2f2e61146db6e900dd828dc8254215b9de23df2dba06664f")); + printf("genblock hash=%s\n", consensus.hashGenesisBlock.ToString().c_str() ); + assert(consensus.hashGenesisBlock == uint256S("0xe76fb931218cd30c8bc6e6dfe26925eeff7611c7e6957466ea0d38cde03f0008")); + //assert(consensus.hashGenesisBlock == uint256S("0x02dd14e268a4b7a7e6758f14e718abf82cc6649e53bf00bace3059a74d66ec79")); //TODO: assert merkle root nDefaultPort = 17779; From 16df92af5983757f6de61e5cbc7f59e28e9b98bc Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 19 May 2018 10:45:12 -0700 Subject: [PATCH 146/157] Use latest Zcash regtest params, could not use the same as Hush because KMD has merged in latest consensus changes from ZEC upstream --- src/chainparams.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7fd9ba9ad..43acd0bb2 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -532,18 +532,15 @@ public: BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; nEquihashK = K; - // #define KOMODO_MINDIFF_NBITS 0x200f0f0f + genesis = CreateGenesisBlock( 1296688602, - uint256S("0x000000000000000000000000000000000000000000000000000000000000002f"), - ParseHex("1d64134e87a42ad5f12196da1452cb56b1f22a438fabd776ee8fca71ce1fb9b7fcc6f5ec"), - KOMODO_MINDIFF_NBITS, 4, 0); - + uint256S("0x0000000000000000000000000000000000000000000000000000000000000009"), + ParseHex("01936b7db1eb4ac39f151b8704642d0a8bda13ec547d54cd5e43ba142fc6d8877cab07b3"), + 0x200f0f0f, 4, 0); consensus.hashGenesisBlock = genesis.GetHash(); - printf("genblock hash=%s\n", consensus.hashGenesisBlock.ToString().c_str() ); - assert(consensus.hashGenesisBlock == uint256S("0xe76fb931218cd30c8bc6e6dfe26925eeff7611c7e6957466ea0d38cde03f0008")); - //assert(consensus.hashGenesisBlock == uint256S("0x02dd14e268a4b7a7e6758f14e718abf82cc6649e53bf00bace3059a74d66ec79")); - //TODO: assert merkle root + assert(consensus.hashGenesisBlock == uint256S("0x029f11d80ef9765602235e1bc9727e3eb6ba20839319f761fee920d63401e327")); + assert(genesis.hashMerkleRoot == uint256S("0xc4eaa58879081de3c24a7b117ed2b28300e7ec4c4c1dff1d3f1268b7857a4ddb")); nDefaultPort = 17779; nPruneAfterHeight = 1000; From 8cf70067ac76378278eaab6a35b506c8e228edc1 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 19 May 2018 10:49:01 -0700 Subject: [PATCH 147/157] Use the KOMODO_MINDIFF_NBITS constant --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 43acd0bb2..d78e1351b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -537,7 +537,7 @@ public: 1296688602, uint256S("0x0000000000000000000000000000000000000000000000000000000000000009"), ParseHex("01936b7db1eb4ac39f151b8704642d0a8bda13ec547d54cd5e43ba142fc6d8877cab07b3"), - 0x200f0f0f, 4, 0); + KOMODO_MINDIFF_NBITS, 4, 0); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x029f11d80ef9765602235e1bc9727e3eb6ba20839319f761fee920d63401e327")); assert(genesis.hashMerkleRoot == uint256S("0xc4eaa58879081de3c24a7b117ed2b28300e7ec4c4c1dff1d3f1268b7857a4ddb")); From 137e08d7298750f9316af7c6e09ddfc5b00d4877 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 May 2018 00:12:37 +0300 Subject: [PATCH 148/157] -print --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fa2937005..e50d01f68 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4502,7 +4502,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) script = (uint8_t *)out.tx->vout[out.i].scriptPubKey.data(); if ( out.tx->vout[out.i].scriptPubKey.size() != 35 || script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(notarypub33,script+1,33) != 0 ) { - fprintf(stderr,"scriptsize.%d [0] %02x\n",(int32_t)out.tx->vout[out.i].scriptPubKey.size(),script[0]); + //fprintf(stderr,"scriptsize.%d [0] %02x\n",(int32_t)out.tx->vout[out.i].scriptPubKey.size(),script[0]); continue; } utxovalue = (uint64_t)nValue; From 1333d0d7cfdf5d74a98131eaaa5d36b8cd68e388 Mon Sep 17 00:00:00 2001 From: alrighttt Date: Mon, 21 May 2018 18:34:18 -0400 Subject: [PATCH 149/157] Changed help docs to reflect KMD/assetchains --- src/wallet/rpcwallet.cpp | 209 ++++++++++++++++++++------------------- 1 file changed, 107 insertions(+), 102 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fa2937005..82ff2fa7f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -42,6 +42,7 @@ using namespace std; using namespace libzcash; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); int64_t nWalletUnlockTime; @@ -113,6 +114,11 @@ string AccountFromValue(const UniValue& value) return strAccount; } +char *komodo_chainname() +{ + return(ASSETCHAINS_SYMBOL[0] == 0 ? (char *)"KMD" : ASSETCHAINS_SYMBOL); +} + UniValue getnewaddress(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -121,11 +127,11 @@ UniValue getnewaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() > 1) throw runtime_error( "getnewaddress ( \"account\" )\n" - "\nReturns a new Komodo address for receiving payments.\n" + "\nReturns a new " + strprintf("%s",komodo_chainname()) + " address for receiving payments.\n" "\nArguments:\n" "1. \"account\" (string, optional) DEPRECATED. If provided, it MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" - "\"zcashaddress\" (string) The new Zcash address\n" + "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The new " + strprintf("%s",komodo_chainname()) + " address\n" "\nExamples:\n" + HelpExampleCli("getnewaddress", "") + HelpExampleRpc("getnewaddress", "") @@ -198,11 +204,11 @@ UniValue getaccountaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() != 1) throw runtime_error( "getaccountaddress \"account\"\n" - "\nDEPRECATED. Returns the current Komodo address for receiving payments to this account.\n" + "\nDEPRECATED. Returns the current " + strprintf("%s",komodo_chainname()) + " address for receiving payments to this account.\n" "\nArguments:\n" "1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" - "\"zcashaddress\" (string) The account Zcash address\n" + "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The account " + strprintf("%s",komodo_chainname()) + " address\n" "\nExamples:\n" + HelpExampleCli("getaccountaddress", "") + HelpExampleCli("getaccountaddress", "\"\"") @@ -230,7 +236,7 @@ UniValue getrawchangeaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() > 1) throw runtime_error( "getrawchangeaddress\n" - "\nReturns a new Komodo address, for receiving change.\n" + "\nReturns a new " + strprintf("%s",komodo_chainname()) + " address, for receiving change.\n" "This is for use with raw transactions, NOT normal use.\n" "\nResult:\n" "\"address\" (string) The address\n" @@ -264,21 +270,21 @@ UniValue setaccount(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "setaccount \"zcashaddress\" \"account\"\n" + "setaccount \"" + strprintf("%s",komodo_chainname()) + "_address\" \"account\"\n" "\nDEPRECATED. Sets the account associated with the given address.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to be associated with an account.\n" + "1. \"" + strprintf("%s",komodo_chainname()) + "_address\" (string, required) The " + strprintf("%s",komodo_chainname()) + " address to be associated with an account.\n" "2. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nExamples:\n" - + HelpExampleCli("setaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"tabby\"") - + HelpExampleRpc("setaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", \"tabby\"") + + HelpExampleCli("setaccount", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" \"tabby\"") + + HelpExampleRpc("setaccount", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", \"tabby\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Komodo address"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); string strAccount; if (params.size() > 1) @@ -310,22 +316,22 @@ UniValue getaccount(const UniValue& params, bool fHelp) if (fHelp || params.size() != 1) throw runtime_error( - "getaccount \"zcashaddress\"\n" + "getaccount \"" + strprintf("%s",komodo_chainname()) + "_address\"\n" "\nDEPRECATED. Returns the account associated with the given address.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address for account lookup.\n" + "1. \"" + strprintf("%s",komodo_chainname()) + "_address\" (string, required) The " + strprintf("%s",komodo_chainname()) + " address for account lookup.\n" "\nResult:\n" "\"accountname\" (string) the account address\n" "\nExamples:\n" - + HelpExampleCli("getaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") - + HelpExampleRpc("getaccount", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") + + HelpExampleCli("getaccount", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"") + + HelpExampleRpc("getaccount", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Komodo address"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); string strAccount; map::iterator mi = pwalletMain->mapAddressBook.find(address.Get()); @@ -348,7 +354,7 @@ UniValue getaddressesbyaccount(const UniValue& params, bool fHelp) "1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" "[ (json array of string)\n" - " \"zcashaddress\" (string) a Zcash address associated with the given account\n" + " \"" + strprintf("%s",komodo_chainname()) + "_address\" (string) a " + strprintf("%s",komodo_chainname()) + " address associated with the given account\n" " ,...\n" "]\n" "\nExamples:\n" @@ -424,33 +430,33 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2 || params.size() > 5) throw runtime_error( - "sendtoaddress \"zcashaddress\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n" + "sendtoaddress \"" + strprintf("%s",komodo_chainname()) + "_address\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n" "\nSend an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001\n" + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to send to.\n" - "2. \"amount\" (numeric, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n" + "1. \"" + strprintf("%s",komodo_chainname()) + "_address\" (string, required) The " + strprintf("%s",komodo_chainname()) + " address to send to.\n" + "2. \"amount\" (numeric, required) The amount in " + strprintf("%s",komodo_chainname()) + " to send. eg 0.1\n" "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" " This is not part of the transaction, just kept in your wallet.\n" "4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" " to which you're sending the transaction. This is not part of the \n" " transaction, just kept in your wallet.\n" "5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" - " The recipient will receive less Zcash than you enter in the amount field.\n" + " The recipient will receive less " + strprintf("%s",komodo_chainname()) + " than you enter in the amount field.\n" "\nResult:\n" "\"transactionid\" (string) The transaction id.\n" "\nExamples:\n" - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"donation\" \"seans outpost\"") - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true") - + HelpExampleRpc("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.1, \"donation\", \"seans outpost\"") + + HelpExampleCli("sendtoaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 0.1") + + HelpExampleCli("sendtoaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 0.1 \"donation\" \"seans outpost\"") + + HelpExampleCli("sendtoaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 0.1 \"\" \"\" true") + + HelpExampleRpc("sendtoaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", 0.1, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Komodo address"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); // Amount CAmount nAmount = AmountFromValue(params[1]); @@ -483,7 +489,6 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis); int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen); #define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern int32_t KOMODO_PAX; extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t komodo_is_issuer(); @@ -712,8 +717,8 @@ UniValue listaddressgroupings(const UniValue& params, bool fHelp) "[\n" " [\n" " [\n" - " \"zcashaddress\", (string) The zcash address\n" - " amount, (numeric) The amount in " + CURRENCY_UNIT + "\n" + " \"" + strprintf("%s",komodo_chainname()) + " address\", (string) The " + strprintf("%s",komodo_chainname()) + " address\n" + " amount, (numeric) The amount in " + strprintf("%s",komodo_chainname()) + "\n" " \"account\" (string, optional) The account (DEPRECATED)\n" " ]\n" " ,...\n" @@ -755,11 +760,11 @@ UniValue signmessage(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error( - "signmessage \"zcashaddress\" \"message\"\n" + "signmessage \"" + strprintf("%s",komodo_chainname()) + " address\" \"message\"\n" "\nSign a message with the private key of an address" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address to use for the private key.\n" + "1. \"" + strprintf("%s",komodo_chainname()) + " address\" (string, required) The " + strprintf("%s",komodo_chainname()) + " address to use for the private key.\n" "2. \"message\" (string, required) The message to create a signature of.\n" "\nResult:\n" "\"signature\" (string) The signature of the message encoded in base 64\n" @@ -767,11 +772,11 @@ UniValue signmessage(const UniValue& params, bool fHelp) "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" - + HelpExampleCli("signmessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"my message\"") + + + HelpExampleCli("signmessage", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" \"my message\"") + "\nVerify the signature\n" - + HelpExampleCli("verifymessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" \"signature\" \"my message\"") + + + HelpExampleCli("verifymessage", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" \"signature\" \"my message\"") + "\nAs json rpc\n" - + HelpExampleRpc("signmessage", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", \"my message\"") + + HelpExampleRpc("signmessage", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", \"my message\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -811,22 +816,22 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "getreceivedbyaddress \"zcashaddress\" ( minconf )\n" - "\nReturns the total amount received by the given Zcash address in transactions with at least minconf confirmations.\n" + "getreceivedbyaddress \"" + strprintf("%s",komodo_chainname()) + "_address\" ( minconf )\n" + "\nReturns the total amount received by the given " + strprintf("%s",komodo_chainname()) + " address in transactions with at least minconf confirmations.\n" "\nArguments:\n" - "1. \"zcashaddress\" (string, required) The Zcash address for transactions.\n" + "1. \"" + strprintf("%s",komodo_chainname()) + "_address\" (string, required) The " + strprintf("%s",komodo_chainname()) + " address for transactions.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" - "amount (numeric) The total amount in " + CURRENCY_UNIT + " received at this address.\n" + "amount (numeric) The total amount in " + strprintf("%s",komodo_chainname()) + " received at this address.\n" "\nExamples:\n" "\nThe amount from transactions with at least 1 confirmation\n" - + HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\"") + + + HelpExampleCli("getreceivedbyaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"") + "\nThe amount including unconfirmed transactions, zero confirmations\n" - + HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" 0") + + + HelpExampleCli("getreceivedbyaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 0") + "\nThe amount with at least 6 confirmations, very safe\n" - + HelpExampleCli("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\" 6") + + + HelpExampleCli("getreceivedbyaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 6") + "\nAs a json rpc call\n" - + HelpExampleRpc("getreceivedbyaddress", "\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\", 6") + + HelpExampleRpc("getreceivedbyaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", 6") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -834,7 +839,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) // Bitcoin address CBitcoinAddress address = CBitcoinAddress(params[0].get_str()); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Komodo address"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); CScript scriptPubKey = GetScriptForDestination(address.Get()); if (!IsMine(*pwalletMain,scriptPubKey)) return (double)0.0; @@ -875,7 +880,7 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp) "1. \"account\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" - "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n" + "amount (numeric) The total amount in " + strprintf("%s",komodo_chainname()) + " received for this account.\n" "\nExamples:\n" "\nAmount received by the default account with at least 1 confirmation\n" + HelpExampleCli("getreceivedbyaccount", "\"\"") + @@ -965,7 +970,7 @@ UniValue getbalance(const UniValue& params, bool fHelp) "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "3. includeWatchonly (bool, optional, default=false) Also include balance in watchonly addresses (see 'importaddress')\n" "\nResult:\n" - "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n" + "amount (numeric) The total amount in " + strprintf("%s",komodo_chainname()) + " received for this account.\n" "\nExamples:\n" "\nThe total amount in the wallet\n" + HelpExampleCli("getbalance", "") + @@ -1051,15 +1056,15 @@ UniValue movecmd(const UniValue& params, bool fHelp) "\nArguments:\n" "1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "2. \"toaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" - "3. amount (numeric) Quantity of " + CURRENCY_UNIT + " to move between accounts.\n" + "3. amount (numeric) Quantity of " + strprintf("%s",komodo_chainname()) + " to move between accounts.\n" "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" "5. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n" "\nResult:\n" "true|false (boolean) true if successful.\n" "\nExamples:\n" - "\nMove 0.01 " + CURRENCY_UNIT + " from the default account to the account named tabby\n" + "\nMove 0.01 " + strprintf("%s",komodo_chainname()) + " from the default account to the account named tabby\n" + HelpExampleCli("move", "\"\" \"tabby\" 0.01") + - "\nMove 0.01 " + CURRENCY_UNIT + " timotei to akiko with a comment and funds have 6 confirmations\n" + "\nMove 0.01 " + strprintf("%s",komodo_chainname()) + " timotei to akiko with a comment and funds have 6 confirmations\n" + HelpExampleCli("move", "\"timotei\" \"akiko\" 0.01 6 \"happy birthday!\"") + "\nAs a json rpc call\n" + HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"") @@ -1119,14 +1124,14 @@ UniValue sendfrom(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3 || params.size() > 6) throw runtime_error( - "sendfrom \"fromaccount\" \"tozcashaddress\" amount ( minconf \"comment\" \"comment-to\" )\n" - "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a Zcash address.\n" + "sendfrom \"fromaccount\" \"to" + strprintf("%s",komodo_chainname()) + "address\" amount ( minconf \"comment\" \"comment-to\" )\n" + "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a " + strprintf("%s",komodo_chainname()) + " address.\n" "The amount is a real and is rounded to the nearest 0.00000001." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" - "2. \"tozcashaddress\" (string, required) The Zcash address to send funds to.\n" - "3. amount (numeric, required) The amount in " + CURRENCY_UNIT + " (transaction fee is added on top).\n" + "2. \"to" + strprintf("%s",komodo_chainname()) + "address\" (string, required) The " + strprintf("%s",komodo_chainname()) + " address to send funds to.\n" + "3. amount (numeric, required) The amount in " + strprintf("%s",komodo_chainname()) + " (transaction fee is added on top).\n" "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" "5. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" " This is not part of the transaction, just kept in your wallet.\n" @@ -1136,12 +1141,12 @@ UniValue sendfrom(const UniValue& params, bool fHelp) "\nResult:\n" "\"transactionid\" (string) The transaction id.\n" "\nExamples:\n" - "\nSend 0.01 " + CURRENCY_UNIT + " from the default account to the address, must have at least 1 confirmation\n" - + HelpExampleCli("sendfrom", "\"\" \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01") + + "\nSend 0.01 " + strprintf("%s",komodo_chainname()) + " from the default account to the address, must have at least 1 confirmation\n" + + HelpExampleCli("sendfrom", "\"\" \"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 0.01") + "\nSend 0.01 from the tabby account to the given address, funds must have at least 6 confirmations\n" - + HelpExampleCli("sendfrom", "\"tabby\" \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01 6 \"donation\" \"seans outpost\"") + + + HelpExampleCli("sendfrom", "\"tabby\" \"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 0.01 6 \"donation\" \"seans outpost\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("sendfrom", "\"tabby\", \"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.01, 6, \"donation\", \"seans outpost\"") + + HelpExampleRpc("sendfrom", "\"tabby\", \"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", 0.01, 6, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1149,7 +1154,7 @@ UniValue sendfrom(const UniValue& params, bool fHelp) string strAccount = AccountFromValue(params[0]); CBitcoinAddress address(params[1].get_str()); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Komodo address"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); CAmount nAmount = AmountFromValue(params[2]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); @@ -1191,14 +1196,14 @@ UniValue sendmany(const UniValue& params, bool fHelp) "1. \"fromaccount\" (string, required) MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "2. \"amounts\" (string, required) A json object with addresses and amounts\n" " {\n" - " \"address\":amount (numeric) The Zcash address is the key, the numeric amount in " + CURRENCY_UNIT + " is the value\n" + " \"address\":amount (numeric) The " + strprintf("%s",komodo_chainname()) + " address is the key, the numeric amount in " + strprintf("%s",komodo_chainname()) + " is the value\n" " ,...\n" " }\n" "3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n" "4. \"comment\" (string, optional) A comment\n" "5. subtractfeefromamount (string, optional) A json array with addresses.\n" " The fee will be equally deducted from the amount of each selected address.\n" - " Those recipients will receive less Zcash than you enter in their corresponding amount field.\n" + " Those recipients will receive less " + strprintf("%s",komodo_chainname()) + " than you enter in their corresponding amount field.\n" " If no addresses are specified here, the sender pays the fee.\n" " [\n" " \"address\" (string) Subtract fee from this address\n" @@ -1209,13 +1214,13 @@ UniValue sendmany(const UniValue& params, bool fHelp) " the number of addresses.\n" "\nExamples:\n" "\nSend two amounts to two different addresses:\n" - + HelpExampleCli("sendmany", "\"\" \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") + + + HelpExampleCli("sendmany", "\"\" \"{\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.01,\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.02}\"") + "\nSend two amounts to two different addresses setting the confirmation and comment:\n" - + HelpExampleCli("sendmany", "\"\" \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 6 \"testing\"") + + + HelpExampleCli("sendmany", "\"\" \"{\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.01,\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.02}\" 6 \"testing\"") + "\nSend two amounts to two different addresses, subtract fee from amount:\n" - + HelpExampleCli("sendmany", "\"\" \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 1 \"\" \"[\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\",\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") + + + HelpExampleCli("sendmany", "\"\" \"{\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.01,\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.02}\" 1 \"\" \"[\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\",\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\"]\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("sendmany", "\"\", \"{\\\"t14oHp2v54vfmdgQ3v3SNuQga8JKHTNi2a1\\\":0.01,\\\"t1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\", 6, \"testing\"") + + HelpExampleRpc("sendmany", "\"\", \"{\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.01,\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\":0.02}\", 6, \"testing\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1244,7 +1249,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) { CBitcoinAddress address(name_); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Komodo address: ")+name_); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid " + strprintf("%s",komodo_chainname()) + " address: ")+name_); //if (setAddress.count(address)) // throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+name_); @@ -1301,26 +1306,26 @@ UniValue addmultisigaddress(const UniValue& params, bool fHelp) { string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n" "\nAdd a nrequired-to-sign multisignature address to the wallet.\n" - "Each key is a Komodo address or hex-encoded public key.\n" + "Each key is a " + strprintf("%s",komodo_chainname()) + " address or hex-encoded public key.\n" "If 'account' is specified (DEPRECATED), assign address to that account.\n" "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" - "2. \"keysobject\" (string, required) A json array of Zcash addresses or hex-encoded public keys\n" + "2. \"keysobject\" (string, required) A json array of " + strprintf("%s",komodo_chainname()) + " addresses or hex-encoded public keys\n" " [\n" - " \"address\" (string) Zcash address or hex-encoded public key\n" + " \"address\" (string) " + strprintf("%s",komodo_chainname()) + " address or hex-encoded public key\n" " ...,\n" " ]\n" "3. \"account\" (string, optional) DEPRECATED. If provided, MUST be set to the empty string \"\" to represent the default account. Passing any other string will result in an error.\n" "\nResult:\n" - "\"zcashaddress\" (string) A Zcash address associated with the keys.\n" + "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) A " + strprintf("%s",komodo_chainname()) + " address associated with the keys.\n" "\nExamples:\n" "\nAdd a multisig address from 2 addresses\n" - + HelpExampleCli("addmultisigaddress", "2 \"[\\\"t16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"t171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + + HelpExampleCli("addmultisigaddress", "2 \"[\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\",\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\"]\"") + "\nAs json rpc call\n" - + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"t16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"t171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\",\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\"]\"") ; throw runtime_error(msg); } @@ -1493,7 +1498,7 @@ UniValue listreceivedbyaddress(const UniValue& params, bool fHelp) " \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n" " \"address\" : \"receivingaddress\", (string) The receiving address\n" " \"account\" : \"accountname\", (string) DEPRECATED. The account of the receiving address. The default account is \"\".\n" - " \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " received by the address\n" + " \"amount\" : x.xxx, (numeric) The total amount in " + strprintf("%s",komodo_chainname()) + " received by the address\n" " \"confirmations\" : n (numeric) The number of confirmations of the most recent transaction included\n" " }\n" " ,...\n" @@ -1669,17 +1674,17 @@ UniValue listtransactions(const UniValue& params, bool fHelp) " {\n" " \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. \n" " It will be \"\" for the default account.\n" - " \"address\":\"zcashaddress\", (string) The Zcash address of the transaction. Not present for \n" + " \"address\":\"" + strprintf("%s",komodo_chainname()) + "_address\", (string) The " + strprintf("%s",komodo_chainname()) + " address of the transaction. Not present for \n" " move transactions (category = move).\n" " \"category\":\"send|receive|move\", (string) The transaction category. 'move' is a local (off blockchain)\n" " transaction between accounts, and not associated with an address,\n" " transaction id or block. 'send' and 'receive' transactions are \n" " associated with an address, transaction id and block details\n" - " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the\n" + " \"amount\": x.xxx, (numeric) The amount in " + strprintf("%s",komodo_chainname()) + ". This is negative for the 'send' category, and for the\n" " 'move' category for moves outbound. It is positive for the 'receive' category,\n" " and for the 'move' category for inbound funds.\n" " \"vout\" : n, (numeric) the vout value\n" - " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" + " \"fee\": x.xxx, (numeric) The amount of the fee in " + strprintf("%s",komodo_chainname()) + ". This is negative and only available for the \n" " 'send' category of transactions.\n" " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n" " 'receive' category of transactions.\n" @@ -1869,12 +1874,12 @@ UniValue listsinceblock(const UniValue& params, bool fHelp) "{\n" " \"transactions\": [\n" " \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. Will be \"\" for the default account.\n" - " \"address\":\"zcashaddress\", (string) The Zcash address of the transaction. Not present for move transactions (category = move).\n" + " \"address\":\"" + strprintf("%s",komodo_chainname()) + "_address\", (string) The " + strprintf("%s",komodo_chainname()) + " address of the transaction. Not present for move transactions (category = move).\n" " \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" - " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the 'move' category for moves \n" + " \"amount\": x.xxx, (numeric) The amount in " + strprintf("%s",komodo_chainname()) + ". This is negative for the 'send' category, and for the 'move' category for moves \n" " outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" " \"vout\" : n, (numeric) the vout value\n" - " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions.\n" + " \"fee\": x.xxx, (numeric) The amount of the fee in " + strprintf("%s",komodo_chainname()) + ". This is negative and only available for the 'send' category of transactions.\n" " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" " \"blockindex\": n, (numeric) The block index containing the transaction. Available for 'send' and 'receive' category of transactions.\n" @@ -1957,7 +1962,7 @@ UniValue gettransaction(const UniValue& params, bool fHelp) "2. \"includeWatchonly\" (bool, optional, default=false) Whether to include watchonly addresses in balance calculation and details[]\n" "\nResult:\n" "{\n" - " \"amount\" : x.xxx, (numeric) The transaction amount in " + CURRENCY_UNIT + "\n" + " \"amount\" : x.xxx, (numeric) The transaction amount in " + strprintf("%s",komodo_chainname()) + "\n" " \"confirmations\" : n, (numeric) The number of confirmations\n" " \"blockhash\" : \"hash\", (string) The block hash\n" " \"blockindex\" : xx, (numeric) The block index\n" @@ -1968,9 +1973,9 @@ UniValue gettransaction(const UniValue& params, bool fHelp) " \"details\" : [\n" " {\n" " \"account\" : \"accountname\", (string) DEPRECATED. The account name involved in the transaction, can be \"\" for the default account.\n" - " \"address\" : \"zcashaddress\", (string) The Zcash address involved in the transaction\n" + " \"address\" : \"" + strprintf("%s",komodo_chainname()) + "_address\", (string) The " + strprintf("%s",komodo_chainname()) + " address involved in the transaction\n" " \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n" - " \"amount\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n" + " \"amount\" : x.xxx (numeric) The amount in " + strprintf("%s",komodo_chainname()) + "\n" " \"vout\" : n, (numeric) the vout value\n" " }\n" " ,...\n" @@ -2128,7 +2133,7 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp) throw runtime_error( "walletpassphrase \"passphrase\" timeout\n" "\nStores the wallet decryption key in memory for 'timeout' seconds.\n" - "This is needed prior to performing transactions related to private keys such as sending Zcash\n" + "This is needed prior to performing transactions related to private keys such as sending " + strprintf("%s",komodo_chainname()) + "\n" "\nArguments:\n" "1. \"passphrase\" (string, required) The wallet passphrase\n" "2. timeout (numeric, required) The time to keep the decryption key in seconds.\n" @@ -2242,7 +2247,7 @@ UniValue walletlock(const UniValue& params, bool fHelp) "\nSet the passphrase for 2 minutes to perform a transaction\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + "\nPerform a send (requires passphrase set)\n" - + HelpExampleCli("sendtoaddress", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") + + + HelpExampleCli("sendtoaddress", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" 1.0") + "\nClear the passphrase since we are done before 2 minutes is up\n" + HelpExampleCli("walletlock", "") + "\nAs json rpc call\n" @@ -2293,10 +2298,10 @@ UniValue encryptwallet(const UniValue& params, bool fHelp) "\nExamples:\n" "\nEncrypt you wallet\n" + HelpExampleCli("encryptwallet", "\"my pass phrase\"") + - "\nNow set the passphrase to use the wallet, such as for signing or sending Zcash\n" + "\nNow set the passphrase to use the wallet, such as for signing or sending " + strprintf("%s",komodo_chainname()) + "\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\"") + "\nNow we can so something like sign\n" - + HelpExampleCli("signmessage", "\"zcashaddress\" \"test message\"") + + + HelpExampleCli("signmessage", "\"" + strprintf("%s",komodo_chainname()) + "_address\" \"test message\"") + "\nNow lock the wallet again by removing the passphrase\n" + HelpExampleCli("walletlock", "") + "\nAs a json rpc call\n" @@ -2344,7 +2349,7 @@ UniValue lockunspent(const UniValue& params, bool fHelp) "lockunspent unlock [{\"txid\":\"txid\",\"vout\":n},...]\n" "\nUpdates list of temporarily unspendable outputs.\n" "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" - "A locked transaction output will not be chosen by automatic coin selection, when spending Zcash.\n" + "A locked transaction output will not be chosen by automatic coin selection, when spending " + strprintf("%s",komodo_chainname()) + ".\n" "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n" "is always cleared (by virtue of process exit) when a node stops or fails.\n" "Also see the listunspent call\n" @@ -2477,7 +2482,7 @@ UniValue settxfee(const UniValue& params, bool fHelp) "settxfee amount\n" "\nSet the transaction fee per kB.\n" "\nArguments:\n" - "1. amount (numeric, required) The transaction fee in " + CURRENCY_UNIT + "/kB rounded to the nearest 0.00000001\n" + "1. amount (numeric, required) The transaction fee in " + strprintf("%s",komodo_chainname()) + "/kB rounded to the nearest 0.00000001\n" "\nResult\n" "true|false (boolean) Returns true if successful\n" "\nExamples:\n" @@ -2506,9 +2511,9 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp) "\nResult:\n" "{\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" - " \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + "\n" - " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n" - " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n" + " \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + strprintf("%s",komodo_chainname()) + "\n" + " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + strprintf("%s",komodo_chainname()) + "\n" + " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + strprintf("%s",komodo_chainname()) + "\n" " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" @@ -2577,9 +2582,9 @@ UniValue listunspent(const UniValue& params, bool fHelp) "\nArguments:\n" "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n" "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n" - "3. \"addresses\" (string) A json array of Zcash addresses to filter\n" + "3. \"addresses\" (string) A json array of " + strprintf("%s",komodo_chainname()) + " addresses to filter\n" " [\n" - " \"address\" (string) Zcash address\n" + " \"address\" (string) " + strprintf("%s",komodo_chainname()) + " address\n" " ,...\n" " ]\n" "\nResult\n" @@ -2588,10 +2593,10 @@ UniValue listunspent(const UniValue& params, bool fHelp) " \"txid\" : \"txid\", (string) the transaction id \n" " \"vout\" : n, (numeric) the vout value\n" " \"generated\" : true|false (boolean) true if txout is a coinbase transaction output\n" - " \"address\" : \"address\", (string) the Zcash address\n" + " \"address\" : \"address\", (string) the " + strprintf("%s",komodo_chainname()) + " address\n" " \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n" " \"scriptPubKey\" : \"key\", (string) the script key\n" - " \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n" + " \"amount\" : x.xxx, (numeric) the transaction amount in " + strprintf("%s",komodo_chainname()) + "\n" " \"confirmations\" : n (numeric) The number of confirmations\n" " }\n" " ,...\n" @@ -2599,8 +2604,8 @@ UniValue listunspent(const UniValue& params, bool fHelp) "\nExamples\n" + HelpExampleCli("listunspent", "") - + HelpExampleCli("listunspent", "6 9999999 \"[\\\"t1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"t1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") - + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"t1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"t1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") + + HelpExampleCli("listunspent", "6 9999999 \"[\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\",\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\"]\"") + + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\",\\\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\\\"]\"") ); RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)(UniValue::VNUM)(UniValue::VARR)); @@ -2620,7 +2625,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) const UniValue& input = inputs[idx]; CBitcoinAddress address(input.get_str()); if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Komodo address: ")+input.get_str()); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid " + strprintf("%s",komodo_chainname()) + " address: ")+input.get_str()); if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+input.get_str()); setAddress.insert(address); @@ -3231,7 +3236,7 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp) "\nReturns a new zaddr for receiving payments.\n" "\nArguments:\n" "\nResult:\n" - "\"zcashaddress\" (string) The new zaddr\n" + "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The new zaddr\n" "\nExamples:\n" + HelpExampleCli("z_getnewaddress", "") + HelpExampleRpc("z_getnewaddress", "") @@ -3670,8 +3675,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) "\nResult:\n" "\"operationid\" (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "\nExamples:\n" - + HelpExampleCli("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" '[{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]'") - + HelpExampleRpc("z_sendmany", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", [{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]") + + HelpExampleCli("z_sendmany", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" '[{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]'") + + HelpExampleRpc("z_sendmany", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", [{\"address\": \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\" ,\"amount\": 5.0}]") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3890,8 +3895,8 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("z_shieldcoinbase", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") - + HelpExampleRpc("z_shieldcoinbase", "\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleCli("z_shieldcoinbase", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\" \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleRpc("z_shieldcoinbase", "\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\", \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4118,8 +4123,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("z_mergetoaddress", "'[\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") - + HelpExampleRpc("z_mergetoaddress", "[\"t1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleCli("z_mergetoaddress", "'[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") + + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); if (!fEnableMergeToAddress) { From e2d299ee8349ba05e0b15db6b884a5f8aa42d6e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 May 2018 10:05:51 +0300 Subject: [PATCH 150/157] GAME freq.5 --- src/dpowassets | 2 +- src/komodo_gateway.h | 3 ++- src/rpcrawtransaction.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dpowassets b/src/dpowassets index f148bda05..40bb89cce 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -33,4 +33,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":10,\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7b642746a..9b2f3eb8e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -717,7 +717,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( height >= activation ) { - fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + if ( height > 800000 ) + fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); return(-1); } } diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 123e0bbb9..904fe1c5e 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -452,7 +452,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid }*/ CTransaction tx; uint256 hashBlock; - if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) return(-1); else if ( n <= tx.vout.size() ) // vout.size() seems off by 1 { From 4543015b01046e46589d78c04d1eaa4776ddbd70 Mon Sep 17 00:00:00 2001 From: igorvoltaic Date: Wed, 23 May 2018 11:32:44 +0300 Subject: [PATCH 151/157] lets get rid of this message: 'section __textcoal_nt is deprecated' --- README-mac.md | 40 ++++++++++++++++++++++++++++++++------ darwin.host.mk.patch | 4 ++-- darwin.mk.patch | 8 ++++---- depends/builders/darwin.mk | 8 ++++---- depends/hosts/darwin.mk | 4 ++-- libsnark.mk.patch | 2 +- toolchain-info.sh | 2 +- zcutil/build-mac.sh | 6 +++--- 8 files changed, 51 insertions(+), 23 deletions(-) diff --git a/README-mac.md b/README-mac.md index c085cb617..f3dd5e281 100644 --- a/README-mac.md +++ b/README-mac.md @@ -1,4 +1,6 @@ -First off you need Apple's Xcode (at least version 7, preferably 8.x) and the Xcode Command Line Tools: +## Install for Mac OS X + +First off you need Apple's Xcode (at least version 7, preferably 8.x or later) and the Xcode Command Line Tools: https://itunes.apple.com/us/app/xcode/id497799835?mt=12 @@ -11,25 +13,51 @@ And this is the list of brew packages you'll need installed: ```shell brew tap discoteq/discoteq; brew install flock brew install autoconf autogen automake -brew tap homebrew/versions; brew install homebrew/versions/gcc5 +brew install gcc@6 brew install binutils brew install protobuf brew install coreutils brew install wget ``` +or + +```shell +brew tap discoteq/discoteq; brew install flock autoconf autogen automake gcc@6 binutils protobuf coreutils wget +``` + Get all that installed, then run: ```shell -git clone https://github.com/j-cimb-barker/komodo.git +git clone https://github.com/jl777/komodo.git cd komodo -git checkout dev ./zcutil/build-mac.sh +./zcutil/fetch-params.sh ``` To build a distributable version of komodo then run the makeDistrib.sh script after building. -When you are done building, you need to do a few things in the [Configuration](https://github.com/zcash/zcash/wiki/1.0-User-Guide#configuration) section of the Zcash User Guide differently because we are on the Mac. All instances of `~/.zcash` need to be replaced by `~/Library/Application\ Support/Zcash` -The fetch-params.sh script, however, has already been altered to fetch the proving keys into the correct directory to conform to Mac specific naming conventions. +When you are done building, you need to create `Komodo.conf` the Mac way. + +```shell +mkdir ~/Library/Application\ Support/Komodo +touch ~/Library/Application\ Support/Komodo/Komodo.conf +nano ~/Library/Application\ Support/Komodo/Komodo.conf +``` + +Add the following lines to the Komodo.conf file: + +```shell +rpcuser=dontuseweakusernameoryougetrobbed +rpcpassword=dontuseweakpasswordoryougetrobbed +txindex=1 +addnode=5.9.102.210 +addnode=78.47.196.146 +addnode=178.63.69.164 +addnode=88.198.65.74 +addnode=5.9.122.241 +addnode=144.76.94.38 +addnode=89.248.166.91 +``` Happy Building diff --git a/darwin.host.mk.patch b/darwin.host.mk.patch index 426702563..deeb7a810 100644 --- a/darwin.host.mk.patch +++ b/darwin.host.mk.patch @@ -5,8 +5,8 @@ OSX_SDK_VERSION=10.9 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=241.9 -! darwin_CC=gcc-5 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -! darwin_CXX=g++-5 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +! darwin_CC=gcc-6 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +! darwin_CXX=g++-6 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) diff --git a/darwin.mk.patch b/darwin.mk.patch index 80bc5b2d9..fdfd7bc38 100644 --- a/darwin.mk.patch +++ b/darwin.mk.patch @@ -2,8 +2,8 @@ --- ../../komodo-jl777/depends/builders/darwin.mk 2017-01-03 09:48:21.646034937 +0000 *************** *** 1,5 **** -! build_darwin_CC = gcc-5 -! build_darwin_CXX = g++-5 +! build_darwin_CC = gcc-6 +! build_darwin_CXX = g++-6 build_darwin_AR: = $(shell xcrun -f ar) build_darwin_RANLIB: = $(shell xcrun -f ranlib) build_darwin_STRIP: = $(shell xcrun -f strip) @@ -21,8 +21,8 @@ ! build_darwin_DOWNLOAD = wget --timeout=$(DOWNLOAD_CONNECT_TIMEOUT) --tries=$(DOWNLOAD_RETRIES) -nv -O #darwin host on darwin builder. overrides darwin host preferences. -! darwin_CC= gcc-5 -! darwin_CXX= g++-5 +! darwin_CC= gcc-6 +! darwin_CXX= g++-6 darwin_AR:=$(shell xcrun -f ar) darwin_RANLIB:=$(shell xcrun -f ranlib) darwin_STRIP:=$(shell xcrun -f strip) diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk index 0028d3f6f..f9b066fcf 100644 --- a/depends/builders/darwin.mk +++ b/depends/builders/darwin.mk @@ -1,5 +1,5 @@ -build_darwin_CC = gcc-5 -build_darwin_CXX = g++-5 +build_darwin_CC = gcc-6 +build_darwin_CXX = g++-6 build_darwin_AR: = $(shell xcrun -f ar) build_darwin_RANLIB: = $(shell xcrun -f ranlib) build_darwin_STRIP: = $(shell xcrun -f strip) @@ -10,8 +10,8 @@ build_darwin_SHA256SUM = shasum -a 256 build_darwin_DOWNLOAD = curl --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -L -f -o #darwin host on darwin builder. overrides darwin host preferences. -darwin_CC= gcc-5 -darwin_CXX= g++-5 +darwin_CC= gcc-6 +darwin_CXX= g++-6 darwin_AR:=$(shell xcrun -f ar) darwin_RANLIB:=$(shell xcrun -f ranlib) darwin_STRIP:=$(shell xcrun -f strip) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 70211078b..5eaeddc26 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -2,8 +2,8 @@ OSX_MIN_VERSION=10.8 OSX_SDK_VERSION=10.11 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=253.9 -darwin_CC=gcc-5 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -darwin_CXX=g++-5 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CC=gcc-6 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CXX=g++-6 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) diff --git a/libsnark.mk.patch b/libsnark.mk.patch index f43ea2188..28a60c8b6 100644 --- a/libsnark.mk.patch +++ b/libsnark.mk.patch @@ -14,7 +14,7 @@ - ifeq ($(build_os),darwin) - define $(package)_build_cmds -- CC=gcc-5 CXX=g++-5 CXXFLAGS="-arch x86_64 -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=0 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT +- CC=gcc-6 CXX=g++-6 CXXFLAGS="-arch x86_64 -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=0 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT - endef - else define $(package)_build_cmds diff --git a/toolchain-info.sh b/toolchain-info.sh index 3322755f0..0bb39c19b 100755 --- a/toolchain-info.sh +++ b/toolchain-info.sh @@ -1,6 +1,6 @@ #!/bin/bash -tools=("gcc-5" "g++-5" "otool" "nm") +tools=("gcc-6" "g++-6" "otool" "nm") echo "Platform: `uname -a`" echo "-------------------------------------" diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index cf2af5a2a..138508cb5 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -1,6 +1,6 @@ #!/bin/bash -export CC=gcc-5 -export CXX=g++-5 +export CC=gcc-6 +export CXX=g++-6 export LIBTOOL=libtool export AR=ar export RANLIB=ranlib @@ -44,7 +44,7 @@ make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 ./autogen.sh CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ -CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc5/5.4.0/include/c++/5.4.0 -I$PREFIX/include -fwrapv -fno-strict-aliasing -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ +CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ ./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" make "$@" V=1 NO_GTEST=1 STATIC=1 From a035da46d511a4e5f50966b693366fc2e080a28a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 May 2018 00:39:41 -1100 Subject: [PATCH 152/157] +print --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9b2f3eb8e..0849d4870 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -746,7 +746,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( overflow != 0 || total > 0 || strangeout != 0 ) { if ( strangeout != 0 ) - fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); + fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); return(-1); } } From a6c06faf32de1c103b51945f48324b309240eee4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 May 2018 00:42:21 -1100 Subject: [PATCH 153/157] Synchronize with dev --- src/komodo_gateway.h | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ce51746f7..cd23c0c3c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -686,15 +686,18 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); //if ( n <= 2 || script[0] != 0x6a ) { - int64_t val,prevtotal = 0; int32_t overflow = 0; + int64_t val,prevtotal = 0; int32_t strangeout=0,overflow = 0; total = 0; for (i=1; i= MAX_MONEY ) { overflow = 1; break; } + if ( i > 1 && script[0] != 0x6a && val < 5000 ) + strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) { @@ -707,9 +710,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( overflow != 0 || total > COIN/10 ) { - fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= activation ) + { + if ( height > 800000 ) + fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); return(-1); + } } else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) // to deal with fee stealing { @@ -717,11 +723,27 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } + if ( strangeout != 0 || notmatched != 0 ) + { + if ( 0 && strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) + fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); + if ( height > 1000000 && strangeout != 0 ) + return(-1); + } + else if ( height > 814000 ) + { + script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); + return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); + } } else { - if ( overflow != 0 || total > 0 ) + if ( overflow != 0 || total > 0 || strangeout != 0 ) + { + if ( strangeout != 0 ) + fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); return(-1); + } } return(0); } From 885d458054bff7267170713a2dc893802b660ae6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 May 2018 00:53:43 -1100 Subject: [PATCH 154/157] Fix syntax --- src/komodo_gateway.h | 315 +------------------------------------------ 1 file changed, 6 insertions(+), 309 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cd23c0c3c..5897484e5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -668,6 +668,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { for (i=0; i 1 && block.vtx[txn_count-1].vout.size() > 0 && block.vtx[txn_count-1].vout[0].nValue == 5000 ) + { + if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) + notmatched = 1; + } n = block.vtx[i].vin.size(); for (j=0; j= 235300 ) - return(-1); - strcpy(symbol,(char *)"KMD"); - if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) // init time already in DB - return(0); - } - else - { - strcpy(symbol,ASSETCHAINS_SYMBOL); - opcode = 'I'; - if ( (baseid= komodo_baseid(symbol)) < 0 ) - { - if ( block.vtx[0].vout.size() != 1 ) - { - printf("%s has more than one coinbase?\n",symbol); - return(-1); - } - return(0); - } - while ( KOMODO_PASSPORT_INITDONE == 0 ) - komodo_passport_iteration(); - komodo_passport_iteration(); - // grandfathering preexisting - if ( height < 777 ) - return(0); - if ( baseid == USD ) // 6820 in balance calcs - { - if ( height <= 6821 || height <= 2000 || height == 2968 || height == 2960 || height == 2649 || height == 3275 || height == 3282 || height == 3328 || height == 3468 ) - return(0); - } - else if ( baseid == EUR ) - { - if ( height < 1200 || height == 1408 || height == 1111 || height == 1094 || height == 1092 || height == 1080 || height == 1053 || height == 1005 || height == 822 || height == 821 || height == 810 || height == 797 || height == 790 || height == 787 || height == 785 || height == 1313 || height == 1288 || height == 1263 || height == 1262 || height <= 211 || height == 210 || height == 188 || height == 185 || height == 182 || height == 181 || height == 171 || height == 170 || height == 169 || height == 168 || height == 167 || height == 166 || height == 165 || height == 164 || height == 163 || height == 162 ) - return(0); - } - else if ( baseid == JPY ) - { - if ( height == 1038 || height == 1039 || height == 1040 || height == 1041 || height == 1014 || height == 998 || height == 973 || height == 139 || height == 971 || height == 141 || height == 816 || height == 814 || height == 803 || height == 142 || height == 782 || height == 145 || height == 181 || height == 186 || height == 192 || height == 190 || height == 189 || height == 255 || height == 218 || height == 233 || height == 259 || height == 278 || height == 361 || height == 367 || height == 733 || height == 688 || height == 468 ) - return(0); - } - else if ( baseid == GBP ) - { - if ( height == 1025 || height == 1026 || height == 1027 || height == 1028 || height == 997 || height == 970 || height == 953 || height == 951 || height == 803 || height == 800 || height == 786 || height == 123 || height == 771 || height == 137 || height == 139 || height == 140 || height == 146 || height == 194 || height == 200 || height == 202 || height == 203 || height == 205 || height == 210 || height == 216 || height == 271 || height == 233 || height == 294 ) - return(0); - } - else if ( baseid == AUD ) - { - if ( height == 1012 || height == 1013 || height == 1014 || height == 985 || height == 958 || height == 936 || height == 933 || height == 790 || height == 788 || height == 778 || height == 124 || height == 777 || height == 122 || height == 140 || height == 142 || height == 143 || height == 186 || height == 196 || height == 198 || height == 201 || height == 210 || height == 192 ) - return(0); - } - else if ( baseid == CAD ) - { - if ( height < 1000 || height == 836 || height == 781 || height == 779 || height == 798 || height == 794 || height == 1181 || height == 1179 || height == 1159 || height == 1134 || height == 1132 || height == 121 || height == 970 || height == 119 || height == 299 || height == 302 || height == 303 || height == 306 || height == 308 || height == 355 || height == 362 || height == 367 || height == 363 || height == 364 || height == 380 || height == 373 || height == 390 || height == 437 || height == 777 ) - return(0); - } - else if ( baseid == CHF ) - { - if ( height == 987 || height == 988 || height == 989 || height == 960 || height == 931 || height == 914 || height == 122 || height == 912 || height == 141 || height == 780 || height == 145 || height == 777 || height == 151 || height == 775 || height == 765 || height == 195 || height == 764 || height == 737 || height == 194 || height == 193 || height == 198 || height == 207 || height == 216 || height == 227 || height == 256 || height == 260 || height == 276 || height == 289 || height == 292 || height == 349 ) - return(0); - } - else if ( baseid == NZD ) - { - if ( height < 1000 || height == 787 || height == 786 || height == 784 || height == 785 || height == 777 || height == 1113 || height == 1083 || height == 1067 || height == 265 || height == 1064 || height == 920 || height == 913 || height == 124 || height == 911 || height == 903 || height == 900 || height == 879 || height == 122 || height == 266 || height == 269 || height == 270 || height == 278 || height == 307 || height == 318 || height == 322 || height == 335 || height == 395 || height == 406 || height == 314 ) - return(0); - } - else if ( baseid == CNY ) - { - if ( height == 987 || height == 988 || height == 989 || height == 982 || height == 957 || height == 931 || height == 119 || height == 929 || height == 134 || height == 782 || height == 137 || height == 775 || height == 143 || height == 772 || height == 186 || height == 763 || height == 761 || height == 734 || height == 183 || height == 190 || height == 192 || height == 211 || height == 203 || height == 226 || height == 263 || height == 264 || height == 277 || height == 342 || height == 613 || height == 525 ) - return(0); - } - else if ( baseid == RUB ) - { - if ( height == 819 || height == 812 || height == 810 || height == 802 || height == 801 || height == 1074 || height == 1040 || height == 1014 || height == 163 || height == 1013 || height == 877 || height == 867 || height == 863 || height == 834 || height == 158 || height == 126 || height == 106 || height == 105 || height == 174 || height == 175 || height == 176 || height == 177 || height == 181 || height == 183 || height == 184 || height == 187 ) - return(0); - } - else if ( baseid == MXN ) - { - if ( height == 1079 || height == 1080 || height == 1081 || height == 1069 || height == 1048 || height == 1028 || height == 121 || height == 1027 || height == 146 || height == 894 || height == 891 || height == 148 || height == 882 || height == 879 || height == 151 || height == 856 || height == 158 || height == 822 || height == 197 || height == 203 || height == 207 || height == 209 || height == 213 || height == 217 || height == 218 || height == 226 || height == 283 || height == 302 || height == 319 || height == 318 || height == 569 ) - return(0); - } - else if ( baseid == BRL ) - { - if ( height == 1003 || height == 1004 || height == 1005 || height == 972 || height == 943 || height == 922 || height == 118 || height == 920 || height == 145 || height == 787 || height == 783 || height == 147 || height == 781 || height == 774 || height == 148 || height == 771 || height == 154 || height == 751 || height == 156 || height == 188 || height == 193 || height == 195 || height == 199 || height == 203 || height == 225 || height == 230 || height == 262 || height == 266 || height == 284 || height == 300 || height == 640 ) - return(0); - } - else if ( baseid == INR ) - { - if ( height == 998 || height == 999 || height == 1000 || height == 788 || height == 786 || height == 775 || height == 753 || height == 125 || height == 153 || height == 155 || height == 159 || height == 204 || height == 206 || height == 211 || height == 217 || height == 220 || height == 229 || height == 265 || height == 292 || height == 300 ) - return(0); - } - else if ( baseid == PLN ) - { - if ( height == 1029 || height == 1030 || height == 1031 || height == 1009 || height == 984 || height == 960 || height == 959 || height == 798 || height == 794 || height == 792 || height == 782 || height == 775 || height == 755 || height == 122 || height == 120 || height == 158 || height == 160 || height == 163 || height == 225 || height == 217 || height == 219 || height == 229 || height == 234 || height == 286 || height == 231 || height == 292 ) - return(0); - } - else if ( baseid == HKD ) - { - if ( height == 1013 || height == 1014 || height == 1015 || height == 1002 || height == 979 || height == 947 || height == 123 || height == 946 || height == 153 || height == 811 || height == 808 || height == 806 || height == 155 || height == 795 || height == 157 || height == 773 || height == 205 || height == 208 || height == 210 || height == 211 || height == 215 || height == 221 || height == 231 || height == 255 || height == 273 || height == 293 || height == 310 || height == 654 ) - return(0); - } - else if ( baseid == TRY ) - { - if ( height == 1022 || height == 1023 || height == 1051 || height == 991 || height == 974 || height == 949 || height == 141 || height == 948 || height == 783 || height == 153 || height == 781 || height == 779 || height == 776 || height == 768 || height == 765 || height == 121 || height == 142 || height == 144 || height == 143 || height == 149 || height == 204 || height == 210 || height == 216 || height == 229 || height == 280 || height == 145 ) - return(0); - } - else if ( baseid == NOK ) - { - if ( height == 987 || height == 988 || height == 989 || height == 962 || height == 911 || height == 907 || height == 125 || height == 765 || height == 150 || height == 762 || height == 760 || height == 753 || height == 152 || height == 751 || height == 151 || height == 154 || height == 160 || height == 195 || height == 203 || height == 207 || height == 211 || height == 220 || height == 236 || height == 253 || height == 278 || height == 283 ) - return(0); - } - else if ( baseid == ZAR ) - { - if ( height == 979 || height == 980 || height == 981 || height == 956 || height == 937 || height == 906 || height == 905 || height == 122 || height == 756 || height == 754 || height == 752 || height == 749 || height == 742 || height == 739 || height == 120 || height == 151 || height == 153 || height == 157 || height == 159 || height == 206 || height == 213 || height == 216 || height == 222 || height == 277 || height == 287 || height == 215 ) - return(0); - } - else if ( baseid == SEK ) - { - if ( height == 960 || height == 961 || height == 962 || height == 943 || height == 925 || height == 896 || height == 147 || height == 894 || height == 759 || height == 751 || height == 749 || height == 742 || height == 740 || height == 716 || height == 123 || height == 148 || height == 150 || height == 151 || height == 157 || height == 199 || height == 200 || height == 201 || height == 206 || height == 256 || height == 257 || height == 268 ) - return(0); - } - else if ( baseid == CZK ) - { - if ( height < 1000 || height == 1084 || height == 1085 || height == 1086 || height == 778 || height == 1079 || height == 1054 || height == 1032 || height == 121 || height == 1030 || height == 182 || height == 876 || height == 873 || height == 871 || height == 184 || height == 862 || height == 185 || height == 861 || height == 186 || height == 838 || height == 238 || height == 242 || height == 246 || height == 248 || height == 250 || height == 251 || height == 256 || height == 282 || height == 322 || height == 343 || height == 433 || height == 323 || height == 276 ) - return(0); - } - else if ( baseid == HUF ) - { - if ( height < 2200 || height == 1531 || height == 1528 || height == 1530 || height == 1451 || height == 1448 || height == 1442 || height == 1418 || height == 1407 || height == 1406 || height == 1392 || height == 1391 || height == 1387 || height == 1383 || height == 1335 || height == 1337 || height == 1338 || height == 1649 || height == 2378 || height == 2376 || height == 2371 || height == 1330 || height == 2326 || height == 1344 || height == 2305 || height == 2304 || height == 2171 || height == 2168 || height == 2166 || height == 2156 || height == 2135 || height == 1343 || height == 1342 || height == 1341 || height == 1340 || height == 1339 || height == 1336 || height == 1334 || height == 1333 || height == 1346 || height == 1400 || height == 1525 || height == 1509 ) - return(0); - } - else if ( baseid == DKK ) - { - if ( height == 1241 || height == 945 || height == 898 || height == 894 || height == 892 || height == 866 || height == 857 || height == 853 || height == 834 || height == 812 || height == 792 || height == 784 || height == 778 || height == 783 || height == 1214 || height == 1186 || height == 1158 || height == 126 || height == 1156 || height == 329 || height == 1021 || height == 1016 || height == 1014 || height == 333 || height == 1003 || height == 1002 || height == 978 || height == 332 || height == 337 || height == 381 || height == 390 || height == 386 || height == 401 || height == 389 || height == 396 || height == 428 || height == 473 || height == 490 || height == 493 ) - return(0); - } - else if ( baseid == ILS ) - { - if ( height == 1017 || height == 1018 || height == 1019 || height == 1010 || height == 985 || height == 954 || height == 120 || height == 952 || height == 143 || height == 819 || height == 817 || height == 808 || height == 145 || height == 786 || height == 155 || height == 753 || height == 151 || height == 149 || height == 199 || height == 193 || height == 201 || height == 209 || height == 284 || height == 305 || height == 676 || height == 702 || height == 406 ) - return(0); - } - else if ( baseid == MYR ) - { - if ( height == 1020 || height == 1021 || height == 1022 || height == 1015 || height == 984 || height == 950 || height == 949 || height == 823 || height == 820 || height == 818 || height == 812 || height == 809 || height == 126 || height == 789 || height == 144 || height == 746 || height == 146 || height == 147 || height == 148 || height == 150 || height == 205 || height == 210 || height == 215 || height == 219 || height == 222 || height == 290 || height == 242 || height == 312 ) - return(0); - } - else if ( baseid == PHP ) - { - if ( height == 859 || height == 817 || height == 812 || height == 811 || height == 792 || height == 779 || height == 778 || height == 781 || height == 1154 || height == 1114 || height == 1077 || height == 1076 || height == 931 || height == 927 || height == 925 || height == 918 || height == 891 || height == 127 || height == 125 || height == 272 || height == 275 || height == 276 || height == 278 || height == 328 || height == 330 || height == 335 || height == 344 || height == 315 ) - return(0); - } - else if ( baseid == KRW ) - { - if ( height == 1021 || height == 1022 || height == 1023 || height == 1010 || height == 950 || height == 916 || height == 138 || height == 914 || height == 140 || height == 785 || height == 782 || height == 781 || height == 142 || height == 775 || height == 148 || height == 772 || height == 751 || height == 147 || height == 146 || height == 159 || height == 175 || height == 181 || height == 184 || height == 186 || height == 188 || height == 196 || height == 209 || height == 238 ) - return(0); - } - else if ( baseid == RON ) - { - if ( height == 1008 || height == 1009 || height == 1010 || height == 1003 || height == 973 || height == 940 || height == 939 || height == 806 || height == 802 || height == 800 || height == 793 || height == 789 || height == 768 || height == 123 || height == 141 || height == 143 || height == 144 || height == 150 || height == 197 || height == 200 || height == 202 || height == 217 || height == 240 || height == 276 ) - return(0); - } - else if ( baseid == SGD ) - { - if ( height == 1016 || height == 1017 || height == 1018 || height == 1010 || height == 984 || height == 951 || height == 950 || height == 801 || height == 798 || height == 792 || height == 788 || height == 122 || height == 769 || height == 120 || height == 158 || height == 160 || height == 164 || height == 169 || height == 229 || height == 234 || height == 246 || height == 297 || height == 299 || height == 316 || height == 233 ) - return(0); - } - else if ( baseid == THB ) - { - if ( height == 977 || height == 978 || height == 968 || height == 933 || height == 898 || height == 897 || height == 788 || height == 786 || height == 779 || height == 777 || height == 757 || height == 119 || height == 140 || height == 142 || height == 146 || height == 152 || height == 196 || height == 200 || height == 214 || height == 260 || height == 263 ) - return(0); - } - else if ( baseid == BGN ) - { - if ( height == 1044 || height == 1045 || height == 1046 || height == 1030 || height == 995 || height == 960 || height == 959 || height == 830 || height == 822 || height == 819 || height == 810 || height == 809 || height == 781 || height == 124 || height == 122 || height == 189 || height == 193 || height == 200 || height == 194 || height == 250 || height == 256 || height == 260 || height == 280 ) - return(0); - } - else if ( baseid == HRK ) - { - if ( height == 1027 || height == 1028 || height == 1029 || height == 1022 || height == 999 || height == 969 || height == 967 || height == 832 || height == 829 || height == 827 || height == 817 || height == 792 || height == 754 || height == 125 || height == 123 || height == 184 || height == 186 || height == 187 || height == 227 || height == 230 || height == 235 || height == 240 || height == 242 || height == 261 || height == 336 ) - return(0); - } - else if ( baseid == IDR ) - { - if ( height == 836 || height == 1036 || height == 837 || height == 720 || height == 715 || height == 714 || height == 696 || height == 695 || height == 694 || height == 693 || height == 119 || height == 689 || height == 120 || height == 669 || height == 123 || height == 662 || height == 122 || height == 634 || height == 121 || height == 609 || height == 124 || height == 174 || height == 603 || height == 595 || height == 166 || height == 176 || height == 589 || height == 172 || height == 587 || height == 179 || height == 239 || height == 175 || height == 245 || height == 260 ) - return(0); - } - } - if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) - { - if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) - { - for (i=1; iRTmask & (1LL << 32)) == 0 ) - { - if ( rtflag == 0 ) - printf("[%s] skip checkdeposit.%s not RT %llx\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]],(long long)sp->RTmask); - sleep(60); - rtflag = 1; - //matched++; - //continue; - } - if ( rtflag != 0 ) - printf("[%s] %s reached RT\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]); - } - if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one - { - pax->type = opcode; - if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) - { - printf("checkdeposit.[%s.%d]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,height,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); - return(-1); - } - if ( pax->fiatoshis == block.vtx[0].vout[i].nValue ) - { - matched++; - if ( pax->marked != 0 && height >= 80820 ) - { - printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f paxmarked.%d kht.%d ht.%d [%s].%d\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax->marked,pax->height,pax->otherheight,ASSETCHAINS_SYMBOL,height); - } - else - { - } - if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) - { - //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - char destaddr[64],coinaddr[64]; uint8_t pubkey33[33]; - checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis); - //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 ) - { - printf("paxcmp FAIL when check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); - return(-1); - } //else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); - } - } - else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) - { - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind %c txid [%d]\n",opcode,height); - printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p [%s] ht.%d\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax,ASSETCHAINS_SYMBOL,height); - return(-1); - } - } - else //if ( kmdheights[i-1] > 0 && otherheights[i-1] > 0 ) - { - hash = block.GetHash(); - for (j=0; j= activation ) - return(-1); - } - } - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - //if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) - //{ - // printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); - // can easily happen depending on order of loading - //if ( height > 200000 ) - //{ - // printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); - // return(-1); - //} - //} // disabled 'X' path - } - else - { - if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) - { - printf("REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); - return(-1); - } - } - } - else - { - for (i=0; i= activation ) - return(-1); - } - //printf("opretlen.%d num.%d\n",opretlen,num); - } - else - { - for (i=0; i Date: Wed, 23 May 2018 00:55:13 -1100 Subject: [PATCH 155/157] +comment --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0849d4870..410e106ae 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256],notmatched=0; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); From ab78e2413064fbcdd589efca5f2fbe2f0eb5031b Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Mon, 28 May 2018 14:19:11 +0300 Subject: [PATCH 156/157] 2 new chains --- src/assetchains | 2 ++ src/assetchains.old | 2 ++ src/dpowassets | 2 ++ src/fiat-cli | 2 ++ src/fiat/eql | 2 ++ src/fiat/glxt | 2 ++ 6 files changed, 12 insertions(+) create mode 100755 src/fiat/eql create mode 100755 src/fiat/glxt diff --git a/src/assetchains b/src/assetchains index a8ab28155..ec77fba28 100755 --- a/src/assetchains +++ b/src/assetchains @@ -55,3 +55,5 @@ komodo_asset BNTN 500000000 komodo_asset CHAIN 999999 komodo_asset PRLPAY 500000000 komodo_asset DSEC 7000000 +komodo_asset GLXT 100000000 +komodo_asset EQL 500000000 diff --git a/src/assetchains.old b/src/assetchains.old index 4e56fe639..cf46922de 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -32,6 +32,8 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & ./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & +./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=100000000 -addnode=13.230.224.15 & +./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 & #sleep $delay #./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & diff --git a/src/dpowassets b/src/dpowassets index 40bb89cce..dbf928d79 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -31,6 +31,8 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GLXT\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EQL\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat-cli b/src/fiat-cli index 463906cf2..8e54aeeb6 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -28,3 +28,5 @@ echo bntn; fiat/bntn $1 $2 $3 $4 echo chain; fiat/chain $1 $2 $3 $4 echo prlpay; fiat/prlpay $1 $2 $3 $4 echo dsec; fiat/dsec $1 $2 $3 $4 +echo dsec; fiat/glxt $1 $2 $3 $4 +echo dsec; fiat/eql $1 $2 $3 $4 diff --git a/src/fiat/eql b/src/fiat/eql new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/fiat/eql @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/glxt b/src/fiat/glxt new file mode 100755 index 000000000..6cedfbf87 --- /dev/null +++ b/src/fiat/glxt @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6 From f3c9d7c7e9c4040cf285c06f7f0d124908bef167 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Mon, 28 May 2018 14:22:02 +0300 Subject: [PATCH 157/157] 2 new chains --- src/ac/eql | 2 ++ src/ac/glxt | 2 ++ src/fiat-cli | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100755 src/ac/eql create mode 100755 src/ac/glxt diff --git a/src/ac/eql b/src/ac/eql new file mode 100755 index 000000000..99cfa9a09 --- /dev/null +++ b/src/ac/eql @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/glxt b/src/ac/glxt new file mode 100755 index 000000000..6cedfbf87 --- /dev/null +++ b/src/ac/glxt @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6 diff --git a/src/fiat-cli b/src/fiat-cli index 8e54aeeb6..6183f35d1 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -28,5 +28,5 @@ echo bntn; fiat/bntn $1 $2 $3 $4 echo chain; fiat/chain $1 $2 $3 $4 echo prlpay; fiat/prlpay $1 $2 $3 $4 echo dsec; fiat/dsec $1 $2 $3 $4 -echo dsec; fiat/glxt $1 $2 $3 $4 -echo dsec; fiat/eql $1 $2 $3 $4 +echo glxt; fiat/glxt $1 $2 $3 $4 +echo eql; fiat/eql $1 $2 $3 $4