From cbb14226569d8815137524c672fde8250b3327c4 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Tue, 4 Sep 2018 17:12:04 -0300 Subject: [PATCH 001/951] fix for TXSCL data leak --- src/crosschain.cpp | 7 +++++-- src/notarisationdb.cpp | 7 ++++++- src/notarisationdb.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 197390e59..831c7bcae 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -50,6 +50,8 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh int seenOwnNotarisations = 0; + bool txscl = IsTXSCL(symbol); + for (int i=0; i kmdHeight) break; NotarisationsInBlock notarisations; @@ -72,8 +74,9 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (seenOwnNotarisations == 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { - if (nota.second.ccId == targetCCid) - moms.push_back(nota.second.MoM); + if (IsTXSCL(nota.second.symbol) == txscl) + if (nota.second.ccId == targetCCid) + moms.push_back(nota.second.MoM); } } } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index cdfbb82c1..de3dd75f2 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -26,7 +26,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) { NotarisationData data; if (ParseNotarisationOpReturn(tx, data)) - if (strlen(data.symbol) >= 5 && strncmp(data.symbol, "TXSCL", 5) == 0) + if (IsTXSCL(data.symbol)) isTxscl = 1; } @@ -46,6 +46,11 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) return vNotarisations; } +bool IsTXSCL(const char* symbol) +{ + return strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0; +} + bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs) { diff --git a/src/notarisationdb.h b/src/notarisationdb.h index b8cd93691..f01a5a587 100644 --- a/src/notarisationdb.h +++ b/src/notarisationdb.h @@ -24,5 +24,6 @@ bool GetBackNotarisation(uint256 notarisationHash, Notarisation &n); void WriteBackNotarisations(const NotarisationsInBlock notarisations, CLevelDBBatch &batch); void EraseBackNotarisations(const NotarisationsInBlock notarisations, CLevelDBBatch &batch); int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Notarisation& out); +bool IsTXSCL(const char* symbol); #endif /* NOTARISATIONDB_H */ From 538de2ee49fe3b3531c6a09dd9ac6f08bb090287 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 5 Sep 2018 00:19:12 -0300 Subject: [PATCH 002/951] multiple authorities --- src/Makefile.am | 1 + src/cc/eval.cpp | 36 ++---------------- src/crosschain.cpp | 4 +- src/crosschain.h | 14 +++++++ src/crosschain_authority.cpp | 72 ++++++++++++++++++++++++++++++++++++ src/notarisationdb.cpp | 44 ++++++++++------------ 6 files changed, 113 insertions(+), 58 deletions(-) create mode 100644 src/crosschain_authority.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 8b10c06e0..7a9f660e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -272,6 +272,7 @@ libbitcoin_server_a_SOURCES = \ chain.cpp \ checkpoints.cpp \ crosschain.cpp \ + crosschain_authority.cpp \ deprecation.cpp \ httprpc.cpp \ httpserver.cpp \ diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index b6fcf57dd..cb9774a7a 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -140,45 +140,17 @@ int32_t Eval::GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t time return komodo_notaries(pubkeys, height, timestamp); } - bool Eval::CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const { if (tx.vin.size() < 11) return false; - uint8_t seenNotaries[64] = {0}; - uint8_t notaries[64][33]; - int nNotaries = GetNotaries(notaries, height, timestamp); + CrosschainAuthority auth; + auth.requiredSigs = 11; + auth.size = GetNotaries(auth.notaries, height, timestamp); - BOOST_FOREACH(const CTxIn &txIn, tx.vin) - { - // Get notary pubkey - CTransaction tx; - uint256 hashBlock; - if (!GetTxUnconfirmed(txIn.prevout.hash, tx, hashBlock)) return false; - if (tx.vout.size() < txIn.prevout.n) return false; - CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; - if (spk.size() != 35) return false; - const unsigned char *pk = spk.data(); - if (pk++[0] != 33) return false; - if (pk[33] != OP_CHECKSIG) return false; - - // Check it's a notary - for (int i=0; i kmdHeight) break; @@ -74,7 +74,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (seenOwnNotarisations == 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { - if (IsTXSCL(nota.second.symbol) == txscl) + if (GetSymbolAuthority(nota.second.symbol) == authority) if (nota.second.ccId == targetCCid) moms.push_back(nota.second.MoM); } diff --git a/src/crosschain.h b/src/crosschain.h index 15452ac63..65be53f92 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -3,6 +3,20 @@ #include "cc/eval.h" +const int CROSSCHAIN_KOMODO = 1; +const int CROSSCHAIN_TXSCL = 2; +const int CROSSCHAIN_STAKED = 3; + +typedef struct CrosschainAuthority { + uint8_t notaries[64][33]; + size_t size; + size_t requiredSigs; +} CrosschainAuthority; + +extern const CrosschainAuthority auth_STAKED; + +int GetSymbolAuthority(const char* symbol); +bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth); /* On assetchain */ TxProof GetAssetchainProof(uint256 hash); diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp new file mode 100644 index 000000000..5ea277387 --- /dev/null +++ b/src/crosschain_authority.cpp @@ -0,0 +1,72 @@ +#include "cc/eval.h" +#include "crosschain.h" +#include "notarisationdb.h" + + +int GetSymbolAuthority(const char* symbol) +{ + if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) + return CROSSCHAIN_TXSCL; + if (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) + return CROSSCHAIN_STAKED; + return CROSSCHAIN_KOMODO; +} + + +bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) +{ + EvalRef eval; + + if (tx.vin.size() < auth.requiredSigs) return false; + + uint8_t seesize[64]; + + BOOST_FOREACH(const CTxIn &txIn, tx.vin) + { + // Get notary pubkey + CTransaction tx; + uint256 hashBlock; + if (!eval->GetTxUnconfirmed(txIn.prevout.hash, tx, hashBlock)) return false; + if (tx.vout.size() < txIn.prevout.n) return false; + CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; + if (spk.size() != 35) return false; + const unsigned char *pk = spk.data(); + if (pk++[0] != 33) return false; + if (pk[33] != OP_CHECKSIG) return false; + + // Check it's a notary + for (int i=0; i @@ -21,36 +22,31 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; - // Special case for TXSCL. Should prob be removed at some point. - bool isTxscl = 0; - { - NotarisationData data; - if (ParseNotarisationOpReturn(tx, data)) - if (IsTXSCL(data.symbol)) - isTxscl = 1; + NotarisationData data; + bool parsed = ParseNotarisationOpReturn(tx, data); + if (!parsed) data = NotarisationData(); + int authority = GetSymbolAuthority(data.symbol); + + if (authority == CROSSCHAIN_KOMODO) { + if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) + continue; + } else if (authority == CROSSCHAIN_STAKED) { + if (!CheckTxAuthority(tx, auth_STAKED)) + continue; } - if (isTxscl || eval->CheckNotaryInputs(tx, nHeight, block.nTime)) { - NotarisationData data; - if (ParseNotarisationOpReturn(tx, data)) { - vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", - // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); - //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); - } - else - LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", - tx.GetHash().GetHex().data(), nHeight); - } + if (parsed) { + vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); + //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", + // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); + //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); + } else + LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", + tx.GetHash().GetHex().data(), nHeight); } return vNotarisations; } -bool IsTXSCL(const char* symbol) -{ - return strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0; -} - bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs) { From 64a4efaa700e5682096998a741116b140178799a Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 5 Sep 2018 00:22:38 -0300 Subject: [PATCH 003/951] put clarifying comment --- src/crosschain_authority.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 5ea277387..d9d75632a 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -59,6 +59,11 @@ const char *notaries_STAKED[4][2] = {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"} }; +/* + * TO EDIT: + * 1) Edit sigs above + * 2) Update size and requiredSigs below + */ const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; From 040078433fd6f2e5db76fddf86b44efa5a91a214 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Wed, 5 Sep 2018 00:27:06 -0300 Subject: [PATCH 004/951] fix outrageous typo --- src/crosschain_authority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index d9d75632a..0eeb8ad27 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,7 +19,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vin.size() < auth.requiredSigs) return false; - uint8_t seesize[64]; + uint8_t seen[64]; BOOST_FOREACH(const CTxIn &txIn, tx.vin) { @@ -36,9 +36,9 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) // Check it's a notary for (int i=0; i Date: Wed, 5 Sep 2018 20:47:22 +0000 Subject: [PATCH 005/951] temp add test pubkeys --- src/crosschain_authority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 0eeb8ad27..a75016770 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -54,9 +54,9 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const char *notaries_STAKED[4][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"} + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"} }; /* From 062b77092772a7dc96c8009010d22aa363ab2617 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Thu, 6 Sep 2018 00:14:45 -0300 Subject: [PATCH 006/951] bugfix; seen members not zeroed --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 0eeb8ad27..33c1d1d3e 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,7 +19,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vin.size() < auth.requiredSigs) return false; - uint8_t seen[64]; + uint8_t seen[64] = {0}; BOOST_FOREACH(const CTxIn &txIn, tx.vin) { From 489eb6710d8216aedba89d20c4140267bbf20000 Mon Sep 17 00:00:00 2001 From: blackjok3rtt Date: Fri, 7 Sep 2018 04:02:17 +0800 Subject: [PATCH 007/951] Test modification to allow STAKED* chains to have their own notary pubkeys. --- src/komodo_notary.h | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4711a9afc..8d1b6d582 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -198,6 +198,20 @@ const char *Notaries_elected1[][2] = {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, }; +const char *Notaries_staked[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; + + int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; @@ -226,13 +240,24 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1)); - for (i=0; i Date: Sat, 8 Sep 2018 09:29:00 +0800 Subject: [PATCH 008/951] Test, use single array, dynamically sized for crosschain auth --- src/crosschain_authority.cpp | 20 +++----------------- src/komodo_notary.h | 8 ++++---- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 12a44d8ce..7a153b7ff 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,6 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" +#include "komodo_notary.h" int GetSymbolAuthority(const char* symbol) @@ -51,27 +52,12 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) } -const char *notaries_STAKED[4][2] = -{ - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"} -}; - -/* - * TO EDIT: - * 1) Edit sigs above - * 2) Update size and requiredSigs below - */ - const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = 4; - auth.requiredSigs = 2; + auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + auth.requiredSigs = (auth.size/5); for (int n=0; n Date: Sat, 8 Sep 2018 09:35:26 +0800 Subject: [PATCH 009/951] try again --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7a153b7ff..fc8752db1 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,7 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -#include "komodo_notary.h" +#include "notaries_STAKED.h" int GetSymbolAuthority(const char* symbol) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6334af56b..6246fca52 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,6 +18,8 @@ #include "komodo_cJSON.h" +#include "notaries_STAKED.h" + #define KOMODO_MAINNET_START 178999 const char *Notaries_genesis[][2] = @@ -198,20 +200,6 @@ const char *Notaries_elected1[][2] = {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, }; -const char notaries_STAKED[][2] = -{ - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, -}; - - int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; From e18e04bed7bfd8296dda21fb0489311cf31aa326 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:38:12 +0800 Subject: [PATCH 010/951] LOL im drunk --- notaries_STAKED.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 notaries_STAKED.h diff --git a/notaries_STAKED.h b/notaries_STAKED.h new file mode 100644 index 000000000..8891a92fa --- /dev/null +++ b/notaries_STAKED.h @@ -0,0 +1,14 @@ +# notaries_STAKED + +const char notaries_STAKED[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; From c069525a77da1d84a6c9dc9f4e2db07aed381dd8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:49:50 +0800 Subject: [PATCH 011/951] fix stupidity --- notaries_STAKED.h => src/notaries_STAKED.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename notaries_STAKED.h => src/notaries_STAKED.h (100%) diff --git a/notaries_STAKED.h b/src/notaries_STAKED.h similarity index 100% rename from notaries_STAKED.h rename to src/notaries_STAKED.h From 9f93a0de963896d317a83095cc1c6c808f5be583 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:52:08 +0800 Subject: [PATCH 012/951] poofish --- src/notaries_STAKED.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 8891a92fa..a53cb3e27 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,3 @@ -# notaries_STAKED - const char notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From d5b43746be0dd22d09cdd9d71118d8e91a4164fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 09:58:29 +0800 Subject: [PATCH 013/951] fingers crossed --- src/notaries_STAKED.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index a53cb3e27..b5454d2f4 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,4 +1,4 @@ -const char notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, From 1ab289383976c956d1714b048aa85e0615d8d17c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:08:07 +0800 Subject: [PATCH 014/951] test --- src/notaries_STAKED.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index b5454d2f4..94f20acd2 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,3 +1,4 @@ +#pragma once const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From 14f27f2e498235b3b616706ab02d062a56cef7dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:26:32 +0800 Subject: [PATCH 015/951] test --- src/notaries_STAKED.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 94f20acd2..ed21cd2bd 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,4 +1,5 @@ #pragma once +#define notaries_STAKED const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From 1049d013b78bafd35ef38cef6c22f6c4217438f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:28:02 +0800 Subject: [PATCH 016/951] test --- src/notaries_STAKED.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index ed21cd2bd..7c540c9a4 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ #pragma once -#define notaries_STAKED +#define *notaries_STAKED[][2] const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From f04396d2c0497a7c2c6a5256aad102745155841e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:30:47 +0800 Subject: [PATCH 017/951] a --- src/crosschain_authority.cpp | 2 +- src/notaries_STAKED.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index fc8752db1..6c60d9f97 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,7 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -#include "notaries_STAKED.h" +//#include "notaries_STAKED.h" int GetSymbolAuthority(const char* symbol) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 7c540c9a4..f75c453b6 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ #pragma once -#define *notaries_STAKED[][2] + const char *notaries_STAKED[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, From ead6f50464ca7d91f70a2c40447802ada993daad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 12:38:29 +0800 Subject: [PATCH 018/951] testing --- src/crosschain_authority.cpp | 13 +++++++++++++ src/komodo_notary.h | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6c60d9f97..48162ad24 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,6 +3,19 @@ #include "notarisationdb.h" //#include "notaries_STAKED.h" +const char *notaries_STAKED[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; + int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6246fca52..5e63a4648 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,20 @@ #include "komodo_cJSON.h" -#include "notaries_STAKED.h" +//#include "notaries_STAKED.h" + +const char *notaries_STAKED[][2] = +{ + {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, + {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, + {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, + {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, + {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; #define KOMODO_MAINNET_START 178999 From b20459fee2dcb4504f21ccd39d1b1ad79c6f156b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 13:01:02 +0800 Subject: [PATCH 019/951] test again --- src/crosschain_authority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 48162ad24..eaeb010b4 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,7 @@ #include "notarisationdb.h" //#include "notaries_STAKED.h" -const char *notaries_STAKED[][2] = +const char *notaries_STAKEDcc[][2] = { {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, @@ -67,10 +67,10 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); auth.requiredSigs = (auth.size/5); for (int n=0; n Date: Sat, 8 Sep 2018 21:25:55 +0800 Subject: [PATCH 020/951] update pubkeys --- src/crosschain_authority.cpp | 20 +++++++++++--------- src/komodo_notary.h | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index eaeb010b4..c8108608c 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,15 +5,17 @@ const char *notaries_STAKEDcc[][2] = { - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, + {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, + {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, + {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, + {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, + {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"} }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5e63a4648..43c6805c6 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -21,16 +21,17 @@ //#include "notaries_STAKED.h" const char *notaries_STAKED[][2] = -{ - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, + {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, + {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, + {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, + {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, + {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, }; #define KOMODO_MAINNET_START 178999 From a8e94f86c5e1ee15b747b74cab90e1ee878fff58 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:28:31 +0800 Subject: [PATCH 021/951] pubkeys update --- src/crosschain_authority.cpp | 4 ++-- src/komodo_notary.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index c8108608c..a2fb95cff 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,9 +5,9 @@ const char *notaries_STAKEDcc[][2] = { - {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 43c6805c6..d377de319 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -21,9 +21,9 @@ //#include "notaries_STAKED.h" const char *notaries_STAKED[][2] = - {"alright", "037fa9d151c8bafd67c1829707b9d72e193e8c27c7b284fef1ffe2070601e508be"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"CrisF", "03921b5e03b3b4d31f94f6ad40b21170a524ab9f2f344bb575811aeca059ca174b"}, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, From fa9fd0a1e32f2623cbc2c5d682fe0c76aa32d688 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:40:20 +0800 Subject: [PATCH 022/951] drunk again --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index a2fb95cff..1960d7c32 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -15,7 +15,7 @@ const char *notaries_STAKEDcc[][2] = {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, - {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"} + {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, }; From e84001da53303bf8f18fe06ec9909cdb06cc80e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:44:19 +0800 Subject: [PATCH 023/951] soooo drunk --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1960d7c32..ffb3048ea 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -6,7 +6,7 @@ const char *notaries_STAKEDcc[][2] = { {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d377de319..e64024a19 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ const char *notaries_STAKED[][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, From 362c398046dad7c89fb84189ff6beecf03093b42 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:52:50 +0800 Subject: [PATCH 024/951] more beer --- src/crosschain_authority.cpp | 21 ++++++++++----------- src/komodo_notary.h | 18 +++++++++--------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ffb3048ea..492b5149b 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,17 +5,16 @@ const char *notaries_STAKEDcc[][2] = { - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, - {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, - {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, - {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, - {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, - {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, - {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, + {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, + {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, + {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e64024a19..a49ceeda9 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,20 +18,20 @@ #include "komodo_cJSON.h" -//#include "notaries_STAKED.h" +#include "notaries_STAKED.h" const char *notaries_STAKED[][2] = +{ {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, - {"Emman", "038F642DCDACBDF510B7869D74544DBC6792548D9D1F8D73A999DD9F45F513C935"}, - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943"}, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f"}, - {"jorian","02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3"}, - {"gcharang","024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d"}, - {"nabob","03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf"}, - {"TonyL","02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622"}, - {"blackjok3r","021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e"}, + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, + {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, + {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, + {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, }; #define KOMODO_MAINNET_START 178999 From fe6f552be66ee806db2ff922a541eed06ee61d79 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 8 Sep 2018 21:55:32 +0800 Subject: [PATCH 025/951] LOL lol --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index a49ceeda9..e9570db6a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,7 @@ #include "komodo_cJSON.h" -#include "notaries_STAKED.h" +//include "notaries_STAKED.h" const char *notaries_STAKED[][2] = { From 89223d139888ea373896d53c1b33d6f1217c9a98 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sat, 8 Sep 2018 14:39:26 +0000 Subject: [PATCH 026/951] add pubkey --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 492b5149b..ccac930f7 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -15,6 +15,7 @@ const char *notaries_STAKEDcc[][2] = {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e9570db6a..c46fb22dd 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -32,6 +32,7 @@ const char *notaries_STAKED[][2] = {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; #define KOMODO_MAINNET_START 178999 From a35ead4321925533f2c8dd8ff2638b35321576ab Mon Sep 17 00:00:00 2001 From: tonymorony Date: Sat, 8 Sep 2018 21:25:03 +0000 Subject: [PATCH 027/951] changed pubket TonyL --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ccac930f7..b726c034d 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -13,7 +13,7 @@ const char *notaries_STAKEDcc[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, - {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c46fb22dd..bfcdcfba5 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -30,7 +30,7 @@ const char *notaries_STAKED[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, - {"TonyL", "02f5988bda204b42fd451163257ff409d11dcbd818eb2d96ab6a72382eff2b2622" }, + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; From 2f358266f8acb5d495c088ec0afbdb6b39d09dcf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 9 Sep 2018 07:18:39 +0800 Subject: [PATCH 028/951] fix webworker --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 492b5149b..883bd886f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -6,7 +6,7 @@ const char *notaries_STAKEDcc[][2] = { {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, + {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e9570db6a..d20ae6912 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -23,7 +23,7 @@ const char *notaries_STAKED[][2] = { {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7"}, + {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 From ce77a270483eba8924473477d565a25cdc48e033 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 05:08:48 +0000 Subject: [PATCH 029/951] finalize pubkeys --- src/crosschain_authority.cpp | 8 +++----- src/komodo_notary.h | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index f169c47b3..4913a4ea0 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,16 +5,14 @@ const char *notaries_STAKEDcc[][2] = { + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, - {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, - {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index db0aeb988..3fbcb25ff 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,16 +22,14 @@ const char *notaries_STAKED[][2] = { + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01_NA", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // 60 + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, - {"gcharang", "024ce12f3423345350d8535e402803da30abee3c2941840b5002bf05e88b7f6e2d" }, - {"nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, }; From d33fc13c596c3e2960b37009a1166586a2858076 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 05:17:20 +0000 Subject: [PATCH 030/951] add titomane --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 4913a4ea0..4b5f7f62d 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -14,6 +14,7 @@ const char *notaries_STAKEDcc[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3fbcb25ff..acbff97c7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -31,6 +31,7 @@ const char *notaries_STAKED[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, }; #define KOMODO_MAINNET_START 178999 From fdae4d44e9c0d606d1fdcbe3c5e482e41771145b Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 05:40:41 +0000 Subject: [PATCH 031/951] add CHMEX, add addresses --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 4b5f7f62d..772558268 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -15,6 +15,7 @@ const char *notaries_STAKEDcc[][2] = {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index acbff97c7..9214ee3e0 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,16 +22,17 @@ const char *notaries_STAKED[][2] = { - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, }; #define KOMODO_MAINNET_START 178999 From 31b6db4b4187a94bbc2666dbcc998d917c25ad63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Sep 2018 13:53:47 +0800 Subject: [PATCH 032/951] fix spaces just incase --- src/crosschain_authority.cpp | 6 +++--- src/komodo_notary.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 772558268..e191fec84 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -6,9 +6,9 @@ const char *notaries_STAKEDcc[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9214ee3e0..131fc2438 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -23,9 +23,9 @@ const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8"}, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4"}, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3"}, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 From a86d6f81ad9f740f458440eff77f8dcfd2d16c0b Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 07:36:17 +0000 Subject: [PATCH 033/951] add metaphilibert --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 772558268..1c2c2146b 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -16,6 +16,7 @@ const char *notaries_STAKEDcc[][2] = {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9214ee3e0..23fa61b9c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -32,7 +32,8 @@ const char *notaries_STAKED[][2] = {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 }; #define KOMODO_MAINNET_START 178999 From 48d531894933bc11ce137d6c4dc75fd6f2603876 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 07:43:05 +0000 Subject: [PATCH 034/951] add address --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index bd3e5acd1..9e6f17097 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -29,7 +29,7 @@ const char *notaries_STAKED[][2] = {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL From de3377d94467495223f753ea479472653bae86d2 Mon Sep 17 00:00:00 2001 From: webworker01 Date: Mon, 10 Sep 2018 07:52:10 +0000 Subject: [PATCH 035/951] update webworker keys --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1b82c32af..39579811c 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ const char *notaries_STAKEDcc[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9e6f17097..d42d3e17e 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -24,7 +24,7 @@ const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, From e3f69857503c5ed0e205ee1b4d99eb047a4d12a0 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Mon, 10 Sep 2018 09:07:43 +0000 Subject: [PATCH 036/951] add jusoaresf, add mylo --- src/crosschain_authority.cpp | 2 ++ src/komodo_notary.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1b82c32af..6c92cfe07 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -17,6 +17,8 @@ const char *notaries_STAKEDcc[][2] = {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9e6f17097..105f4a5b1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -34,6 +34,8 @@ const char *notaries_STAKED[][2] = {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx }; #define KOMODO_MAINNET_START 178999 From b3c526f9c667aa14f49b1c7028f77f558f632526 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Sep 2018 20:28:20 +0800 Subject: [PATCH 037/951] add placeholder 15th pubkey --- src/crosschain_authority.cpp | 1 + src/komodo_notary.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6c92cfe07..33b868e3a 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,6 +19,7 @@ const char *notaries_STAKEDcc[][2] = {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, }; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 105f4a5b1..a08e7fc97 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -36,6 +36,7 @@ const char *notaries_STAKED[][2] = {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. }; #define KOMODO_MAINNET_START 178999 From 63fe933da5c566dd772918bc0e5726dbee048584 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Sep 2018 20:30:04 +0800 Subject: [PATCH 038/951] notaries_staked.h bounty to fix this is valid --- src/notaries_STAKED.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index f75c453b6..a92d71684 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -2,13 +2,19 @@ const char *notaries_STAKED[][2] = { - {"alright", "03b4f49a1c22087e0a9dfaa87aef98ef496c544f9f86038f6c9fea4550543a7679"}, - {"test1", "0323b1271dceb046a91e79bf80fc5874fb51b9a5ad572c50ca5f58ee9444b32965"}, - {"test2", "027b45bc21781c287b06b4af48081b49c9ff42cf9e925a8b32dc28a9e85edd2ccd"}, - {"test3", "023142dd900025a812c985e0c8d8730cbe7791126b8ceac71a506eeee1cb4d2633"}, - {"test4", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "03d01b559004b88fe71f9034ca25c7da0c142e4428afc969473dfbd101c984e7b4" }, // RKjJctJfaExgzcUgbrZDTqzzhxeaC5HP3G + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, + {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. }; From b22e7d44f43f2a3247d14a34478d13e28d4a5e72 Mon Sep 17 00:00:00 2001 From: blackjok3rtt Date: Tue, 11 Sep 2018 14:09:04 +0000 Subject: [PATCH 039/951] add modofication to stop normal komodo repo using staked chains --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d98418c82..4856931ac 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1554,7 +1554,7 @@ void komodo_args(char *argv0) if ( name.c_str()[0] != 0 ) { MAX_BLOCK_SIGOPS = 60000; - ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); + ASSETCHAINS_SUPPLY = ( GetArg("-ac_supply",10) + 1 ); ASSETCHAINS_ENDSUBSIDY = GetArg("-ac_end",0); ASSETCHAINS_REWARD = GetArg("-ac_reward",0); ASSETCHAINS_HALVING = GetArg("-ac_halving",0); From 139aca9821e857775ba2962c5f8970e82667345b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 12 Sep 2018 21:22:05 +0800 Subject: [PATCH 040/951] Add smk762 --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 21d824f9e..f5eed2fb0 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -10,7 +10,7 @@ const char *notaries_STAKEDcc[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, + {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 15932378b..ddea06e2c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -27,7 +27,7 @@ const char *notaries_STAKED[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"xrobesx", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, + {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 From 2333d409375d4a1ab2d6b71aee4aeebf507ea735 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 12 Sep 2018 23:34:28 +0800 Subject: [PATCH 041/951] FIX STKD != STAKED --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index f5eed2fb0..6553b66d3 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -27,7 +27,7 @@ int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) + if (strlen(symbol) >= 6 && strncmp(symbol, "STKD", 4) == 0) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index ddea06e2c..618cecd5d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -247,7 +247,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( strncmp("STAKED",ASSETCHAINS_SYMBOL,6) == 0 ) + if ( strncmp("STKD",ASSETCHAINS_SYMBOL,4) == 0 ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Wed, 12 Sep 2018 23:51:25 +0800 Subject: [PATCH 042/951] Fix --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6553b66d3..af8f82b6f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -27,7 +27,7 @@ int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (strlen(symbol) >= 6 && strncmp(symbol, "STKD", 4) == 0) + if (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } From 55215da21811a10871eab3d45c28321dc5c481b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 00:03:41 +0800 Subject: [PATCH 043/951] not sure --- src/crosschain_authority.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index af8f82b6f..e383272cb 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -5,24 +5,25 @@ const char *notaries_STAKEDcc[][2] = { - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, - {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, + {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. }; + int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) From 4aa70c42538d5f3898e570deba0d45e1e308dbd7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 02:07:47 +0800 Subject: [PATCH 044/951] put metaphillibert back in ... etf happened there LOL --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index e383272cb..ec8a286ce 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -16,7 +16,7 @@ const char *notaries_STAKEDcc[][2] = {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 618cecd5d..fd7e31864 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -33,7 +33,7 @@ const char *notaries_STAKED[][2] = {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. From a025b6f4e707c314a18de0667050101f757aea83 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 02:13:14 +0800 Subject: [PATCH 045/951] fix smk WTF?!? --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ec8a286ce..75bb3d516 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -10,7 +10,7 @@ const char *notaries_STAKEDcc[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index fd7e31864..0c010a962 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -27,7 +27,7 @@ const char *notaries_STAKED[][2] = {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, - {"smk762", "020a403b030211c87c77fc3d397db91313d96b3b43b86ca15cb08481508a7f754f" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 From bd2169b57dc5adcdc5276c3202724fe4e3d76988 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Sep 2018 12:37:28 +0800 Subject: [PATCH 046/951] Add some keys, and change to use STKD and STAKED. --- src/crosschain_authority.cpp | 7 +++---- src/komodo_notary.h | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 75bb3d516..13f27fb4c 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -9,7 +9,6 @@ const char *notaries_STAKEDcc[][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev @@ -19,16 +18,16 @@ const char *notaries_STAKEDcc[][2] = {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN }; - int GetSymbolAuthority(const char* symbol) { if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) + if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 0c010a962..1872d49ca 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -26,7 +26,6 @@ const char *notaries_STAKED[][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev @@ -36,7 +35,8 @@ const char *notaries_STAKED[][2] = {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"ca333", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - placeholder, blackjok3r has a privkey for this if needed to be used. + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN }; #define KOMODO_MAINNET_START 178999 @@ -247,7 +247,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( strncmp("STKD",ASSETCHAINS_SYMBOL,4) == 0 ) + if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Thu, 13 Sep 2018 13:50:47 +0800 Subject: [PATCH 047/951] fix stupid mistake --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1872d49ca..28797a003 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -247,7 +247,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) + if ( (strlen(ASSETCHAINS_SYMBOL) >= 4 && strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strlen(ASSETCHAINS_SYMBOL) >= 6 && strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Thu, 13 Sep 2018 19:10:52 +0800 Subject: [PATCH 048/951] remove one pubkey just incase --- src/crosschain_authority.cpp | 1 - src/komodo_notary.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 13f27fb4c..b6b6c22e7 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -13,7 +13,6 @@ const char *notaries_STAKEDcc[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 28797a003..05c7f0f42 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -30,7 +30,6 @@ const char *notaries_STAKED[][2] = {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"titomane", "0222d144bbf15280c574a0ccdc4f390f87779504692fef6e567543c03aa057dfcf" }, //RUS5jcf55AupeEDjotmKLeXnLZye2rwoUg {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu From c0128ed414fda99c0b9193776a399e582dc0dea1 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Sat, 15 Sep 2018 14:17:18 +0800 Subject: [PATCH 049/951] fix issue where if there are not two notarisations the MoMoM is indeterninate --- src/crosschain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 76771b186..16fc5e854 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -80,6 +80,11 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh } } } + + // Not enough own notarisations found to return determinate MoMoM + destNotarisationTxid = uint256(); + moms.clear(); + return uint256(); end: return GetMerkleRoot(moms); From 1444ed4e2d92d3d74e5f01a27ac01f2652127b83 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 19 Sep 2018 14:51:41 +0800 Subject: [PATCH 050/951] add print of MoMoM data each time it is called. --- src/cc/import.cpp | 6 +++--- src/crosschain.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index ffc94ac43..988264aa6 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -37,7 +37,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!UnmarshalImportTx(importTx, proof, burnTx, payouts)) return Invalid("invalid-params"); - + // Control all aspects of this transaction // It should not be at all malleable if (MakeImportCoinTransaction(proof, burnTx, payouts).GetHash() != importTx.GetHash()) @@ -79,6 +79,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); + printf("momom: %s\n", momom.GetHex().data()) + target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) return Invalid("momom-check-fail"); @@ -86,5 +88,3 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp return Valid(); } - - diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 8d886ece6..97e6d9823 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -80,7 +80,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh } } } - + // Not enough own notarisations found to return determinate MoMoM destNotarisationTxid = uint256(); moms.clear(); @@ -162,6 +162,8 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); + printf("momom: %s\n", MoMoM.GetHex().data()) + // Find index of source MoM in MoMoM int nIndex; for (nIndex=0; nIndex Date: Wed, 19 Sep 2018 14:52:22 +0800 Subject: [PATCH 051/951] ; --- src/cc/import.cpp | 4 ++-- src/crosschain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 988264aa6..7224c40cd 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,8 +79,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("momom: %s\n", momom.GetHex().data()) - + printf("momom: %s\n", momom.GetHex().data()); + target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) return Invalid("momom-check-fail"); diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 97e6d9823..82d4be193 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,8 +162,8 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("momom: %s\n", MoMoM.GetHex().data()) - + printf("momom: %s\n", MoMoM.GetHex().data()); + // Find index of source MoM in MoMoM int nIndex; for (nIndex=0; nIndex Date: Wed, 19 Sep 2018 15:31:09 +0800 Subject: [PATCH 052/951] make it so prints are diffrent. --- src/cc/import.cpp | 2 +- src/crosschain.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 7224c40cd..cc0c3b61f 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,7 +79,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("momom: %s\n", momom.GetHex().data()); + printf("IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 82d4be193..23416c682 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,7 +162,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("momom: %s\n", MoMoM.GetHex().data()); + printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); // Find index of source MoM in MoMoM int nIndex; From d1b74ce6d19ecfad8a2e4ac404e27a43bef20e1b Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Wed, 19 Sep 2018 18:50:38 +0200 Subject: [PATCH 053/951] hard fork mandatory update --- src/komodo_notary.h | 3 +++ src/version.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c2645b3f2..e0851b209 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -36,6 +36,9 @@ const char *notaries_STAKED[][2] = {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; #define KOMODO_MAINNET_START 178999 diff --git a/src/version.h b/src/version.h index 25527895d..1efbecdf8 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170003; +static const int PROTOCOL_VERSION = 170004; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -18,7 +18,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170002; +static const int MIN_PEER_PROTO_VERSION = 170004; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 3a9b05001400575cd6f54deca233ac12d84873fb Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Wed, 19 Sep 2018 18:52:22 +0200 Subject: [PATCH 054/951] whoops --- src/crosschain_authority.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b6b6c22e7..d635e6e22 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -19,6 +19,9 @@ const char *notaries_STAKEDcc[][2] = {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; From c2059876c3a13c60d4d41c0c31b0e2417dd005af Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Wed, 19 Sep 2018 13:38:33 -0400 Subject: [PATCH 055/951] Update version.h --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 1efbecdf8..25527895d 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170004; +static const int PROTOCOL_VERSION = 170003; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -18,7 +18,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170004; +static const int MIN_PEER_PROTO_VERSION = 170002; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 3330881171f284e9edc2b578e681237f551aedd3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Sep 2018 22:44:41 +0800 Subject: [PATCH 056/951] Use min sigs = 3 for staked chains, so we can add more pubkeys. --- src/crosschain_authority.cpp | 2 +- src/komodo.h | 5 +++-- src/komodo_notary.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b6b6c22e7..30e4e725a 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -73,7 +73,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); - auth.requiredSigs = (auth.size/5); + auth.requiredSigs = 3; for (int n=0; n= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5)) ) + numvalid > (numnotaries/5)) || + ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 3 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c2645b3f2..c2e7ed631 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -246,7 +246,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( (strlen(ASSETCHAINS_SYMBOL) >= 4 && strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strlen(ASSETCHAINS_SYMBOL) >= 6 && strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) { n1 = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); for (i=0; i Date: Thu, 20 Sep 2018 23:15:00 +0800 Subject: [PATCH 057/951] Change min protcol version so STAKED chains have their own value, so KMD can still work. --- src/main.cpp | 1128 +++++++++++++++++++++++++------------------------ src/version.h | 3 +- 2 files changed, 573 insertions(+), 558 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4edb4f604..73a1ff364 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,30 +114,30 @@ const string strMessageMagic = "Komodo Signed Message:\n"; // Internal stuff namespace { - + struct CBlockIndexWorkComparator { bool operator()(CBlockIndex *pa, CBlockIndex *pb) const { // First sort by most total work, ... if (pa->nChainWork > pb->nChainWork) return false; if (pa->nChainWork < pb->nChainWork) return true; - + // ... then by earliest time received, ... if (pa->nSequenceId < pb->nSequenceId) return false; if (pa->nSequenceId > pb->nSequenceId) return true; - + // Use pointer address as tie breaker (should only happen with blocks // loaded from disk, as those all have id 0). if (pa < pb) return false; if (pa > pb) return true; - + // Identical blocks. return false; } }; - + CBlockIndex *pindexBestInvalid; - + /** * The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and * as good as our current tip or better. Entries may be failed, though, and pruning nodes may be @@ -150,7 +150,7 @@ namespace { * Pruned nodes may have entries where B is missing data. */ multimap mapBlocksUnlinked; - + CCriticalSection cs_LastBlockFile; std::vector vinfoBlockFile; int nLastBlockFile = 0; @@ -159,7 +159,7 @@ namespace { * or if we allocate more file space when we're in prune mode */ bool fCheckForPruning = false; - + /** * Every received block is assigned a unique and increasing identifier, so we * know which one to give priority in case of a fork. @@ -167,14 +167,14 @@ namespace { CCriticalSection cs_nBlockSequenceId; /** Blocks loaded from disk are assigned id 0, so start the counter at 1. */ uint32_t nBlockSequenceId = 1; - + /** * Sources of received blocks, saved to be able to send them reject * messages or ban them when processing happens afterwards. Protected by * cs_main. */ map mapBlockSource; - + /** * Filter for transactions that were recently rejected by * AcceptToMemoryPool. These are not rerequested until the chain tip @@ -197,7 +197,7 @@ namespace { */ boost::scoped_ptr recentRejects; uint256 hashRecentRejectsChainTip; - + /** Blocks that are in flight, and that are in the queue to be downloaded. Protected by cs_main. */ struct QueuedBlock { uint256 hash; @@ -207,16 +207,16 @@ namespace { int64_t nTimeDisconnect; //! The timeout for this block request (for disconnecting a slow peer) }; map::iterator> > mapBlocksInFlight; - + /** Number of blocks in flight with validated headers. */ int nQueuedValidatedHeaders = 0; - + /** Number of preferable block download peers. */ int nPreferredDownload = 0; - + /** Dirty block index entries. */ set setDirtyBlockIndex; - + /** Dirty block file entries. */ set setDirtyFileInfo; } // anon namespace @@ -227,13 +227,13 @@ namespace { // namespace { - + struct CBlockReject { unsigned char chRejectCode; string strRejectReason; uint256 hashBlock; }; - + /** * Maintain validation-specific state about nodes, protected by cs_main, instead * by CNode's own locks. This simplifies asynchronous operation, where @@ -268,7 +268,7 @@ namespace { int nBlocksInFlightValidHeaders; //! Whether we consider this a preferred download peer. bool fPreferredDownload; - + CNodeState() { fCurrentlyConnected = false; nMisbehavior = 0; @@ -283,10 +283,10 @@ namespace { fPreferredDownload = false; } }; - + /** Map maintaining per-node state. Requires cs_main. */ map mapNodeState; - + // Requires cs_main. CNodeState *State(NodeId pnode) { map::iterator it = mapNodeState.find(pnode); @@ -294,67 +294,67 @@ namespace { return NULL; return &it->second; } - + int GetHeight() { LOCK(cs_main); return chainActive.Height(); } - + void UpdatePreferredDownload(CNode* node, CNodeState* state) { nPreferredDownload -= state->fPreferredDownload; - + // Whether this node should be marked as a preferred download node. state->fPreferredDownload = (!node->fInbound || node->fWhitelisted) && !node->fOneShot && !node->fClient; - + nPreferredDownload += state->fPreferredDownload; } - + // Returns time at which to timeout block request (nTime in microseconds) int64_t GetBlockTimeout(int64_t nTime, int nValidatedQueuedBefore, const Consensus::Params &consensusParams) { return nTime + 500000 * consensusParams.nPowTargetSpacing * (4 + nValidatedQueuedBefore); } - + void InitializeNode(NodeId nodeid, const CNode *pnode) { LOCK(cs_main); CNodeState &state = mapNodeState.insert(std::make_pair(nodeid, CNodeState())).first->second; state.name = pnode->addrName; state.address = pnode->addr; } - + void FinalizeNode(NodeId nodeid) { LOCK(cs_main); CNodeState *state = State(nodeid); - + if (state->fSyncStarted) nSyncStarted--; - + if (state->nMisbehavior == 0 && state->fCurrentlyConnected) { AddressCurrentlyConnected(state->address); } - + BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight) mapBlocksInFlight.erase(entry.hash); EraseOrphansFor(nodeid); nPreferredDownload -= state->fPreferredDownload; - + mapNodeState.erase(nodeid); } - + void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) { /* int expired = pool.Expire(GetTime() - age); if (expired != 0) LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired); - + std::vector vNoSpendsRemaining; pool.TrimToSize(limit, &vNoSpendsRemaining); BOOST_FOREACH(const uint256& removed, vNoSpendsRemaining) pcoinsTip->Uncache(removed);*/ } - + // Requires cs_main. // Returns a bool indicating whether we requested this block. bool MarkBlockAsReceived(const uint256& hash) { @@ -371,15 +371,15 @@ namespace { } return false; } - + // Requires cs_main. void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, CBlockIndex *pindex = NULL) { CNodeState *state = State(nodeid); assert(state != NULL); - + // Make sure it's not listed somewhere already. MarkBlockAsReceived(hash); - + int64_t nNow = GetTimeMicros(); QueuedBlock newentry = {hash, pindex, nNow, pindex != NULL, GetBlockTimeout(nNow, nQueuedValidatedHeaders, consensusParams)}; nQueuedValidatedHeaders += newentry.fValidatedHeaders; @@ -388,12 +388,12 @@ namespace { state->nBlocksInFlightValidHeaders += newentry.fValidatedHeaders; mapBlocksInFlight[hash] = std::make_pair(nodeid, it); } - + /** Check whether the last unknown block a peer advertized is not yet known. */ void ProcessBlockAvailability(NodeId nodeid) { CNodeState *state = State(nodeid); assert(state != NULL); - + if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) @@ -404,14 +404,14 @@ namespace { } } } - + /** Update tracking information about which blocks a peer is assumed to have. */ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { CNodeState *state = State(nodeid); assert(state != NULL); - + /*ProcessBlockAvailability(nodeid); - + BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. @@ -423,7 +423,7 @@ namespace { state->hashLastUnknownBlock = hash; } } - + /** Find the last common ancestor two blocks have. * Both pa and pb must be non-NULL. */ CBlockIndex* LastCommonAncestor(CBlockIndex* pa, CBlockIndex* pb) { @@ -432,47 +432,47 @@ namespace { } else if (pb->nHeight > pa->nHeight) { pb = pb->GetAncestor(pa->nHeight); } - + while (pa != pb && pa && pb) { pa = pa->pprev; pb = pb->pprev; } - + // Eventually all chain branches meet at the genesis block. assert(pa == pb); return pa; } - + /** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has * at most count entries. */ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector& vBlocks, NodeId& nodeStaller) { if (count == 0) return; - + vBlocks.reserve(vBlocks.size() + count); CNodeState *state = State(nodeid); assert(state != NULL); - + // Make sure pindexBestKnownBlock is up to date, we'll need it. ProcessBlockAvailability(nodeid); - + if (state->pindexBestKnownBlock == NULL || state->pindexBestKnownBlock->nChainWork < chainActive.Tip()->nChainWork) { // This peer has nothing interesting. return; } - + if (state->pindexLastCommonBlock == NULL) { // Bootstrap quickly by guessing a parent of our best tip is the forking point. // Guessing wrong in either direction is not a problem. state->pindexLastCommonBlock = chainActive[std::min(state->pindexBestKnownBlock->nHeight, chainActive.Height())]; } - + // If the peer reorganized, our previous pindexLastCommonBlock may not be an ancestor // of its current tip anymore. Go back enough to fix that. state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, state->pindexBestKnownBlock); if (state->pindexLastCommonBlock == state->pindexBestKnownBlock) return; - + std::vector vToFetch; CBlockIndex *pindexWalk = state->pindexLastCommonBlock; // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last @@ -492,7 +492,7 @@ namespace { for (unsigned int i = nToFetch - 1; i > 0; i--) { vToFetch[i - 1] = vToFetch[i]->pprev; } - + // Iterate over those blocks in vToFetch (in forward direction), adding the ones that // are not yet downloaded and not in flight to vBlocks. In the meantime, update // pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's @@ -526,7 +526,7 @@ namespace { } } } - + } // anon namespace bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) { @@ -616,7 +616,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c uint256 hash = tx.GetHash(); if (mapOrphanTransactions.count(hash)) return false; - + // Ignore big transactions, to avoid a // send-big-orphans memory exhaustion attack. If a peer has a legitimate // large transaction with a missing parent then we assume @@ -630,12 +630,12 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); return false; } - + mapOrphanTransactions[hash].tx = tx; mapOrphanTransactions[hash].fromPeer = peer; BOOST_FOREACH(const CTxIn& txin, tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); - + LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), mapOrphanTransactions.size(), mapOrphanTransactionsByPrev.size()); return true; @@ -695,7 +695,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRE bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) { bool isOverwinter = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - + if (isOverwinter) { // Overwinter standard rules apply if (tx.nVersion > CTransaction::OVERWINTER_MAX_CURRENT_VERSION || tx.nVersion < CTransaction::OVERWINTER_MIN_CURRENT_VERSION) { @@ -709,7 +709,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) return false; } } - + BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed @@ -728,7 +728,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) return false; } } - + unsigned int v=0,nDataOut = 0; txnouttype whichType; BOOST_FOREACH(const CTxOut& txout, tx.vout) @@ -739,7 +739,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) //fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut); return false; } - + if (whichType == TX_NULL_DATA) { if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) @@ -759,13 +759,13 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) } v++; } - + // only one OP_RETURN txout is permitted if (nDataOut > 1) { reason = "multi-op-return"; return false; } - + return true; } @@ -780,7 +780,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) { if ( txin.nSequence == 0xfffffffe && (((int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime > nBlockTime) || ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime > nBlockHeight)) ) { - + } else if (!txin.IsFinal()) { @@ -802,7 +802,7 @@ bool IsExpiredTx(const CTransaction &tx, int nBlockHeight) bool CheckFinalTx(const CTransaction &tx, int flags) { AssertLockHeld(cs_main); - + // By convention a negative value for flags indicates that the // current network-enforced consensus rules should be used. In // a future soft-fork scenario that would mean checking which @@ -810,7 +810,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) // appropriate flags. At the present time no soft-forks are // scheduled, so no flags are set. flags = std::max(flags, 0); - + // CheckFinalTx() uses chainActive.Height()+1 to evaluate // nLockTime because when IsFinalTx() is called within // CBlock::AcceptBlock(), the height of the block *being* @@ -818,7 +818,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) // transaction can be part of the *next* block, we need to call // IsFinalTx() with one more than chainActive.Height(). const int nBlockHeight = chainActive.Height() + 1; - + // Timestamps on the other hand don't get any special treatment, // because we can't know what timestamp the next block will have, // and there aren't timestamp applications where it matters. @@ -826,7 +826,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) const int64_t nBlockTime = (flags & LOCKTIME_MEDIAN_TIME_PAST) ? chainActive.Tip()->GetMedianTimePast() : GetAdjustedTime(); - + return IsFinalTx(tx, nBlockHeight, nBlockTime); } @@ -850,7 +850,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& prev = mapInputs.GetOutputFor(tx.vin[i]); - + vector > vSolutions; txnouttype whichType; // get the scriptPubKey corresponding to this input: @@ -860,7 +860,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions); if (nArgsExpected < 0) return false; - + // Transactions with extra stuff in their scriptSigs are // non-standard. Note that this EvalScript() call will // be quick, because if there are any operations @@ -870,7 +870,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, vector > stack; if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), consensusBranchId)) return false; - + if (whichType == TX_SCRIPTHASH) { if (stack.empty()) @@ -893,11 +893,11 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, return (sigops <= MAX_P2SH_SIGOPS); } } - + if (stack.size() != (unsigned int)nArgsExpected) return false; } - + return true; } @@ -919,7 +919,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in { if (tx.IsCoinBase() || tx.IsCoinImport()) return 0; - + unsigned int nSigOps = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) { @@ -942,13 +942,13 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, { bool isOverwinter = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); bool isSprout = !isOverwinter; - + // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond if (isSprout && tx.fOverwintered) { return state.DoS(dosLevel, error("ContextualCheckTransaction(): overwinter is not active yet"), REJECT_INVALID, "tx-overwinter-not-active"); } - + // If Overwinter rules apply: if (isOverwinter) { // Reject transactions with valid version but missing overwinter flag @@ -956,19 +956,19 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, return state.DoS(dosLevel, error("ContextualCheckTransaction(): overwinter flag must be set"), REJECT_INVALID, "tx-overwinter-flag-not-set"); } - + // Reject transactions with invalid version if (tx.fOverwintered && tx.nVersion > OVERWINTER_MAX_TX_VERSION ) { return state.DoS(100, error("CheckTransaction(): overwinter version too high"), REJECT_INVALID, "bad-tx-overwinter-version-too-high"); } - + // Reject transactions intended for Sprout if (!tx.fOverwintered) { return state.DoS(dosLevel, error("ContextualCheckTransaction: overwinter is active"), REJECT_INVALID, "tx-overwinter-active"); } - + // Check that all transactions are unexpired if (IsExpiredTx(tx, nHeight)) { return state.DoS(dosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired"); @@ -986,9 +986,9 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, return state.DoS(100, error("CheckTransaction(): error computing signature hash"), REJECT_INVALID, "error-computing-signature-hash"); } - + BOOST_STATIC_ASSERT(crypto_sign_PUBLICKEYBYTES == 32); - + // We rely on libsodium to check that the signature is canonical. // https://github.com/jedisct1/libsodium/commit/62911edb7ff2275cccd74bf1c8aefcc4d76924e0 if (crypto_sign_verify_detached(&tx.joinSplitSig[0], @@ -1026,7 +1026,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, if (!tx.IsCoinBase()) { transactionsValidated.increment(); } - + if (!CheckTransactionWithoutProofVerification(tx, state)) { return false; } else { @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state) { // Basic checks that don't depend on any context - + /** * Previously: * 1. The consensus rule below was: @@ -1085,7 +1085,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio REJECT_INVALID, "bad-tx-expiry-height-too-high"); } } - + // Transactions can contain empty `vin` and `vout` so long as // `vjoinsplit` is non-empty. // Migrations may also have empty `vin` @@ -1095,13 +1095,13 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio if (tx.vout.empty() && tx.vjoinsplit.empty()) return state.DoS(10, error("CheckTransaction(): vout empty"), REJECT_INVALID, "bad-txns-vout-empty"); - + // Size limits BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE); // sanity if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE) return state.DoS(100, error("CheckTransaction(): size limits failed"), REJECT_INVALID, "bad-txns-oversize"); - + // Check for negative or overflow output values CAmount nValueOut = 0; int32_t iscoinbase = tx.IsCoinBase(); @@ -1128,7 +1128,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio return state.DoS(100, error("CheckTransaction(): txout total out of range"), REJECT_INVALID, "bad-txns-txouttotal-toolarge"); } - + // Ensure that joinsplit values are well-formed BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) { @@ -1141,34 +1141,34 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old negative"), REJECT_INVALID, "bad-txns-vpub_old-negative"); } - + if (joinsplit.vpub_new < 0) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_new negative"), REJECT_INVALID, "bad-txns-vpub_new-negative"); } - + if (joinsplit.vpub_old > MAX_MONEY) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old too high"), REJECT_INVALID, "bad-txns-vpub_old-toolarge"); } - + if (joinsplit.vpub_new > MAX_MONEY) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_new too high"), REJECT_INVALID, "bad-txns-vpub_new-toolarge"); } - + if (joinsplit.vpub_new != 0 && joinsplit.vpub_old != 0) { return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_new and joinsplit.vpub_old both nonzero"), REJECT_INVALID, "bad-txns-vpubs-both-nonzero"); } - + nValueOut += joinsplit.vpub_old; if (!MoneyRange(nValueOut)) { return state.DoS(100, error("CheckTransaction(): txout total out of range"), REJECT_INVALID, "bad-txns-txouttotal-toolarge"); } } - + // Ensure input values do not exceed MAX_MONEY // We have not resolved the txin values at this stage, // but we do know what the joinsplits claim to add @@ -1178,15 +1178,15 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio for (std::vector::const_iterator it(tx.vjoinsplit.begin()); it != tx.vjoinsplit.end(); ++it) { nValueIn += it->vpub_new; - + if (!MoneyRange(it->vpub_new) || !MoneyRange(nValueIn)) { return state.DoS(100, error("CheckTransaction(): txin total out of range"), REJECT_INVALID, "bad-txns-txintotal-toolarge"); } } } - - + + // Check for duplicate inputs set vInOutPoints; BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -1196,7 +1196,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio REJECT_INVALID, "bad-txns-inputs-duplicate"); vInOutPoints.insert(txin.prevout); } - + // Check for duplicate joinsplit nullifiers in this transaction set vJoinSplitNullifiers; BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) @@ -1206,18 +1206,18 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio if (vJoinSplitNullifiers.count(nf)) return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"), REJECT_INVALID, "bad-joinsplits-nullifiers-duplicate"); - + vJoinSplitNullifiers.insert(nf); } } - + if (tx.IsMint()) { // There should be no joinsplits in a coinbase transaction if (tx.vjoinsplit.size() > 0) return state.DoS(100, error("CheckTransaction(): coinbase has joinsplits"), REJECT_INVALID, "bad-cb-has-joinsplits"); - + if (tx.vin[0].scriptSig.size() < 2 || tx.vin[0].scriptSig.size() > 100) return state.DoS(100, error("CheckTransaction(): coinbase script size"), REJECT_INVALID, "bad-cb-length"); @@ -1229,7 +1229,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio return state.DoS(10, error("CheckTransaction(): prevout is null"), REJECT_INVALID, "bad-txns-prevout-null"); } - + return true; } @@ -1245,9 +1245,9 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF if (dPriorityDelta > 0 || nFeeDelta > 0) return 0; } - + CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes); - + if (fAllowFree) { // There is a free transaction area in blocks created by most miners, @@ -1257,7 +1257,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF if (nBytes < (DEFAULT_BLOCK_PRIORITY_SIZE - 1000)) nMinFee = 0; } - + if (!MoneyRange(nMinFee)) nMinFee = MAX_MONEY; return nMinFee; @@ -1269,10 +1269,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa AssertLockHeld(cs_main); if (pfMissingInputs) *pfMissingInputs = false; - + int flag=0,nextBlockHeight = chainActive.Height() + 1; auto consensusBranchId = CurrentEpochBranchId(nextBlockHeight, Params().GetConsensus()); - + // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); @@ -1283,7 +1283,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } - + auto verifier = libzcash::ProofVerifier::Strict(); if ( komodo_validate_interest(tx,chainActive.LastTip()->nHeight+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) { @@ -1300,7 +1300,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } - + // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) { @@ -1329,7 +1329,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"already in mempool\n"); return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); } - + // Check for conflicts with in-memory transactions { LOCK(pool.cs); // protect pool.mapNextTx @@ -1357,7 +1357,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } - + { CCoinsView dummy; CCoinsViewCache view(&dummy); @@ -1367,14 +1367,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa LOCK(pool.cs); CCoinsViewMemPool viewMemPool(pcoinsTip, pool); view.SetBackend(viewMemPool); - + // do we already have it? if (view.HaveCoins(hash)) { //fprintf(stderr,"view.HaveCoins(hash) error\n"); return state.Invalid(false, REJECT_DUPLICATE, "already have coins"); } - + if (tx.IsCoinImport()) { // Inverse of normal case; if input exists, it's been spent @@ -1396,7 +1396,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } - + // are the actual inputs available? if (!view.HaveInputs(tx)) { @@ -1410,21 +1410,21 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"accept failure.2\n"); return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); } - + // Bring the best block into scope view.GetBestBlock(); - + nValueIn = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime); if ( 0 && interest != 0 ) fprintf(stderr,"add interest %.8f\n",(double)interest/COIN); // we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool view.SetBackend(dummy); } - + // Check for non-standard pay-to-script-hash in inputs if (Params().RequireStandard() && !AreInputsStandard(tx, view, consensusBranchId)) return error("AcceptToMemoryPool: reject nonstandard transaction input"); - + // Check that the transaction doesn't have an excessive number of // sigops, making it impossible to mine. Since the coinbase transaction // itself can contain sigops MAX_STANDARD_TX_SIGOPS is less than @@ -1437,11 +1437,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa fprintf(stderr,"accept failure.4\n"); return state.DoS(0, error("AcceptToMemoryPool: too many sigops %s, %d > %d", hash.ToString(), nSigOps, MAX_STANDARD_TX_SIGOPS),REJECT_NONSTANDARD, "bad-txns-too-many-sigops"); } - + CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; double dPriority = view.GetPriority(tx, chainActive.Height()); - + // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; @@ -1454,15 +1454,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } - + // Grab the branch ID we expect this transaction to commit to. We don't // yet know if it does, but if the entry gets added to the mempool, then // it has passed ContextualCheckInputs and therefore this is correct. auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - + CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), mempool.HasNoInputsOf(tx), fSpendsCoinbase, consensusBranchId); unsigned int nSize = entry.GetTxSize(); - + // Accept a tx if it contains joinsplits and has at least the default fee specified by z_sendmany. if (tx.vjoinsplit.size() > 0 && nFees >= ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE) { // In future we will we have more accurate and dynamic computation of fees for tx with joinsplits. @@ -1475,13 +1475,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d",hash.ToString(), nFees, txMinFee),REJECT_INSUFFICIENTFEE, "insufficient fee"); } } - + // Require that free transactions have sufficient priority to be mined in the next block. if (GetBoolArg("-relaypriority", false) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) { fprintf(stderr,"accept failure.6\n"); return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority"); } - + // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. @@ -1491,9 +1491,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa static double dFreeCount; static int64_t nLastTime; int64_t nNow = GetTime(); - + LOCK(csFreeLimiter); - + // Use an exponentially decaying ~10-minute window: dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); nLastTime = nNow; @@ -1507,13 +1507,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); dFreeCount += nSize; } - + if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/19 ) { fprintf(stderr,"accept failure.8\n"); return error("AcceptToMemoryPool: absurdly high fees %s, %d > %d",hash.ToString(), nFees, ::minRelayTxFee.GetFee(nSize) * 10000); } - + // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. PrecomputedTransactionData txdata(tx); @@ -1522,7 +1522,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa //fprintf(stderr,"accept failure.9\n"); return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString()); } - + // Check again against just the consensus-critical mandatory script // verification flags, in case of bugs in the standard flags that cause // transactions to pass as valid when they're actually invalid. For @@ -1565,9 +1565,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } } } - + SyncWithWallets(tx, NULL); - + return true; } @@ -1685,14 +1685,14 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) { CBlockIndex *pindexSlow = NULL; - + LOCK(cs_main); - + if (mempool.lookup(hash, txOut)) { return true; } - + if (fTxIndex) { CDiskTxPos postx; if (pblocktree->ReadTxIndex(hash, postx)) { @@ -1713,7 +1713,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock return true; } } - + if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it int nHeight = -1; { @@ -1725,7 +1725,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock if (nHeight > 0) pindexSlow = chainActive[nHeight]; } - + if (pindexSlow) { CBlock block; if (ReadBlockFromDisk(block, pindexSlow,1)) { @@ -1738,7 +1738,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock } } } - + return false; } @@ -1768,18 +1768,18 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) return error("WriteBlockToDisk: OpenBlockFile failed"); - + // Write index header unsigned int nSize = fileout.GetSerializeSize(block); fileout << FLATDATA(messageStart) << nSize; - + // Write block long fileOutPos = ftell(fileout.Get()); if (fileOutPos < 0) return error("WriteBlockToDisk: ftell failed"); pos.nPos = (unsigned int)fileOutPos; fileout << block; - + return true; } @@ -1787,7 +1787,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo { uint8_t pubkey33[33]; block.SetNull(); - + // Open history file to read CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION); if (filein.IsNull()) @@ -1795,7 +1795,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo //fprintf(stderr,"readblockfromdisk err A\n"); return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString()); } - + // Read block try { filein >> block; @@ -1813,7 +1813,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos,bo int32_t i; for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey33[i]); fprintf(stderr," warning unexpected diff at ht.%d\n",height); - + return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); } } @@ -1911,14 +1911,14 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) nSubsidy *= (nHeight+1); return nSubsidy; } - + assert(nHeight > consensusParams.SubsidySlowStartShift()); int halvings = (nHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nSubsidyHalvingInterval;*/ // Force block reward to zero when right shift is undefined. //int halvings = nHeight / consensusParams.nSubsidyHalvingInterval; //if (halvings >= 64) // return 0; - + // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. //nSubsidy >>= halvings; return nSubsidy; @@ -1972,12 +1972,12 @@ void CheckForkWarningConditions() // (we assume we don't get stuck on a fork before the last checkpoint) if (IsInitialBlockDownload()) return; - + // If our best fork is no longer within 288 blocks (+/- 12 hours if no one mines it) // of our head, drop it if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->nHeight >= 288) pindexBestForkTip = NULL; - + if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.LastTip()->nChainWork + (GetBlockProof(*chainActive.LastTip()) * 6))) { if (!fLargeWorkForkFound && pindexBestForkBase) @@ -2022,7 +2022,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) break; pfork = pfork->pprev; } - + // We define a condition where we should warn the user about as a fork of at least 7 blocks // with a tip within 72 blocks (+/- 3 hours if no one mines it) of ours // We use 7 blocks rather arbitrarily as it represents just under 10% of sustained network @@ -2037,7 +2037,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip) pindexBestForkTip = pindexNewForkTip; pindexBestForkBase = pfork; } - + CheckForkWarningConditions(); } @@ -2046,11 +2046,11 @@ void Misbehaving(NodeId pnode, int howmuch) { if (howmuch == 0) return; - + CNodeState *state = State(pnode); if (state == NULL) return; - + state->nMisbehavior += howmuch; int banscore = GetArg("-banscore", 101); if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore) @@ -2065,7 +2065,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew) { if (!pindexBestInvalid || pindexNew->nChainWork > pindexBestInvalid->nChainWork) pindexBestInvalid = pindexNew; - + LogPrintf("%s: invalid block=%s height=%d log2_work=%.8g date=%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", @@ -2105,7 +2105,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund BOOST_FOREACH(const CTxIn &txin, tx.vin) { CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash); unsigned nPos = txin.prevout.n; - + if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull()) assert(false); // mark an outpoint spent, and construct undo information @@ -2125,7 +2125,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund } } inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight); // add outputs - + // Unorthodox state if (tx.IsCoinImport()) { // add a tombstone for the burnTx @@ -2163,11 +2163,11 @@ namespace Consensus { // for an attacker to attempt to split the network. if (!inputs.HaveInputs(tx)) return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString())); - + // are the JoinSplit's requirements met? if (!inputs.HaveJoinSplitRequirements(tx)) return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString())); - + CAmount nValueIn = 0; CAmount nFees = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) @@ -2175,7 +2175,7 @@ namespace Consensus { const COutPoint &prevout = tx.vin[i].prevout; const CCoins *coins = inputs.AccessCoins(prevout.hash); assert(coins); - + if (coins->IsCoinBase()) { // Ensure that coinbases are matured if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { @@ -2183,7 +2183,7 @@ namespace Consensus { error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight), REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); } - + // Ensure that coinbases cannot be spent to transparent outputs // Disabled on regtest if (fCoinbaseEnforcedProtectionEnabled && @@ -2194,7 +2194,7 @@ namespace Consensus { REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs"); } } - + // Check for negative or overflow input values nValueIn += coins->vout[prevout.n].nValue; #ifdef KOMODO_ENABLE_INTEREST @@ -2214,14 +2214,14 @@ namespace Consensus { if (!MoneyRange(coins->vout[prevout.n].nValue) || !MoneyRange(nValueIn)) return state.DoS(100, error("CheckInputs(): txin values out of range"), REJECT_INVALID, "bad-txns-inputvalues-outofrange"); - + } - + nValueIn += tx.GetJoinSplitValueIn(); if (!MoneyRange(nValueIn)) return state.DoS(100, error("CheckInputs(): vpub_old values out of range"), REJECT_INVALID, "bad-txns-inputvalues-outofrange"); - + if (nValueIn < tx.GetValueOut()) { fprintf(stderr,"spentheight.%d valuein %s vs %s error\n",nSpendHeight,FormatMoney(nValueIn).c_str(), FormatMoney(tx.GetValueOut()).c_str()); @@ -2258,14 +2258,14 @@ bool ContextualCheckInputs( if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs), consensusParams)) { return false; } - + if (pvChecks) pvChecks->reserve(tx.vin.size()); - + // The first loop above does all the inexpensive checks. // Only if ALL inputs pass do we perform expensive ECDSA signature checks. // Helps prevent CPU exhaustion attacks. - + // Skip ECDSA signature verification when connecting blocks // before the last block chain checkpoint. This is safe because block merkle hashes are // still computed and checked, and any change will be caught at the next checkpoint. @@ -2274,7 +2274,7 @@ bool ContextualCheckInputs( const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = inputs.AccessCoins(prevout.hash); assert(coins); - + // Verify signature CScriptCheck check(*coins, tx, i, flags, cacheStore, consensusBranchId, &txdata); if (pvChecks) { @@ -2322,7 +2322,7 @@ bool ContextualCheckInputs( fprintf(stderr,"ContextualCheckInputs failure.0\n"); return false; } - + if (!tx.IsCoinBase()) { // While checking, GetBestBlock() refers to the parent block. @@ -2336,60 +2336,60 @@ bool ContextualCheckInputs( // Assertion is okay because NonContextualCheckInputs ensures the inputs // are available. assert(coins); - + // If prev is coinbase, check that it's matured if (coins->IsCoinBase()) { if ( ASSETCHAINS_SYMBOL[0] == 0 ) COINBASE_MATURITY = _COINBASE_MATURITY; if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { fprintf(stderr,"ContextualCheckInputs failure.1 i.%d of %d\n",i,(int32_t)tx.vin.size()); - + return state.Invalid( error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),REJECT_INVALID, "bad-txns-premature-spend-of-coinbase"); } } } } - + return true; }*/ namespace { - + bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart) { // Open history file to append CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) return error("%s: OpenUndoFile failed", __func__); - + // Write index header unsigned int nSize = fileout.GetSerializeSize(blockundo); fileout << FLATDATA(messageStart) << nSize; - + // Write undo data long fileOutPos = ftell(fileout.Get()); if (fileOutPos < 0) return error("%s: ftell failed", __func__); pos.nPos = (unsigned int)fileOutPos; fileout << blockundo; - + // calculate & write checksum CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION); hasher << hashBlock; hasher << blockundo; fileout << hasher.GetHash(); - + return true; } - + bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock) { // Open history file to read CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION); if (filein.IsNull()) return error("%s: OpenBlockFile failed", __func__); - + // Read block uint256 hashChecksum; try { @@ -2405,10 +2405,10 @@ namespace { hasher << blockundo; if (hashChecksum != hasher.GetHash()) return error("%s: Checksum mismatch", __func__); - + return true; } - + /** Abort with a message */ bool AbortNode(const std::string& strMessage, const std::string& userMessage="") { @@ -2420,13 +2420,13 @@ namespace { StartShutdown(); return false; } - + bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="") { AbortNode(strMessage, userMessage); return state.Error(strMessage); } - + } // anon namespace /** @@ -2439,7 +2439,7 @@ namespace { static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint& out) { bool fClean = true; - + CCoinsModifier coins = view.ModifyCoins(out.hash); if (undo.nHeight != 0) { // undo data contains height: this is the last output of the prevout tx being spent @@ -2458,7 +2458,7 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const CO if (coins->vout.size() < out.n+1) coins->vout.resize(out.n+1); coins->vout[out.n] = undo.txout; - + return fClean; } @@ -2496,10 +2496,10 @@ void DisconnectNotarisations(const CBlock &block) bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean) { assert(pindex->GetBlockHash() == view.GetBestBlock()); - + if (pfClean) *pfClean = false; - + bool fClean = true; komodo_disconnect(pindex,block); CBlockUndo blockUndo; @@ -2508,7 +2508,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex return error("DisconnectBlock(): no undo data available"); if (!UndoReadFromDisk(blockUndo, pos, pindex->pprev->GetBlockHash())) return error("DisconnectBlock(): failure reading undo data"); - + if (blockUndo.vtxundo.size() + 1 != block.vtx.size()) return error("DisconnectBlock(): block and undo data inconsistent"); std::vector > addressIndex; @@ -2546,23 +2546,23 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex } else if (out.scriptPubKey.IsPayToPublicKey()) { vector hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34); - + // undo receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, k, false), out.nValue)); - + // undo unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), hash, k), CAddressUnspentValue())); - + } else if (out.scriptPubKey.IsPayToCryptoCondition()) { vector hashBytes(out.scriptPubKey.begin(), out.scriptPubKey.end()); - + // undo receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, k, false), out.nValue)); - + // undo unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), hash, k), CAddressUnspentValue())); - + } else { continue; @@ -2577,7 +2577,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex { CCoinsModifier outs = view.ModifyCoins(hash); outs->ClearUnspendable(); - + CCoins outsBlock(tx, pindex->nHeight); // The CCoins serialization does not serialize negative numbers. // No network rules currently depend on the version here, so an inconsistency is harmless @@ -2586,18 +2586,18 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex outs->nVersion = outsBlock.nVersion; if (*outs != outsBlock) fClean = fClean && error("DisconnectBlock(): added transaction mismatch? database corrupted"); - + // remove outputs outs->Clear(); } - + // unspend nullifiers BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { view.SetNullifier(nf, false); } } - + // restore inputs if (!tx.IsMint()) { const CTxUndo &txundo = blockUndo.vtxundo[i-1]; @@ -2641,23 +2641,23 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex } else if (prevout.scriptPubKey.IsPayToPublicKey()) { vector hashBytes(prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34); - + // undo spending activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, j, true), prevout.nValue * -1)); - + // restore unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), input.prevout.hash, input.prevout.n), CAddressUnspentValue(prevout.nValue, prevout.scriptPubKey, undo.nHeight))); - + } else if (prevout.scriptPubKey.IsPayToCryptoCondition()) { vector hashBytes(prevout.scriptPubKey.begin(), prevout.scriptPubKey.end()); - + // undo spending activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, hash, j, true), prevout.nValue * -1)); - + // restore unspent index addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), input.prevout.hash, input.prevout.n), CAddressUnspentValue(prevout.nValue, prevout.scriptPubKey, undo.nHeight))); - + } else { continue; @@ -2673,10 +2673,10 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // set the old best anchor back view.PopAnchor(blockUndo.old_tree_root); - + // move best block pointer to prevout block view.SetBestBlock(pindex->pprev->GetBlockHash()); - + if (pfClean) { *pfClean = fClean; return true; @@ -2697,9 +2697,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex void static FlushBlockFile(bool fFinalize = false) { LOCK(cs_LastBlockFile); - + CDiskBlockPos posOld(nLastBlockFile, 0); - + FILE *fileOld = OpenBlockFile(posOld); if (fileOld) { if (fFinalize) @@ -2707,7 +2707,7 @@ void static FlushBlockFile(bool fFinalize = false) FileCommit(fileOld); fclose(fileOld); } - + fileOld = OpenUndoFile(posOld); if (fileOld) { if (fFinalize) @@ -2735,20 +2735,20 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const int64_t nPowTargetSpacing) { if (bestHeader == NULL || initialDownloadCheck()) return; - + static int64_t lastAlertTime = 0; int64_t now = GetAdjustedTime(); if (lastAlertTime > now-60*60*24) return; // Alert at most once per day - + const int SPAN_HOURS=4; const int SPAN_SECONDS=SPAN_HOURS*60*60; int BLOCKS_EXPECTED = SPAN_SECONDS / nPowTargetSpacing; - + boost::math::poisson_distribution poisson(BLOCKS_EXPECTED); - + std::string strWarning; int64_t startTime = GetAdjustedTime()-SPAN_SECONDS; - + LOCK(cs); const CBlockIndex* i = bestHeader; int nBlocks = 0; @@ -2757,17 +2757,17 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const i = i->pprev; if (i == NULL) return; // Ran out of chain, we must not be fully synced } - + // How likely is it to find that many by chance? double p = boost::math::pdf(poisson, nBlocks); - + LogPrint("partitioncheck", "%s : Found %d blocks in the last %d hours\n", __func__, nBlocks, SPAN_HOURS); LogPrint("partitioncheck", "%s : likelihood: %g\n", __func__, p); - + // Aim for one false-positive about every fifty years of normal running: const int FIFTY_YEARS = 50*365*24*60*60; double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS); - + if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED) { // Many fewer blocks than expected: alert! @@ -2819,7 +2819,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //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(); if ( hashPrevBlock != view.GetBestBlock() ) @@ -2829,7 +2829,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin REJECT_INVALID, "hashPrevBlock-not-bestblock"); } assert(hashPrevBlock == view.GetBestBlock()); - + // Special case for the genesis block, skipping connection of its transactions // (its coinbase is unspendable) if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) { @@ -2843,7 +2843,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } return true; } - + bool fScriptChecks = (!fCheckpointsEnabled || pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints())); //if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" // return(false); @@ -2855,13 +2855,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"), REJECT_INVALID, "bad-txns-BIP30"); } - + unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; - + // DERSIG (BIP66) is also always enforced, but does not have a flag. - + CBlockUndo blockundo; - + if ( ASSETCHAINS_CC != 0 ) { if ( scriptcheckqueue.IsIdle() == 0 ) @@ -2871,7 +2871,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } CCheckQueueControl control(fExpensiveChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL); - + int64_t nTimeStart = GetTimeMicros(); CAmount nFees = 0; int nInputs = 0; @@ -2895,16 +2895,16 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // This should never fail: we should always be able to get the root // that is on the tip of our chain assert(view.GetAnchorAt(old_tree_root, tree)); - + { // Consistency check: the root of the tree we're given should // match what we asked for. assert(tree.root() == old_tree_root); } - + // Grab the consensus branch ID for the block's height auto consensusBranchId = CurrentEpochBranchId(pindex->nHeight, Params().GetConsensus()); - + std::vector txdata; txdata.reserve(block.vtx.size()); // Required so that pointers to individual PrecomputedTransactionData don't get invalidated for (unsigned int i = 0; i < block.vtx.size(); i++) @@ -2982,14 +2982,14 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): too many sigops"), REJECT_INVALID, "bad-blk-sigops"); } - + txdata.emplace_back(tx); - + if (!tx.IsCoinBase()) { nFees += view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime) - tx.GetValueOut(); sum += interest; - + std::vector vChecks; if (!ContextualCheckInputs(tx, state, view, fExpensiveChecks, flags, false, txdata[i], chainparams.GetConsensus(), consensusBranchId, nScriptCheckThreads ? &vChecks : NULL)) return false; @@ -3022,23 +3022,23 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } else if (out.scriptPubKey.IsPayToPublicKey()) { vector hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34); - + // record receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, txhash, k, false), out.nValue)); - + // record unspent output addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), txhash, k), CAddressUnspentValue(out.nValue, out.scriptPubKey, pindex->nHeight))); - + } else if (out.scriptPubKey.IsPayToCryptoCondition()) { vector hashBytes(out.scriptPubKey.begin(), out.scriptPubKey.end()); - + // record receiving activity addressIndex.push_back(make_pair(CAddressIndexKey(1, Hash160(hashBytes), pindex->nHeight, i, txhash, k, false), out.nValue)); - + // record unspent output addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(1, Hash160(hashBytes), txhash, k), CAddressUnspentValue(out.nValue, out.scriptPubKey, pindex->nHeight))); - + } else { continue; @@ -3054,28 +3054,28 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin blockundo.vtxundo.push_back(CTxUndo()); } UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); - + BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 ¬e_commitment, joinsplit.commitments) { // Insert the note commitments into our temporary tree. - + tree.append(note_commitment); } } - + vPos.push_back(std::make_pair(tx.GetHash(), pos)); pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); } - + view.PushAnchor(tree); if (!fJustCheck) { pindex->hashAnchorEnd = tree.root(); } blockundo.old_tree_root = old_tree_root; - + int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); - + CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) { @@ -3102,10 +3102,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, false); int64_t nTime2 = GetTimeMicros(); nTimeVerify += nTime2 - nTimeStart; LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime2 - nTimeStart), nInputs <= 1 ? 0 : 0.001 * (nTime2 - nTimeStart) / (nInputs-1), nTimeVerify * 0.000001); - + if (fJustCheck) return true; - + // Write undo information to disk if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)) { @@ -3115,12 +3115,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return error("ConnectBlock(): FindUndoPos failed"); if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart())) return AbortNode(state, "Failed to write undo data"); - + // update nUndoPos in block index pindex->nUndoPos = pos.nPos; pindex->nStatus |= BLOCK_HAVE_UNDO; } - + // Now that all consensus rules have been validated, set nCachedBranchId. // Move this if BLOCK_VALID_CONSENSUS is ever altered. static_assert(BLOCK_VALID_CONSENSUS == BLOCK_VALID_SCRIPTS, @@ -3131,13 +3131,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } else if (pindex->pprev) { pindex->nCachedBranchId = pindex->pprev->nCachedBranchId; } - + pindex->RaiseValidity(BLOCK_VALID_SCRIPTS); setDirtyBlockIndex.insert(pindex); } ConnectNotarisations(block, pindex->nHeight); - + if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); @@ -3178,18 +3178,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // add this block to the view's block chain view.SetBestBlock(pindex->GetBlockHash()); - + int64_t nTime3 = GetTimeMicros(); nTimeIndex += nTime3 - nTime2; LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeIndex * 0.000001); - + // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase); hashPrevBestCoinBase = block.vtx[0].GetHash(); - + int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3; LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); - + //FlushStateToDisk(); komodo_connectblock(pindex,*(CBlock *)&block); return true; @@ -3319,7 +3319,7 @@ void PruneAndFlush() { void static UpdateTip(CBlockIndex *pindexNew) { const CChainParams& chainParams = Params(); chainActive.SetTip(pindexNew); - + // New best block nTimeBestReceived = GetTime(); mempool.AddTransactionsUpdated(1); @@ -3337,9 +3337,9 @@ void static UpdateTip(CBlockIndex *pindexNew) { log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.LastTip()->nChainTx, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.LastTip()->GetBlockTime()), progress, pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); - + cvBlockChange.notify_all(); - + // Check the version of the last 100 blocks to see if we need to upgrade: static bool fWarned = false; if (!IsInitialBlockDownload() && !fWarned) @@ -3403,7 +3403,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { // Write the chain state to disk, if necessary. if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED)) return false; - + if (!fBare) { // Resurrect mempool transactions from the disconnected block. @@ -3423,7 +3423,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { mempool.removeWithAnchor(anchorBeforeDisconnect); } } - + // Update chainActive and related variables. UpdateTip(pindexDelete->pprev); // Get the current commitment tree @@ -3464,7 +3464,7 @@ static int64_t nTimePostConnect = 0; * You probably want to call mempool.removeWithoutBranchId after this, with cs_main held. */ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) { - + assert(pindexNew->pprev == chainActive.Tip()); // Read block from disk. int64_t nTime1 = GetTimeMicros(); @@ -3507,10 +3507,10 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * // Remove conflicting transactions from the mempool. list txConflicted; mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload()); - + // Remove transactions that expire at new block height from mempool mempool.removeExpired(pindexNew->nHeight); - + // Update chainActive & related variables. UpdateTip(pindexNew); // Tell wallet about transactions that went from mempool @@ -3525,9 +3525,9 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * // Update cached incremental witnesses //fprintf(stderr,"chaintip true\n"); GetMainSignals().ChainTip(pindexNew, pblock, oldTree, true); - + EnforceNodeDeprecation(pindexNew->nHeight); - + int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); @@ -3547,7 +3547,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * static CBlockIndex* FindMostWorkChain() { do { CBlockIndex *pindexNew = NULL; - + // Find the best candidate header. { std::set::reverse_iterator it = setBlockIndexCandidates.rbegin(); @@ -3555,14 +3555,14 @@ static CBlockIndex* FindMostWorkChain() { return NULL; pindexNew = *it; } - + // Check whether all blocks on the path between the currently active chain and the candidate are valid. // Just going until the active chain is an optimization, as we know all blocks in it are valid already. CBlockIndex *pindexTest = pindexNew; bool fInvalidAncestor = false; while (pindexTest && !chainActive.Contains(pindexTest)) { assert(pindexTest->nChainTx || pindexTest->nHeight == 0); - + // Pruned nodes may have entries in setBlockIndexCandidates for // which block files have been deleted. Remove those as candidates // for the most work chain if we come across them; we can't switch @@ -3619,7 +3619,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo bool fInvalidFound = false; const CBlockIndex *pindexOldTip = chainActive.Tip(); const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork); - + // - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks. // - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain, // then pindexFork will be null, and we would need to remove the entire chain including @@ -3644,7 +3644,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo StartShutdown(); return false; } - + // Disconnect active blocks which are no longer in the best chain. bool fBlocksDisconnected = false; while (chainActive.Tip() && chainActive.Tip() != pindexFork) { @@ -3686,7 +3686,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo pindexIter = pindexIter->pprev; } nHeight = nTargetHeight; - + // Connect new blocks. BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { if (!ConnectTip(state, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) { @@ -3712,20 +3712,20 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } } } - + if (fBlocksDisconnected) { mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS); } mempool.removeWithoutBranchId( CurrentEpochBranchId(chainActive.Tip()->nHeight + 1, Params().GetConsensus())); mempool.check(pcoinsTip); - + // Callbacks/notifications for a new best chain. if (fInvalidFound) CheckForkWarningConditionsOnNewFork(vpindexToConnect.back()); else CheckForkWarningConditions(); - + return true; } @@ -3740,23 +3740,23 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { const CChainParams& chainParams = Params(); do { boost::this_thread::interruption_point(); - + bool fInitialDownload; { LOCK(cs_main); pindexMostWork = FindMostWorkChain(); - + // Whether we have anything to do at all. if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip()) return true; - + if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); } // When we reach this point, we switched to a new tip (stored in pindexNewTip). - + // Notifications/callbacks that can run without cs_main if (!fInitialDownload) { uint256 hashNewTip = pindexNewTip->GetBlockHash(); @@ -3778,23 +3778,23 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { } //else fprintf(stderr,"initial download skips propagation\n"); } while(pindexMostWork != chainActive.Tip()); CheckBlockIndex(); - + // Write changes periodically to disk, after relay. if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) { return false; } - + return true; } bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { AssertLockHeld(cs_main); - + // Mark the block itself as invalid. pindex->nStatus |= BLOCK_FAILED_VALID; setDirtyBlockIndex.insert(pindex); setBlockIndexCandidates.erase(pindex); - + while (chainActive.Contains(pindex)) { CBlockIndex *pindexWalk = chainActive.Tip(); pindexWalk->nStatus |= BLOCK_FAILED_CHILD; @@ -3810,7 +3810,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { } } //LimitMempoolSize(mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); - + // The resulting new best tip may not be in setBlockIndexCandidates anymore, so // add it again. BlockMap::iterator it = mapBlockIndex.begin(); @@ -3820,7 +3820,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { } it++; } - + InvalidChainFound(pindex); mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS); mempool.removeWithoutBranchId( @@ -3830,9 +3830,9 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) { AssertLockHeld(cs_main); - + int nHeight = pindex->nHeight; - + // Remove the invalidity flag from this block and all its descendants. BlockMap::iterator it = mapBlockIndex.begin(); while (it != mapBlockIndex.end()) { @@ -3849,7 +3849,7 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) { } it++; } - + // Remove the invalidity flag from all ancestors too. while (pindex != NULL) { if (pindex->nStatus & BLOCK_FAILED_MASK) { @@ -3901,7 +3901,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) pindexNew->RaiseValidity(BLOCK_VALID_TREE); if (pindexBestHeader == NULL || pindexBestHeader->nChainWork < pindexNew->nChainWork) pindexBestHeader = pindexNew; - + setDirtyBlockIndex.insert(pindexNew); //fprintf(stderr,"added to block index %s %p\n",hash.ToString().c_str(),pindexNew); mi->second = pindexNew; @@ -3928,12 +3928,12 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl pindexNew->nStatus |= BLOCK_HAVE_DATA; pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); setDirtyBlockIndex.insert(pindexNew); - + if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) { // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS. deque queue; queue.push_back(pindexNew); - + // Recursively process any descendant blocks that now may be eligible to be connected. while (!queue.empty()) { CBlockIndex *pindex = queue.front(); @@ -3968,19 +3968,19 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl mapBlocksUnlinked.insert(std::make_pair(pindexNew->pprev, pindexNew)); } } - + return true; } bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false) { LOCK(cs_LastBlockFile); - + unsigned int nFile = fKnown ? pos.nFile : nLastBlockFile; if (vinfoBlockFile.size() <= nFile) { vinfoBlockFile.resize(nFile + 1); } - + if (!fKnown) { while (vinfoBlockFile[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { nFile++; @@ -3991,7 +3991,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd pos.nFile = nFile; pos.nPos = vinfoBlockFile[nFile].nSize; } - + if (nFile != nLastBlockFile) { if (!fKnown) { LogPrintf("Leaving block file %i: %s\n", nFile, vinfoBlockFile[nFile].ToString()); @@ -3999,13 +3999,13 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd FlushBlockFile(!fKnown); nLastBlockFile = nFile; } - + vinfoBlockFile[nFile].AddBlock(nHeight, nTime); if (fKnown) vinfoBlockFile[nFile].nSize = std::max(pos.nPos + nAddSize, vinfoBlockFile[nFile].nSize); else vinfoBlockFile[nFile].nSize += nAddSize; - + if (!fKnown) { unsigned int nOldChunks = (pos.nPos + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; unsigned int nNewChunks = (vinfoBlockFile[nFile].nSize + BLOCKFILE_CHUNK_SIZE - 1) / BLOCKFILE_CHUNK_SIZE; @@ -4024,7 +4024,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd return state.Error("out of disk space"); } } - + setDirtyFileInfo.insert(nFile); return true; } @@ -4032,14 +4032,14 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize) { pos.nFile = nFile; - + LOCK(cs_LastBlockFile); - + unsigned int nNewSize; pos.nPos = vinfoBlockFile[nFile].nUndoSize; nNewSize = vinfoBlockFile[nFile].nUndoSize += nAddSize; setDirtyFileInfo.insert(nFile); - + unsigned int nOldChunks = (pos.nPos + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE; unsigned int nNewChunks = (nNewSize + UNDOFILE_CHUNK_SIZE - 1) / UNDOFILE_CHUNK_SIZE; if (nNewChunks > nOldChunks) { @@ -4056,7 +4056,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne else return state.Error("out of disk space"); } - + return true; } @@ -4101,7 +4101,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, // 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"); - + // Check Equihash solution is valid if ( fCheckPOW ) { @@ -4156,7 +4156,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (block.hashMerkleRoot != hashMerkleRoot2) return state.DoS(100, error("CheckBlock: hashMerkleRoot mismatch"), REJECT_INVALID, "bad-txnmrklroot", true); - + // Check for merkle tree malleability (CVE-2012-2459): repeating sequences // of transactions in a block without affecting the merkle root of a block, // while still invalidating it. @@ -4164,16 +4164,16 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C return state.DoS(100, error("CheckBlock: duplicate transaction"), REJECT_INVALID, "bad-txns-duplicate", true); } - + // All potential-corruption validation must be done before we do any // transaction validation, as otherwise we may mark the header as invalid // because we receive the wrong transactions for it. - + // Size limits if (block.vtx.empty() || block.vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) return state.DoS(100, error("CheckBlock: size limits failed"), REJECT_INVALID, "bad-blk-length"); - + // First transaction must be coinbase, the rest must not be if (block.vtx.empty() || !block.vtx[0].IsCoinBase()) return state.DoS(100, error("CheckBlock: first tx is not coinbase"), @@ -4182,7 +4182,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (block.vtx[i].IsCoinBase()) return state.DoS(100, error("CheckBlock: more than one coinbase"), REJECT_INVALID, "bad-cb-multiple"); - + // Check transactions if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { @@ -4246,11 +4246,11 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta uint256 hash = block.GetHash(); if (hash == consensusParams.hashGenesisBlock) return true; - + assert(pindexPrev); - + int nHeight = pindexPrev->nHeight+1; - + // Check proof of work if ( (ASSETCHAINS_SYMBOL[0] != 0 || nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) { @@ -4258,12 +4258,12 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta return state.DoS(100, error("%s: incorrect proof of work", __func__), REJECT_INVALID, "bad-diffbits"); } - + // Check timestamp against prev if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast()) return state.Invalid(error("%s: block's timestamp is too early", __func__), REJECT_INVALID, "time-too-old"); - + if (fCheckpointsEnabled) { // Check that the block chain matches the known block chain up to a checkpoint @@ -4306,7 +4306,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta if (block.nVersion < 4) return state.Invalid(error("%s : rejected nVersion<4 block", __func__), REJECT_OBSOLETE, "bad-version"); - + return true; } @@ -4314,15 +4314,15 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn { const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; const Consensus::Params& consensusParams = Params().GetConsensus(); - + // Check that all transactions are finalized BOOST_FOREACH(const CTransaction& tx, block.vtx) { - + // Check transaction contextually against consensus rules at block height if (!ContextualCheckTransaction(tx, state, nHeight, 100)) { return false; // Failure reason has been set in validation state object } - + int nLockTimeFlags = 0; int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) ? pindexPrev->GetMedianTimePast() @@ -4331,7 +4331,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } - + // Enforce BIP 34 rule that the coinbase starts with serialized block height. // In Zcash this has been enforced since launch, except that the genesis // block didn't include the height in the coinbase (see Zcash protocol spec @@ -4344,7 +4344,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); } } - + return true; } @@ -4437,7 +4437,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C { const CChainParams& chainparams = Params(); AssertLockHeld(cs_main); - + CBlockIndex *&pindex = *ppindex; if (!AcceptBlockHeader(futureblockp,block, state, &pindex)) { @@ -4464,7 +4464,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // regardless of whether pruning is enabled; it should generally be safe to // not process unrequested blocks. 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); @@ -4474,7 +4474,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if (!fHasMoreWork) return true; // Don't process less-work chains if (fTooFarAhead) return true; // Block height is too high } - + // See method docstring for why this is always disabled auto verifier = libzcash::ProofVerifier::Disabled(); if ((!CheckBlock(futureblockp,pindex->nHeight,pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev)) @@ -4489,7 +4489,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C return false; } } - + int nHeight = pindex->nHeight; // Write block to history file try { @@ -4507,7 +4507,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } catch (const std::runtime_error& e) { return AbortNode(state, std::string("System error: ") + e.what()); } - + if (fCheckForPruning) FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files if ( *futureblockp == 0 ) @@ -4653,7 +4653,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo return error("%s: AcceptBlock FAILED", __func__); //else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev); } - + if (futureblock == 0 && !ActivateBestChain(state, pblock)) return error("%s: ActivateBestChain failed", __func__); //fprintf(stderr,"finished ProcessBlock %d\n",(int32_t)chainActive.LastTip()->nHeight); @@ -4665,7 +4665,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex { AssertLockHeld(cs_main); assert(pindexPrev == chainActive.Tip()); - + CCoinsViewCache viewNew(pcoinsTip); CBlockIndex indexDummy(block); indexDummy.pprev = pindexPrev; @@ -4726,7 +4726,7 @@ void PruneOneBlockFile(const int fileNumber) pindex->nDataPos = 0; pindex->nUndoPos = 0; setDirtyBlockIndex.insert(pindex); - + // Prune from mapBlocksUnlinked -- any block we prune would have // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for @@ -4741,7 +4741,7 @@ void PruneOneBlockFile(const int fileNumber) } } } - + vinfoBlockFile[fileNumber].SetNull(); setDirtyFileInfo.insert(fileNumber); } @@ -4775,21 +4775,21 @@ void FindFilesToPrune(std::set& setFilesToPrune) uint64_t nBuffer = BLOCKFILE_CHUNK_SIZE + UNDOFILE_CHUNK_SIZE; uint64_t nBytesToPrune; int count=0; - + if (nCurrentUsage + nBuffer >= nPruneTarget) { for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { nBytesToPrune = vinfoBlockFile[fileNumber].nSize + vinfoBlockFile[fileNumber].nUndoSize; - + if (vinfoBlockFile[fileNumber].nSize == 0) continue; - + if (nCurrentUsage + nBuffer < nPruneTarget) // are we below our target? break; - + // don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip but keep scanning if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) continue; - + PruneOneBlockFile(fileNumber); // Queue up the files for removal setFilesToPrune.insert(fileNumber); @@ -4797,7 +4797,7 @@ void FindFilesToPrune(std::set& setFilesToPrune) count++; } } - + LogPrint("prune", "Prune: target=%dMiB actual=%dMiB diff=%dMiB max_prune_height=%d removed %d blk/rev pairs\n", nPruneTarget/1024/1024, nCurrentUsage/1024/1024, ((int64_t)nPruneTarget - (int64_t)nCurrentUsage)/1024/1024, @@ -4807,11 +4807,11 @@ void FindFilesToPrune(std::set& setFilesToPrune) bool CheckDiskSpace(uint64_t nAdditionalBytes) { uint64_t nFreeBytesAvailable = boost::filesystem::space(GetDataDir()).available; - + // Check for nMinDiskSpace bytes (currently 50MB) if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes) return AbortNode("Disk space is low!", _("Error: Disk space is low!")); - + return true; } @@ -4861,12 +4861,12 @@ CBlockIndex * InsertBlockIndex(uint256 hash) { if (hash.IsNull()) return NULL; - + // Return existing BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) return (*mi).second; - + // Create new CBlockIndex* pindexNew = new CBlockIndex(); if (!pindexNew) @@ -4888,7 +4888,7 @@ bool static LoadBlockIndexDB() return false; LogPrintf("%s: loaded guts\n", __func__); boost::this_thread::interruption_point(); - + // Calculate nChainWork vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); @@ -4967,7 +4967,7 @@ bool static LoadBlockIndexDB() break; } } - + // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); set setBlkDataFiles; @@ -4987,17 +4987,17 @@ bool static LoadBlockIndexDB() return false; } } - + // Check whether we have ever pruned block & undo files pblocktree->ReadFlag("prunedblockfiles", fHavePruned); if (fHavePruned) LogPrintf("LoadBlockIndexDB(): Block files have previously been pruned\n"); - + // Check whether we need to continue reindexing bool fReindexing = false; pblocktree->ReadReindexing(fReindexing); fReindex |= fReindexing; - + // Check whether we have a transaction index pblocktree->ReadFlag("txindex", fTxIndex); LogPrintf("%s: transaction index %s\n", __func__, fTxIndex ? "enabled" : "disabled"); @@ -5027,7 +5027,7 @@ bool static LoadBlockIndexDB() } //komodo_pindex_init(pindex,(int32_t)pindex->nHeight); } - + // Load pointer to end of best chain BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); if (it == mapBlockIndex.end()) @@ -5035,7 +5035,7 @@ bool static LoadBlockIndexDB() chainActive.SetTip(it->second); // Set hashAnchorEnd for the end of best chain it->second->hashAnchorEnd = pcoinsTip->GetBestAnchor(); - + PruneBlockIndexCandidates(); double progress; @@ -5047,14 +5047,14 @@ bool static LoadBlockIndexDB() // runs, which makes it return 0, so we guess 50% for now progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 0.5; } - + LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__, chainActive.LastTip()->GetBlockHash().ToString(), chainActive.Height(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.LastTip()->GetBlockTime()), progress); - + EnforceNodeDeprecation(chainActive.Height(), true); - + return true; } @@ -5073,7 +5073,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth LOCK(cs_main); if (chainActive.Tip() == NULL || chainActive.Tip()->pprev == NULL) return true; - + // Verify blocks in the best chain if (nCheckDepth <= 0) nCheckDepth = 1000000000; // suffices until the year 19000 @@ -5130,7 +5130,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth //fprintf(stderr,"end VerifyDB %u\n",(uint32_t)time(NULL)); if (pindexFailure) return error("VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n", chainActive.Height() - pindexFailure->nHeight + 1, nGoodTransactions); - + // check level 4: try reconnecting blocks if (nCheckLevel >= 4) { CBlockIndex *pindex = pindexState; @@ -5145,16 +5145,16 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); } } - + LogPrintf("No coin database inconsistencies in last %i blocks (%i transactions)\n", chainActive.Height() - pindexState->nHeight, nGoodTransactions); - + return true; } bool RewindBlockIndex(const CChainParams& params) { LOCK(cs_main); - + // RewindBlockIndex is called after LoadBlockIndex, so at this point every block // index will have nCachedBranchId set based on the values previously persisted // to disk. By definition, a set nCachedBranchId means that the block was @@ -5172,7 +5172,7 @@ bool RewindBlockIndex(const CChainParams& params) pindex->nCachedBranchId && *pindex->nCachedBranchId == CurrentEpochBranchId(pindex->nHeight, consensus); }; - + int nHeight = 1; while (nHeight <= chainActive.Height()) { if (!sufficientlyValidated(chainActive[nHeight])) { @@ -5180,7 +5180,7 @@ bool RewindBlockIndex(const CChainParams& params) } nHeight++; } - + // nHeight is now the height of the first insufficiently-validated block, or tipheight + 1 auto rewindLength = chainActive.Height() - nHeight; if (rewindLength > 0 && rewindLength > MAX_REORG_LENGTH) { @@ -5201,7 +5201,7 @@ bool RewindBlockIndex(const CChainParams& params) StartShutdown(); return false; } - + CValidationState state; CBlockIndex* pindex = chainActive.Tip(); while (chainActive.Height() >= nHeight) { @@ -5220,13 +5220,13 @@ bool RewindBlockIndex(const CChainParams& params) if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) return false; } - + // Reduce validity flag and have-data flags. // We do this after actual disconnecting, otherwise we'll end up writing the lack of data // to disk before writing the chainstate, resulting in a failure to continue if interrupted. for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) { CBlockIndex* pindexIter = it->second; - + // Note: If we encounter an insufficiently validated block that // is on chainActive, it must be because we are a pruning node, and // this block or some successor doesn't HAVE_DATA, so we were unable to @@ -5259,7 +5259,7 @@ bool RewindBlockIndex(const CChainParams& params) //fprintf(stderr,"Reset invalid block marker if it was pointing to this block\n"); pindexBestInvalid = NULL; } - + // Update indices setBlockIndexCandidates.erase(pindexIter); auto ret = mapBlocksUnlinked.equal_range(pindexIter->pprev); @@ -5274,15 +5274,15 @@ bool RewindBlockIndex(const CChainParams& params) setBlockIndexCandidates.insert(pindexIter); } } - + PruneBlockIndexCandidates(); - + CheckBlockIndex(); - + if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) { return false; } - + return true; } @@ -5309,7 +5309,7 @@ void UnloadBlockIndex() setDirtyFileInfo.clear(); mapNodeState.clear(); recentRejects.reset(NULL); - + BOOST_FOREACH(BlockMap::value_type& entry, mapBlockIndex) { delete entry.second; } @@ -5334,7 +5334,7 @@ bool LoadBlockIndex() bool InitBlockIndex() { const CChainParams& chainparams = Params(); LOCK(cs_main); - + // Initialize global variables that cannot be constructed at startup. recentRejects.reset(new CRollingBloomFilter(120000, 0.000001)); // Check whether we're already initialized @@ -5352,12 +5352,12 @@ bool InitBlockIndex() { // Use the provided setting for -timestampindex in the new database fTimestampIndex = GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX); pblocktree->WriteFlag("timestampindex", fTimestampIndex); - + fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX); pblocktree->WriteFlag("spentindex", fSpentIndex); fprintf(stderr,"fAddressIndex.%d/%d fSpentIndex.%d/%d\n",fAddressIndex,DEFAULT_ADDRESSINDEX,fSpentIndex,DEFAULT_SPENTINDEX); LogPrintf("Initializing databases...\n"); - + // Only add the genesis block if not reindexing (in which case we reuse the one already on disk) if (!fReindex) { try { @@ -5383,7 +5383,7 @@ bool InitBlockIndex() { return error("LoadBlockIndex(): failed to initialize block database: %s", e.what()); } } - + return true; } @@ -5395,7 +5395,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) // Map of disk positions for blocks with unknown parent (only used for reindex) static std::multimap mapBlocksUnknownParent; int64_t nStart = GetTimeMillis(); - + int nLoaded = 0; try { // This takes over fileIn and calls fclose() on it in the CBufferedFile destructor @@ -5404,7 +5404,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) uint64_t nRewind = blkdat.GetPos(); while (!blkdat.eof()) { boost::this_thread::interruption_point(); - + blkdat.SetPos(nRewind); nRewind++; // start one byte further next time, in case of failure blkdat.SetLimit(); // remove former limit @@ -5435,7 +5435,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) CBlock block; blkdat >> block; nRewind = blkdat.GetPos(); - + // detect out of order blocks, and store them for later uint256 hash = block.GetHash(); if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) { @@ -5445,7 +5445,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) mapBlocksUnknownParent.insert(std::make_pair(block.hashPrevBlock, *dbp)); continue; } - + // process in case the block isn't known yet if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) { CValidationState state; @@ -5456,7 +5456,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) } else if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex[hash]->nHeight % 1000 == 0) { LogPrintf("Block Import: already had block %s at height %d\n", hash.ToString(), mapBlockIndex[hash]->nHeight); } - + // Recursively process earlier encountered successors of this block deque queue; queue.push_back(hash); @@ -5499,9 +5499,9 @@ void static CheckBlockIndex() if (!fCheckBlockIndex) { return; } - + LOCK(cs_main); - + // During a reindex, we read the genesis block and call CheckBlockIndex before ActivateBestChain, // so we have the genesis block in mapBlockIndex but no active chain. (A few of the tests when // iterating the block tree require that chainActive has been initialized.) @@ -5509,7 +5509,7 @@ void static CheckBlockIndex() assert(mapBlockIndex.size() <= 1); return; } - + // Build forward-pointing map of the entire block tree. std::multimap forward; for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) { @@ -5518,12 +5518,12 @@ void static CheckBlockIndex() } if ( Params().NetworkIDString() != "regtest" ) assert(forward.size() == mapBlockIndex.size()); - + std::pair::iterator,std::multimap::iterator> rangeGenesis = forward.equal_range(NULL); CBlockIndex *pindex = rangeGenesis.first->second; rangeGenesis.first++; assert(rangeGenesis.first == rangeGenesis.second); // There is only one index entry with parent NULL. - + // Iterate over the entire block tree, using depth-first search. // Along the way, remember whether there are blocks on the path from genesis // block being explored which are the first to have certain properties. @@ -5545,7 +5545,7 @@ void static CheckBlockIndex() if (pindex->pprev != NULL && pindexFirstNotTransactionsValid == NULL && (pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS) pindexFirstNotTransactionsValid = pindex; if (pindex->pprev != NULL && pindexFirstNotChainValid == NULL && (pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_CHAIN) pindexFirstNotChainValid = pindex; if (pindex->pprev != NULL && pindexFirstNotScriptsValid == NULL && (pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_SCRIPTS) pindexFirstNotScriptsValid = pindex; - + // Begin: actual consistency checks. if (pindex->pprev == NULL) { // Genesis block checks. @@ -5631,7 +5631,7 @@ void static CheckBlockIndex() } // assert(pindex->GetBlockHash() == pindex->GetBlockHeader().GetHash()); // Perhaps too slow // End: actual consistency checks. - + // Try descending into the first subnode. std::pair::iterator,std::multimap::iterator> range = forward.equal_range(pindex); if (range.first != range.second) { @@ -5674,7 +5674,7 @@ void static CheckBlockIndex() } } } - + // Check that we actually traversed the entire map. assert(nNodes == forward.size()); } @@ -5689,20 +5689,20 @@ std::string GetWarnings(const std::string& strFor) int nPriority = 0; string strStatusBar; string strRPC; - + if (!CLIENT_VERSION_IS_RELEASE) strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); - + if (GetBoolArg("-testsafemode", false)) strStatusBar = strRPC = "testsafemode enabled"; - + // Misc warnings like out of disk space and clock is wrong if (strMiscWarning != "") { nPriority = 1000; strStatusBar = strMiscWarning; } - + if (fLargeWorkForkFound) { nPriority = 2000; @@ -5713,7 +5713,7 @@ std::string GetWarnings(const std::string& strFor) nPriority = 2000; strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."); } - + // Alerts { LOCK(cs_mapAlerts); @@ -5730,7 +5730,7 @@ std::string GetWarnings(const std::string& strFor) } } } - + if (strFor == "statusbar") return strStatusBar; else if (strFor == "rpc") @@ -5768,7 +5768,7 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) hashRecentRejectsChainTip = chainActive.Tip()->GetBlockHash(); recentRejects->reset(); } - + return recentRejects->contains(inv.hash) || mempool.exists(inv.hash) || mapOrphanTransactions.count(inv.hash) || @@ -5784,21 +5784,21 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) void static ProcessGetData(CNode* pfrom) { std::deque::iterator it = pfrom->vRecvGetData.begin(); - + vector vNotFound; - + LOCK(cs_main); - + while (it != pfrom->vRecvGetData.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) break; - + const CInv &inv = *it; { boost::this_thread::interruption_point(); it++; - + if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK) { bool send = false; @@ -5902,17 +5902,17 @@ void static ProcessGetData(CNode* pfrom) vNotFound.push_back(inv); } } - + // Track requests for our stuff. GetMainSignals().Inventory(inv.hash); - + if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK) break; } } - + pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it); - + if (!vNotFound.empty()) { // Let the peer know that we didn't find what it asked for, so it doesn't // have to wait around forever. Currently only SPV clients actually care @@ -5935,10 +5935,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } - - - - + + + + if (strCommand == "version") { // Each connection can only send one version message @@ -5948,22 +5948,36 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 1); return false; } - + int64_t nTime; CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) { - // disconnect from peers older than this proto version - LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); - pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, - strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); - pfrom->fDisconnect = true; - return false; + if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) + { + // disconnect from peers older than this proto version + LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); + pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, + strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); + pfrom->fDisconnect = true; + return false; + } + } else + { + if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + { + // disconnect from peers older than this proto version + LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); + pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, + strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); + pfrom->fDisconnect = true; + return false; + } } - + // When Overwinter is active, reject incoming connections from non-Overwinter nodes const Consensus::Params& params = Params().GetConsensus(); if (NetworkUpgradeActive(GetHeight(), params, Consensus::UPGRADE_OVERWINTER) @@ -5976,7 +5990,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - + if (pfrom->nVersion == 10300) pfrom->nVersion = 300; if (!vRecv.empty()) @@ -5991,7 +6005,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vRecv >> pfrom->fRelayTxes; // set to true after we get the first filter* message else pfrom->fRelayTxes = true; - + // Disconnect if we connected to ourself if (nNonce == nLocalHostNonce && nNonce > 1) { @@ -5999,26 +6013,26 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return true; } - + pfrom->addrLocal = addrMe; if (pfrom->fInbound && addrMe.IsRoutable()) { SeenLocal(addrMe); } - + // Be shy and don't send version until we hear if (pfrom->fInbound) pfrom->PushVersion(); - + pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); - + // Potentially mark this peer as a preferred download peer. UpdatePreferredDownload(pfrom, State(pfrom->GetId())); - + // Change version pfrom->PushMessage("verack"); pfrom->ssSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); - + if (!pfrom->fInbound) { // Advertise our address @@ -6035,7 +6049,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->PushAddress(addr); } } - + // Get recent addresses if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || addrman.size() < 1000) { @@ -6050,51 +6064,51 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, addrman.Good(addrFrom); } } - + // Relay alerts { LOCK(cs_mapAlerts); BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) item.second.RelayTo(pfrom); } - + pfrom->fSuccessfullyConnected = true; - + string remoteAddr; if (fLogIPs) remoteAddr = ", peeraddr=" + pfrom->addr.ToString(); - + LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, peer=%d%s\n", pfrom->cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), pfrom->id, remoteAddr); - + int64_t nTimeOffset = nTime - GetTime(); pfrom->nTimeOffset = nTimeOffset; AddTimeData(pfrom->addr, nTimeOffset); } - - + + else if (pfrom->nVersion == 0) { // Must have a version message before anything else Misbehaving(pfrom->GetId(), 1); return false; } - - + + else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); - + // Mark this node as currently connected, so we update its timestamp later. if (pfrom->fNetworkNode) { LOCK(cs_main); State(pfrom->GetId())->fCurrentlyConnected = true; } } - - + + // Disconnect existing peer connection when: // 1. The version message has been received // 2. Overwinter is active @@ -6109,13 +6123,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - - + + else if (strCommand == "addr") { vector vAddr; vRecv >> vAddr; - + // Don't want addr from older versions unless seeding if (pfrom->nVersion < CADDR_TIME_VERSION && addrman.size() > 1000) return true; @@ -6124,7 +6138,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("message addr size() = %u", vAddr.size()); } - + // Store the new addresses vector vAddrOk; int64_t nNow = GetAdjustedTime(); @@ -6132,7 +6146,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, BOOST_FOREACH(CAddress& addr, vAddr) { boost::this_thread::interruption_point(); - + if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; pfrom->AddAddressKnown(addr); @@ -6176,8 +6190,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (pfrom->fOneShot) pfrom->fDisconnect = true; } - - + + else if (strCommand == "inv") { vector vInv; @@ -6187,24 +6201,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("message inv size() = %u", vInv.size()); } - + LOCK(cs_main); - + std::vector vToFetch; - + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { const CInv &inv = vInv[nInv]; - + boost::this_thread::interruption_point(); pfrom->AddInventoryKnown(inv); - + bool fAlreadyHave = AlreadyHave(inv); LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id); - + if (!fAlreadyHave && !fImporting && !fReindex && inv.type != MSG_BLOCK) pfrom->AskFor(inv); - + if (inv.type == MSG_BLOCK) { UpdateBlockAvailability(pfrom->GetId(), inv.hash); if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count(inv.hash)) { @@ -6228,21 +6242,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrint("net", "getheaders (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id); } } - + // Track requests for our stuff GetMainSignals().Inventory(inv.hash); - + if (pfrom->nSendSize > (SendBufferSize() * 2)) { Misbehaving(pfrom->GetId(), 50); return error("send buffer size() = %u", pfrom->nSendSize); } } - + if (!vToFetch.empty()) pfrom->PushMessage("getdata", vToFetch); } - - + + else if (strCommand == "getdata") { vector vInv; @@ -6252,29 +6266,29 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 20); return error("message getdata size() = %u", vInv.size()); } - + if (fDebug || (vInv.size() != 1)) LogPrint("net", "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id); - + if ((fDebug && vInv.size() > 0) || (vInv.size() == 1)) LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id); - + pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom); } - - + + else if (strCommand == "getblocks") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; - + LOCK(cs_main); - + // Find the last block the caller has in the main chain CBlockIndex* pindex = FindForkInGlobalIndex(chainActive, locator); - + // Send the rest of the chain if (pindex) pindex = chainActive.Next(pindex); @@ -6298,19 +6312,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } - - + + else if (strCommand == "getheaders") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; - + LOCK(cs_main); - + if (IsInitialBlockDownload()) return true; - + CBlockIndex* pindex = NULL; if (locator.IsNull()) { @@ -6327,7 +6341,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (pindex) pindex = chainActive.Next(pindex); } - + // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end vector vHeaders; int nLimit = MAX_HEADERS_RESULTS; @@ -6350,37 +6364,37 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, 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); }*/ } - - + + else if (strCommand == "tx") { vector vWorkQueue; vector vEraseQueue; CTransaction tx; vRecv >> tx; - + CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); - + LOCK(cs_main); - + bool fMissingInputs = false; CValidationState state; - + pfrom->setAskFor.erase(inv.hash); mapAlreadyAskedFor.erase(inv); - + if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) { mempool.check(pcoinsTip); RelayTransaction(tx); vWorkQueue.push_back(inv.hash); - + LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s: accepted %s (poolsz %u)\n", pfrom->id, pfrom->cleanSubVer, tx.GetHash().ToString(), mempool.mapTx.size()); - + // Recursively process any orphan transactions that depended on this one set setMisbehaving; for (unsigned int i = 0; i < vWorkQueue.size(); i++) @@ -6400,8 +6414,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get // anyone relaying LegitTxX banned) CValidationState stateDummy; - - + + if (setMisbehaving.count(fromPeer)) continue; if (AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2)) @@ -6431,7 +6445,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, mempool.check(pcoinsTip); } } - + BOOST_FOREACH(uint256 hash, vEraseQueue) EraseOrphanTx(hash); } @@ -6439,7 +6453,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (fMissingInputs && tx.vjoinsplit.size() == 0) { AddOrphanTx(tx, pfrom->GetId()); - + // DoS prevention: do not allow mapOrphanTransactions to grow unbounded unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); @@ -6448,7 +6462,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } else { assert(recentRejects); recentRejects->insert(tx.GetHash()); - + if (pfrom->fWhitelisted) { // Always relay transactions received from whitelisted peers, even // if they were already in the mempool or rejected from it due @@ -6480,12 +6494,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), nDoS); } } - - + + else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing { std::vector headers; - + // Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks. unsigned int nCount = ReadCompactSize(vRecv); if (nCount > MAX_HEADERS_RESULTS) { @@ -6497,14 +6511,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vRecv >> headers[n]; ReadCompactSize(vRecv); // ignore tx count; assume it is 0. } - + LOCK(cs_main); - + if (nCount == 0) { // Nothing interesting. Stop asking this peers for more headers. return true; } - + CBlockIndex *pindexLast = NULL; BOOST_FOREACH(const CBlockHeader& header, headers) { CValidationState state; @@ -6523,10 +6537,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } - + if (pindexLast) UpdateBlockAvailability(pfrom->GetId(), pindexLast->GetBlockHash()); - + if (nCount == MAX_HEADERS_RESULTS && pindexLast) { // Headers message had its maximum size; the peer may have more headers. // TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue @@ -6538,20 +6552,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256()); } } - + CheckBlockIndex(); } - + else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing { CBlock block; vRecv >> block; - + CInv inv(MSG_BLOCK, block.GetHash()); LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id); - + pfrom->AddInventoryKnown(inv); - + CValidationState state; // Process all blocks from whitelisted peers, even if not requested, // unless we're still syncing with the network. @@ -6568,10 +6582,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), nDoS); } } - + } - - + + // This asymmetric behavior for inbound and outbound connections was introduced // to prevent a fingerprinting attack: an attacker can send specific fake addresses // to users' AddrMan and later request them by sending getaddr messages. @@ -6586,18 +6600,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } pfrom->fSentAddr = true; - + pfrom->vAddrToSend.clear(); vector vAddr = addrman.GetAddr(); BOOST_FOREACH(const CAddress &addr, vAddr) pfrom->PushAddress(addr); } - - + + else if (strCommand == "mempool") { LOCK2(cs_main, pfrom->cs_filter); - + std::vector vtxid; mempool.queryHashes(vtxid); vector vInv; @@ -6617,8 +6631,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (vInv.size() > 0) pfrom->PushMessage("inv", vInv); } - - + + else if (strCommand == "ping") { if (pfrom->nVersion > BIP0031_VERSION) @@ -6639,8 +6653,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->PushMessage("pong", nonce); } } - - + + else if (strCommand == "pong") { int64_t pingUsecEnd = nTimeReceived; @@ -6648,10 +6662,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, size_t nAvail = vRecv.in_avail(); bool bPingFinished = false; std::string sProblem; - + if (nAvail >= sizeof(nonce)) { vRecv >> nonce; - + // Only process pong message if there is an outstanding ping (old ping without nonce should never pong) if (pfrom->nPingNonceSent != 0) { if (nonce == pfrom->nPingNonceSent) { @@ -6683,7 +6697,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, bPingFinished = true; sProblem = "Short payload"; } - + if (!(sProblem.empty())) { LogPrint("net", "pong peer=%d %s: %s, %x expected, %x received, %u bytes\n", pfrom->id, @@ -6697,13 +6711,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->nPingNonceSent = 0; } } - - + + else if (fAlerts && strCommand == "alert") { CAlert alert; vRecv >> alert; - + uint256 alertHash = alert.GetHash(); if (pfrom->setKnown.count(alertHash) == 0) { @@ -6728,13 +6742,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } - - + + else if (strCommand == "filterload") { CBloomFilter filter; vRecv >> filter; - + if (!filter.IsWithinSizeConstraints()) // There is no excuse for sending a too-large filter Misbehaving(pfrom->GetId(), 100); @@ -6747,13 +6761,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->fRelayTxes = true; } - - + + else if (strCommand == "filteradd") { vector vData; vRecv >> vData; - + // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object, // and thus, the maximum size any matched object can have) in a filteradd message if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE) @@ -6767,8 +6781,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), 100); } } - - + + else if (strCommand == "filterclear") { LOCK(pfrom->cs_filter); @@ -6776,18 +6790,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->pfilter = new CBloomFilter(); pfrom->fRelayTxes = true; } - - + + else if (strCommand == "reject") { if (fDebug) { try { string strMsg; unsigned char ccode; string strReason; vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); - + ostringstream ss; ss << strMsg << " code " << itostr(ccode) << ": " << strReason; - + if (strMsg == "block" || strMsg == "tx") { uint256 hash; @@ -6805,14 +6819,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // We do not care about the NOTFOUND message, but logging an Unknown Command // message would be undesirable as we transmit it ourselves. } - + else { // Ignore unknown commands for extensibility LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id); } - - - + + + return true; } @@ -6821,7 +6835,7 @@ bool ProcessMessages(CNode* pfrom) { //if (fDebug) // LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size()); - + // // Message format // (4) message start @@ -6831,41 +6845,41 @@ bool ProcessMessages(CNode* pfrom) // (x) data // bool fOk = true; - + if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom); - + // this maintains the order of responses if (!pfrom->vRecvGetData.empty()) return fOk; - + std::deque::iterator it = pfrom->vRecvMsg.begin(); while (!pfrom->fDisconnect && it != pfrom->vRecvMsg.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) break; - + // get next message CNetMessage& msg = *it; - + //if (fDebug) // LogPrintf("%s(message %u msgsz, %u bytes, complete:%s)\n", __func__, // msg.hdr.nMessageSize, msg.vRecv.size(), // msg.complete() ? "Y" : "N"); - + // end, if an incomplete message is found if (!msg.complete()) break; - + // at this point, any failure means we can delete the current message it++; - + // Scan for message start if (memcmp(msg.hdr.pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) { LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id); fOk = false; break; } - + // Read header CMessageHeader& hdr = msg.hdr; if (!hdr.IsValid(Params().MessageStart())) @@ -6874,10 +6888,10 @@ bool ProcessMessages(CNode* pfrom) continue; } string strCommand = hdr.GetCommand(); - + // Message size unsigned int nMessageSize = hdr.nMessageSize; - + // Checksum CDataStream& vRecv = msg.vRecv; uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); @@ -6888,7 +6902,7 @@ bool ProcessMessages(CNode* pfrom) SanitizeString(strCommand), nMessageSize, nChecksum, hdr.nChecksum); continue; } - + // Process message bool fRet = false; try @@ -6922,17 +6936,17 @@ bool ProcessMessages(CNode* pfrom) } catch (...) { PrintExceptionContinue(NULL, "ProcessMessages()"); } - + if (!fRet) LogPrintf("%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->id); - + break; } - + // In case the connection got shut down, its receive buffer was wiped if (!pfrom->fDisconnect) pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); - + return fOk; } @@ -6944,7 +6958,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Don't send anything until we get its version message if (pto->nVersion == 0) return true; - + // // Message: ping // @@ -6973,11 +6987,11 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->PushMessage("ping"); } } - + TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState() if (!lockMain) return true; - + // Address refresh broadcast static int64_t nLastRebroadcast; if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) @@ -6988,14 +7002,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Periodically clear addrKnown to allow refresh broadcasts if (nLastRebroadcast) pnode->addrKnown.reset(); - + // Rebroadcast our address AdvertizeLocal(pnode); } if (!vNodes.empty()) nLastRebroadcast = GetTime(); } - + // // Message: addr // @@ -7021,7 +7035,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (!vAddr.empty()) pto->PushMessage("addr", vAddr); } - + CNodeState &state = *State(pto->GetId()); if (state.fShouldBan) { if (pto->fWhitelisted) @@ -7037,11 +7051,11 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } state.fShouldBan = false; } - + BOOST_FOREACH(const CBlockReject& reject, state.rejects) pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); state.rejects.clear(); - + // Start block sync if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); @@ -7056,7 +7070,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); } } - + // Resend wallet transactions that haven't gotten in a block yet // Except during reindex, importing and IBD, when old wallet // transactions become unconfirmed and spams other nodes. @@ -7064,7 +7078,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) { GetMainSignals().Broadcast(nTimeBestReceived); } - + // // Message: inventory // @@ -7078,7 +7092,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) { if (pto->setInventoryKnown.count(inv)) continue; - + // trickle out tx inv to protect privacy if (inv.type == MSG_TX && !fSendTrickle) { @@ -7089,14 +7103,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle) uint256 hashRand = ArithToUint256(UintToArith256(inv.hash) ^ UintToArith256(hashSalt)); hashRand = Hash(BEGIN(hashRand), END(hashRand)); bool fTrickleWait = ((UintToArith256(hashRand) & 3) != 0); - + if (fTrickleWait) { vInvWait.push_back(inv); continue; } } - + // returns true if wasn't already contained in the set if (pto->setInventoryKnown.insert(inv).second) { @@ -7112,7 +7126,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } if (!vInv.empty()) pto->PushMessage("inv", vInv); - + // Detect whether we're stalling int64_t nNow = GetTimeMicros(); if (!pto->fDisconnect && state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) { @@ -7144,7 +7158,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->fDisconnect = true; } } - + // // Message: getdata (blocks) // @@ -7181,7 +7195,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) komodo_requestedcount = 0; } }*/ - + // // Message: getdata (non-blocks) // @@ -7206,7 +7220,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } if (!vGetData.empty()) pto->PushMessage("getdata", vGetData); - + } return true; } @@ -7227,7 +7241,7 @@ public: for (; it1 != mapBlockIndex.end(); it1++) delete (*it1).second; mapBlockIndex.clear(); - + // orphan transactions mapOrphanTransactions.clear(); mapOrphanTransactionsByPrev.clear(); @@ -7244,14 +7258,14 @@ extern "C" const char* getDataDir() CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) { CMutableTransaction mtx; - + bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); if (isOverwintered) { mtx.fOverwintered = true; mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersion = 3; // Expiry height is not set. Only fields required for a parser to treat as a valid Overwinter V3 tx. - + // TODO: In future, when moving from Overwinter to Sapling, it will be useful // to set the expiry height to: min(activation_height - 1, default_expiry_height) } diff --git a/src/version.h b/src/version.h index 25527895d..b28225df4 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170003; +static const int PROTOCOL_VERSION = 170004; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -19,6 +19,7 @@ static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION = 170002; +static const int STAKEDMIN_PEER_PROTO_VERSION = 170004; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 47cd790436985fd93b253337b58ffc8caf5c89e0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 01:46:02 +0800 Subject: [PATCH 058/951] try staked.h again --- src/crosschain_authority.cpp | 29 ++++++----------------------- src/komodo_notary.h | 22 +++------------------- src/notaries_STAKED.h | 14 ++++++++------ 3 files changed, 17 insertions(+), 48 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 30e4e725a..3c257c4a7 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,32 +1,15 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -//#include "notaries_STAKED.h" - -const char *notaries_STAKEDcc[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN -}; +#include "notaries_STAKED.h" +extern char *notaries_STAKED int GetSymbolAuthority(const char* symbol) { - if (strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0) + if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if ( (strlen(symbol) >= 4 && strncmp(symbol, "STKD", 4) == 0) || (strlen(symbol) >= 6 && strncmp(symbol, "STAKED", 6) == 0) ) + if ( (strncmp(symbol, "STKD", 4) == 0) || (strncmp(symbol, "STAKED", 6) == 0) ) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } @@ -72,10 +55,10 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); + auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); auth.requiredSigs = 3; for (int n=0; n Date: Fri, 21 Sep 2018 01:48:37 +0800 Subject: [PATCH 059/951] ; --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 3c257c4a7..046abff82 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,7 @@ #include "notarisationdb.h" #include "notaries_STAKED.h" -extern char *notaries_STAKED +extern char *notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 37fa6b1ac..08ed1a91a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ #define KOMODO_MAINNET_START 178999 -extern char *notaries_STAKED +extern char *notaries_STAKED; const char *Notaries_genesis[][2] = { From 9a241aa9c29c40bf75da075cccc9ecb69233d8ec Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:10:11 +0800 Subject: [PATCH 060/951] try again --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- src/notaries_STAKED.cpp | 22 ++++++++++++++++++++++ src/notaries_STAKED.h | 26 +++++--------------------- 4 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 src/notaries_STAKED.cpp diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 046abff82..10145013b 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,7 @@ #include "notarisationdb.h" #include "notaries_STAKED.h" -extern char *notaries_STAKED; +//extern char *notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 08ed1a91a..7bec772b1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ #define KOMODO_MAINNET_START 178999 -extern char *notaries_STAKED; +//extern char *notaries_STAKED; const char *Notaries_genesis[][2] = { diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp new file mode 100644 index 000000000..e34100eff --- /dev/null +++ b/src/notaries_STAKED.cpp @@ -0,0 +1,22 @@ +#include "notaries_STAKED.h" + +const char *notaries_STAKED[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 99169f1a6..b6e209733 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,22 +1,6 @@ -#pragma once +#ifndef NOTARIES_STAKED +#define NOTARIES_STAKED -const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; +extern char *notaries_STAKED[][2]; + +#endif From 550e9a54ac185935bb1b87ed53546182fb0c8467 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:19:24 +0800 Subject: [PATCH 061/951] i --- src/notaries_STAKED.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index b6e209733..479979a57 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,6 +1,26 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -extern char *notaries_STAKED[][2]; +//extern char *notaries_STAKED[][2]; +const char *notaries_STAKED[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; #endif From 9b97cb1a5dadef69047f6ebf39ad84828098a61b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:54:13 +0800 Subject: [PATCH 062/951] one more time --- src/notaries_STAKED.cpp | 7 +++++++ src/notaries_STAKED.h | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp index e34100eff..a012bc08c 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_STAKED.cpp @@ -20,3 +20,10 @@ const char *notaries_STAKED[][2] = {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; + +bool is_STAKED() { + int32_t STAKED = 0; + if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + STAKED = 1; + return(STAKED) +} diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 479979a57..f6be14222 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,9 +1,11 @@ -#ifndef NOTARIES_STAKED -#define NOTARIES_STAKED +#ifndef NOTARIES_STAKED_H +#define NOTARIES_STAKED_H -//extern char *notaries_STAKED[][2]; +extern const char *notaries_STAKED[][2]; -const char *notaries_STAKED[][2] = +bool is_STAKED(); + +/*const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -22,5 +24,5 @@ const char *notaries_STAKED[][2] = {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; +};*/ #endif From f58cc01b5e0451e1c8f3182523d3639c3a17d559 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 02:58:53 +0800 Subject: [PATCH 063/951] ; --- src/notaries_STAKED.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp index a012bc08c..2038f6897 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_STAKED.cpp @@ -26,4 +26,4 @@ bool is_STAKED() { if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED) -} +}; From 75a86d88a299c8251193b09ae4cb3894832ae4df Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 03:10:28 +0800 Subject: [PATCH 064/951] ? --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- src/notaries_STAKED.cpp | 4 +++- src/notaries_STAKED.h | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 10145013b..6b4f1d7ad 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -55,7 +55,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + auth.size = num_notaries_STAKED; auth.requiredSigs = 3; for (int n=0; n Date: Fri, 21 Sep 2018 03:12:24 +0800 Subject: [PATCH 065/951] ? --- src/notaries_STAKED.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 23e58e1ee..814cc0a7a 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ -#ifndef NOTARIES_STAKED_H -#define NOTARIES_STAKED_H +//#ifndef NOTARIES_STAKED_H +//#define NOTARIES_STAKED_H extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; @@ -26,4 +26,4 @@ bool is_STAKED(); {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s };*/ -#endif +//#endif From 41c25e89db3dc730229e07b578dfe96a90265309 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 03:16:35 +0800 Subject: [PATCH 066/951] ? --- src/notaries_STAKED.cpp | 2 +- src/notaries_STAKED.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_STAKED.cpp b/src/notaries_STAKED.cpp index 41b106066..b3c97020a 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_STAKED.cpp @@ -28,4 +28,4 @@ bool is_STAKED() { return(STAKED) }; -int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 814cc0a7a..4b2f8ba90 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -2,7 +2,7 @@ //#define NOTARIES_STAKED_H extern const char *notaries_STAKED[][2]; -extern int num_notaries_STAKED; +extern const int num_notaries_STAKED; bool is_STAKED(); From 24f0f84417bd0dc89d48f741c91a01cf36953c03 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 11:20:09 +0800 Subject: [PATCH 067/951] try this --- src/notaries_STAKED.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_STAKED.h b/src/notaries_STAKED.h index 4b2f8ba90..7bf13b8c9 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_STAKED.h @@ -1,5 +1,5 @@ -//#ifndef NOTARIES_STAKED_H -//#define NOTARIES_STAKED_H +#ifndef NOTARIES_STAKED_H +#define NOTARIES_STAKED_H extern const char *notaries_STAKED[][2]; extern const int num_notaries_STAKED; @@ -26,4 +26,4 @@ bool is_STAKED(); {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s };*/ -//#endif +#endif From b7a3348ed19dde86b3dbc174d3f48db39aa703bd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 11:43:32 +0800 Subject: [PATCH 068/951] change some stuff --- src/crosschain_authority.cpp | 3 ++- src/komodo_notary.h | 3 ++- src/{notaries_STAKED.cpp => notaries_staked.cpp} | 5 +++-- src/{notaries_STAKED.h => notaries_staked.h} | 11 +++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) rename src/{notaries_STAKED.cpp => notaries_staked.cpp} (94%) rename src/{notaries_STAKED.h => notaries_staked.h} (91%) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6b4f1d7ad..6ccf631dc 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,7 +3,8 @@ #include "notarisationdb.h" #include "notaries_STAKED.h" -//extern char *notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index cf485e41f..cab36642d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,8 @@ #define KOMODO_MAINNET_START 178999 -//extern char *notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; const char *Notaries_genesis[][2] = { diff --git a/src/notaries_STAKED.cpp b/src/notaries_staked.cpp similarity index 94% rename from src/notaries_STAKED.cpp rename to src/notaries_staked.cpp index b3c97020a..daab6fe3d 100644 --- a/src/notaries_STAKED.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_STAKED.h" -const char *notaries_STAKED[][2] = +/*const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -20,6 +20,7 @@ const char *notaries_STAKED[][2] = {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; +*/ bool is_STAKED() { bool STAKED = 0; @@ -28,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +//const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_STAKED.h b/src/notaries_staked.h similarity index 91% rename from src/notaries_STAKED.h rename to src/notaries_staked.h index 7bf13b8c9..ba491dd95 100644 --- a/src/notaries_STAKED.h +++ b/src/notaries_staked.h @@ -1,12 +1,12 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; bool is_STAKED(); -/*const char *notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -25,5 +25,8 @@ bool is_STAKED(); {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -};*/ +}; + +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + #endif From 6f3af3ff83c717689b3ed1551b0dcaffbf69bd7b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 11:46:25 +0800 Subject: [PATCH 069/951] Change minsigs to 4, remove supply hack. --- src/crosschain_authority.cpp | 2 +- src/komodo.h | 2 +- src/komodo_utils.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7cec5f382..a010126a1 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -76,7 +76,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.size = (int32_t)(sizeof(notaries_STAKEDcc)/sizeof(*notaries_STAKEDcc)); - auth.requiredSigs = 3; + auth.requiredSigs = 4; for (int n=0; n= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 3 ) + ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 4 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4856931ac..44516ba6b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1554,7 +1554,7 @@ void komodo_args(char *argv0) if ( name.c_str()[0] != 0 ) { MAX_BLOCK_SIGOPS = 60000; - ASSETCHAINS_SUPPLY = ( GetArg("-ac_supply",10) + 1 ); + ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_ENDSUBSIDY = GetArg("-ac_end",0); ASSETCHAINS_REWARD = GetArg("-ac_reward",0); ASSETCHAINS_HALVING = GetArg("-ac_halving",0); @@ -1752,4 +1752,3 @@ void komodo_prefetch(FILE *fp) } fseek(fp,fpos,SEEK_SET); } - From 95918c6402d806a7d6793bec58370db1ee0f361d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 12:29:39 +0800 Subject: [PATCH 070/951] fix dumbness --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 27 +-------------------------- src/notaries_staked.cpp | 2 +- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 849c083bc..b382b4fc9 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -1,7 +1,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "notarisationdb.h" -#include "notaries_STAKED.h" +#include "notaries_staked.h" extern const char *notaries_STAKED[][2]; extern const int num_notaries_STAKED; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b5e147855..7b041f8b9 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,32 +18,7 @@ #include "komodo_cJSON.h" -<<<<<<< HEAD -//include "notaries_STAKED.h" -//{"kmdcrazy", "02da444a2627d420f1f622fcdfb9bddb67d6d4241ad6b4d5054716ddbde8a25dfb"} // RJPJBbHcm5mkAxhkkERHRfEE9Cvkr4Euoi -const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; -======= -#include "notaries_STAKED.h" ->>>>>>> blackjok3r +#include "notaries_staked.h" #define KOMODO_MAINNET_START 178999 diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index daab6fe3d..9f6301f80 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,4 +1,4 @@ -#include "notaries_STAKED.h" +#include "notaries_staked.h" /*const char *notaries_STAKED[][2] = { From 9f1e5ad6c0ffd3d11f667e262c28f1c553fda919 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 12:41:10 +0800 Subject: [PATCH 071/951] runnign around in circles here, little sense! --- src/notaries_staked.cpp | 6 +++--- src/notaries_staked.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9f6301f80..a3b3844d3 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -/*const char *notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -20,7 +20,7 @@ {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; -*/ + bool is_STAKED() { bool STAKED = 0; @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -//const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ba491dd95..59e083a41 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,12 +1,12 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; bool is_STAKED(); -const char *notaries_STAKED[][2] = +/*const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -28,5 +28,5 @@ const char *notaries_STAKED[][2] = }; const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); - +*/ #endif From 3dcbdcb85c3c441fbacc3916c8f8bfeaaaca6e19 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:08:13 +0800 Subject: [PATCH 072/951] try something else --- src/notaries_staked.cpp | 4 ++-- src/notaries_staked.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3b3844d3..9350ecdf2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -const char *notaries_STAKED[][2] = +extern const char *const notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +extern const int const num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 59e083a41..a3d3599b7 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,8 +1,8 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +extern const char *const notaries_STAKED[][2]; +extern const int const num_notaries_STAKED; bool is_STAKED(); From bb7815b05bd650fefb8e89051f4e9c9fa795f8ef Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:09:53 +0800 Subject: [PATCH 073/951] that didnt work --- src/notaries_staked.cpp | 4 ++-- src/notaries_staked.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9350ecdf2..0a9db207d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -extern const char *const notaries_STAKED[][2] = +extern const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -extern const int const num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +extern const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index a3d3599b7..59e083a41 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,8 +1,8 @@ #ifndef NOTARIES_STAKED_H #define NOTARIES_STAKED_H -extern const char *const notaries_STAKED[][2]; -extern const int const num_notaries_STAKED; +extern const char *notaries_STAKED[][2]; +extern const int num_notaries_STAKED; bool is_STAKED(); From 158d7befbc384c5d45ecada1c35d5e373ecb4858 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:11:12 +0800 Subject: [PATCH 074/951] WTF!??!? --- src/notaries_staked.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 59e083a41..9b843f2c5 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,6 +1,3 @@ -#ifndef NOTARIES_STAKED_H -#define NOTARIES_STAKED_H - extern const char *notaries_STAKED[][2]; extern const int num_notaries_STAKED; @@ -29,4 +26,3 @@ bool is_STAKED(); const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); */ -#endif From 14acb852d578d8ca39da6834bed7124449c439f4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:23:00 +0800 Subject: [PATCH 075/951] try again --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 0a9db207d..a3b3844d3 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -extern const char *notaries_STAKED[][2] = +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -extern const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); From 1183a043b2a561327b09eac8b11d62edd7a7b30e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:28:25 +0800 Subject: [PATCH 076/951] try again --- src/crosschain_authority.cpp | 4 ++-- src/komodo_notary.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b382b4fc9..31ea0b547 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,8 +3,8 @@ #include "notarisationdb.h" #include "notaries_staked.h" -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; int GetSymbolAuthority(const char* symbol) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 7b041f8b9..d8b25a0ef 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,8 +22,8 @@ #define KOMODO_MAINNET_START 178999 -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; const char *Notaries_genesis[][2] = { From 9a469cda6f4c03c8dd136ab4089bd28db913be6b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:37:26 +0800 Subject: [PATCH 077/951] try hardcode of array length --- src/notaries_staked.cpp | 4 ++-- src/notaries_staked.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3b3844d3..24c8562df 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,6 @@ #include "notaries_staked.h" -const char *notaries_STAKED[][2] = +const char *notaries_STAKED[17][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -29,4 +29,4 @@ bool is_STAKED() { return(STAKED) }; -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9b843f2c5..ef54eb6aa 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,5 +1,5 @@ -extern const char *notaries_STAKED[][2]; -extern const int num_notaries_STAKED; +extern const char *notaries_STAKED[17[2]; +extern int num_notaries_STAKED; bool is_STAKED(); From 3539848b6031b76204a2a0e2675c26b478eaec38 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 13:41:40 +0800 Subject: [PATCH 078/951] typo --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ef54eb6aa..3defe851c 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,4 +1,4 @@ -extern const char *notaries_STAKED[17[2]; +extern const char *notaries_STAKED[17][2]; extern int num_notaries_STAKED; bool is_STAKED(); From bb33491657b778b6e9bc02bde8c8a8b9ae3ecc87 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:11:36 +0800 Subject: [PATCH 079/951] thanks mike --- src/notaries_staked.cpp | 12 ++++++++---- src/notaries_staked.h | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 24c8562df..735136b7d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,10 @@ -#include "notaries_staked.h" -const char *notaries_STAKED[17][2] = +#include "notaries_staked.h" +#include + +extern char ASSETCHAINS_SYMBOL[65]; + +const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg @@ -26,7 +30,7 @@ bool is_STAKED() { bool STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; - return(STAKED) + return(STAKED); }; -int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 3defe851c..d7ea4c4fd 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -1,3 +1,7 @@ + +#ifndef NOTARIES_STAKED +#define NOTARIES_STAKED + extern const char *notaries_STAKED[17][2]; extern int num_notaries_STAKED; @@ -26,3 +30,4 @@ bool is_STAKED(); const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); */ +#endif From c83285ffe2dcfe09cfa637121da2fb5d6548b447 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:24:53 +0800 Subject: [PATCH 080/951] add include file to makefile ... Please work?! --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index 7113a1e42..de476385e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -291,6 +291,7 @@ libbitcoin_server_a_SOURCES = \ metrics.cpp \ miner.cpp \ net.cpp \ + notaries_staked.cpp \ noui.cpp \ notarisationdb.cpp \ paymentdisclosure.cpp \ From 77ee7feec84a9e91f7d7532f0c06340da4d10d61 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:43:16 +0800 Subject: [PATCH 081/951] about to blow it up --- src/bitcoin-cli.cpp | 3 ++- src/komodo_notary.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index bf189e483..db99b6a67 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -74,11 +74,12 @@ public: #include "komodo_globals.h" #include "komodo_utils.h" #include "komodo_cJSON.c" +#include "notaries_staked.h" #include "komodo_notary.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { - + } uint32_t komodo_heightstamp(int32_t height) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d8b25a0ef..45f325648 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,7 @@ #include "komodo_cJSON.h" -#include "notaries_staked.h" +//#include "notaries_staked.h" #define KOMODO_MAINNET_START 178999 From 7384746b72d090a32f92e8d69fe85f7277292828 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:48:26 +0800 Subject: [PATCH 082/951] WTFWTFW --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 45f325648..d8b25a0ef 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -18,7 +18,7 @@ #include "komodo_cJSON.h" -//#include "notaries_staked.h" +#include "notaries_staked.h" #define KOMODO_MAINNET_START 178999 From 3b210ee00cbd89399088c3dadb4eda43b4740b0f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 15:57:30 +0800 Subject: [PATCH 083/951] WTFTWTFEWIDlknPI --- src/bitcoin-cli.cpp | 1 - src/notaries_staked.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index db99b6a67..60a185284 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -74,7 +74,6 @@ public: #include "komodo_globals.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "notaries_staked.h" #include "komodo_notary.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index d7ea4c4fd..b8243513d 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,7 +2,7 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -extern const char *notaries_STAKED[17][2]; +extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; bool is_STAKED(); From 5f2b70662553a62518d9bd680bb43cafe911f21e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 16:09:51 +0800 Subject: [PATCH 084/951] meh --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index de476385e..0559230c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -179,6 +179,7 @@ BITCOIN_CORE_H = \ mruset.h \ net.h \ netbase.h \ + notaries_staked.h \ noui.h \ paymentdisclosure.h \ paymentdisclosuredb.h \ From 263c24b266e9e4537772064da62c0725f0d6a152 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 16:56:34 +0800 Subject: [PATCH 085/951] maybe --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 60a185284..6164cf463 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -75,6 +75,7 @@ public: #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" +#include "notaries_staked.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From c85b1ace10f684a7e92282011231f6a858529377 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:02:22 +0800 Subject: [PATCH 086/951] hmmmm --- src/notaries_staked.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 735136b7d..01e09bf07 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -25,7 +25,6 @@ const char *notaries_STAKED[][2] = {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; - bool is_STAKED() { bool STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) From 90f50a9ee705766c3bc369f83e2677d2defdac92 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:15:21 +0800 Subject: [PATCH 087/951] add is_staked function --- src/crosschain_authority.cpp | 7 ++----- src/komodo.h | 3 ++- src/komodo_notary.h | 2 +- src/main.cpp | 4 ++-- src/notaries_staked.h | 25 ++----------------------- 5 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 31ea0b547..cca6d6b21 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -3,14 +3,11 @@ #include "notarisationdb.h" #include "notaries_staked.h" -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if ( (strncmp(symbol, "STKD", 4) == 0) || (strncmp(symbol, "STAKED", 6) == 0) ) + if (is_STAKED() == 1) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } @@ -56,7 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.requiredSigs = 4; + auth.requiredSigs = STAKED_MIN_SIGS; auth.size = num_notaries_STAKED; for (int n=0; n= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) && numvalid > 4 ) + ( (is_STAKED == 1) && (numvalid > STAKED_MIN_SIGS) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d8b25a0ef..6cb69ef0c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -231,7 +231,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if (is_STAKED == 1) { n1 = num_notaries_STAKED; for (i=0; i> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if ( is_STAKED == 1 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { diff --git a/src/notaries_staked.h b/src/notaries_staked.h index b8243513d..eac34e0d0 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,29 +5,8 @@ extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; +static const int STAKED_MIN_SIGS = 4; + bool is_STAKED(); -/*const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -const int num_notaries_STAKED = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); -*/ #endif From 0233e249cf1cd2079b69553ded79a594717d5697 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:19:16 +0800 Subject: [PATCH 088/951] change to int --- src/notaries_staked.cpp | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 01e09bf07..323ec094f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -25,7 +25,7 @@ const char *notaries_STAKED[][2] = {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; -bool is_STAKED() { +int is_STAKED() { bool STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index eac34e0d0..bf8c3c58e 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,6 +7,6 @@ extern int num_notaries_STAKED; static const int STAKED_MIN_SIGS = 4; -bool is_STAKED(); +int is_STAKED(); #endif From c2ec9c54688da5386af23959e29256bb0d90d0e9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:21:30 +0800 Subject: [PATCH 089/951] syntax --- src/komodo.h | 2 +- src/komodo_notary.h | 2 +- src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7c8a226df..4ff65fa18 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,7 +858,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (is_STAKED == 1) && (numvalid > STAKED_MIN_SIGS) ) + ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6cb69ef0c..d4f3e4ead 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -231,7 +231,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { if ( did1 == 0 ) { - if (is_STAKED == 1) + if (is_STAKED() == 1) { n1 = num_notaries_STAKED; for (i=0; i> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( is_STAKED == 1 ) + if ( is_STAKED() == 1 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { From d35a88824596927ed36405b9d322f3d03250d522 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Sep 2018 17:23:26 +0800 Subject: [PATCH 090/951] ) --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 4ff65fa18..cdf660189 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,7 +858,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) || - ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) ) + ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) )) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { From b076f0ed148421a8ff06860ac1d6ce710670ddd5 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sat, 22 Sep 2018 23:58:55 +0000 Subject: [PATCH 091/951] edit assetchains.json STAKED chains --- src/assetchains.json | 195 +++++++++++-------------------------------- 1 file changed, 51 insertions(+), 144 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index ceda4cce1..9faa54f16 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -1,149 +1,56 @@ [ { - "ac_name": "REVS", - "ac_supply": "1300000" - }, - { - "ac_name": "SUPERNET", - "ac_supply": "816061" - }, - { - "ac_name": "DEX", - "ac_supply": "999999" - }, - { - "ac_name": "PANGEA", - "ac_supply": "999999" - }, - { - "ac_name": "JUMBLR", - "ac_supply": "999999" - }, - { - "ac_name": "BET", - "ac_supply": "999999" - }, - { - "ac_name": "CRYPTO", - "ac_supply": "999999" - }, - { - "ac_name": "HODL", - "ac_supply": "9999999" - }, - { - "ac_name": "MSHARK", - "ac_supply": "1400000" - }, - { - "ac_name": "BOTS", - "ac_supply": "999999" - }, - { - "ac_name": "MGW", - "ac_supply": "999999" - }, - { - "ac_name": "COQUI", - "ac_supply": "72000000", - "ac_ccactivate": "200000" - }, - { - "ac_name": "WLC", - "ac_supply": "210000000" - }, - { - "ac_name": "KV", - "ac_supply": "1000000" - }, - { - "ac_name": "CEAL", - "ac_supply": "366666666" - }, - { - "ac_name": "MESH", - "ac_supply": "1000007" - }, - { - "ac_name": "MNZ", - "ac_supply": "257142858" - }, - { - "ac_name": "AXO", - "ac_supply": "200000000" - }, - { - "ac_name": "ETOMIC", - "ac_supply": "100000000" - }, - { - "ac_name": "BTCH", - "ac_supply": "20998641" - }, - { - "ac_name": "PIZZA", - "ac_supply": "100000000" - }, - { - "ac_name": "BEER", - "ac_supply": "100000000" - }, - { - "ac_name": "NINJA", - "ac_supply": "100000000" - }, - { - "ac_name": "OOT", - "ac_supply": "216000000" - }, - { - "ac_name": "BNTN", - "ac_supply": "500000000" - }, - { - "ac_name": "CHAIN", - "ac_supply": "999999" - }, - { - "ac_name": "PRLPAY", - "ac_supply": "500000000" - }, - { - "ac_name": "DSEC", - "ac_supply": "7000000" - }, - { - "ac_name": "GLXT", - "ac_supply": "10000000000" - }, - { - "ac_name": "EQL", - "ac_supply": "500000000" - }, - { - "ac_name": "ZILLA", - "ac_supply": "11000000" - }, - { - "ac_name": "RFOX", - "ac_supply": "1000000000", - "ac_reward": "100000000" - }, - { - "ac_name": "SEC", - "ac_supply": "1000000000", - "ac_cc": "333" - }, - { - "ac_name": "CCL", - "ac_supply": "200000000", - "ac_end": "1", - "ac_cc": "2", - "addressindex": "1", - "spentindex": "1", + "ac_name": "STAKEDB1", + "ac_supply": "100000", + "ac_reward" : "1000000000", + "ac_cc": "667", "addnode": [ - "142.93.136.89", - "195.201.22.89" + "195.201.137.5", + "195.201.20.230" ] - } + }, + { + "ac_name": "STAKEDW1", + "ac_supply": "100000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDPERC", + "ac_supply": "1000000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "ac_perc": "10000000", + "ac_pubkey": "03bd221868abc063b54a3fceafb9898b1931ed767298a17ac0c9923500a7c60e4b", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDS1", + "ac_supply": "1000000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "ac_staked": "10", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDS9", + "ac_supply": "1000000", + "ac_reward" : "1000000000", + "ac_cc": "667", + "ac_staked": "90", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + } ] From 44f2c39adae28a792dd3fef97b688373f09939ae Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:27:14 +0800 Subject: [PATCH 092/951] try and add eras, for notaries, with timestamp activation --- src/crosschain_authority.cpp | 2 +- src/komodo.h | 3 +- src/komodo_notary.h | 132 ++++++++++++++++++++++++----------- src/main.cpp | 2 +- src/notaries_staked.cpp | 91 +++++++++++++++++++++++- src/notaries_staked.h | 15 +++- 6 files changed, 199 insertions(+), 46 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index cca6d6b21..1d9ba93f4 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED() == 1) + if (is_STAKED() != 0) return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } diff --git a/src/komodo.h b/src/komodo.h index cdf660189..d1587fbb4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -857,8 +857,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5)) || - ( (is_STAKED() == 1) && (numvalid > STAKED_MIN_SIGS) )) + numvalid > (numnotaries/5)) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d4f3e4ead..87947a9b8 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -206,53 +206,107 @@ const char *Notaries_elected1[][2] = int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; + static uint8_t staked_pubkeys[64][33],staked_pubkeys1[64][33],didstaked,didstaked1; static int32_t ns,ns1; + static uint8_t staked_pubkeys2[64][33],staked_pubkeys3[64][33],didstaked2,didstaked3; static int32_t ns2,ns3; + int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) timestamp = komodo_heightstamp(height); else if ( ASSETCHAINS_SYMBOL[0] == 0 ) timestamp = 0; - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. + if (is_STAKED() == 0) { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; diff --git a/src/main.cpp b/src/main.cpp index e86fe47bc..596518ecf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5954,7 +5954,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( is_STAKED() == 1 ) + if ( is_STAKED() != 0 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 323ec094f..4f335a444 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,6 +4,7 @@ extern char ASSETCHAINS_SYMBOL[65]; +// Era 0 set of pubkeys const char *notaries_STAKED[][2] = { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x @@ -25,11 +26,97 @@ const char *notaries_STAKED[][2] = {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s }; +int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); + +// Era 1 set of pubkeys +const char *notaries_STAKED1[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED1 = (sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1)); + +// Era 2 set of pubkeys +const char *notaries_STAKED2[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED2 = (sizeof(notaries_STAKED2)/sizeof(*notaries_STAKED2)); + +// Era 3 set of pubkeys +const char *notaries_STAKED3[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); + int is_STAKED() { - bool STAKED = 0; + int STAKED = 0; if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED); }; -int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); +int STAKED_era(uint32_t timestamp) +{ + int era; + if (timestamp <= STAKED_NOTARIES_TIMESTAMP) + era = 0; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 && timestamp >= STAKED_NOTARIES_TIMESTAMP) + era = 1; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= STAKED_NOTARIES_TIMESTAMP1) + era = 2; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= STAKED_NOTARIES_TIMESTAMP2) + era = 3; + return(era); +} diff --git a/src/notaries_staked.h b/src/notaries_staked.h index bf8c3c58e..201f8cb40 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,11 +2,24 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED +static const uint32_t STAKED_NOTARIES_TIMESTAMP = 1537780949; +static const uint32_t STAKED_NOTARIES_TIMESTAMP1 = 1537791749; +static const uint32_t STAKED_NOTARIES_TIMESTAMP2 = 1537802549; +static const uint32_t STAKED_NOTARIES_TIMESTAMP3 = 1537813349; + extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; -static const int STAKED_MIN_SIGS = 4; +extern const char *notaries_STAKED1[][2]; +extern int num_notaries_STAKED1; + +extern const char *notaries_STAKED2[][2]; +extern int num_notaries_STAKED2; + +extern const char *notaries_STAKED3[][2]; +extern int num_notaries_STAKED3; int is_STAKED(); +int STAKED_era(uint32_t timestamp); #endif From 91c308014611e1b9edb5b8bf423d8a533fc9e85c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:37:15 +0800 Subject: [PATCH 093/951] hmmm need to have height activation for MoMoM aswell, as uses a diffrent array for its pubkeys,disable this for now to test. --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1d9ba93f4..06a01dbd5 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,7 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.requiredSigs = STAKED_MIN_SIGS; + auth.requiredSigs = 4; auth.size = num_notaries_STAKED; for (int n=0; n Date: Mon, 24 Sep 2018 15:43:43 +0800 Subject: [PATCH 094/951] change to just int, compiler was mad --- src/notaries_staked.cpp | 2 +- src/notaries_staked.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 4f335a444..81d249d96 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED() { return(STAKED); }; -int STAKED_era(uint32_t timestamp) +int STAKED_era(int timestamp) { int era; if (timestamp <= STAKED_NOTARIES_TIMESTAMP) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 201f8cb40..84296d4e5 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,10 +2,10 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -static const uint32_t STAKED_NOTARIES_TIMESTAMP = 1537780949; -static const uint32_t STAKED_NOTARIES_TIMESTAMP1 = 1537791749; -static const uint32_t STAKED_NOTARIES_TIMESTAMP2 = 1537802549; -static const uint32_t STAKED_NOTARIES_TIMESTAMP3 = 1537813349; +static const int STAKED_NOTARIES_TIMESTAMP = 1537780949; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537791749; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537802549; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537813349; extern const char *notaries_STAKED[][2]; extern int num_notaries_STAKED; @@ -20,6 +20,6 @@ extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; int is_STAKED(); -int STAKED_era(uint32_t timestamp); +int STAKED_era(int timestamp); #endif From 5ef1dc51272e4c036c4d23fe492029c03286ebde Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:45:03 +0800 Subject: [PATCH 095/951] ; --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 87947a9b8..5c85c0885 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -303,7 +303,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam memcpy(pubkeys,staked_pubkeys3,ns1 * 33); return(ns3); } - free(staked_era) + free(staked_era); } } From 533cb0369c9daab7a387d7096ac4a1019fd8ee1b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 15:46:38 +0800 Subject: [PATCH 096/951] pointless line remove --- src/komodo_notary.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5c85c0885..8be1c2feb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -303,7 +303,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam memcpy(pubkeys,staked_pubkeys3,ns1 * 33); return(ns3); } - free(staked_era); } } From fdf332d9abcf8be292dc573620da298c59d38a11 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 16:24:25 +0800 Subject: [PATCH 097/951] fix silly --- src/komodo_notary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8be1c2feb..af84287b4 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -264,7 +264,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam didstaked = 1; printf("THIS CHAIN IS A STAKED CHAIN and is era 0 \n"); } - memcpy(pubkeys,staked_pubkeys,n1 * 33); + memcpy(pubkeys,staked_pubkeys,ns * 33); return(ns); } else if (staked_era == 1) { @@ -288,7 +288,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam didstaked2 = 1; printf("THIS CHAIN IS A STAKED CHAIN and is era 2 \n"); } - memcpy(pubkeys,staked_pubkeys2,ns1 * 33); + memcpy(pubkeys,staked_pubkeys2,ns2 * 33); return(ns2); } else if (staked_era == 3) { @@ -300,7 +300,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam didstaked2 = 1; printf("THIS CHAIN IS A STAKED CHAIN and is era 3 \n"); } - memcpy(pubkeys,staked_pubkeys3,ns1 * 33); + memcpy(pubkeys,staked_pubkeys3,ns3 * 33); return(ns3); } } From 6120642eb124099c2b0b63f1104eaa84e412809d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 18:58:38 +0800 Subject: [PATCH 098/951] add a print for isstaked --- src/crosschain_authority.cpp | 3 ++- src/komodo_notary.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 06a01dbd5..049b97cd4 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -8,6 +8,7 @@ int GetSymbolAuthority(const char* symbol) if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; if (is_STAKED() != 0) + printf("RETURNED CROSSCHAIN STAKED AS TRUE"); return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } @@ -53,7 +54,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; - auth.requiredSigs = 4; + auth.requiredSigs = (num_notaries_STAKED / 5); auth.size = num_notaries_STAKED; for (int n=0; n Date: Mon, 24 Sep 2018 19:14:59 +0800 Subject: [PATCH 099/951] fix format --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 049b97cd4..aa2188457 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -8,7 +8,7 @@ int GetSymbolAuthority(const char* symbol) if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; if (is_STAKED() != 0) - printf("RETURNED CROSSCHAIN STAKED AS TRUE"); + printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; } From b2c4fd58ecc344f9f92c34fdcf9a90d447b5f5a8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:45:17 +0800 Subject: [PATCH 100/951] add another print --- src/notarisationdb.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 779489fd8..0df999e53 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -24,6 +24,8 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); + printf("Parsed notarisation data for %s",data.symbol); + if (!parsed) data = NotarisationData(); int authority = GetSymbolAuthority(data.symbol); From 8496fdbeeded2173d0493448880938419ffb7587 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:49:10 +0800 Subject: [PATCH 101/951] better? --- src/notarisationdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 0df999e53..45aff2ac7 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -24,9 +24,10 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); - printf("Parsed notarisation data for %s",data.symbol); + printf("Parsed notarisation data for %s \n",data.symbol); if (!parsed) data = NotarisationData(); + printf("Parsed notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { From d75be221a0b256e3d60750b8fa5339bcce74d4bd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:55:23 +0800 Subject: [PATCH 102/951] fux stupid error --- src/crosschain_authority.cpp | 2 +- src/komodo_notary.h | 2 +- src/main.cpp | 2 +- src/notaries_staked.cpp | 6 ++---- src/notaries_staked.h | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index aa2188457..1b41c2aad 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED() != 0) + if (is_STAKED(symbol) != 0) printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; return CROSSCHAIN_KOMODO; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4f1645f98..1b572b17c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -215,7 +215,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam else if ( ASSETCHAINS_SYMBOL[0] == 0 ) timestamp = 0; // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if (is_STAKED() == 0) + if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) { if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) { diff --git a/src/main.cpp b/src/main.cpp index 596518ecf..89aea8360 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5954,7 +5954,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if ( is_STAKED() != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 81d249d96..33dfa8bb5 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -2,8 +2,6 @@ #include "notaries_staked.h" #include -extern char ASSETCHAINS_SYMBOL[65]; - // Era 0 set of pubkeys const char *notaries_STAKED[][2] = { @@ -100,9 +98,9 @@ const char *notaries_STAKED3[][2] = int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); -int is_STAKED() { +int is_STAKED(const *char chain_name) { int STAKED = 0; - if ( (strncmp(ASSETCHAINS_SYMBOL, "STKD", 4) == 0) || (strncmp(ASSETCHAINS_SYMBOL, "STAKED", 6) == 0) ) + if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 84296d4e5..7d3748d4e 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -19,7 +19,7 @@ extern int num_notaries_STAKED2; extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; -int is_STAKED(); +int is_STAKED(const *char chain_name); int STAKED_era(int timestamp); #endif From 267745130baca8ddbd6db732f06ea7ca9e126643 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 19:58:56 +0800 Subject: [PATCH 103/951] ok --- src/notaries_staked.cpp | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 33dfa8bb5..0741ecd58 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -98,7 +98,7 @@ const char *notaries_STAKED3[][2] = int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); -int is_STAKED(const *char chain_name) { +int is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 7d3748d4e..d0df3906c 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -19,7 +19,7 @@ extern int num_notaries_STAKED2; extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; -int is_STAKED(const *char chain_name); +int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); #endif From 108c04eaf6bec0725bf1dc48074ff4936b571c12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:03:01 +0800 Subject: [PATCH 104/951] more prints --- src/notarisationdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 45aff2ac7..9243cd17f 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -27,7 +27,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Parsed notarisation data for %s \n",data.symbol); if (!parsed) data = NotarisationData(); - printf("Parsed notarisation data for %s \n",data.symbol); + printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { @@ -47,6 +47,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); } + printf("Authorised and added notarisation data for %s \n",data.symbol); return vNotarisations; } From 6f610e9bdd2cc400b082c833dceed8859cdd427e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:06:33 +0800 Subject: [PATCH 105/951] things --- src/notarisationdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 9243cd17f..b79527cca 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -35,6 +35,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) continue; } else if (authority == CROSSCHAIN_STAKED) { if (!CheckTxAuthority(tx, auth_STAKED)) + printf("Authorised notarisation data for %s \n",data.symbol); continue; } @@ -47,7 +48,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); } - printf("Authorised and added notarisation data for %s \n",data.symbol); + printf("Added notarisation data\n"); return vNotarisations; } From 250cb3ffd4d0f47a5c4e81dce2e5ac911b91ed88 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:14:35 +0800 Subject: [PATCH 106/951] try again --- src/notarisationdb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index b79527cca..20b412979 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -34,13 +34,14 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; } else if (authority == CROSSCHAIN_STAKED) { + printf("Authorised notarisation data for %s \n",data.symbol); if (!CheckTxAuthority(tx, auth_STAKED)) - printf("Authorised notarisation data for %s \n",data.symbol); continue; } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); + printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); @@ -48,7 +49,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight); } - printf("Added notarisation data\n"); return vNotarisations; } From 93381421e1ca4ffc8c54a6ea390dae037c1a0190 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:21:31 +0800 Subject: [PATCH 107/951] more --- src/notarisationdb.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 20b412979..d9f1b2aeb 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -31,6 +31,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { + printf("Authorised notarisation data for %s \n",data.symbol); if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; } else if (authority == CROSSCHAIN_STAKED) { @@ -38,7 +39,8 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!CheckTxAuthority(tx, auth_STAKED)) continue; } - + printf("Authorised notarisation data for %s \n",data.symbol); + if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); printf("Added notarisation data for %s \n",data.symbol); From f7826be127553d469211c0c9cc97cdbdc65e6ad6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:41:19 +0800 Subject: [PATCH 108/951] test --- src/crosschain_authority.cpp | 4 +++- src/notarisationdb.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 1b41c2aad..7f95d1533 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,9 +7,11 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED(symbol) != 0) + if (is_STAKED(symbol) != 0) { printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; + } + printf("RETURNED CROSSCHAIN KOMODO AS TRUE\n"); return CROSSCHAIN_KOMODO; } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index d9f1b2aeb..51b692270 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -40,7 +40,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) continue; } printf("Authorised notarisation data for %s \n",data.symbol); - + if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); printf("Added notarisation data for %s \n",data.symbol); From 43de331bef672f00acd64d9cbf4baa5f28afac55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:46:52 +0800 Subject: [PATCH 109/951] make staked chains not authorised to test if notarizations are still added --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7f95d1533..5c0897512 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED(symbol) != 0) { + if (is_STAKED("TEST") != 0) { printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; } From a8412c31cea05d6dc9a1e50998a725b9036965f3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 20:58:30 +0800 Subject: [PATCH 110/951] bail from check notarization if there is no valid notarization --- src/notarisationdb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 51b692270..ee99a8020 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -24,9 +24,13 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); + printf("Parsed notarisation data for %s \n",data.symbol); if (!parsed) data = NotarisationData(); + if (strlen(data.symbol) == 0) + continue; + printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); From 8010a2567c55c4ab28a4af4853a7af50084c4779 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:04:26 +0800 Subject: [PATCH 111/951] check --- src/notarisationdb.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index ee99a8020..916a5a185 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -30,7 +30,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!parsed) data = NotarisationData(); if (strlen(data.symbol) == 0) continue; - + printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); @@ -43,7 +43,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (!CheckTxAuthority(tx, auth_STAKED)) continue; } - printf("Authorised notarisation data for %s \n",data.symbol); if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); From 7aea99c1a4abe7ef5893be07f37cc319d9be810c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:24:48 +0800 Subject: [PATCH 112/951] try and get timesstamp for crosschain auth height activation --- src/crosschain_authority.cpp | 1 - src/notarisationdb.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 5c0897512..78958b362 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,7 +53,6 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } - const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.requiredSigs = (num_notaries_STAKED / 5); diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 916a5a185..ee6b4d267 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -4,6 +4,7 @@ #include "cc/eval.h" #include "crosschain.h" #include "main.h" +#include "notaries_staked.h" #include @@ -18,6 +19,9 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) { EvalRef eval; NotarisationsInBlock vNotarisations; + //CrosschainAuthority auth_STAKED; + int timestamp = komodo_heightstamp(nHeight); + printf("timestamp = %d",timestamp) for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; @@ -40,6 +44,8 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) continue; } else if (authority == CROSSCHAIN_STAKED) { printf("Authorised notarisation data for %s \n",data.symbol); + // We need to create auth_STAKED dynamically here based on timestamp + if (!CheckTxAuthority(tx, auth_STAKED)) continue; } From 2b91c1d732801f90a9e9d20f4dfcbd1f15e989d0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:29:20 +0800 Subject: [PATCH 113/951] try this instead --- src/notarisationdb.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index ee6b4d267..1b459e363 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -39,15 +39,14 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { - printf("Authorised notarisation data for %s \n",data.symbol); if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; - } else if (authority == CROSSCHAIN_STAKED) { printf("Authorised notarisation data for %s \n",data.symbol); + } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp - if (!CheckTxAuthority(tx, auth_STAKED)) continue; + printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { From f541d4a7d5b27c91b34b1d17dc72c11a18e1e4c7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:40:51 +0800 Subject: [PATCH 114/951] try pull from cBlock --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 1b459e363..8ec508e21 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -20,7 +20,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) EvalRef eval; NotarisationsInBlock vNotarisations; //CrosschainAuthority auth_STAKED; - int timestamp = komodo_heightstamp(nHeight); + int timestamp = block.nTime; printf("timestamp = %d",timestamp) for (unsigned int i = 0; i < block.vtx.size(); i++) { From 360925ac6a238c592589ee99e0df18e66dd92afd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:42:22 +0800 Subject: [PATCH 115/951] ; --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 8ec508e21..a2052c8bf 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -21,7 +21,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationsInBlock vNotarisations; //CrosschainAuthority auth_STAKED; int timestamp = block.nTime; - printf("timestamp = %d",timestamp) + printf("timestamp = %d",timestamp); for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; From 7d8a97e1f98ae9d72f56ba62a123409248c4f9e9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:51:13 +0800 Subject: [PATCH 116/951] reactivate staked auth, and try to fetch era from auto function --- src/crosschain_authority.cpp | 2 +- src/notarisationdb.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 78958b362..8dc8fc77f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -7,7 +7,7 @@ int GetSymbolAuthority(const char* symbol) { if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; - if (is_STAKED("TEST") != 0) { + if (is_STAKED(symbol) != 0) { printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index a2052c8bf..f4ba4dfe7 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -21,7 +21,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationsInBlock vNotarisations; //CrosschainAuthority auth_STAKED; int timestamp = block.nTime; - printf("timestamp = %d",timestamp); for (unsigned int i = 0; i < block.vtx.size(); i++) { CTransaction tx = block.vtx[i]; @@ -44,6 +43,9 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp + printf("timestamp = %d\n",timestamp); + int staked_era = STAKED_era(timestamp); + printf("ERA = %d \n", ); if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From 9cdde9ca1257cbab6801beae2eae86ed2f24b88e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 21:53:00 +0800 Subject: [PATCH 117/951] oops --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index f4ba4dfe7..3811ccb8f 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -45,7 +45,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) // We need to create auth_STAKED dynamically here based on timestamp printf("timestamp = %d\n",timestamp); int staked_era = STAKED_era(timestamp); - printf("ERA = %d \n", ); + printf("ERA = %d \n",staked_era); if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From bb5402c9a9199db1ea64b7931e50eb2965445f02 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 22:10:37 +0800 Subject: [PATCH 118/951] add eras for cross chain auth? --- src/crosschain_authority.cpp | 2 ++ src/notarisationdb.cpp | 42 +++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 8dc8fc77f..ed7457e23 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,6 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } +/* const CrosschainAuthority auth_STAKED = [&](){ CrosschainAuthority auth; auth.requiredSigs = (num_notaries_STAKED / 5); @@ -62,3 +63,4 @@ const CrosschainAuthority auth_STAKED = [&](){ sscanf(notaries_STAKED[n][1]+(i*2), "%2hhx", auth.notaries[n]+i); return auth; }(); +*/ diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 3811ccb8f..3c5234089 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -19,7 +19,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) { EvalRef eval; NotarisationsInBlock vNotarisations; - //CrosschainAuthority auth_STAKED; + CrosschainAuthority auth_STAKED; int timestamp = block.nTime; for (unsigned int i = 0; i < block.vtx.size(); i++) { @@ -43,9 +43,45 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp - printf("timestamp = %d\n",timestamp); int staked_era = STAKED_era(timestamp); - printf("ERA = %d \n",staked_era); + printf("ERA.(%d) \n",staked_era); + if (staked_era == 0) + { + // era 0 + auth_STAKED.requiredSigs = (num_notaries_STAKED / 5); + auth_STAKED.size = num_notaries_STAKED; + for (int n=0; n 3) { + printf("Invalid ERA.(%d), this should not happen",staked_era); + continue; + } + } if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From 3ae25942127ee7a1cfd8548c8bdba5adc2e0b208 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 22:13:38 +0800 Subject: [PATCH 119/951] } --- src/notarisationdb.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 3c5234089..685440d1a 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -81,7 +81,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("Invalid ERA.(%d), this should not happen",staked_era); continue; } - } if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); From 475e8bc5cb8c163cfa6b447af5321b759d9da6e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:22:38 +0800 Subject: [PATCH 120/951] add era gap, and change to start at era 1 instead of 0. --- src/komodo_notary.h | 41 ++++++++++++++++----------- src/notaries_staked.cpp | 61 +++++++++++++++++++++-------------------- src/notaries_staked.h | 14 ++++++---- src/notarisationdb.cpp | 20 ++++++++------ 4 files changed, 76 insertions(+), 60 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1b572b17c..3dc0c05f3 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -206,8 +206,9 @@ const char *Notaries_elected1[][2] = int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys[64][33],staked_pubkeys1[64][33],didstaked,didstaked1; static int32_t ns,ns1; - static uint8_t staked_pubkeys2[64][33],staked_pubkeys3[64][33],didstaked2,didstaked3; static int32_t ns2,ns3; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; + static uint8_t null_pubkeys[64][33]; int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -250,23 +251,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } } else - { // here we can activate our pubkeys. + { // here we can activate our pubkeys for STAKED chains by era. if (timestamp != 0) { staked_era = STAKED_era(timestamp); - if (staked_era == 0) - { - if (didstaked == 0) - { - ns = num_notaries_STAKED; - for (i=0; i -// Era 0 set of pubkeys -const char *notaries_STAKED[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED = (sizeof(notaries_STAKED)/sizeof(*notaries_STAKED)); - // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = { @@ -98,6 +74,30 @@ const char *notaries_STAKED3[][2] = int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); +// Era 4 set of pubkeys +const char *notaries_STAKED4[][2] = +{ + {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x + {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg + {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 + {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ + {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 + {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev + {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 + {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL + {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu + {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx + {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 + {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s +}; + +int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); + int is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) @@ -108,13 +108,16 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int era; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP) - era = 0; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 && timestamp >= STAKED_NOTARIES_TIMESTAMP) + if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 era = 1; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= STAKED_NOTARIES_TIMESTAMP1) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) era = 2; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= STAKED_NOTARIES_TIMESTAMP2) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + era = 4; + else + era = 0; + // if we are in a gap, return era 0, so any notarizations submitted are invalid. return(era); } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index d0df3906c..6c51a0050 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,13 +2,12 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED -static const int STAKED_NOTARIES_TIMESTAMP = 1537780949; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537791749; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537802549; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537813349; +static const int STAKED_ERA_GAP = 777; -extern const char *notaries_STAKED[][2]; -extern int num_notaries_STAKED; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537780949; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537791749; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537802549; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537813349; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; @@ -19,6 +18,9 @@ extern int num_notaries_STAKED2; extern const char *notaries_STAKED3[][2]; extern int num_notaries_STAKED3; +extern const char *notaries_STAKED4[][2]; +extern int num_notaries_STAKED4; + int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 685440d1a..9f2610feb 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -47,12 +47,9 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { - // era 0 - auth_STAKED.requiredSigs = (num_notaries_STAKED / 5); - auth_STAKED.size = num_notaries_STAKED; - for (int n=0; n 3) { - printf("Invalid ERA.(%d), this should not happen",staked_era); - continue; + } else if (staked_era == 4) + { + // era 4 + auth_STAKED.requiredSigs = (num_notaries_STAKED4 / 5); + auth_STAKED.size = num_notaries_STAKED4; + for (int n=0; n Date: Mon, 24 Sep 2018 23:25:33 +0800 Subject: [PATCH 121/951] ) --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 2c45b5dbd..f7d64a168 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -108,7 +108,7 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int era; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP1 + if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) era = 2; From 595f3d7a5fbb7efd47d6e1c5d68eb4b1ed29e769 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:27:45 +0800 Subject: [PATCH 122/951] fix pointless print --- src/notarisationdb.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 9f2610feb..4e0be704a 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -27,9 +27,6 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) NotarisationData data; bool parsed = ParseNotarisationOpReturn(tx, data); - - printf("Parsed notarisation data for %s \n",data.symbol); - if (!parsed) data = NotarisationData(); if (strlen(data.symbol) == 0) continue; From 01b6ef666a5da230a6ab73ade08c052ac7e83d9c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:46:08 +0800 Subject: [PATCH 123/951] add check for num vins over 2 for all AC --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d1587fbb4..3fef07475 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized. { static FILE *signedfp; if ( signedfp == 0 ) From 6368a83fe3c921581dd20fb32ac518515f938bec Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 24 Sep 2018 23:51:38 +0800 Subject: [PATCH 124/951] retest gap --- src/komodo.h | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3fef07475..ead20f034 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized. + if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized.u { static FILE *signedfp; if ( signedfp == 0 ) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 6c51a0050..aab392301 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1537780949; static const int STAKED_NOTARIES_TIMESTAMP2 = 1537791749; static const int STAKED_NOTARIES_TIMESTAMP3 = 1537802549; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537813349; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537805431; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From b60948261bf96b7acfd3a9d83795987811583e3a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 00:03:00 +0800 Subject: [PATCH 125/951] reset eras, try from reqync --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index aab392301..f1af9595a 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -4,10 +4,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537780949; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537791749; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537802549; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537805431; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537807474; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537818274; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537839874; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 2cf2e5f83ed27dcf45b1b98d57683819b7b93f49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 01:17:49 +0800 Subject: [PATCH 126/951] try to zero array of pubkeys --- src/komodo.h | 2 +- src/komodo_notary.h | 18 +++++++++--------- src/notarisationdb.cpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ead20f034..d8376d15c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && numvins >= 2) // check numvins, because on STAKED during ERA GAP, it counts every TX as notarized.u + if ( ASSETCHAINS_SYMBOL[0] != 0) { static FILE *signedfp; if ( signedfp == 0 ) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3dc0c05f3..352316e77 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -208,7 +208,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33]; + static uint8_t null_pubkeys[64][33] = {0}; int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -263,7 +263,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam for (i=0; i Date: Tue, 25 Sep 2018 10:16:05 +0800 Subject: [PATCH 127/951] that didnt work, try another way --- src/komodo.h | 5 ++++- src/komodo_notary.h | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d8376d15c..3c708989f 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,6 +831,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) != 0)) + printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); + continue; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; @@ -857,7 +860,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5)) ) + numvalid > (numnotaries/5))) { if ( ASSETCHAINS_SYMBOL[0] != 0) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 352316e77..de343e184 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -305,12 +305,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam return(ns4); } else if (staked_era == 0) { - // this means we are in a gap, so we set the array of pubkeys to zero, so all notarizations are invalid. + // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. for (i=0; i<1; i++) decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); - printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we ignored it.\n",ASSETCHAINS_SYMBOL); + printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); memcpy(pubkeys,null_pubkeys,64 * 33); - return(2); + return(64); } } } From 2e82dcdf8efccdbc3c2c3787f0d1b91276ed4cd2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 10:19:27 +0800 Subject: [PATCH 128/951] change eras --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index f1af9595a..5545f8714 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -4,9 +4,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537807474; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537818274; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537839874; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537839874; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537843474; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537847074; static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; extern const char *notaries_STAKED1[][2]; From 582b359c15385428800f7eb75661510d5690e3f7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 10:24:15 +0800 Subject: [PATCH 129/951] == 0 --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 3c708989f..7c927a3d8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,7 +831,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) != 0)) + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; txhash = block.vtx[i].GetHash(); From 3e86777927d5bf04a5064248659ca11eb2994f3d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 13:49:15 +0800 Subject: [PATCH 130/951] try move crosschain auth to a function, and clean up code a bit. --- src/crosschain_authority.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ed7457e23..6c8df2219 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,6 +53,15 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen,int num_notaries){ + CrosschainAuthority auth; + auth.requiredSigs = (num_notaries / 5); + auth.size = num_notaries; + for (int n=0; n Date: Tue, 25 Sep 2018 14:16:39 +0800 Subject: [PATCH 131/951] timstaps --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 5545f8714..5d2450f0b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -4,10 +4,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537839874; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537843474; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537847074; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537859688; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537863288; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537866888; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537870488; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 562d0132f7a532a8c1c1ce78707fe58e23ce803c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 14:20:21 +0800 Subject: [PATCH 132/951] test --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 6c8df2219..be54f2a43 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,7 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen,int num_notaries){ +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ CrosschainAuthority auth; auth.requiredSigs = (num_notaries / 5); auth.size = num_notaries; From 84f0f23626ec988d8726b688816fdc9ee95fbdf0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 14:25:27 +0800 Subject: [PATCH 133/951] try call function --- src/notarisationdb.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index fd2d9cac0..1867aa748 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -50,11 +50,14 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (staked_era == 1) { // era 1 + auth_STAKED = auth_STAKED_chosen(notaries_STAKED,num_notaries_STAKED); + /* auth_STAKED.requiredSigs = (num_notaries_STAKED1 / 5); auth_STAKED.size = num_notaries_STAKED1; for (int n=0; n Date: Tue, 25 Sep 2018 14:27:08 +0800 Subject: [PATCH 134/951] 1 --- src/notarisationdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 1867aa748..be1ae5dfa 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -50,7 +50,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (staked_era == 1) { // era 1 - auth_STAKED = auth_STAKED_chosen(notaries_STAKED,num_notaries_STAKED); + auth_STAKED = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1); /* auth_STAKED.requiredSigs = (num_notaries_STAKED1 / 5); auth_STAKED.size = num_notaries_STAKED1; From f16893312fe10e00eec9f88fd9b07eb1a6a346a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 14:29:22 +0800 Subject: [PATCH 135/951] try that --- src/crosschain.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain.h b/src/crosschain.h index 65be53f92..75c0b2e9f 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -13,7 +13,7 @@ typedef struct CrosschainAuthority { size_t requiredSigs; } CrosschainAuthority; -extern const CrosschainAuthority auth_STAKED; +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); int GetSymbolAuthority(const char* symbol); bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth); From 07f90f985292e2991ad1e0c5db0202b34475c27e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 15:17:51 +0800 Subject: [PATCH 136/951] move cross chain choose to staked.cpp --- src/crosschain.h | 2 -- src/crosschain_authority.cpp | 10 +--------- src/notaries_staked.cpp | 11 +++++++++++ src/notaries_staked.h | 3 +++ src/notarisationdb.cpp | 7 ------- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/crosschain.h b/src/crosschain.h index 75c0b2e9f..29b6bec4b 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -13,8 +13,6 @@ typedef struct CrosschainAuthority { size_t requiredSigs; } CrosschainAuthority; -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); - int GetSymbolAuthority(const char* symbol); bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth); diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index be54f2a43..ef09c5e00 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -53,15 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) return true; } -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ - CrosschainAuthority auth; - auth.requiredSigs = (num_notaries / 5); - auth.size = num_notaries; - for (int n=0; n // Era 1 set of pubkeys @@ -121,3 +122,13 @@ int STAKED_era(int timestamp) // if we are in a gap, return era 0, so any notarizations submitted are invalid. return(era); } + +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ + CrosschainAuthority auth; + auth.requiredSigs = (num_notaries / 5); + auth.size = num_notaries; + for (int n=0; n Date: Tue, 25 Sep 2018 15:19:21 +0800 Subject: [PATCH 137/951] opps --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index f6139cc98..375077cac 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -24,7 +24,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); -CrosschainAuthority Choose_auth_STAKED(staked_era) +//CrosschainAuthority Choose_auth_STAKED(staked_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); #endif From a2d3bd9f849129a37d0d85820d2211d52a24d257 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 15:21:04 +0800 Subject: [PATCH 138/951] try --- src/notaries_staked.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 375077cac..c5ffe5219 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,6 +2,8 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED +#include "crosschain.h" + static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1537859688; From 211f57fb452943fe44ece0be3f6a513a52c3c942 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 15:40:44 +0800 Subject: [PATCH 139/951] tidy up --- src/notaries_staked.cpp | 27 +++++++++++++++++++++++---- src/notaries_staked.h | 2 +- src/notarisationdb.cpp | 38 ++++++-------------------------------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d2cc0bafb..489a9ea78 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -115,15 +115,34 @@ int STAKED_era(int timestamp) era = 2; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; else era = 0; - // if we are in a gap, return era 0, so any notarizations submitted are invalid. + // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(era); -} +}; -CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){ +CrosschainAuthority Choose_auth_STAKED(int chosen_era) { + CrosschainAuthority auth; + switch (chosen_era) { + case 1: + auth = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1); + break; + case 2: + auth = auth_STAKED_chosen(notaries_STAKED2,num_notaries_STAKED2); + break; + case 3: + auth = auth_STAKED_chosen(notaries_STAKED3,num_notaries_STAKED3); + break; + case 4: + auth = auth_STAKED_chosen(notaries_STAKED4,num_notaries_STAKED4); + break; + } + return(auth); +}; + +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries) { CrosschainAuthority auth; auth.requiredSigs = (num_notaries / 5); auth.size = num_notaries; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index c5ffe5219..3776c6828 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -26,7 +26,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); -//CrosschainAuthority Choose_auth_STAKED(staked_era); +CrosschainAuthority Choose_auth_STAKED(int chosen_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); #endif diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index acd1d2287..68c00546b 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -31,50 +31,24 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) if (strlen(data.symbol) == 0) continue; - printf("Checked notarisation data for %s \n",data.symbol); + //printf("Checked notarisation data for %s \n",data.symbol); int authority = GetSymbolAuthority(data.symbol); if (authority == CROSSCHAIN_KOMODO) { if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime)) continue; - printf("Authorised notarisation data for %s \n",data.symbol); + //printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int staked_era = STAKED_era(timestamp); printf("ERA.(%d) \n",staked_era); - if (staked_era == 0) - { + if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; - } else if (staked_era == 1) - { - // era 1 - auth_STAKED = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1); - } else if (staked_era == 2) - { - // era 2 - auth_STAKED.requiredSigs = (num_notaries_STAKED2 / 5); - auth_STAKED.size = num_notaries_STAKED2; - for (int n=0; n Date: Tue, 25 Sep 2018 15:41:55 +0800 Subject: [PATCH 140/951] ) --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 489a9ea78..9a91b9d84 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -115,7 +115,7 @@ int STAKED_era(int timestamp) era = 2; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; - else if timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if (timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; else era = 0; From 1a948db4fda982931c763e62b847d3a54ab35a7e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 16:38:39 +0800 Subject: [PATCH 141/951] who knows --- src/crosschain_authority.cpp | 4 ++-- src/komodo_notary.h | 2 +- src/notaries_staked.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index ef09c5e00..8116b2887 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -8,10 +8,10 @@ int GetSymbolAuthority(const char* symbol) if (strncmp(symbol, "TXSCL", 5) == 0) return CROSSCHAIN_TXSCL; if (is_STAKED(symbol) != 0) { - printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); + //printf("RETURNED CROSSCHAIN STAKED AS TRUE\n"); return CROSSCHAIN_STAKED; } - printf("RETURNED CROSSCHAIN KOMODO AS TRUE\n"); + //printf("RETURNED CROSSCHAIN KOMODO AS TRUE\n"); return CROSSCHAIN_KOMODO; } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index de343e184..4f5f7aea7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -305,7 +305,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam return(ns4); } else if (staked_era == 0) { - // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. + // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell, fix here welcome. for (i=0; i<1; i++) decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 3776c6828..c87f27f98 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537859688; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537863288; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537866888; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537870488; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537868073; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537871673; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537875273; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537878873; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 75979d037a877904965ae852a012d6713c2ad970 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 17:27:10 +0800 Subject: [PATCH 142/951] increse era wtf happened there lol --- src/notaries_staked.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 5545f8714..0a722f512 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -2,12 +2,14 @@ #ifndef NOTARIES_STAKED #define NOTARIES_STAKED +#include "crosschain.h" + static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537839874; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537843474; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537847074; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537850674; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537871673; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537875273; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537878873; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537895873; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; @@ -24,4 +26,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); +CrosschainAuthority Choose_auth_STAKED(int chosen_era); +CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); + #endif From 3aee2fae5e4125627b692d013d119a9284445082 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Tue, 25 Sep 2018 17:38:18 +0800 Subject: [PATCH 143/951] hopefully fixed that lol --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9a91b9d84..e2170ba94 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -115,7 +115,7 @@ int STAKED_era(int timestamp) era = 2; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) era = 3; - else if (timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; else era = 0; From 15fe2fb59dada5d57d36b4413be7f271fb44aa90 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 17:50:51 +0800 Subject: [PATCH 144/951] I think this might be it --- src/komodo_notary.h | 4 ++-- src/notaries_staked.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4f5f7aea7..a4e673b79 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -306,8 +306,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } else if (staked_era == 0) { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell, fix here welcome. - for (i=0; i<1; i++) - decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); + //for (i=0; i<1; i++) + // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); memcpy(pubkeys,null_pubkeys,64 * 33); return(64); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index c87f27f98..03ed5f306 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537868073; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537871673; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537875273; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537878873; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537872577; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537876177; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537879777; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537883377; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 8abbd8e183bb4b431f0488e96fb93bf63fc9ab55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 17:56:49 +0800 Subject: [PATCH 145/951] meh --- src/komodo.h | 4 ++-- src/komodo_notary.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7c927a3d8..66374f6fe 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,9 +858,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || + if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5))) + numvalid > (numnotaries/5) ) { if ( ASSETCHAINS_SYMBOL[0] != 0) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index a4e673b79..84d0cbed1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -308,9 +308,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell, fix here welcome. //for (i=0; i<1; i++) // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); - printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); - memcpy(pubkeys,null_pubkeys,64 * 33); - return(64); + printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); + //memcpy(pubkeys,null_pubkeys,64 * 33); + return(0); } } } From 7422645f78c5c4d7998861e4f7fb5fb4a02a4fa0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:08:30 +0800 Subject: [PATCH 146/951] add print for numvalid --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index 7c927a3d8..6fc219c32 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -858,6 +858,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); + printf("numvalid.%d \n",numvalid); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5))) From b9673a33a8a62cc443ff840255cdce87989b65af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:14:13 +0800 Subject: [PATCH 147/951] more rpints --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index 6fc219c32..b0056f6c7 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -810,6 +810,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); + printf("numnotaries.%d\n",numnotaries); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; From ad98d05ba1938404adf32223fee9e82fd1e0265f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:26:47 +0800 Subject: [PATCH 148/951] more prints --- src/komodo.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b0056f6c7..e7ea104aa 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -810,7 +810,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); - printf("numnotaries.%d\n",numnotaries); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; @@ -826,8 +825,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->nHeight); + printf("BEFORE pindex != 0 check.\n", ); if ( pindex != 0 ) { + printf("AFTER pindex != 0 check.\n", ); height = pindex->nHeight; txn_count = block.vtx.size(); for (i=0; i 0 ) { @@ -860,9 +862,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } numvalid = bitweight(signedmask); printf("numvalid.%d \n",numvalid); - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || + if (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || - numvalid > (numnotaries/5))) + numvalid > (numnotaries/5)) { if ( ASSETCHAINS_SYMBOL[0] != 0) { From aeeec99a0b3830a23e1e756f652f2caafcbd00cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:28:50 +0800 Subject: [PATCH 149/951] oops --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e7ea104aa..937e1f788 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,10 +825,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->nHeight); - printf("BEFORE pindex != 0 check.\n", ); + printf("BEFORE pindex != 0 check.\n"); if ( pindex != 0 ) { - printf("AFTER pindex != 0 check.\n", ); + printf("AFTER pindex != 0 check.\n"); height = pindex->nHeight; txn_count = block.vtx.size(); for (i=0; i Date: Tue, 25 Sep 2018 18:29:52 +0800 Subject: [PATCH 150/951] opps --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 937e1f788..7d2a75b4e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -845,7 +845,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (j=0; j 0 ) { From 233666172a91564fc01b1c445a4f29bdb13b7e95 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:33:28 +0800 Subject: [PATCH 151/951] maybe this lol --- src/komodo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7d2a75b4e..0425a5002 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,17 +825,17 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->nHeight); - printf("BEFORE pindex != 0 check.\n"); if ( pindex != 0 ) { - printf("AFTER pindex != 0 check.\n"); height = pindex->nHeight; txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) == 0)) + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) { printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; + } + printf("we working now?\n"); txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; From b3cb6ec56de629090cb986902b8bc6c315d537e0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:37:02 +0800 Subject: [PATCH 152/951] fix --- src/komodo.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0425a5002..c4200a1e8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -835,7 +835,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } - printf("we working now?\n"); txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; @@ -845,7 +844,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (j=0; j 0 ) { From 5b1b6887ecdec3f463d4318d1bc1176d828c02c4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:41:08 +0800 Subject: [PATCH 153/951] good --- src/komodo.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index c4200a1e8..cc2a5dd3d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -859,7 +859,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); - printf("numvalid.%d \n",numvalid); if (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) From 4becb91f8e90fca4e31becf2e683e6f99e99b53d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:42:30 +0800 Subject: [PATCH 154/951] fix silly mistake --- src/komodo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 66374f6fe..fb40c1e09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,9 +831,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) == 0)) + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) { printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; + } txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; From 6ecc2a17bf75b6847dcd2a0ea99c443add9a944d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 25 Sep 2018 18:53:32 +0800 Subject: [PATCH 155/951] new timestamps try again lol --- src/komodo_notary.h | 4 ++-- src/notaries_staked.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 84d0cbed1..1e764a603 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -309,8 +309,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam //for (i=0; i<1; i++) // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - //memcpy(pubkeys,null_pubkeys,64 * 33); - return(0); + memcpy(pubkeys,null_pubkeys,64 * 33); + return(64); } } } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 03ed5f306..12aae29d3 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537872577; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537876177; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537879777; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537883377; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1537876325; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537879925; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1537883525; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1537983525; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 2e25cdf0a4958f156d62eaf6105dafa0402c7e32 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Wed, 26 Sep 2018 02:26:48 +0000 Subject: [PATCH 156/951] add STAKEDED --- src/assetchains.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/assetchains.json b/src/assetchains.json index 9faa54f16..00c491935 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -52,5 +52,15 @@ "195.201.137.5", "195.201.20.230" ] + }, + { + "ac_name": "STAKEDED", + "ac_supply": "1072452", + "ac_reward" : "1000000000", + "ac_cc": "667", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] } ] From dcffb1c796c151fe528a3c600c6d3be68bb8b11a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 11:30:31 +0800 Subject: [PATCH 157/951] change ERA's --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 12aae29d3..526ad5f9b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1537876325; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537879925; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1537883525; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1537983525; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1537983525; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1538083525; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1548083525; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From dee9067adc99f3d677417bf40aa5b83c770522e9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 14:53:41 +0800 Subject: [PATCH 158/951] modified: src/komodo_notary.h --- src/komodo_notary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index de343e184..0365a1faf 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -306,9 +306,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } else if (staked_era == 0) { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. - for (i=0; i<1; i++) - decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); - printf("%s IS A STAKED CHAIN and is in an ERA GAP, so we zeroed the pubkeys.\n",ASSETCHAINS_SYMBOL); + //for (i=0; i<1; i++) + // decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]); + printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); memcpy(pubkeys,null_pubkeys,64 * 33); return(64); } From 79171fa13b55fcb4445e5dbb5a0255bf8489839b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 15:03:55 +0800 Subject: [PATCH 159/951] try to add error check if export/import chain is the same --- src/rpccrosschain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 09f1b21d1..baa4d4984 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -50,7 +50,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp) UniValue crosschainproof(const UniValue& params, bool fHelp) { - + } @@ -90,7 +90,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; } @@ -169,6 +169,9 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); + if (strncmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) + throw runtime_error("cant send a coin to the same chain"); + CAmount burnAmount = AmountFromValue(params[2]); if (burnAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export"); @@ -220,8 +223,8 @@ UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp) CTransaction burnTx; if (!E_UNMARSHAL(txData, ss >> burnTx)) throw runtime_error("Couldn't parse burnTx"); - - + + vector payouts; if (!E_UNMARSHAL(ParseHexV(params[1], "argument 2"), ss >> payouts)) throw runtime_error("Couldn't parse payouts"); @@ -240,7 +243,7 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) throw runtime_error("migrate_completeimporttransaction importTx\n\n" "Takes a cross chain import tx with proof generated on assetchain " "and extends proof to target chain proof root"); - + if (ASSETCHAINS_SYMBOL[0] != 0) throw runtime_error("Must be called on KMD"); @@ -294,7 +297,7 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) if (height == 0) { height = chainActive.Height(); } - + Notarisation nota; int matchedHeight = ScanNotarisationsDB(height, symbol, limit, nota); if (!matchedHeight) return NullUniValue; From 054eb923f9c4266f085edd04e47c1a08e5ebee55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 15:56:38 +0800 Subject: [PATCH 160/951] n --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index baa4d4984..15e7a0393 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - if (strncmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) throw runtime_error("cant send a coin to the same chain"); CAmount burnAmount = AmountFromValue(params[2]); From 7d7b68dc6fe6b42a3207474055ea5929021e5db1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 15:58:23 +0800 Subject: [PATCH 161/951] maybe thos willl work --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 15e7a0393..eaa059ec8 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol) == 0) + if (ASSETCHAINS_SYMBOL == targetSymbol) throw runtime_error("cant send a coin to the same chain"); CAmount burnAmount = AmountFromValue(params[2]); From 66874998de55e44ffbcda4c750b05fb2ee99466d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 16:02:36 +0800 Subject: [PATCH 162/951] or this --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index eaa059ec8..52df5efaf 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - if (ASSETCHAINS_SYMBOL == targetSymbol) + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); CAmount burnAmount = AmountFromValue(params[2]); From 3e94e0a37bd3e0b1980d7f6c4328d47645e08e8b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 16:59:52 +0800 Subject: [PATCH 163/951] hmmm --- src/rpccrosschain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 52df5efaf..83554d1f6 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,6 +169,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); + printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()) + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From dc43d728486b5b5b550b23204fbddcb0372877be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:04:02 +0800 Subject: [PATCH 164/951] ; --- src/rpccrosschain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 83554d1f6..e991de71e 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,8 +169,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()) - + printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From 42df9ee0602ef7d63716bb7c9da9de8c87749289 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:19:17 +0800 Subject: [PATCH 165/951] try this --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index e991de71e..f92632c8b 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,7 +169,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - printf("source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); + fprintf(stderr,"source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From 1a0749e538df926521b6eeda6820e4d15d77410c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:24:06 +0800 Subject: [PATCH 166/951] remove non wokring print --- src/rpccrosschain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index f92632c8b..52df5efaf 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -169,8 +169,6 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); - fprintf(stderr,"source.%s target.%s",ASSETCHAINS_SYMBOL,targetSymbol.c_str()); - if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); From 396d4e42099cdad584573935e8d7c8fad7635eb2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 26 Sep 2018 17:25:02 +0800 Subject: [PATCH 167/951] Add error for sending coin to source chain --- src/rpccrosschain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 09f1b21d1..52df5efaf 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -50,7 +50,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp) UniValue crosschainproof(const UniValue& params, bool fHelp) { - + } @@ -90,7 +90,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; } @@ -169,6 +169,9 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (targetSymbol.size() == 0 || targetSymbol.size() > 32) throw runtime_error("targetSymbol length must be >0 and <=32"); + if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) + throw runtime_error("cant send a coin to the same chain"); + CAmount burnAmount = AmountFromValue(params[2]); if (burnAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export"); @@ -220,8 +223,8 @@ UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp) CTransaction burnTx; if (!E_UNMARSHAL(txData, ss >> burnTx)) throw runtime_error("Couldn't parse burnTx"); - - + + vector payouts; if (!E_UNMARSHAL(ParseHexV(params[1], "argument 2"), ss >> payouts)) throw runtime_error("Couldn't parse payouts"); @@ -240,7 +243,7 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) throw runtime_error("migrate_completeimporttransaction importTx\n\n" "Takes a cross chain import tx with proof generated on assetchain " "and extends proof to target chain proof root"); - + if (ASSETCHAINS_SYMBOL[0] != 0) throw runtime_error("Must be called on KMD"); @@ -294,7 +297,7 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) if (height == 0) { height = chainActive.Height(); } - + Notarisation nota; int matchedHeight = ScanNotarisationsDB(height, symbol, limit, nota); if (!matchedHeight) return NullUniValue; From e5eda68dbd79448bef5a9ec3700014ff585a6dbe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 18:00:28 +0800 Subject: [PATCH 168/951] remove all prints that are not momom that we normally see --- src/komodo.h | 18 +++++++++--------- src/komodo_bitcoind.h | 34 +++++++++++++++++----------------- src/notarisationdb.cpp | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index fb40c1e09..dcb5f63de 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); + //printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); @@ -856,7 +856,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%02x",scriptPubKey[k]); printf(" scriptPubKey doesnt match any notary vini.%d of %d\n",j,numvins); } - } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); + } //else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || @@ -880,7 +880,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + //printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; } @@ -917,20 +917,20 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { for (k=0; k 2 ) { @@ -959,8 +959,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); - printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); - } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); + //printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); + } //else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 13501d2a9..4a2a9fc41 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -169,7 +169,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -198,7 +198,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -238,7 +238,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ @@ -1303,24 +1303,24 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he { n++; percPoS++; - if ( ASSETCHAINS_STAKED < 100 ) - fprintf(stderr,"0"); + //if ( ASSETCHAINS_STAKED < 100 ) + // fprintf(stderr,"0"); } else { - if ( ASSETCHAINS_STAKED < 100 ) - fprintf(stderr,"1"); + //if ( ASSETCHAINS_STAKED < 100 ) + // fprintf(stderr,"1"); sum += UintToArith256(pindex->GetBlockHash()); m++; } } - if ( ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) - fprintf(stderr," %d, ",percPoS); + //if ( ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) + // fprintf(stderr," %d, ",percPoS); } if ( m+n < 100 ) percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; if ( ASSETCHAINS_STAKED < 100 ) - fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); + //fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; if ( m > 0 ) { @@ -1337,7 +1337,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( oldflag != 0 ) bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); else bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); - if ( ASSETCHAINS_STAKED < 100 ) + /*if ( ASSETCHAINS_STAKED < 100 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1348,7 +1348,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he 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 { @@ -1367,7 +1367,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( bnTarget < ave ) bnTarget = ave; } - if ( 1 ) + /*if ( 1 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1378,7 +1378,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he 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); diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 68c00546b..426cdb806 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -44,7 +44,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization - printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); + //printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; } else { // pass era slection off to notaries_staked.cpp file @@ -52,12 +52,12 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } if (!CheckTxAuthority(tx, auth_STAKED)) continue; - printf("Authorised notarisation data for %s \n",data.symbol); + //printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - printf("Added notarisation data for %s \n",data.symbol); + //printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); From f0587239fa5fe099f9d6b9b7d3bc004e5fc2aef1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 19:04:24 +0800 Subject: [PATCH 169/951] found more --- src/komodo.h | 16 ++++++++-------- src/notarisationdb.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index dcb5f63de..1846fd25c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -620,8 +620,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr notarized = 1; 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); + //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); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); if ( matched != 0 ) @@ -685,8 +685,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - if ( matched != 0 ) - printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); + //if ( matched != 0 ) + // printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); @@ -706,8 +706,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr 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); + //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); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -733,8 +733,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } } } - } else if ( opretlen != 149 && height > 600000 && matched != 0 ) - printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); + } //else if ( opretlen != 149 && height > 600000 && matched != 0 ) + //printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 426cdb806..df17de2c7 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -41,7 +41,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int staked_era = STAKED_era(timestamp); - printf("ERA.(%d) \n",staked_era); + //printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization //printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); From a5c1bc3360cfcae92204e36d575c25fb77b10233 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 19:50:45 +0800 Subject: [PATCH 170/951] add target to MoMoM print --- src/cc/import.cpp | 4 ++-- src/crosschain.cpp | 2 +- src/komodo_bitcoind.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index cc0c3b61f..dc5eff440 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,11 +79,11 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("IMPORT momom: %s\n", momom.GetHex().data()); + printf("[%s] IMPORT momom: %s\n", targetSymbol,momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) - return Invalid("momom-check-fail"); + return Invalid("momom-check-fai"); } return Valid(); diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 23416c682..335bcc6c8 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,7 +162,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); + printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); // Find index of source MoM in MoMoM int nIndex; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4a2a9fc41..4a354830d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1445,7 +1445,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( isPoS != 2 ) { - fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); + //fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); isPoS = 0; } else From eddc4d53952181123454a5fe991e0290c65c62fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 20:00:40 +0800 Subject: [PATCH 171/951] remove for import, compile angry --- src/cc/import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index dc5eff440..578e6a52b 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,7 +79,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - printf("[%s] IMPORT momom: %s\n", targetSymbol,momom.GetHex().data()); + printf("IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) From 32ed8b04441f1ed1e2419a2691e0822ae8e5b62e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 20:32:37 +0800 Subject: [PATCH 172/951] another one --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4a354830d..5afb549cc 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1453,7 +1453,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { - fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); + //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } From 97a59fc2c62aa2452b79c1abb19951e6e2d0d704 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 20:57:58 +0800 Subject: [PATCH 173/951] fprintf? --- src/cc/import.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 578e6a52b..fd0126ad4 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -78,8 +78,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp uint256 momom, target; if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - - printf("IMPORT momom: %s\n", momom.GetHex().data()); + + fprintf(stderr,"IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) From 985808cbb40f0b8fb5c66e5c3d99579a14bc2d0a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 27 Sep 2018 21:38:00 +0800 Subject: [PATCH 174/951] try print momom to file --- src/cc/import.cpp | 6 +++++- src/crosschain.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index fd0126ad4..1f96a5d29 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -78,8 +78,12 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp uint256 momom, target; if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - + fprintf(stderr,"IMPORT momom: %s\n", momom.GetHex().data()); + FILE * fptr; + fptr = fopen("/home/cc/kmdmomom", "a+"); + fprintf(fptr, "%s\n", momom.GetHex().data()); + fclose(fptr); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 335bcc6c8..137e823ab 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -163,6 +163,10 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ throw std::runtime_error("No MoMs found"); printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); + FILE * fptr; + fptr = fopen("/home/cc/acmomom", "a+"); + fprintf(fptr, "%s\n", MoMoM.GetHex().data()); + fclose(fptr); // Find index of source MoM in MoMoM int nIndex; From 2782c1fb5b9a3afd70a8bb2ec9dd9a968feed195 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 12:31:16 +0800 Subject: [PATCH 175/951] fix error typo --- src/cc/import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 1f96a5d29..b72124735 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -87,7 +87,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) - return Invalid("momom-check-fai"); + return Invalid("momom-check-fail"); } return Valid(); From f56c91238afddd751cd34158f6aa8d2a0748ed42 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 12:49:40 +0800 Subject: [PATCH 176/951] change ac_private pubkeys to use STAKED notaries instead of elected --- src/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4fabaeb29..5a4d5c152 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,8 @@ #include "wallet/asyncrpcoperation_sendmany.h" #include "wallet/asyncrpcoperation_shieldcoinbase.h" +#include "notaries_staked.h" + #include #include @@ -1045,21 +1047,21 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + static int32_t didinit; static char notaryaddrs[sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) + 1][64]; int32_t i; if ( didinit == 0 ) { uint8_t pubkey33[33]; - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) { - if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) - decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + if ( i < sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) ) + decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); } didinit = 1; } - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); return(0); From c6fb1e911760c72a40447342c7da24937d1c9580 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 13:00:09 +0800 Subject: [PATCH 177/951] try this instead --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5a4d5c152..90dac54aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1047,21 +1047,21 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - static int32_t didinit; static char notaryaddrs[sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) + 1][64]; + static int32_t didinit; static char notaryaddrs[num_notaries_STAKED1 + 1][64]; int32_t i; if ( didinit == 0 ) { uint8_t pubkey33[33]; - for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) + for (i=0; i<=num_notaries_STAKED1; i++) { - if ( i < sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1) ) + if ( i < num_notaries_STAKED1 ) decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); } didinit = 1; } - for (i=0; i<=sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1); i++) + for (i=0; i<=num_notaries_STAKED1; i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); return(0); From d5f8644985e50469a3efebe57c4033dfcef3551a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 13:07:38 +0800 Subject: [PATCH 178/951] change array to non static and remove init --- src/main.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 90dac54aa..b3e31681c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1047,20 +1047,16 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - static int32_t didinit; static char notaryaddrs[num_notaries_STAKED1 + 1][64]; + char notaryaddrs[num_notaries_STAKED1 + 1][64]; int32_t i; - if ( didinit == 0 ) - { - uint8_t pubkey33[33]; - for (i=0; i<=num_notaries_STAKED1; i++) - { - if ( i < num_notaries_STAKED1 ) - decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - didinit = 1; - } + uint8_t pubkey33[33]; + for (i=0; i<=num_notaries_STAKED1; i++) + { + if ( i < num_notaries_STAKED1 ) + decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } for (i=0; i<=num_notaries_STAKED1; i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); From 220df8ac00ab64f44d3acc6708e68d63a3744353 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Sep 2018 13:12:33 +0800 Subject: [PATCH 179/951] hard code number of notaries --- src/main.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b3e31681c..f432eca29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1047,17 +1047,21 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - char notaryaddrs[num_notaries_STAKED1 + 1][64]; + static int32_t didinit; static char notaryaddrs[17 + 1][64]; int32_t i; - uint8_t pubkey33[33]; - for (i=0; i<=num_notaries_STAKED1; i++) - { - if ( i < num_notaries_STAKED1 ) - decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - for (i=0; i<=num_notaries_STAKED1; i++) + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=17; i++) + { + if ( i < 17 ) + decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; + } + for (i=0; i<=17; i++) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) return(1); return(0); From 03327034480ce73196a49e1df10a447804e36a76 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Sun, 30 Sep 2018 11:32:39 +0000 Subject: [PATCH 180/951] add ac_priv chains --- src/assetchains.json | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 00c491935..4b3247d48 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -62,5 +62,27 @@ "195.201.137.5", "195.201.20.230" ] - } + }, + { + "ac_name": "STAKEDPRIV", + "ac_supply": "1000000", + "ac_reward" : "10000000000", + "ac_private": "1", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + }, + { + "ac_name": "STAKEDCCP", + "ac_supply": "1000000", + "ac_reward" : "10000000000", + "ac_private": "1", + "ac_cc": "667", + "addnode": [ + "195.201.137.5", + "195.201.20.230" + ] + } +] ] From 644ae923c06f8334c88aca48d55ccd2a76d896d1 Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Mon, 1 Oct 2018 08:09:21 -0400 Subject: [PATCH 181/951] derp --- src/assetchains.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 4b3247d48..aa7c8bfb4 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -85,4 +85,3 @@ ] } ] -] From 12e14f15a0972a866975b8c089a5169d36f877d1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:13:35 +0800 Subject: [PATCH 182/951] add some prints to see where values are --- src/wallet/rpcwallet.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 055352973..e5433d4ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -398,7 +398,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Parse Zcash address CScript scriptPubKey = GetScriptForDestination(address); - + // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; @@ -4133,7 +4133,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) strDisabledMsg = "\nWARNING: z_mergetoaddress is DISABLED but can be enabled as an experimental feature.\n"; } - if (fHelp || params.size() < 2 || params.size() > 6) + if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" + strDisabledMsg + @@ -4165,6 +4165,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" + "6. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" "\nResult:\n" "{\n" " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" @@ -4295,6 +4296,16 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + if (params.size() > 6) { + maximum_utxo_size = params[6].get_int() + printf("maximum utxo size = %d\n", maximum_utxo_size); + if (maximum_utxo_size < 10) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + } + } else { + maximum_utxo_size = 0; + } + MergeToAddressRecipient recipient(destaddress, memo); // Prepare to get UTXOs and notes @@ -4343,6 +4354,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; + if (maximum_utxo_size != 0) { + printf("maximum utxo size = %d \n", maximum_utxo_size); + printf("nValue = %s\n", nValue); + } + if (!maxedOutUTXOsFlag) { CBitcoinAddress ba(address); size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; @@ -5669,7 +5685,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) UniValue oraclessamples(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; + UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); if ( ensure_CCrequirements() < 0 ) From d411178c7e0fa3df85e47776e1c0b63112a0207f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:18:05 +0800 Subject: [PATCH 183/951] syntax --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e5433d4ff..b1261c695 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,6 +4296,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + std::int maximum_utxo_size if (params.size() > 6) { maximum_utxo_size = params[6].get_int() printf("maximum utxo size = %d\n", maximum_utxo_size); @@ -4356,7 +4357,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %d \n", maximum_utxo_size); - printf("nValue = %s\n", nValue); + printf("nValue = %lld\n", nValue); } if (!maxedOutUTXOsFlag) { From 4f1650383a88438d961d4847101ad3ef90f3ccb4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:21:49 +0800 Subject: [PATCH 184/951] test --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b1261c695..e005eec5b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,10 +4296,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - std::int maximum_utxo_size + CAmount maximum_utxo_size if (params.size() > 6) { maximum_utxo_size = params[6].get_int() - printf("maximum utxo size = %d\n", maximum_utxo_size); + printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); } @@ -4357,7 +4357,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %d \n", maximum_utxo_size); - printf("nValue = %lld\n", nValue); + printf("nValue = %ld\n", nValue); } if (!maxedOutUTXOsFlag) { From 57d237b5bc68a88e25c0078b373194dca63152f5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:24:04 +0800 Subject: [PATCH 185/951] ; --- 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 e005eec5b..81383d992 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,7 +4296,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - CAmount maximum_utxo_size + CAmount maximum_utxo_size; if (params.size() > 6) { maximum_utxo_size = params[6].get_int() printf("maximum utxo size = %ld\n", maximum_utxo_size); From 2499a4fef8fa8f846b8fd89edaaf2843917ee115 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:25:17 +0800 Subject: [PATCH 186/951] ld --- 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 81383d992..1cd38bca2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4356,7 +4356,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - printf("maximum utxo size = %d \n", maximum_utxo_size); + printf("maximum utxo size = %ld \n", maximum_utxo_size); printf("nValue = %ld\n", nValue); } From 2b81045e2ba5193127a582e629c808ff49e28f66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:27:58 +0800 Subject: [PATCH 187/951] ; --- 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 1cd38bca2..f407710c7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4298,7 +4298,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 6) { - maximum_utxo_size = params[6].get_int() + maximum_utxo_size = params[6].get_int(); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From 93253d38ea755bca797d8acff08646ba880675db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:43:03 +0800 Subject: [PATCH 188/951] make memo last feild again --- src/wallet/rpcwallet.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f407710c7..01dabc4cc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,8 +4164,9 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" - "6. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" + "\nResult:\n" "{\n" " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" @@ -4283,9 +4284,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - std::string memo; + CAmount maximum_utxo_size; if (params.size() > 5) { - memo = params[5].get_str(); + maximum_utxo_size = params[5].get_int(); + printf("maximum utxo size = %ld\n", maximum_utxo_size); + if (maximum_utxo_size < 10) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + } + } else { + maximum_utxo_size = 0; + } + + std::string memo; + if (params.size() > 6) { + memo = params[6].get_str(); if (!isToZaddr) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr."); } else if (!IsHex(memo)) { @@ -4296,17 +4308,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - CAmount maximum_utxo_size; - if (params.size() > 6) { - maximum_utxo_size = params[6].get_int(); - printf("maximum utxo size = %ld\n", maximum_utxo_size); - if (maximum_utxo_size < 10) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); - } - } else { - maximum_utxo_size = 0; - } - MergeToAddressRecipient recipient(destaddress, memo); // Prepare to get UTXOs and notes From a0c1d43977433cfabf79292d5f12acbc9bc23053 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:48:24 +0800 Subject: [PATCH 189/951] long --- 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 01dabc4cc..f69e9eb4b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4286,7 +4286,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { - maximum_utxo_size = params[5].get_int(); + maximum_utxo_size = params[5].get_real(); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From 4bdd7e26cd5ed9e64c87118bf4eb9992eeab210d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:58:42 +0800 Subject: [PATCH 190/951] try --- 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 f69e9eb4b..b147d4307 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4286,7 +4286,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { - maximum_utxo_size = params[5].get_real(); + maximum_utxo_size = AmountFromValue( params[5] ); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From dfba8357f375f599bf641c09dea73af64f75d04c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:09:36 +0800 Subject: [PATCH 191/951] fingers crossed --- src/wallet/rpcwallet.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b147d4307..e0efa9cb4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,7 +4164,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged.\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4289,7 +4289,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) maximum_utxo_size = AmountFromValue( params[5] ); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 0.00000010."); } } else { maximum_utxo_size = 0; @@ -4358,7 +4358,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %ld \n", maximum_utxo_size); - printf("nValue = %ld\n", nValue); + if (nValue > maximum_utxo_size) { + printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); + continue; + } else { + printf("utxo found under maximum size so we will add it!\n", ); + } } if (!maxedOutUTXOsFlag) { From 743131799fb25db2145a450aa59d1bfb52e224e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:10:53 +0800 Subject: [PATCH 192/951] , --- 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 e0efa9cb4..cb81244ae 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - printf("utxo found under maximum size so we will add it!\n", ); + printf("utxo found under maximum size so we will add it!\n"); } } From cd6fbe09777fbef8a5b6f9a130c3bb71a4f334a9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:25:24 +0800 Subject: [PATCH 193/951] add exeption for iguana utxo --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cb81244ae..a05aed988 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - printf("utxo found under maximum size so we will add it!\n"); + if (out.tx->vout[out.i].scriptPubKey.size() != 35) { + printf("utxo is an iguana utxo so we will ingore it!\n"); + continue; + } + printf("utxo found under maximum size that is not p2pk so we will add it!\n"); } } From 41fddfc0bf860d178a9b5328a4c8c69924cfa91d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:31:05 +0800 Subject: [PATCH 194/951] fix --- 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 a05aed988..def79e51d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4357,12 +4357,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - printf("maximum utxo size = %ld \n", maximum_utxo_size); + //printf("maximum utxo size = %ld \n", maximum_utxo_size); if (nValue > maximum_utxo_size) { printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() != 35) { + if (out.tx->vout[out.i].scriptPubKey.size() = 35) { printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } From 30c320d1f66032ca1e02a505982a0940f362a94e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:32:21 +0800 Subject: [PATCH 195/951] = --- 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 def79e51d..e766e6bf6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() = 35) { + if (out.tx->vout[out.i].scriptPubKey.size() == 35) { printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } From 5d8a1637ae63b3aa38e60e1ac18ac42298462683 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:43:20 +0800 Subject: [PATCH 196/951] remove prints to speed it up --- src/wallet/rpcwallet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e766e6bf6..a429b81ac 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,7 +4164,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4287,7 +4287,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { maximum_utxo_size = AmountFromValue( params[5] ); - printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 0.00000010."); } @@ -4366,7 +4365,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } - printf("utxo found under maximum size that is not p2pk so we will add it!\n"); } } From f882623570959e3566ae0dca500272d4ebdf5de4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:42:14 +0800 Subject: [PATCH 197/951] remove prints and fix utxo counter in wrong place --- src/wallet/rpcwallet.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a429b81ac..641a42f04 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4352,22 +4352,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } - utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - //printf("maximum utxo size = %ld \n", maximum_utxo_size); if (nValue > maximum_utxo_size) { - printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { if (out.tx->vout[out.i].scriptPubKey.size() == 35) { - printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } } } + utxoCounter++; + if (!maxedOutUTXOsFlag) { CBitcoinAddress ba(address); size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; From 478370fd6c3322dc6a2e65960d2ac8ed27d08450 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:52:12 +0800 Subject: [PATCH 198/951] numutxos < 2 instead of 0... cant merge 1 utxo --- 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 641a42f04..7ef43e5db 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4429,7 +4429,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) #endif - if (numUtxos == 0 && numNotes == 0) { + if (numUtxos > 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From 0367b1a6856da6f5176f76ff11f15023d97ca3d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:53:28 +0800 Subject: [PATCH 199/951] < --- 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 7ef43e5db..7de29528f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4429,7 +4429,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) #endif - if (numUtxos > 2 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From b9b7f12d84dad450d80cac7834a81321bfb6e0b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 12 Oct 2018 14:06:26 +0800 Subject: [PATCH 200/951] fix edgcase where eras before current get chosen out of order and prevent later ones being activated. --- src/komodo_notary.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d0ab8c078..a9750369a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -264,6 +264,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam for (i=0; i Date: Tue, 16 Oct 2018 12:58:43 +0800 Subject: [PATCH 201/951] give this a go --- src/komodo_bitcoind.h | 48 +++++++++-------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 6 ++- src/main.cpp | 16 +++++- src/miner.cpp | 117 +++++++++++++++++++++--------------------- src/pow.cpp | 48 +++++++++-------- 6 files changed, 135 insertions(+), 102 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 86ed8f7b3..8bfca7dc4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -169,7 +169,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -198,7 +198,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -238,7 +238,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ +extern int32_t ASSETCHAINS_STREAM; 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; - } + 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; + } + else + { + commission = 10000; } - //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); } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f352b5333..c456d3e44 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index bfd59fd57..50b0e3020 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1561,6 +1561,7 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = GetArg("-ac_decay",0); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); + ASSETCHAINS_STREAM = GetArg("-ac_stream",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) @@ -1589,7 +1590,10 @@ void komodo_args(char *argv0) { ASSETCHAINS_COMMISSION = 0; printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); - } + } else if ( ASSETCHAINS_STREAM != 0) { + ASSETCHAINS_STREAM = 0; + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); + } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); diff --git a/src/main.cpp b/src/main.cpp index 1ff5f8012..39270a0b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1866,6 +1866,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint32_t ASSETCHAINS_MAGIC; +extern int32_t ASSETCHAINS_STREAM; extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; @@ -1895,7 +1896,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { if ( ASSETCHAINS_REWARD == 0 ) return(10000); - else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY ) + else if ( ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )|| ASSETCHAINS_STREAM != 0) return(0); else { @@ -2961,6 +2962,19 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!view.HaveJoinSplitRequirements(tx)) return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); + + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( ASSETCHAINS_STREAM != 0 ) + { + if ( block.vtx.size() == 1 && block.vtx[0].vout.size() == 2 && pindex->nHeight > ASSETCHAINS_MINHEIGHT) + { + return state.DoS(100, error("ConnectBlock(): There are no TX in this block, it is invalid!"), + REJECT_INVALID, "bad-block-no-transactions"); + } + } + } + if (fAddressIndex || fSpentIndex) { for (size_t j = 0; j < tx.vin.size(); j++) { diff --git a/src/miner.cpp b/src/miner.cpp index 874c1b4f8..8fbfcff05 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -64,7 +64,7 @@ public: set setDependsOn; CFeeRate feeRate; double dPriority; - + COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0) { } @@ -78,10 +78,10 @@ typedef boost::tuple TxPriority; class TxPriorityCompare { bool byFee; - + public: TxPriorityCompare(bool _byFee) : byFee(_byFee) { } - + bool operator()(const TxPriority& a, const TxPriority& b) { if (byFee) @@ -106,7 +106,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; @@ -141,27 +141,27 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // -blockversion=N to test forking scenarios if (Params().MineBlocksOnDemand()) pblock->nVersion = GetArg("-blockversion", pblock->nVersion); - + // Add dummy coinbase tx as first transaction pblock->vtx.push_back(CTransaction()); pblocktemplate->vTxFees.push_back(-1); // updated at end pblocktemplate->vTxSigOps.push_back(-1); // updated at end - + // Largest block you're willing to create: unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE); // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize)); - + // How much of the block should be dedicated to high-priority transactions, // included regardless of the fees they pay unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); - + // Minimum block size you want to create; block will be filled with free transactions // until there are no more or the block reaches this size: unsigned int nBlockMinSize = GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE); nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); - + // Collect memory pool transactions into the block CAmount nFees = 0; CBlockIndex* pindexPrev = 0; @@ -174,12 +174,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; - + // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; bool fPrintPriority = GetBoolArg("-printpriority", false); - + // This vector will be sorted into a priority queue: vector vecPriority; vecPriority.reserve(mempool.mapTx.size()); @@ -187,11 +187,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) mi != mempool.mapTx.end(); ++mi) { const CTransaction& tx = mi->GetTx(); - + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) ? nMedianTimePast : pblock->GetBlockTime(); - + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); @@ -256,16 +256,16 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } if (fMissingInputs) continue; - + // Priority is sum(valuein * age) / modified_txsize unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); dPriority = tx.ComputePriority(dPriority, nTxSize); - + uint256 hash = tx.GetHash(); mempool.ApplyDeltas(hash, dPriority, nTotalIn); - + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - + if (porphan) { porphan->dPriority = dPriority; @@ -274,27 +274,27 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } - + // Collect transactions into block uint64_t nBlockSize = 1000; uint64_t nBlockTx = 0; int64_t interest; int nBlockSigOps = 100; bool fSortedByFee = (nBlockPrioritySize <= 0); - + TxPriorityCompare comparer(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - + while (!vecPriority.empty()) { // Take highest priority transaction off the priority queue: double dPriority = vecPriority.front().get<0>(); CFeeRate feeRate = vecPriority.front().get<1>(); const CTransaction& tx = *(vecPriority.front().get<2>()); - + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); vecPriority.pop_back(); - + // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx @@ -302,7 +302,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); continue; } - + // Legacy limits on sigOps: unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) @@ -329,14 +329,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) comparer = TxPriorityCompare(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); } - + if (!view.HaveInputs(tx)) { //fprintf(stderr,"dont have inputs\n"); continue; } CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - + nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { @@ -354,7 +354,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) continue; } UpdateCoins(tx, view, nHeight); - + // Added pblock->vtx.push_back(tx); pblocktemplate->vTxFees.push_back(nTxFees); @@ -363,12 +363,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) ++nBlockTx; nBlockSigOps += nTxSigOps; nFees += nTxFees; - + if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); } - + // Add transactions that depend on this one to the priority queue if (mapDependers.count(hash)) { @@ -386,7 +386,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } } } - + nLastBlockTx = nBlockTx; nLastBlockSize = nBlockSize; blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); @@ -411,7 +411,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->nHeight+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } - + // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(chainparams.GetConsensus(), nHeight); txNew.vin.resize(1); @@ -426,9 +426,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; - + pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -449,7 +449,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) nonce <<= 32; nonce >>= 16; pblock->nNonce = ArithToUint256(nonce); - + // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashReserved = uint256(); @@ -527,7 +527,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return pblocktemplate.release(); } - + /* #ifdef ENABLE_WALLET boost::optional GetMinerScriptPubKey(CReserveKey& reservekey) @@ -550,11 +550,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return boost::optional(); #endif } - + CScript scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG; return scriptPubKey; } - + #ifdef ENABLE_WALLET CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) { @@ -564,7 +564,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) { boost::optional scriptPubKey = GetMinerScriptPubKey(); #endif - + if (!scriptPubKey) { return NULL; } @@ -592,7 +592,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CMutableTransaction txCoinbase(pblock->vtx[0]); txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS; assert(txCoinbase.vin[0].scriptSig.size() <= 100); - + pblock->vtx[0] = txCoinbase; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); } @@ -606,7 +606,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; - if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) + if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; } @@ -615,7 +615,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } - else { if (!reservekey.GetReservedKey(pubkey)) { @@ -661,7 +660,7 @@ static bool ProcessBlockFound(CBlock* pblock) { LogPrintf("%s\n", pblock->ToString()); LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.LastTip()->nHeight+1); - + // Found a solution { //LOCK(cs_main); @@ -676,11 +675,11 @@ static bool ProcessBlockFound(CBlock* pblock) for (i=31; i>=0; i--) fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); fprintf(stderr," <- chainTip (stale)\n"); - + return error("KomodoMiner: generated block is stale"); } } - + #ifdef ENABLE_WALLET // Remove key from key pool if ( IS_KOMODO_NOTARY == 0 ) @@ -704,7 +703,7 @@ static bool ProcessBlockFound(CBlock* pblock) CValidationState state; if (!ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, pblock, true, NULL)) return error("KomodoMiner: ProcessNewBlock, block not accepted"); - + TrackMinedBlock(pblock->GetHash()); komodo_broadcast(pblock,16); return true; @@ -728,15 +727,15 @@ void static BitcoinMiner() SetThreadPriority(THREAD_PRIORITY_LOWEST); RenameThread("komodo-miner"); const CChainParams& chainparams = Params(); - + #ifdef ENABLE_WALLET // Each thread has its own key CReserveKey reservekey(pwallet); #endif - + // Each thread has its own counter unsigned int nExtraNonce = 0; - + unsigned int n = chainparams.EquihashN(); unsigned int k = chainparams.EquihashK(); uint8_t *script; uint64_t total,checktoshis; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1; @@ -767,7 +766,7 @@ void static BitcoinMiner() } ); miningTimer.start(); - + try { if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); @@ -790,7 +789,7 @@ void static BitcoinMiner() break; MilliSleep(15000); //fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload()); - + } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); miningTimer.start(); @@ -1054,13 +1053,13 @@ void static BitcoinMiner() std::lock_guard lock{m_cs}; return cancelSolver; }; - + // TODO: factor this out into a function with the same API for each solver. if (solver == "tromp" ) { //&& notaryid >= 0 ) { // Create solver and initialize it. equi eq(1); eq.setstate(&curr_state); - + // Initialization done, start algo driver. eq.digit0(0); eq.xfull = eq.bfull = eq.hfull = 0; @@ -1072,7 +1071,7 @@ void static BitcoinMiner() } eq.digitK(0); ehSolverRuns.increment(); - + // Convert solution indices to byte array (decompress) and pass it to validBlock method. for (size_t s = 0; s < eq.nsols; s++) { LogPrint("pow", "Checking solution %d\n", s+1); @@ -1081,7 +1080,7 @@ void static BitcoinMiner() index_vector[i] = eq.sols[s][i]; } std::vector sol_char = GetMinimalFromIndices(index_vector, DIGITBITS); - + if (validBlock(sol_char)) { // If we find a POW solution, do not try other solutions // because they become invalid as we created a new block in blockchain. @@ -1108,7 +1107,7 @@ void static BitcoinMiner() cancelSolver = false; } } - + // Check for stop or if block needs to be rebuilt boost::this_thread::interruption_point(); // Regtest mode doesn't require peers @@ -1178,7 +1177,7 @@ void static BitcoinMiner() miningTimer.stop(); c.disconnect(); } - + #ifdef ENABLE_WALLET void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads) #else @@ -1186,10 +1185,10 @@ void static BitcoinMiner() #endif { static boost::thread_group* minerThreads = NULL; - + if (nThreads < 0) nThreads = GetNumCores(); - + if (minerThreads != NULL) { minerThreads->interrupt_all(); @@ -1201,7 +1200,7 @@ void static BitcoinMiner() nThreads = 1; if (nThreads == 0 || !fGenerate) return; - + minerThreads = new boost::thread_group(); for (int i = 0; i < nThreads; i++) { #ifdef ENABLE_WALLET @@ -1211,5 +1210,5 @@ void static BitcoinMiner() #endif } } - + #endif // ENABLE_MINING diff --git a/src/pow.cpp b/src/pow.cpp index 1291e445e..9c8f68586 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -20,31 +20,39 @@ #include "librustzcash.h" #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); +extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); - // Genesis block - if (pindexLast == NULL ) - return nProofOfWorkLimit; + if ( ASSETCHAINS_STREAM == 0) + { + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + // Genesis block + if (pindexLast == NULL ) + return nProofOfWorkLimit; - // Find the first block in the averaging interval - const CBlockIndex* pindexFirst = pindexLast; - arith_uint256 bnTot {0}; - for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { - arith_uint256 bnTmp; - bnTmp.SetCompact(pindexFirst->nBits); - bnTot += bnTmp; - pindexFirst = pindexFirst->pprev; + // Find the first block in the averaging interval + const CBlockIndex* pindexFirst = pindexLast; + arith_uint256 bnTot {0}; + for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { + arith_uint256 bnTmp; + bnTmp.SetCompact(pindexFirst->nBits); + bnTot += bnTmp; + pindexFirst = pindexFirst->pprev; + } + + // Check we have enough blocks + if (pindexFirst == NULL) + return nProofOfWorkLimit; + + arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; + + return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); + } + else + { + return 537857807; } - - // Check we have enough blocks - if (pindexFirst == NULL) - return nProofOfWorkLimit; - - arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; - - return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); } unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, From 4e9596efeab6fa2426960c338b1dc72576143e98 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:02:16 +0800 Subject: [PATCH 202/951] fix commission --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8bfca7dc4..1b8daf3a7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1109,9 +1109,9 @@ extern int32_t ASSETCHAINS_STREAM; uint64_t komodo_commission(const CBlock *pblock) { + int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; if ( ASSETCHAINS_STREAM == 0 ) { - int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); for (i=0; i Date: Tue, 16 Oct 2018 13:07:30 +0800 Subject: [PATCH 203/951] prevent STREAM and PERC being used at the same time --- src/komodo_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 50b0e3020..4c4827f6d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,6 +1562,11 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); + if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_COMMISSION != 0 ) { + printf("ASSETCHAINS_STREAM cannot be used with ASSETCHAINS_COMMISSION setting both to 0! \n"); + ASSETCHAINS_STREAM = 0; + ASSETCHAINS_COMMISSION = 0; + } if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) From c175848729fa19799d0910a6bac236c2123e1d4c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:12:53 +0800 Subject: [PATCH 204/951] set minimum supply for ac_stream to 100k --- src/komodo_utils.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4c4827f6d..b60328c54 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1599,6 +1599,10 @@ void komodo_args(char *argv0) ASSETCHAINS_STREAM = 0; printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); } + if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { + ASSETCHAINS_SUPPLY = 100000; + printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 100,000 coins. \n"); + } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); From 0d63c1f908db9bcd68e2dddb89d9eae7f01cd966 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:36:24 +0800 Subject: [PATCH 205/951] add some prints --- src/komodo_bitcoind.h | 5 ++++- src/miner.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1b8daf3a7..83b8399b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1577,9 +1577,12 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( height == 1 ) { + fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { + fprintf(stderr, "failed the check\n"); return(-1); + } } else { diff --git a/src/miner.cpp b/src/miner.cpp index 8fbfcff05..79a3c1eec 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,6 +609,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + fprintf(stderr, "assechains stream should be mining to override pubkey\n"); } else if ( USE_EXTERNAL_PUBKEY != 0 ) { From 497f834d1f1d81ef89f99c9e84b57d8640b310e3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 13:49:38 +0800 Subject: [PATCH 206/951] disable check to see what block is being created --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 83b8399b8..d0ee426b8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1575,7 +1575,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - if ( height == 1 ) + /*if ( height == 1 ) { fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); @@ -1585,10 +1585,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } } else - { + {*/ if ( komodo_checkcommission(pblock,height) < 0 ) 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 ) From 45ef1a21c7552c5dfe9a722104b777c9ea0aeb56 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 14:21:23 +0800 Subject: [PATCH 207/951] try this --- src/komodo_bitcoind.h | 8 ++++---- src/komodo_gateway.h | 13 ++++++------- src/komodo_utils.h | 2 +- src/main.cpp | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d0ee426b8..f1f5b8efd 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1472,7 +1472,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script; - if ( ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) { checktoshis = komodo_commission(pblock); if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) @@ -1575,7 +1575,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - /*if ( height == 1 ) + if ( height == 1 ) { fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); @@ -1585,10 +1585,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } } else - {*/ + { if ( komodo_checkcommission(pblock,height) < 0 ) 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 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 379224b48..233f87fcf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -90,7 +90,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout pax->marked = mark; //if ( height > 214700 || pax->height > 214700 ) // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - + } pthread_mutex_unlock(&komodo_mutex); return(pax); @@ -203,9 +203,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t // return(0); incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); //41e77b91cb68dc2aa02fa88550eae6b6d44db676a7e935337b6d1392d9718f03cb0200305c90660400000000fbcbeb1f000000bde801006201000058e7945ad08ddba1eac9c9b6c8e1e97e8016a2d152 - + // 41e94d736ec69d88c08b5d238abeeca609c02357a8317e0d56c328bcb1c259be5d0200485bc80200000000404b4c000000000059470200b80b000061f22ba7d19fe29ac3baebd839af8b7127d1f9075553440046bb4cc7a3b5cd39dffe7206507a3482a00780e617f68b273cce9817ed69298d02001069ca1b0000000080f0fa02000000005b470200b90b000061f22ba7d19fe29ac3baebd839af8b7127d1f90755 - + //for (i=0; i 1 ) + if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) { @@ -772,7 +772,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -1185,7 +1185,7 @@ void komodo_stateind_set(struct komodo_state *sp,uint32_t *inds,int32_t n,uint8_ printf("numR.%d numV.%d numN.%d count.%d\n",numR,numV,numN,count); /*else if ( func == 'K' ) // KMD height: stop after 1st else if ( func == 'T' ) // KMD height+timestamp: stop after 1st - + else if ( func == 'N' ) // notarization, scan backwards 1440+ blocks; else if ( func == 'V' ) // price feed: can stop after 1440+ else if ( func == 'R' ) // opreturn:*/ @@ -1518,4 +1518,3 @@ void komodo_passport_iteration() printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid); } } - diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b60328c54..ebeb8324f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1597,7 +1597,7 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } else if ( ASSETCHAINS_STREAM != 0) { ASSETCHAINS_STREAM = 0; - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n %s",ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); } if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { ASSETCHAINS_SUPPLY = 100000; diff --git a/src/main.cpp b/src/main.cpp index 39270a0b9..42f1d624d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3124,7 +3124,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) ) { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block)) != 0 ) From 8ca9133eb4c7ef0735cf93d6e3721d12160dcbb4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 14:44:55 +0800 Subject: [PATCH 208/951] fix --- src/komodo_utils.h | 2 +- src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ebeb8324f..5dc218d76 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1603,7 +1603,7 @@ void komodo_args(char *argv0) ASSETCHAINS_SUPPLY = 100000; printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 100,000 coins. \n"); } - if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_STREAM != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); extraptr = extrabuf; diff --git a/src/miner.cpp b/src/miner.cpp index 79a3c1eec..b058a7c7d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,7 +439,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) for (i=0; i<33; i++) ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; ptr[34] = OP_CHECKSIG; - //printf("autocreate commision vout\n"); + printf("autocreate commission vout\n"); pblock->vtx[0] = txNew; } pblocktemplate->vTxFees[0] = -nFees; From 3793c6386097185cd973b6823e55c208564228e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 15:33:09 +0800 Subject: [PATCH 209/951] oops LOL --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b058a7c7d..36ed84f05 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -615,7 +615,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in { //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; - } + } else { if (!reservekey.GetReservedKey(pubkey)) { From b66f366d5cb4ca6a6c009ed928a3b93dad627b91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 16:06:49 +0800 Subject: [PATCH 210/951] next try --- src/komodo_bitcoind.h | 2 -- src/main.cpp | 9 +++++++-- src/miner.cpp | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f1f5b8efd..b13a2c36e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1577,10 +1577,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( height == 1 ) { - fprintf(stderr, "checking override pubkey thingo \n"); script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { - fprintf(stderr, "failed the check\n"); return(-1); } } diff --git a/src/main.cpp b/src/main.cpp index 42f1d624d..c6d2ee9e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1895,8 +1895,13 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY ) { if ( ASSETCHAINS_REWARD == 0 ) - return(10000); - else if ( ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )|| ASSETCHAINS_STREAM != 0) + { + if ( ASSETCHAINS_STREAM != 0 && nHeight > 128 ) + return(0); + else + return(10000); + } + else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY ) return(0); else { diff --git a/src/miner.cpp b/src/miner.cpp index 36ed84f05..39caa35c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,7 +609,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; - fprintf(stderr, "assechains stream should be mining to override pubkey\n"); } else if ( USE_EXTERNAL_PUBKEY != 0 ) { From 68032ee5a71a557fc10a14a78f951f34d9079566 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 17:14:07 +0800 Subject: [PATCH 211/951] change so only ac_pubkey can mine coinbase --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 13 ++++++------- src/miner.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b13a2c36e..4051eb095 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1575,7 +1575,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - if ( height == 1 ) + if ( height == 1 || ASSETCHAINS_STREAM != 0 ) { script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5dc218d76..1535d5812 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,10 +1562,9 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_COMMISSION != 0 ) { - printf("ASSETCHAINS_STREAM cannot be used with ASSETCHAINS_COMMISSION setting both to 0! \n"); - ASSETCHAINS_STREAM = 0; - ASSETCHAINS_COMMISSION = 0; + if ( ASSETCHAINS_STREAM != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0) { + printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); + exit(0); } if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1597,11 +1596,11 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } else if ( ASSETCHAINS_STREAM != 0) { ASSETCHAINS_STREAM = 0; - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n %s",ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); } if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { - ASSETCHAINS_SUPPLY = 100000; - printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 100,000 coins. \n"); + ASSETCHAINS_SUPPLY = 1000000; + printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 1,000,000 coins. \n"); } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_STREAM != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 39caa35c3..1c83c5a61 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,7 +439,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) for (i=0; i<33; i++) ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; ptr[34] = OP_CHECKSIG; - printf("autocreate commission vout\n"); + //printf("autocreate commission vout\n"); pblock->vtx[0] = txNew; } pblocktemplate->vTxFees[0] = -nFees; @@ -839,7 +839,10 @@ void static BitcoinMiner() { if ( ASSETCHAINS_REWARD == 0 ) { - if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) + int minvoutsize = 1; + if ( ASSETCHAINS_STREAM != 0 ) + minvoutsize = 2; + if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) From dc92daa03cd4f7f45dea09d07b0e82da30686909 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 17:17:44 +0800 Subject: [PATCH 212/951] oops --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1535d5812..aedb6d3c2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,7 +1562,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - if ( ASSETCHAINS_STREAM != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0) { + if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); exit(0); } From fb0f519301b7cb105b2087e7a4364b9eaaba5de5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 21:17:27 +0800 Subject: [PATCH 213/951] try to make miner spend p2pk utxo --- src/miner.cpp | 20 ++++++++++++++++++++ src/wallet/rpcwallet.cpp | 14 ++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1c83c5a61..668c5127f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -493,6 +493,26 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } + else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + { + CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); + if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) + { + CAmount txfees = 10000; + pblock->vtx.push_back(txStream); + pblocktemplate->vTxFees.push_back(txfees); + pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStream)); + nFees += txfees; + pblocktemplate->vTxFees[0] = -nFees; + //*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; + //fprintf(stderr,"added notaryvin\n"); + } + else + { + fprintf(stderr,"error adding streamer vin, the chain broke! \n"); + return(0); + } + } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 936c31fd9..6359dfca5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -44,6 +44,8 @@ using namespace std; using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; +extern int32_t ASSETCHAINS_STREAM; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern uint8_t ASSETCHAINS_PRIVATE; uint32_t komodo_segid32(char *coinaddr); @@ -4606,8 +4608,16 @@ 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(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; - txNew.vout[0].nValue = utxovalue - txfee; + if ( ASSETCHAINS_STREAM != 0 ) + { + txNew.vout[0].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].nValue = 0; + } + else + { + 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); if (!signSuccess) From a11c10fdd215ac290fdfa73da31fa86a4604a163 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 21:39:54 +0800 Subject: [PATCH 214/951] send 0 value utxo to CRYPTO777 address instead of ac_pubkey --- src/wallet/rpcwallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6359dfca5..d352c89e4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4610,14 +4610,13 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin[0].prevout.n = utxovout; if ( ASSETCHAINS_STREAM != 0 ) { - txNew.vout[0].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = 0; } else - { - txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; + { txNew.vout[0].nValue = utxovalue - txfee; } + txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; CTransaction txNewConst(txNew); signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); if (!signSuccess) From 1f5efd44aa827003cc84aca1625ecab67df4e6d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:02:47 +0800 Subject: [PATCH 215/951] not a chance this will work? --- src/komodo_bitcoind.h | 15 +++++++++++++-- src/miner.cpp | 9 ++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4051eb095..988a8251c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1575,14 +1575,25 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - if ( height == 1 || ASSETCHAINS_STREAM != 0 ) + if ( height == 1 ) { script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { return(-1); } } - else + else if ( ASSETCHAINS_STREAM != 0 ) { + int lasttx = ( pblock->vtx.size() -1 ); + uint256 hash; CTransaction tx; CTxIn& txin; + txin = pblock->vtx[lasttx]; + if (GetTransaction(txin.prevout.hash,tx,hash,false)) + { + script = (uint8_t *)tx.vout[txin.prevout.n].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { + return(-1); + } + } + } else { if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); diff --git a/src/miner.cpp b/src/miner.cpp index 668c5127f..a36a33a17 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -626,10 +626,17 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; - if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) + if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; } + else if ( ASSETCHAINS_STREAM != 0 ) + { + if ( nHeight < 128 ) + scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + else + scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; + } else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); From 3267a72a823709b4b985ef3f19f5bec734d174f7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:05:49 +0800 Subject: [PATCH 216/951] try again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 988a8251c..37f2a4411 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1584,7 +1584,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; CTxIn& txin; + uint256 hash; CTransaction tx; CTransaction txin; txin = pblock->vtx[lasttx]; if (GetTransaction(txin.prevout.hash,tx,hash,false)) { From 2e587cdae3f3903b5c231803e141d58ff94e0451 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:07:55 +0800 Subject: [PATCH 217/951] again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 37f2a4411..9b1b05930 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1584,7 +1584,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; CTransaction txin; + uint256 hash; CTransaction tx; CTxIn txin; txin = pblock->vtx[lasttx]; if (GetTransaction(txin.prevout.hash,tx,hash,false)) { From 45df365f804108d2caa1ed52a097f0504270d9f8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:11:21 +0800 Subject: [PATCH 218/951] again --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9b1b05930..deffb6f8a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1584,9 +1584,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; CTxIn txin; - txin = pblock->vtx[lasttx]; - if (GetTransaction(txin.prevout.hash,tx,hash,false)) + uint256 hash; CTransaction tx; + //txin = ; + if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { script = (uint8_t *)tx.vout[txin.prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { From 2448754cc934f86ee6d1a36ac3582ac8a84c932f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:13:34 +0800 Subject: [PATCH 219/951] again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index deffb6f8a..b0df98356 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1588,7 +1588,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) //txin = ; if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { - script = (uint8_t *)tx.vout[txin.prevout.n].scriptPubKey.data(); + script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { return(-1); } From 0be6e9eec81100a282e72eece790f3107470f8be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:18:37 +0800 Subject: [PATCH 220/951] add prints too see if its working --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b0df98356..aa6f848ef 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1585,11 +1585,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) else if ( ASSETCHAINS_STREAM != 0 ) { int lasttx = ( pblock->vtx.size() -1 ); uint256 hash; CTransaction tx; - //txin = ; + printf("ABOUT TO CHECK LAST TX: %d\n",lasttx); if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { + printf("CHECKING THE script pubkey\n"); script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { + printf("THE PUBKEY IS WRONG!\n"); return(-1); } } From 43b535c4c8335656abd66fd1f0a4441ef10236e3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:19:16 +0800 Subject: [PATCH 221/951] remove the actual return --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aa6f848ef..61d86d0d6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1592,7 +1592,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { printf("THE PUBKEY IS WRONG!\n"); - return(-1); + //return(-1); } } } else From 987bed370592604a81a261978d482b4f24451fb2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:31:17 +0800 Subject: [PATCH 222/951] enforce check add print if passed --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 61d86d0d6..278bba0af 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1592,8 +1592,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { printf("THE PUBKEY IS WRONG!\n"); - //return(-1); + return(-1); } + printf("THE PUBKEY IS RIGHT! \n"); } } else { From d118b457b0aa06283a1c568deb6253366649b96e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 16 Oct 2018 23:47:48 +0800 Subject: [PATCH 223/951] temp disable adding last tx to test consensus rule --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index a36a33a17..42d2b209b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -493,7 +493,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } - else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + /* else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } + } */ else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; From a3b0c674155ea518b63b9e836b618bf69a85d6b2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 00:13:38 +0800 Subject: [PATCH 224/951] fix miner, with extra TX --- src/miner.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 42d2b209b..44fb0ba27 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -493,7 +493,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } - /* else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } */ + } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; @@ -867,16 +867,18 @@ void static BitcoinMiner() if ( ASSETCHAINS_REWARD == 0 ) { int minvoutsize = 1; + int minvtxsize = 1; if ( ASSETCHAINS_STREAM != 0 ) minvoutsize = 2; - if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) + minvtxsize = 2; + if ( pblock->vtx.size() == minvtxsize && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"%s tx.%d vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx.size(),(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); From b6b33147b1d85e3b736035d25ac03e5dbdb16845 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 00:31:57 +0800 Subject: [PATCH 225/951] change it, might be safter this way --- src/komodo_bitcoind.h | 16 ++++++++++------ src/wallet/rpcwallet.cpp | 9 +-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 278bba0af..ad8da74d4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1582,10 +1582,18 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } - else if ( ASSETCHAINS_STREAM != 0 ) { + else + { + if ( komodo_checkcommission(pblock,height) < 0 ) + return(-1); + } + if ( ASSETCHAINS_STREAM != 0 && height > 128 ) + { int lasttx = ( pblock->vtx.size() -1 ); - uint256 hash; CTransaction tx; printf("ABOUT TO CHECK LAST TX: %d\n",lasttx); + if ( lasttx == 0 ) + return(-1); + uint256 hash; CTransaction tx; if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) { printf("CHECKING THE script pubkey\n"); @@ -1596,10 +1604,6 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } printf("THE PUBKEY IS RIGHT! \n"); } - } else - { - if ( komodo_checkcommission(pblock,height) < 0 ) - return(-1); } } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d352c89e4..0e9fc8e80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4608,14 +4608,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; - if ( ASSETCHAINS_STREAM != 0 ) - { - txNew.vout[0].nValue = 0; - } - else - { - txNew.vout[0].nValue = utxovalue - txfee; - } + txNew.vout[0].nValue = utxovalue - txfee; txNew.vout[0].scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; CTransaction txNewConst(txNew); signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, utxovalue, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); From af7ee589436c5050266573867bd3dc70ea4ff376 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 09:58:42 +0800 Subject: [PATCH 226/951] disable miner TX to test again --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 44fb0ba27..3f3175e2a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -492,7 +492,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); return(0); } - } + } /* else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } + } */ else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; From 4da719819f298b4ff6f99632d200f38415d5e099 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 17 Oct 2018 10:57:19 +0800 Subject: [PATCH 227/951] disable need for extra TX under 128 blocks --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3f3175e2a..4af7383c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -492,8 +492,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n"); return(0); } - } /* - else if (( ASSETCHAINS_STREAM != 0 ) && ( ASSETCHAINS_SYMBOL[0] != 0 )) + } + else if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SYMBOL[0] != 0 && nHeight > 128 ) { CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) @@ -512,7 +512,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) fprintf(stderr,"error adding streamer vin, the chain broke! \n"); return(0); } - } */ + } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; From 3448cd83bbcf3ebe995ba83aadcf0a426a50d9c1 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 19 Oct 2018 23:03:20 +0200 Subject: [PATCH 228/951] comment out spamming print --- src/cc/oracles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 7cccad0f6..0c7d9e6e2 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -666,7 +666,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); + //fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 5418cd4ad7b7d35e7d2f46c14c0b9983960f0dd9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 22 Oct 2018 17:11:27 +0800 Subject: [PATCH 229/951] disaable longestchain check in miner under 128 blocks --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4af7383c3..7ebf9bc27 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -957,7 +957,7 @@ void static BitcoinMiner() } while (true) { - if ( KOMODO_INSYNC == 0 ) + if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) { fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) From 62c220a9c2c603dbefbf92bb44f0ea4c8b50d8a4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 22 Oct 2018 22:16:16 +0800 Subject: [PATCH 230/951] remove insync check all together, slowing it down too much --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7ebf9bc27..2e26cf6cd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -957,13 +957,13 @@ void static BitcoinMiner() } while (true) { - if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) + /*if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) { fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) KOMODO_INSYNC = 1; sleep(3); - } + } */ // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; From 0aa4f46cccfb3c0f066b7134eec5c439b16df32f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 23 Oct 2018 23:29:49 +0800 Subject: [PATCH 231/951] add getblockdata RPC --- src/rpcblockchain.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++- src/rpcserver.cpp | 25 +++++++------- src/rpcserver.h | 1 + 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e9cf54bb4..ccbf4a6dd 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,6 +257,80 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } +UniValue getdatafromblock(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getdatafromblock \"hash|height\"\n" + "\nReturns all the data sent via streamer in block if there was any data in it.\n" + "\nArguments:\n" + "1. \"hash|height\" (string, required) The block hash or height\n" + "\nResult (for verbose=false):\n" + "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" + "\nExamples:\n" + + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + + HelpExampleCli("getblock", "12800") + + HelpExampleRpc("getblock", "12800") + ); + + LOCK(cs_main); + + std::string strHash = params[0].get_str(); + + // If height is supplied, find the hash + if (strHash.size() < (2 * sizeof(uint256))) { + // std::stoi allows characters, whereas we want to be strict + regex r("[[:digit:]]+"); + if (!regex_match(strHash, r)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + int nHeight = -1; + try { + nHeight = std::stoi(strHash); + } + catch (const std::exception &e) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + if (nHeight < 0 || nHeight > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } + strHash = chainActive[nHeight]->GetBlockHash().GetHex(); + } + + uint256 hash(uint256S(strHash)); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + fprintf(stderr, "%s\n",tx.GetHash().GetHex()); + } + return chainActive.Height(); + /* + UniValue result(UniValue::VOBJ); + UniValue txs(UniValue::VARR); + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + txs.push_back(tx.GetHash().GetHex()); + } + result.push_back(Pair("tx", txs)); + return result; + */ +} + UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); @@ -816,7 +890,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp) " \"currentheight\": xxxxx, (numeric) current height of the chain\n" " \"key\": \"xxxxx\", (string) key\n" " \"keylen\": xxxxx, (string) length of the key \n" - " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" + " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" " \"height\": xxxxx, (numeric) height the key was stored at\n" " \"expiration\": xxxxx, (numeric) height the key will expire\n" " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 7d2eab1e3..b23dbc826 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -285,6 +285,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "getbestblockhash", &getbestblockhash, true }, { "blockchain", "getblockcount", &getblockcount, true }, { "blockchain", "getblock", &getblock, true }, + { "blockchain", "getdatafromblock", &getdatafromblock, true }, { "blockchain", "getblockdeltas", &getblockdeltas, false }, { "blockchain", "getblockhashes", &getblockhashes, true }, { "blockchain", "getblockhash", &getblockhash, true }, @@ -350,16 +351,16 @@ static const CRPCCommand vRPCCommands[] = #endif /* auction */ { "auction", "auctionaddress", &auctionaddress, true }, - + /* lotto */ { "lotto", "lottoaddress", &lottoaddress, true }, - + /* fsm */ { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + /* rewards */ { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -368,16 +369,16 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + /* faucet */ { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - + /* MofN */ { "MofN", "mofnaddress", &mofnaddress, true }, - + /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, { "channels", "channelsinfo", &channelsinfo, true }, @@ -385,7 +386,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + /* Oracles */ { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -395,7 +396,7 @@ static const CRPCCommand vRPCCommands[] = { "oracles", "oraclessubscribe", &oraclessubscribe, true }, { "oracles", "oraclesdata", &oraclesdata, true }, { "oracles", "oraclessamples", &oraclessamples, true }, - + /* Prices */ { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, @@ -405,16 +406,16 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesstatus", &pricesstatus, true }, { "prices", "pricesfinish", &pricesfinish, true }, - + /* Pegs */ { "pegs", "pegsaddress", &pegsaddress, true }, - + /* Triggers */ { "triggers", "triggersaddress", &triggersaddress, true }, - + /* Payments */ { "payments", "paymentsaddress", &paymentsaddress, true }, - + /* Gateways */ { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index a78f1b6fc..d2194db4f 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -363,6 +363,7 @@ extern UniValue getblockdeltas(const UniValue& params, bool fHelp); extern UniValue getblockhash(const UniValue& params, bool fHelp); extern UniValue getblockheader(const UniValue& params, bool fHelp); extern UniValue getblock(const UniValue& params, bool fHelp); +extern UniValue getdatafromblock(const UniValue& params, bool fHelp); extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp); extern UniValue gettxout(const UniValue& params, bool fHelp); extern UniValue verifychain(const UniValue& params, bool fHelp); From 10fbb81f2992e43e41b04b6c844d8b6aadb7ac52 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 23 Oct 2018 23:31:29 +0800 Subject: [PATCH 232/951] cstr --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ccbf4a6dd..13d6d2ad9 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -316,7 +316,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) BOOST_FOREACH(const CTransaction&tx, block.vtx) { - fprintf(stderr, "%s\n",tx.GetHash().GetHex()); + fprintf(stderr, "%s\n",tx.GetHash().GetHex().cstr()); } return chainActive.Height(); /* From 4b6c433e49c7a878b4c9d8d321f118c606def0b4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 23 Oct 2018 23:34:37 +0800 Subject: [PATCH 233/951] try --- src/rpcblockchain.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 13d6d2ad9..a92da3b7c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -314,21 +314,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if(!ReadBlockFromDisk(block, pblockindex,1)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - BOOST_FOREACH(const CTransaction&tx, block.vtx) + /*BOOST_FOREACH(const CTransaction&tx, block.vtx) { fprintf(stderr, "%s\n",tx.GetHash().GetHex().cstr()); } return chainActive.Height(); - /* + */ UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - txs.push_back(tx.GetHash().GetHex()); + UniValue objTx(UniValue::VOBJ); + TxToJSON(tx, uint256(), objTx); + txs.push_back(objTx); } result.push_back(Pair("tx", txs)); return result; - */ } UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) From bbcfc72a6874b53e99e3fc7ca6c878c6223121ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:02:23 +0800 Subject: [PATCH 234/951] try --- src/rpcblockchain.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a92da3b7c..9d842c0e4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -325,11 +325,23 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) BOOST_FOREACH(const CTransaction&tx, block.vtx) { UniValue objTx(UniValue::VOBJ); - TxToJSON(tx, uint256(), objTx); + voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); } result.push_back(Pair("tx", txs)); - return result; + return true; +} + +void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) +{ + UniValue vout(UniValue::VARR); + for (unsigned int i = 0; i < tx.vout.size(); i++) { + const CTxOut& txout = tx.vout[i]; + UniValue out(UniValue::VOBJ); + out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); + vout.push_back(out); + } + entry.push_back(Pair("vout", vout)); } UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) From f376020ee67c2723dcba352bf6a86f4179e7d03e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:04:04 +0800 Subject: [PATCH 235/951] fix --- src/rpcblockchain.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9d842c0e4..f49902afc 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,6 +257,18 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } +void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) +{ + UniValue vout(UniValue::VARR); + for (unsigned int i = 0; i < tx.vout.size(); i++) { + const CTxOut& txout = tx.vout[i]; + UniValue out(UniValue::VOBJ); + out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); + vout.push_back(out); + } + entry.push_back(Pair("vout", vout)); +} + UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -332,18 +344,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return true; } -void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) -{ - UniValue vout(UniValue::VARR); - for (unsigned int i = 0; i < tx.vout.size(); i++) { - const CTxOut& txout = tx.vout[i]; - UniValue out(UniValue::VOBJ); - out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); - vout.push_back(out); - } - entry.push_back(Pair("vout", vout)); -} - UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); From f9bc9ee1e450e984c55b465d8550fb4cf06af276 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:05:28 +0800 Subject: [PATCH 236/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f49902afc..95ae2d1dd 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -341,7 +341,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) txs.push_back(objTx); } result.push_back(Pair("tx", txs)); - return true; + return result; } UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) From 5143ef0c76287ebe10c5689375682cda0bfd5f3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:11:06 +0800 Subject: [PATCH 237/951] try --- src/rpcblockchain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 95ae2d1dd..fd520122b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -334,11 +334,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) */ UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); + unsigned int i = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) { + if ( i != 0 || i != block.vxt.size() ) + { UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); + i = i + 1; + } } result.push_back(Pair("tx", txs)); return result; From b93f04b2bd2c6c29fc6be5bb6f8d16d1c8ea319e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:12:14 +0800 Subject: [PATCH 238/951] xt --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index fd520122b..9bfc8c696 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -337,7 +337,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) unsigned int i = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( i != 0 || i != block.vxt.size() ) + if ( i != 0 || i != block.vtx.size() ) { UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); From c540920d85329997400e6a18c066f09122072554 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:14:33 +0800 Subject: [PATCH 239/951] again --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9bfc8c696..25853bc5b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -337,7 +337,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) unsigned int i = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( i != 0 || i != block.vtx.size() ) + if ( i != 0 || i != (block.vtx.size() -1) ) { UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); From f0d9eab81c29a55d8c763c44d058b3b1b239253f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:18:03 +0800 Subject: [PATCH 240/951] prints --- src/rpcblockchain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 25853bc5b..00db32085 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -335,8 +335,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); unsigned int i = 0; + fprintf(stderr, "%d\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { + fprintf(stderr, "tx number: %d \n",i); if ( i != 0 || i != (block.vtx.size() -1) ) { UniValue objTx(UniValue::VOBJ); From 10a51db52fba6f11d52ec2ebf1290b2661abe062 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:19:24 +0800 Subject: [PATCH 241/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 00db32085..97339ef82 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -335,7 +335,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); UniValue txs(UniValue::VARR); unsigned int i = 0; - fprintf(stderr, "%d\n", block.vtx.size()); + fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { fprintf(stderr, "tx number: %d \n",i); From 65453a89387c04e0f62b31394d77b3b717920b49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:22:44 +0800 Subject: [PATCH 242/951] t --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 97339ef82..3d1ea7e90 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,9 +338,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - fprintf(stderr, "tx number: %d \n",i); if ( i != 0 || i != (block.vtx.size() -1) ) { + fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); From 9408ce62bd1bea34947bd1cc6b642c736203905b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:27:04 +0800 Subject: [PATCH 243/951] wtf --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 3d1ea7e90..00d18c4ba 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,14 +338,14 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( i != 0 || i != (block.vtx.size() -1) ) + if ( (i === 0) || (i == (block.vtx.size() -1)) ) { fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); txs.push_back(objTx); - i = i + 1; } + i = i + 1; } result.push_back(Pair("tx", txs)); return result; From b6a0c1d55ab2ca187b9cefef6d593b82cd9a8646 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:28:12 +0800 Subject: [PATCH 244/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 00d18c4ba..a674dba2d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,7 +338,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "%ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( (i === 0) || (i == (block.vtx.size() -1)) ) + if ( (i == 0) || (i == (block.vtx.size() -1)) ) { fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); From c465fbf0d3358425d8aac17289f58cdf9450297f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:30:58 +0800 Subject: [PATCH 245/951] fix --- src/rpcblockchain.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a674dba2d..ad36e2818 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -333,17 +333,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VOBJ); - UniValue txs(UniValue::VARR); unsigned int i = 0; - fprintf(stderr, "%ld\n", block.vtx.size()); + fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( (i == 0) || (i == (block.vtx.size() -1)) ) + if ( (i != 0) || (i != (block.vtx.size() -1)) ) { fprintf(stderr, "tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); - txs.push_back(objTx); + result.push_back(objTx); } i = i + 1; } From dc9e877b656b65a298af434fbc858efd759437ee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:32:09 +0800 Subject: [PATCH 246/951] fix --- src/rpcblockchain.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ad36e2818..afc0159ba 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -346,7 +346,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - result.push_back(Pair("tx", txs)); return result; } From 85fecb9f761cc579c88b9f7022244bc43521622d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:36:38 +0800 Subject: [PATCH 247/951] fix? --- src/rpcblockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index afc0159ba..8ed47c140 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -332,14 +332,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } return chainActive.Height(); */ - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VARR); unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); BOOST_FOREACH(const CTransaction&tx, block.vtx) { - if ( (i != 0) || (i != (block.vtx.size() -1)) ) + if ( (i == 0) || (i == (block.vtx.size() -1)) ) { - fprintf(stderr, "tx number: %d \n",i); + fprintf(stderr, "skipped tx number: %d \n",i); + } else { + fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); voutToJSON(tx, uint256(), objTx); result.push_back(objTx); From 5a363fdffcf612133e218ea3f37b665fd61f03f1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 00:41:36 +0800 Subject: [PATCH 248/951] maybe --- src/rpcblockchain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8ed47c140..e54ff8fb8 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -343,7 +343,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else { fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); - voutToJSON(tx, uint256(), objTx); + //voutToJSON(tx, uint256(), objTx); + //const CTxOut& txout = tx.vout[i]; + //UniValue out(UniValue::VOBJ); + objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()))); result.push_back(objTx); } i = i + 1; From c4ee47ec3651ec29ce2a5da50ad0cbb21cee8990 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 12:12:18 +0800 Subject: [PATCH 249/951] add rpc to return pubkey --- src/rpcblockchain.cpp | 20 +++++--------------- src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e54ff8fb8..5499ca742 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,18 +257,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) -{ - UniValue vout(UniValue::VARR); - for (unsigned int i = 0; i < tx.vout.size(); i++) { - const CTxOut& txout = tx.vout[i]; - UniValue out(UniValue::VOBJ); - out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end()))); - vout.push_back(out); - } - entry.push_back(Pair("vout", vout)); -} - UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -335,18 +323,20 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue result(UniValue::VARR); unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); + // Iif block tx size is > 2 then we can do this BOOST_FOREACH(const CTransaction&tx, block.vtx) { + //if the vout size = 3 then its a valid TX get the data. dont use the test here! it wont work with notarisations! if ( (i == 0) || (i == (block.vtx.size() -1)) ) { fprintf(stderr, "skipped tx number: %d \n",i); } else { fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); - //voutToJSON(tx, uint256(), objTx); - //const CTxOut& txout = tx.vout[i]; - //UniValue out(UniValue::VOBJ); + objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()))); + // function here to extract seqid from first and last TX + // we an push the data or not depending on input from RPC. result.push_back(objTx); } i = i + 1; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index b23dbc826..15f31d8ef 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,6 +264,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "stop", &stop, true }, + { "control", "getpubkey", &getpubkey, true }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index d2194db4f..658102af0 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -322,6 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue getpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0e9fc8e80..e075a0d8b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4953,6 +4953,35 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +UniValue getpubkey(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + if (fHelp || params.size() > 0) + throw runtime_error( + "getpubkey\n" + "\nReturns the -pubkey the daemon was started with.\n" + "\nResult:\n" + "[\n" + " {\n" + " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " }\n" + "]\n" + "\nExamples:\n" + "\nList pubkey.\n" + + HelpExampleCli("getpubkey", "") + + HelpExampleRpc("getpubkey", "") + ); + + extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY; + if ( NOTARY_PUBKEY33[0] == 0 ) { + result.push_back(Pair("error","pubkey was not set!"; + } else { + result.push_back(Pair("pubkey", NOTARY_PUBKEY); + } + return result; +} + UniValue oraclesaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; From fac14d5dc4abd1c47f031596d15b2798445f14d6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 12:16:36 +0800 Subject: [PATCH 250/951] add pubkey to getinfo for all pubkeys, not just notary --- src/rpcmisc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a42afbb61..a1d576d58 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) { + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } } if ( ASSETCHAINS_CC != 0 ) From 9920c80bde876e8b598b13ec4c3bde9c81ae801b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 12:49:12 +0800 Subject: [PATCH 251/951] add pubkey output to getinfo, and try setpubkey RPC --- src/rpcmisc.cpp | 3 +++ src/rpcserver.cpp | 2 +- src/rpcserver.h | 2 +- src/wallet/rpcwallet.cpp | 20 ++++++++++---------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a42afbb61..f104899e1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) { + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } } if ( ASSETCHAINS_CC != 0 ) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 15f31d8ef..1b590c5ae 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,7 +264,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "stop", &stop, true }, - { "control", "getpubkey", &getpubkey, true }, + { "control", "setpubkey", &setpubkey, true }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 658102af0..81ca8a8b9 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -322,7 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); -extern UniValue getpubkey(const UniValue& params, bool fHelp); +extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e075a0d8b..acbe165c2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4953,13 +4953,13 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } -UniValue getpubkey(const UniValue& params, bool fHelp) +UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - if (fHelp || params.size() > 0) + if ( fHelp || params.size() != 1 ) throw runtime_error( - "getpubkey\n" - "\nReturns the -pubkey the daemon was started with.\n" + "setpubkey\n" + "\Sets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" "\nResult:\n" "[\n" " {\n" @@ -4968,17 +4968,17 @@ UniValue getpubkey(const UniValue& params, bool fHelp) "]\n" "\nExamples:\n" "\nList pubkey.\n" - + HelpExampleCli("getpubkey", "") - + HelpExampleRpc("getpubkey", "") + + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 ) { - result.push_back(Pair("error","pubkey was not set!"; - } else { - result.push_back(Pair("pubkey", NOTARY_PUBKEY); + if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 )) { + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } + result.push_back(Pair("pubkey", NOTARY_PUBKEY); return result; } From 07bc62d2c3dd601a14408eee62605b7a993ef592 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 13:06:51 +0800 Subject: [PATCH 252/951] fix --- src/wallet/rpcwallet.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index acbe165c2..19ec2a498 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4958,27 +4958,26 @@ UniValue setpubkey(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); if ( fHelp || params.size() != 1 ) throw runtime_error( - "setpubkey\n" - "\Sets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" - "\nResult:\n" - "[\n" - " {\n" - " \"pubkey\" : \"pubkey\", (string) The pubkey\n" - " }\n" - "]\n" - "\nExamples:\n" - "\nList pubkey.\n" - + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - ); + "setpubkey\n" + "\nSets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" + "\nArguments:\n" + "1. \"pubkey\" (string) pubkey to set.\n" + "\nResult:\n" + " {\n" + " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " }\n" + "\nExamples:\n" + + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + ); extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 )) { + if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } - result.push_back(Pair("pubkey", NOTARY_PUBKEY); + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; } From 9b6bc59d958e71523db59dfc6daeac591d33cfdf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 13:34:52 +0800 Subject: [PATCH 253/951] set pubkey fix --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 19ec2a498..fd51c47b6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4959,7 +4959,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error( "setpubkey\n" - "\nSets the -pubkey if the daemon was not started with it, if it was started, it returns the pubkey.\n" + "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" "\nArguments:\n" "1. \"pubkey\" (string) pubkey to set.\n" "\nResult:\n" @@ -4974,8 +4974,12 @@ UniValue setpubkey(const UniValue& params, bool fHelp) extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { + LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + + } else { + result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; From 5e95a0e51f0e6c6d60f8b5888172dc32b38400e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:13:39 +0800 Subject: [PATCH 254/951] add convert pubkey to address call --- 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 fd51c47b6..5509a6b09 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4971,13 +4971,15 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); + char *address; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - + pubkey2addr(address,(uint8_t *)NOTARY_PUBKEY33); + result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From bec8436996ad4d495b6e6fa74799963edd3f5b93 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:16:02 +0800 Subject: [PATCH 255/951] try --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5509a6b09..26e9602e9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4953,6 +4953,8 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); From 064e6b67e435ff96092ab8360db6079299bf18ab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:19:33 +0800 Subject: [PATCH 256/951] fix? --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 26e9602e9..1b85e2494 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4980,7 +4980,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr(address,(uint8_t *)NOTARY_PUBKEY33); + pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); + printf("%s\n",address); result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From fb13ce2e73ee2465c8d70301a8e2b8eedbca6410 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:23:43 +0800 Subject: [PATCH 257/951] fix --- 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 1b85e2494..c69b9250e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4973,7 +4973,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); - char *address; + char address[20]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { From 4e989f5d0ed25909ad31b4c9dad6bc5f90377537 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:30:30 +0800 Subject: [PATCH 258/951] fix? --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c69b9250e..ab9eeced1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4982,7 +4982,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); printf("%s\n",address); - result.push_back(Pair("R-address", address)); + std::string str(address); + result.push_back(Pair("R-address", str)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 327f5aeb966f7ceced26409af97e212c4bb0065f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:35:47 +0800 Subject: [PATCH 259/951] hmm --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ab9eeced1..1724be26f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4983,7 +4983,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); printf("%s\n",address); std::string str(address); - result.push_back(Pair("R-address", str)); + cout << str; + //result.push_back(Pair("R-address", str)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 7cc09a50cc13a2e13a5e4b65259c9d2b255a5c68 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:39:04 +0800 Subject: [PATCH 260/951] try --- src/wallet/rpcwallet.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1724be26f..9f25005c1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4973,18 +4973,16 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); - char address[20]; + char address[18]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { - LOCK(cs_main); + //LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); printf("%s\n",address); - std::string str(address); - cout << str; - //result.push_back(Pair("R-address", str)); + result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 27402fecd1251487d8c2348e87b1eb4fec7959cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:46:37 +0800 Subject: [PATCH 261/951] try --- src/wallet/rpcwallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9f25005c1..00b33f7e6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4974,14 +4974,17 @@ UniValue setpubkey(const UniValue& params, bool fHelp) ); char address[18]; + uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)address,(uint8_t *)pubkey33); + printf("%s\n",address); + extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { //LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)address,(uint8_t *)NOTARY_PUBKEY33); - printf("%s\n",address); result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From ecfeb9dd9c449c54c1a6893963a6a3166f85fbce Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:50:43 +0800 Subject: [PATCH 262/951] try --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 00b33f7e6..63e2371f6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4976,9 +4976,9 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char address[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33); - printf("%s\n",address); - + if (pubkey2addr((char *)address,(uint8_t *)pubkey33)) + printf("%s\n",address); + extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { From b412964cf243607a1aec635968ee4aecd672c409 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 14:58:07 +0800 Subject: [PATCH 263/951] fix --- src/wallet/rpcwallet.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 63e2371f6..9bb049371 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4967,6 +4967,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) "\nResult:\n" " {\n" " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " \"R-address\" : \"R address\", (string) The pubkey\n" " }\n" "\nExamples:\n" + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") @@ -4975,16 +4976,14 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char address[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - if (pubkey2addr((char *)address,(uint8_t *)pubkey33)) - printf("%s\n",address); - extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { //LOCK(cs_main); NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)address,(uint8_t *)pubkey33) result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From 906935b4efa6e7c9c00212f84b754618e30d315e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:00:49 +0800 Subject: [PATCH 264/951] fix --- 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 9bb049371..f32f08a84 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4983,7 +4983,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33) + pubkey2addr((char *)address,(uint8_t *)pubkey33); result.push_back(Pair("R-address", address)); } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From 6ef59e5094e3bae67ec15cf322b2241d1dba90d4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:14:54 +0800 Subject: [PATCH 265/951] error checks --- src/wallet/rpcwallet.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f32f08a84..77863165e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4978,13 +4978,19 @@ UniValue setpubkey(const UniValue& params, bool fHelp) uint8_t pubkey33[33]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 && strlen(params[0].get_str().c_str()) == 66 ) { - //LOCK(cs_main); - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33); - result.push_back(Pair("R-address", address)); + if ( NOTARY_PUBKEY33[0] == 0 ) { + if (strlen(params[0].get_str().c_str()) == 66) { + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)address,(uint8_t *)pubkey33); + if (strncmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { + result.push_back(Pair("error", "pubkey entered is invalid.")); + } else { + LOCK(cs_main); + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + result.push_back(Pair("R-address", address)); + } + } } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } From 841a3cc642236f0dfa045dc438a3338b7b44f8c9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:16:10 +0800 Subject: [PATCH 266/951] fix --- 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 77863165e..f24deadf8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4982,7 +4982,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); pubkey2addr((char *)address,(uint8_t *)pubkey33); - if (strncmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { + if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { result.push_back(Pair("error", "pubkey entered is invalid.")); } else { LOCK(cs_main); From 021d89a826201e2719ccd1829b23dbb47df51406 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:19:05 +0800 Subject: [PATCH 267/951] fix --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f24deadf8..74bdf7e47 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4990,6 +4990,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); result.push_back(Pair("R-address", address)); } + } else { + result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); } } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); From fc9a044c7e1be004b04ccdc890e6c995f619d0be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:31:27 +0800 Subject: [PATCH 268/951] try --- src/wallet/rpcwallet.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 74bdf7e47..7a166a495 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4974,21 +4974,37 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); - char address[18]; +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif + + char Raddress[18]; uint8_t pubkey33[33]; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)address,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",address) == 0) { + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { result.push_back(Pair("error", "pubkey entered is invalid.")); } else { - LOCK(cs_main); + CBitcoinAddress address(Raddress); + bool isValid = address.IsValid(); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + result.push_back(Pair("address", currentAddress)); +#ifdef ENABLE_WALLET + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); +#endif + } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - result.push_back(Pair("R-address", address)); } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); From e3237f4a0b3d09e440ac36f369e60bf167462341 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:48:19 +0800 Subject: [PATCH 269/951] test adding pubkey to getinfo and setpubkey RPC --- src/rpcmisc.cpp | 3 ++ src/rpcserver.cpp | 25 ++++++++-------- src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a42afbb61..a1d576d58 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -158,6 +159,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) { + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } } if ( ASSETCHAINS_CC != 0 ) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 7d2eab1e3..f724b5071 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -350,16 +350,16 @@ static const CRPCCommand vRPCCommands[] = #endif /* auction */ { "auction", "auctionaddress", &auctionaddress, true }, - + /* lotto */ { "lotto", "lottoaddress", &lottoaddress, true }, - + /* fsm */ { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + /* rewards */ { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -368,16 +368,16 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + /* faucet */ { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - + /* MofN */ { "MofN", "mofnaddress", &mofnaddress, true }, - + /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, { "channels", "channelsinfo", &channelsinfo, true }, @@ -385,7 +385,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + /* Oracles */ { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -395,7 +395,7 @@ static const CRPCCommand vRPCCommands[] = { "oracles", "oraclessubscribe", &oraclessubscribe, true }, { "oracles", "oraclesdata", &oraclesdata, true }, { "oracles", "oraclessamples", &oraclessamples, true }, - + /* Prices */ { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, @@ -405,16 +405,16 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesstatus", &pricesstatus, true }, { "prices", "pricesfinish", &pricesfinish, true }, - + /* Pegs */ { "pegs", "pegsaddress", &pegsaddress, true }, - + /* Triggers */ { "triggers", "triggersaddress", &triggersaddress, true }, - + /* Payments */ { "payments", "paymentsaddress", &paymentsaddress, true }, - + /* Gateways */ { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, @@ -521,6 +521,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "sendmany", &sendmany, false }, { "wallet", "sendtoaddress", &sendtoaddress, false }, { "wallet", "setaccount", &setaccount, true }, + { "wallet", "setpubkey", &setpubkey, true }, { "wallet", "settxfee", &settxfee, true }, { "wallet", "signmessage", &signmessage, true }, { "wallet", "walletlock", &walletlock, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index a78f1b6fc..98c3357f9 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -322,6 +322,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); extern UniValue getnetworkinfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 936c31fd9..c06477099 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4951,6 +4951,68 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +UniValue setpubkey(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); + if ( fHelp || params.size() != 1 ) + throw runtime_error( + "setpubkey\n" + "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" + "\nArguments:\n" + "1. \"pubkey\" (string) pubkey to set.\n" + "\nResult:\n" + " {\n" + " \"pubkey\" : \"pubkey\", (string) The pubkey\n" + " \"ismine\" : \"true/false\", (bool)\n" + " \"R-address\" : \"R address\", (string) The pubkey\n" + " }\n" + "\nExamples:\n" + + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + ); + +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif + + char Raddress[18]; + uint8_t pubkey33[33]; + extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY; + if ( NOTARY_PUBKEY33[0] == 0 ) { + if (strlen(params[0].get_str().c_str()) == 66) { + decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { + result.push_back(Pair("error", "pubkey entered is invalid.")); + } else { + CBitcoinAddress address(Raddress); + bool isValid = address.IsValid(); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + result.push_back(Pair("address", currentAddress)); +#ifdef ENABLE_WALLET + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); +#endif + } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + } + } else { + result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + } + } else { + result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); + } + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + return result; +} + UniValue oraclesaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; From d1791de6f1b6e624c009f7d1afe583c928365d7d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 15:55:59 +0800 Subject: [PATCH 270/951] fix --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c06477099..3f42fb241 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4951,6 +4951,8 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); From dc28f2eb66d2552ea0856e4e4dcbf709fbcac3b5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 24 Oct 2018 23:57:26 +0800 Subject: [PATCH 271/951] update getdata function --- src/rpcblockchain.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 5499ca742..2212811ef 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -324,22 +324,33 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this - BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - //if the vout size = 3 then its a valid TX get the data. dont use the test here! it wont work with notarisations! - if ( (i == 0) || (i == (block.vtx.size() -1)) ) + if ( block.vtx.size() > 2 ) { + BOOST_FOREACH(const CTransaction&tx, block.vtx) { - fprintf(stderr, "skipped tx number: %d \n",i); - } else { - fprintf(stderr, "added tx number: %d \n",i); - UniValue objTx(UniValue::VOBJ); - - objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()))); - // function here to extract seqid from first and last TX - // we an push the data or not depending on input from RPC. - result.push_back(objTx); + // ignore first and last TX and any TX that does not have 3 vouts. + if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) + { + fprintf(stderr, "skipped tx number: %d \n",i); + } else { + fprintf(stderr, "added tx number: %d \n",i); + UniValue objTx(UniValue::VOBJ); + std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()) + if ( opretstr.size() > 81 ) { + std::string idstr = str.substr (8,64); // stream ID or txid + std::string seqid = str.substr (72,8); // sequence ID + std::string data = str.substr (80); // data chunk + objTx.push_back(Pair("idstr", idstr)); + objTx.push_back(Pair("seqid", seqid)); + objTx.push_back(Pair("data", data)); + result.push_back(objTx); + } + // function here to extract seqid from first and last TX + // we an push the data or not depending on input from RPC. + } + i = i + 1; } - i = i + 1; + } else { + result.push_back(Pair("error","there are no TX in this block.")) } return result; } From d89e0313cbb0fcd71a274693741386707ecf7b5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:01:15 +0800 Subject: [PATCH 272/951] ; --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 2212811ef..eb0aa4675 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -334,7 +334,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else { fprintf(stderr, "added tx number: %d \n",i); UniValue objTx(UniValue::VOBJ); - std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()) + std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = str.substr (8,64); // stream ID or txid std::string seqid = str.substr (72,8); // sequence ID @@ -345,7 +345,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(objTx); } // function here to extract seqid from first and last TX - // we an push the data or not depending on input from RPC. + // we an push the data or not depending on input from RPC. } i = i + 1; } From e80718809fad34d12529b19192b2325bb87c95ed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:02:31 +0800 Subject: [PATCH 273/951] oops --- src/rpcblockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index eb0aa4675..206aabfcf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -336,9 +336,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) UniValue objTx(UniValue::VOBJ); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { - std::string idstr = str.substr (8,64); // stream ID or txid - std::string seqid = str.substr (72,8); // sequence ID - std::string data = str.substr (80); // data chunk + std::string idstr = opretstr.substr (8,64); // stream ID or txid + std::string seqid = opretstr.substr (72,8); // sequence ID + std::string data = opretstr.substr (80); // data chunk objTx.push_back(Pair("idstr", idstr)); objTx.push_back(Pair("seqid", seqid)); objTx.push_back(Pair("data", data)); From deeb2e2d20c347557162c948ef51ad4c8446fbcb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:03:36 +0800 Subject: [PATCH 274/951] ; --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 206aabfcf..85c7ce343 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -350,7 +350,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) i = i + 1; } } else { - result.push_back(Pair("error","there are no TX in this block.")) + result.push_back(Pair("error","there are no TX in this block.")); } return result; } From 7566c9f1612f5bcd1bdf0c6f8ccbe5e799acf925 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:21:50 +0800 Subject: [PATCH 275/951] seqid as int --- src/rpcblockchain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 85c7ce343..cfa823112 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,6 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); + unsigned int lastseqid = 0; unsigned int i = 0; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this @@ -337,7 +338,11 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid - std::string seqid = opretstr.substr (72,8); // sequence ID + std::string seqidstr = opretstr.substr (72,8); // sequence ID + unsigned int seqid; + std::stringstream ss; + ss << std::hex << seqidstr; + ss >> seqid; std::string data = opretstr.substr (80); // data chunk objTx.push_back(Pair("idstr", idstr)); objTx.push_back(Pair("seqid", seqid)); From f8dbd08dc8b14988ae4621b33b115a1630af127e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:24:20 +0800 Subject: [PATCH 276/951] ? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index cfa823112..16316ae4e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -345,7 +345,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; std::string data = opretstr.substr (80); // data chunk objTx.push_back(Pair("idstr", idstr)); - objTx.push_back(Pair("seqid", seqid)); + objTx.push_back(Pair("seqid", (int)seqid)); objTx.push_back(Pair("data", data)); result.push_back(objTx); } From b52da6b92141cfff32588b7e17f5a50982b25fa1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:52:33 +0800 Subject: [PATCH 277/951] try --- src/rpcblockchain.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 16316ae4e..a4d5d8040 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,8 +321,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); - unsigned int lastseqid = 0; - unsigned int i = 0; + unsigned int firstdeqid = lastseqid = i = did1 = 0; + static std::string streamid,firsttxid; + std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this if ( block.vtx.size() > 2 ) { @@ -334,26 +335,37 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "skipped tx number: %d \n",i); } else { fprintf(stderr, "added tx number: %d \n",i); - UniValue objTx(UniValue::VOBJ); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID + std::string data = opretstr.substr (80); // data chunk unsigned int seqid; std::stringstream ss; ss << std::hex << seqidstr; ss >> seqid; - std::string data = opretstr.substr (80); // data chunk - objTx.push_back(Pair("idstr", idstr)); - objTx.push_back(Pair("seqid", (int)seqid)); - objTx.push_back(Pair("data", data)); - result.push_back(objTx); + if ( seqid == 1 ) { + streamid = idstr; + } + if ( seqid == (lastseqid + 1 )) { + blockdata.append(data); + } + if ( did1 == 0 ) { + firstdeqid = seqid; + did1 = 1; + } + lastseqid = seqid; } // function here to extract seqid from first and last TX // we an push the data or not depending on input from RPC. } i = i + 1; } + result.push_back(Pair("streamid", streamid)); + result.push_back(Pair("firstseqid", (int)firstseqid)); + result.push_back(Pair("lastseqid", (int)lastseqid)); + result.push_back(Pair("data", blockdata)); + result.push_back(objTx); } else { result.push_back(Pair("error","there are no TX in this block.")); } From d640ffcea71a8012ec84fdfa120d1b884161f5d9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:54:11 +0800 Subject: [PATCH 278/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a4d5d8040..c9942a5f4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); - unsigned int firstdeqid = lastseqid = i = did1 = 0; + unsigned int firstdeqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); From 04278865dc9596951bed0fb46a60ea0209b7c3d3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:54:28 +0800 Subject: [PATCH 279/951] fix --- src/rpcblockchain.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c9942a5f4..674f99f42 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -365,7 +365,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("data", blockdata)); - result.push_back(objTx); } else { result.push_back(Pair("error","there are no TX in this block.")); } From 61cbc5257fceb7435faa3f238411a745176df961 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:55:30 +0800 Subject: [PATCH 280/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 674f99f42..847ee13db 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VARR); - unsigned int firstdeqid,lastseqid,i,did1; + unsigned int firstseqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); From 11eccfa80bbdea7da4995e8001fb5185156c7910 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 00:56:24 +0800 Subject: [PATCH 281/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 847ee13db..51036995d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -351,7 +351,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) blockdata.append(data); } if ( did1 == 0 ) { - firstdeqid = seqid; + firstseqid = seqid; did1 = 1; } lastseqid = seqid; From 659f97c027ca016c0ef9224cb5dc86308cb69fca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:02:19 +0800 Subject: [PATCH 282/951] fix? --- src/rpcblockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 51036995d..f3f483b5b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -320,7 +320,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } return chainActive.Height(); */ - UniValue result(UniValue::VARR); + UniValue result(UniValue::VOBJ); unsigned int firstseqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; @@ -332,9 +332,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d \n",i); + fprintf(stderr, "skipped tx number: %u \n",i); } else { - fprintf(stderr, "added tx number: %d \n",i); + fprintf(stderr, "added tx number: %u \n",i); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid @@ -346,6 +346,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; if ( seqid == 1 ) { streamid = idstr; + printf("streamid: %s\n",streamid.c_str()); } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -353,6 +354,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( did1 == 0 ) { firstseqid = seqid; did1 = 1; + printf("DID 1 first seqid = %u\n", firstseqid); } lastseqid = seqid; } From 426015aa75d50e763065e15d5c629f3ef80a9f05 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:09:19 +0800 Subject: [PATCH 283/951] WOW! it works --- src/rpcblockchain.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f3f483b5b..adaed6b2e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VOBJ); - unsigned int firstseqid,lastseqid,i,did1; + signed int firstseqid,lastseqid,i,did1; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); @@ -332,9 +332,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %u \n",i); + fprintf(stderr, "skipped tx number: %d \n",i); } else { - fprintf(stderr, "added tx number: %u \n",i); + fprintf(stderr, "added tx number: %d \n",i); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid @@ -346,7 +346,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; if ( seqid == 1 ) { streamid = idstr; - printf("streamid: %s\n",streamid.c_str()); + } else if ( seqid == 2 ) { + firsttxid = idstr; } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -354,7 +355,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( did1 == 0 ) { firstseqid = seqid; did1 = 1; - printf("DID 1 first seqid = %u\n", firstseqid); } lastseqid = seqid; } @@ -364,6 +364,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) i = i + 1; } result.push_back(Pair("streamid", streamid)); + result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("data", blockdata)); From 3d29921a2562895d1634031e36400618a76aa111 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:13:43 +0800 Subject: [PATCH 284/951] fix --- src/rpcblockchain.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index adaed6b2e..56ac5f777 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -321,7 +321,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) return chainActive.Height(); */ UniValue result(UniValue::VOBJ); - signed int firstseqid,lastseqid,i,did1; + signed int firstseqid,lastseqid; + int i = 0; + int did1 = 0; static std::string streamid,firsttxid; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); @@ -332,9 +334,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d \n",i); + fprintf(stderr, "skipped tx number: %d\n,i"; } else { - fprintf(stderr, "added tx number: %d \n",i); std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid From 81ae02e649f3565bf3a285ea29de52b322c05341 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 01:14:47 +0800 Subject: [PATCH 285/951] oops --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 56ac5f777..a972900c1 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -334,7 +334,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d\n,i"; + fprintf(stderr, "skipped tx number: %d\n,i)"; } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { From e42dcb0474697084d94ad3c1761e6a19cbfcf4f6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:24:19 +0800 Subject: [PATCH 286/951] more stuff --- src/rpcblockchain.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a972900c1..0468ace89 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,6 +257,12 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } +int convertstreamid(char *streamid_str, char *streamid_hex) { + char decodedhextest[32]; + decode_hex(streamid_str,32,streamid_hex); + printf("decoded hex: %s\n",decodedhextest); +} + UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -314,12 +320,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if(!ReadBlockFromDisk(block, pblockindex,1)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - /*BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - fprintf(stderr, "%s\n",tx.GetHash().GetHex().cstr()); - } - return chainActive.Height(); - */ UniValue result(UniValue::VOBJ); signed int firstseqid,lastseqid; int i = 0; @@ -338,9 +338,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { - std::string idstr = opretstr.substr (8,64); // stream ID or txid + std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID - std::string data = opretstr.substr (80); // data chunk + std::string data = opretstr.substr (80); // data chunk unsigned int seqid; std::stringstream ss; ss << std::hex << seqidstr; @@ -349,6 +349,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) streamid = idstr; } else if ( seqid == 2 ) { firsttxid = idstr; + } else if (firsttxid.isempty()) { + firsttxid == idstr; } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -364,13 +366,24 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - result.push_back(Pair("streamid", streamid)); + if (streamid.isempty()) { + uint256 hash,firsttxid_256; CTransaction firsttx; + firsttxid_256 = bits256_conv(firsttxid); + if (GetTransaction(firsttxid_256,firsttx,hash,false)) { + std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); + std::string streamid = firststreamid.substr (8,64); + } + } + char decodedstreamid[32]; + decode_hex(decodedstreamid,32,streamid.c_str()); + printf("decoded hex: %s\n",decodedstreamid); + result.push_back(Pair("streamid", decodedstreamid); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); result.push_back(Pair("data", blockdata)); } else { - result.push_back(Pair("error","there are no TX in this block.")); + result.push_back(Pair("error","there is no data in this block.")); } return result; } From be21e25e563456e18a6642358cb2bb80778e4a1f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:32:55 +0800 Subject: [PATCH 287/951] fix --- src/rpcblockchain.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0468ace89..45ce9b70c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,10 +257,14 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int convertstreamid(char *streamid_str, char *streamid_hex) { - char decodedhextest[32]; - decode_hex(streamid_str,32,streamid_hex); - printf("decoded hex: %s\n",decodedhextest); +int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +bits256 bits256_conv(char *hexstr) +{ + bits256 x; + memset(&x,0,sizeof(x)); + if ( strlen(hexstr) == sizeof(x)*2) + decode_hex(x.bytes,sizeof(x.bytes),hexstr); + return(x); } UniValue getdatafromblock(const UniValue& params, bool fHelp) @@ -349,7 +353,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) streamid = idstr; } else if ( seqid == 2 ) { firsttxid = idstr; - } else if (firsttxid.isempty()) { + } else if (firsttxid.empty()) { firsttxid == idstr; } if ( seqid == (lastseqid + 1 )) { @@ -366,7 +370,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - if (streamid.isempty()) { + if (streamid.empty()) { uint256 hash,firsttxid_256; CTransaction firsttx; firsttxid_256 = bits256_conv(firsttxid); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { From aae6bbcdf263295a4fbcc7fa025c493a91716f1c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:35:51 +0800 Subject: [PATCH 288/951] fix some --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 45ce9b70c..f77f5dba7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -338,7 +338,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { - fprintf(stderr, "skipped tx number: %d\n,i)"; + fprintf(stderr, "skipped tx number: %d\n",i); } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); if ( opretstr.size() > 81 ) { @@ -381,7 +381,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) char decodedstreamid[32]; decode_hex(decodedstreamid,32,streamid.c_str()); printf("decoded hex: %s\n",decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid); + result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); From 5e0dd924c6cda3f6d2f24eaa9cc8e24956ec0dcf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 10:51:28 +0800 Subject: [PATCH 289/951] try --- src/rpcblockchain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f77f5dba7..e48473c1c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -258,9 +258,9 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) } int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -bits256 bits256_conv(char *hexstr) +uint256 bits256_conv(char *hexstr) { - bits256 x; + uint256 x; memset(&x,0,sizeof(x)); if ( strlen(hexstr) == sizeof(x)*2) decode_hex(x.bytes,sizeof(x.bytes),hexstr); @@ -379,8 +379,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } char decodedstreamid[32]; - decode_hex(decodedstreamid,32,streamid.c_str()); - printf("decoded hex: %s\n",decodedstreamid); + decode_hex((char *)decodedstreamid,32,streamid.c_str()); + printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); From a1141951cab2afa1c0ebeb3a3547579be9c5d884 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:05:53 +0800 Subject: [PATCH 290/951] try --- src/rpcblockchain.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e48473c1c..d0eb45401 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -258,14 +258,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) } int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -uint256 bits256_conv(char *hexstr) -{ - uint256 x; - memset(&x,0,sizeof(x)); - if ( strlen(hexstr) == sizeof(x)*2) - decode_hex(x.bytes,sizeof(x.bytes),hexstr); - return(x); -} UniValue getdatafromblock(const UniValue& params, bool fHelp) { @@ -371,15 +363,15 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) i = i + 1; } if (streamid.empty()) { - uint256 hash,firsttxid_256; CTransaction firsttx; - firsttxid_256 = bits256_conv(firsttxid); + uint256 hash; CTransaction firsttx; + uint256 firsttxid_256 = ParseHashV(firsttxid); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string streamid = firststreamid.substr (8,64); } } char decodedstreamid[32]; - decode_hex((char *)decodedstreamid,32,streamid.c_str()); + decode_hex((uint8_t)decodedstreamid,32,streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From 7768292e180714c1b980c18425a9ddb5f7d378f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:08:15 +0800 Subject: [PATCH 291/951] ? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index d0eb45401..b798cb22e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -364,7 +364,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } if (streamid.empty()) { uint256 hash; CTransaction firsttx; - uint256 firsttxid_256 = ParseHashV(firsttxid); + uint256 firsttxid_256 = ParseHashV(firsttxid,"firsttxid"); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string streamid = firststreamid.substr (8,64); From 2630e93a16851c5b6549fe2604d63ff2abe492fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:11:42 +0800 Subject: [PATCH 292/951] ? --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b798cb22e..c32e645da 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,7 +257,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +int32_t decode_hex(char *bytes,int32_t n,char *hex); UniValue getdatafromblock(const UniValue& params, bool fHelp) { @@ -371,7 +371,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } char decodedstreamid[32]; - decode_hex((uint8_t)decodedstreamid,32,streamid.c_str()); + decode_hex(decodedstreamid,32,streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From 5b11f256aae923e98c47920000131a2b61e7b1ad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:15:07 +0800 Subject: [PATCH 293/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c32e645da..a009a2752 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -371,7 +371,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } char decodedstreamid[32]; - decode_hex(decodedstreamid,32,streamid.c_str()); + decode_hex(decodedstreamid,32,(char *)streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From 89f6e171dee2c861b7928b89eca6bb8b722c74e5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:17:16 +0800 Subject: [PATCH 294/951] again --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a009a2752..b0dd031a9 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -257,7 +257,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int32_t decode_hex(char *bytes,int32_t n,char *hex); +int32_t decode_hex(uint8_t bytes,int32_t n,char *hex); UniValue getdatafromblock(const UniValue& params, bool fHelp) { From 5d5c1bd4738821416cbf01b57f616cbb68a62098 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:25:40 +0800 Subject: [PATCH 295/951] try --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b0dd031a9..c062669a7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -370,7 +370,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string streamid = firststreamid.substr (8,64); } } - char decodedstreamid[32]; + uint8_t decodedstreamid[32]; decode_hex(decodedstreamid,32,(char *)streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); From 1e8cd9ff69ddcb4a37ff5c1d47a2d69133e9ff63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:28:28 +0800 Subject: [PATCH 296/951] ? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c062669a7..74b3f297d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -371,7 +371,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } uint8_t decodedstreamid[32]; - decode_hex(decodedstreamid,32,(char *)streamid.c_str()); + decode_hex(*decodedstreamid,32,(char *)streamid.c_str()); printf("decoded hex: %s\n",(char *)decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); From e8caddfca3adfbc4f848e8c3b3da961332c02bab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:31:20 +0800 Subject: [PATCH 297/951] include decode hex --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 74b3f297d..76395ca8f 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -20,6 +20,7 @@ #include "script/script_error.h" #include "script/sign.h" #include "script/standard.h" +#include "komodo_utils.h" #include From 5489c976f0c479a69997ad69b315471deebc2832 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:37:54 +0800 Subject: [PATCH 298/951] fix --- src/rpcblockchain.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 76395ca8f..eec2130c1 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -20,7 +20,6 @@ #include "script/script_error.h" #include "script/sign.h" #include "script/standard.h" -#include "komodo_utils.h" #include @@ -258,7 +257,30 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -int32_t decode_hex(uint8_t bytes,int32_t n,char *hex); +unsigned char hexval(unsigned char c) +{ + if ('0' <= c && c <= '9') + return c - '0'; + else if ('a' <= c && c <= 'f') + return c - 'a' + 10; + else if ('A' <= c && c <= 'F') + return c - 'A' + 10; + else abort(); +} + +void hex2ascii(const string& in, string& out) +{ + out.clear(); + out.reserve(in.length() / 2); + for (string::const_iterator p = in.begin(); p != in.end(); p++) + { + unsigned char c = hexval(*p); + p++; + if (p == in.end()) break; // incomplete last digit - should report error + c = (c << 4) + hexval(*p); // + takes precedence over << + out.push_back(c); + } +} UniValue getdatafromblock(const UniValue& params, bool fHelp) { @@ -371,9 +393,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string streamid = firststreamid.substr (8,64); } } - uint8_t decodedstreamid[32]; - decode_hex(*decodedstreamid,32,(char *)streamid.c_str()); - printf("decoded hex: %s\n",(char *)decodedstreamid); + std::string decodedstreamid; + hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); From 95992d4492aff6bdd2ce865697b357fe7e1f0192 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:50:47 +0800 Subject: [PATCH 299/951] add t/f flag for data --- src/rpcblockchain.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index eec2130c1..5f6142300 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -330,6 +330,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + bool fVerbose = true; + if (params.size() > 1) + fVerbose = params[1].get_bool(); + CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; @@ -399,7 +403,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - result.push_back(Pair("data", blockdata)); + if (fVerbose) { + result.push_back(Pair("data", blockdata)); + } } else { result.push_back(Pair("error","there is no data in this block.")); } From c4434400d19d42dc9fd05d767f5d9244c6c1dc40 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 11:55:29 +0800 Subject: [PATCH 300/951] try --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 5f6142300..612acf2bf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -330,9 +330,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - bool fVerbose = true; + bool fVerbose = false; if (params.size() > 1) - fVerbose = params[1].get_bool(); + fVerbose = (params[1].get_int() != 0); CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; From e8cd54ea2fbdb43b495792acf5979ac3d8851f94 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 12:02:58 +0800 Subject: [PATCH 301/951] ? --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 612acf2bf..0178fbf43 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -373,6 +373,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if ( seqid == 2 ) { firsttxid = idstr; } else if (firsttxid.empty()) { + printf("firsttxid is empty: %s\n",idstr.c_str()); firsttxid == idstr; } if ( seqid == (lastseqid + 1 )) { From 6ac869140f17fbead6dff7e1e68d5315032aea8f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 12:53:05 +0800 Subject: [PATCH 302/951] ? --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0178fbf43..204ea7b23 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -374,7 +374,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid = idstr; } else if (firsttxid.empty()) { printf("firsttxid is empty: %s\n",idstr.c_str()); - firsttxid == idstr; + firsttxid.append(idstr); } if ( seqid == (lastseqid + 1 )) { blockdata.append(data); @@ -392,7 +392,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } if (streamid.empty()) { uint256 hash; CTransaction firsttx; - uint256 firsttxid_256 = ParseHashV(firsttxid,"firsttxid"); + uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); std::string streamid = firststreamid.substr (8,64); From ee7e3de254a836821036585c8f60ffca8a54ec7c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 12:57:07 +0800 Subject: [PATCH 303/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 204ea7b23..0fdb17dea 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -395,7 +395,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - std::string streamid = firststreamid.substr (8,64); + streamid.append(firststreamid.substr (8,64)); } } std::string decodedstreamid; From 07f2fa7b1f4a1d7a45708008df4860cf2dac563f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 13:00:29 +0800 Subject: [PATCH 304/951] hex --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0fdb17dea..38c450224 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -401,6 +401,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid)); + result.push_back(Pair("streamidhex", streamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); From d32cdefe7bc9b415469d407e9ea91e145a3bb68f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 13:18:23 +0800 Subject: [PATCH 305/951] test --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 38c450224..f013420e4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -278,6 +278,7 @@ void hex2ascii(const string& in, string& out) p++; if (p == in.end()) break; // incomplete last digit - should report error c = (c << 4) + hexval(*p); // + takes precedence over << + printf("char: %d\n",c); out.push_back(c); } } From ed7c03730365c8cca5a77a38570eed48009d52c6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 13:26:17 +0800 Subject: [PATCH 306/951] try --- src/rpcblockchain.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f013420e4..655d2c906 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -278,7 +278,6 @@ void hex2ascii(const string& in, string& out) p++; if (p == in.end()) break; // incomplete last digit - should report error c = (c << 4) + hexval(*p); // + takes precedence over << - printf("char: %d\n",c); out.push_back(c); } } @@ -401,7 +400,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid)); + result.push_back(Pair("streamid", decodedstreamid.c_str())); result.push_back(Pair("streamidhex", streamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); From 1ec39b2b97a7b1361303020f7048988b3466455a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:09:51 +0800 Subject: [PATCH 307/951] try 2 arg as str --- src/rpcblockchain.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 655d2c906..cd7167dcf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -303,6 +303,11 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string strHash = params[0].get_str(); + if (params.size() > 1) { + std::string getdata = params[1].get_str(); + printf("%s\n",getdata.c_str()); + } + // If height is supplied, find the hash if (strHash.size() < (2 * sizeof(uint256))) { // std::stoi allows characters, whereas we want to be strict @@ -330,10 +335,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - bool fVerbose = false; - if (params.size() > 1) - fVerbose = (params[1].get_int() != 0); - CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; @@ -360,6 +361,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) fprintf(stderr, "skipped tx number: %d\n",i); } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); + // scriptPubKey is longer than 81, should mean its an OP_RETURN. if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID @@ -373,11 +375,15 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if ( seqid == 2 ) { firsttxid = idstr; } else if (firsttxid.empty()) { - printf("firsttxid is empty: %s\n",idstr.c_str()); firsttxid.append(idstr); } + if ( seqid == (lastseqid + 1 )) { blockdata.append(data); + } else { + result.push_back(Pair("error","chunck out of order in this block!")); + result.push_back(Pair("lastvalidseqid", (int)seqid)); + break; } if ( did1 == 0 ) { firstseqid = seqid; @@ -401,7 +407,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); - result.push_back(Pair("streamidhex", streamid)); result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); From a5c99046866f2eaae4616ae4d5a315ba93ff377a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:11:33 +0800 Subject: [PATCH 308/951] fix --- src/rpcblockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index cd7167dcf..b7def7ea6 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -410,9 +410,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose) { - result.push_back(Pair("data", blockdata)); - } + //if (fVerbose) { + // result.push_back(Pair("data", blockdata)); + //} } else { result.push_back(Pair("error","there is no data in this block.")); } From 806a8e93aa997779fd9cb5920db65d8fb78e9a62 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:15:12 +0800 Subject: [PATCH 309/951] fix? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b7def7ea6..f4ec0d1fa 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -378,7 +378,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } - if ( seqid == (lastseqid + 1 )) { + if ( (seqid == (lastseqid + 1 )) && lastseqid != 0 ) { blockdata.append(data); } else { result.push_back(Pair("error","chunck out of order in this block!")); From 9b3cd72603436b8f8e4cc0b0835388b94e49c9fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:23:26 +0800 Subject: [PATCH 310/951] wtf --- src/rpcblockchain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f4ec0d1fa..74536a2af 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -345,7 +345,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); UniValue result(UniValue::VOBJ); - signed int firstseqid,lastseqid; + int firstseqid = 0; + int lastseqid = 0; int i = 0; int did1 = 0; static std::string streamid,firsttxid; @@ -378,12 +379,13 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } - if ( (seqid == (lastseqid + 1 )) && lastseqid != 0 ) { + if ( seqid == (lastseqid + 1 ) ) { blockdata.append(data); } else { + printf("seqid.%d lastseqid.%d\n",seqid,lastseqid); result.push_back(Pair("error","chunck out of order in this block!")); result.push_back(Pair("lastvalidseqid", (int)seqid)); - break; + //break; } if ( did1 == 0 ) { firstseqid = seqid; From 1dd2a13d7c7ea8f231be9b9cdc59d56821910ed7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:29:13 +0800 Subject: [PATCH 311/951] fixed --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 74536a2af..02547ac66 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -379,7 +379,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } - if ( seqid == (lastseqid + 1 ) ) { + if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { printf("seqid.%d lastseqid.%d\n",seqid,lastseqid); From a3b73317734d4552f78175e8b1c08a57c811317a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:52:23 +0800 Subject: [PATCH 312/951] try --- src/rpcblockchain.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 02547ac66..5309b9536 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -286,26 +286,38 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "getdatafromblock \"hash|height\"\n" + "getdatafromblock \"hash|height\" true/false\n" "\nReturns all the data sent via streamer in block if there was any data in it.\n" "\nArguments:\n" "1. \"hash|height\" (string, required) The block hash or height\n" + "2. \"true/false\" (bool, optional) if false do not return the actual data. Default true.\n" + "\nResult (for verbose = true):\n" + "{\n" + " \"streamid\" : \"string\", (string) the name of the stream.\n" + " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" + " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" + " \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n" + "}\n" "\nResult (for verbose=false):\n" - "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" - "\nExamples:\n" - + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + " \"streamid\" : \"string\", (string) the name of the stream.\n" + " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" + " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" + + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"") + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + HelpExampleCli("getblock", "12800") - + HelpExampleRpc("getblock", "12800") + + HelpExampleRpc("getblock", "12800 false") ); LOCK(cs_main); std::string strHash = params[0].get_str(); - + bool fVerbose = true; if (params.size() > 1) { - std::string getdata = params[1].get_str(); - printf("%s\n",getdata.c_str()); + std::string verboseflag = params[1].get_str(); + if ( verboseflag.compare("false") ) + fVerbose = false; } // If height is supplied, find the hash @@ -382,10 +394,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { - printf("seqid.%d lastseqid.%d\n",seqid,lastseqid); result.push_back(Pair("error","chunck out of order in this block!")); - result.push_back(Pair("lastvalidseqid", (int)seqid)); - //break; + result.push_back(Pair("lastvalidseqid", (int)lastseqid)); + break; } if ( did1 == 0 ) { firstseqid = seqid; @@ -412,9 +423,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - //if (fVerbose) { - // result.push_back(Pair("data", blockdata)); - //} + if (fVerbose) { + result.push_back(Pair("data", blockdata)); + } } else { result.push_back(Pair("error","there is no data in this block.")); } From abddda8830bf5f4df0b09f95d6b3f66b4ca6d295 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:54:50 +0800 Subject: [PATCH 313/951] try --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 5309b9536..31b629ac3 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -316,7 +316,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) bool fVerbose = true; if (params.size() > 1) { std::string verboseflag = params[1].get_str(); - if ( verboseflag.compare("false") ) + if ( verboseflag.compare("false") == 1 ) fVerbose = false; } From 71ee7345e5b5a03e8b03a2272d61f31e2eb9c52f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:58:22 +0800 Subject: [PATCH 314/951] try again --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 31b629ac3..6badd753e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -316,7 +316,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) bool fVerbose = true; if (params.size() > 1) { std::string verboseflag = params[1].get_str(); - if ( verboseflag.compare("false") == 1 ) + if ( verboseflag == "false" ) fVerbose = false; } From ce5bf4b0811a0fe15848022d4d6a0ffb3deaac9b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 14:59:02 +0800 Subject: [PATCH 315/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 6badd753e..0c19bcc20 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -423,7 +423,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("firsttxid", firsttxid)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose) { + if (fVerbose == true) { result.push_back(Pair("data", blockdata)); } } else { From 900f9fc8ec43a0bef74fd5d0d8423b7cc972c9cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:08:39 +0800 Subject: [PATCH 316/951] try to print block hash --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0c19bcc20..1edd2152c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -415,6 +415,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); + printf("block hash: %s\n",hash.ToString().c_str()); } } std::string decodedstreamid; From 8cec48894b7c16b6761a270b6d265839eb8cf2fd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:39:17 +0800 Subject: [PATCH 317/951] more error checks --- src/rpcblockchain.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 1edd2152c..f2387a691 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -361,17 +361,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) int lastseqid = 0; int i = 0; int did1 = 0; + int skippedtxs = 0; + int failed = 0; static std::string streamid,firsttxid; + static int firsttxnHeight; std::string blockdata; fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); // Iif block tx size is > 2 then we can do this - if ( block.vtx.size() > 2 ) { + if ( block.vtx.size() > 2 ) + { BOOST_FOREACH(const CTransaction&tx, block.vtx) { // ignore first and last TX and any TX that does not have 3 vouts. if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) { fprintf(stderr, "skipped tx number: %d\n",i); + skippedtxs = skippedtxs + 1; } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); // scriptPubKey is longer than 81, should mean its an OP_RETURN. @@ -389,6 +394,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid = idstr; } else if (firsttxid.empty()) { firsttxid.append(idstr); + } else if ( firsttxid != idstr ) { + printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); } if ( seqid == (lastseqid + 1) || did1 == 0 ) { @@ -403,6 +410,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) did1 = 1; } lastseqid = seqid; + } else { + skippedtxs = skippedtxs + 1; + fprintf(stderr, "skipped tx number: %d\n",i); } // function here to extract seqid from first and last TX // we an push the data or not depending on input from RPC. @@ -415,7 +425,14 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); - printf("block hash: %s\n",hash.ToString().c_str()); + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + if (chainActive.Contains(pindex)) { + firsttxnHeight = pindex->nHeight; + printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); + } + } } } std::string decodedstreamid; @@ -428,6 +445,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) result.push_back(Pair("data", blockdata)); } } else { + failed = 1; + } + + if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); } return result; From 2b21b2e94d534915227f58c22e2d24585ffcea40 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:44:01 +0800 Subject: [PATCH 318/951] fix --- src/rpcblockchain.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f2387a691..bbd5b6d56 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -435,21 +435,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } } } - std::string decodedstreamid; - hex2ascii(streamid, decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid.c_str())); - result.push_back(Pair("firsttxid", firsttxid)); - result.push_back(Pair("firstseqid", (int)firstseqid)); - result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose == true) { - result.push_back(Pair("data", blockdata)); - } } else { failed = 1; } if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); + } else { + std::string decodedstreamid; + hex2ascii(streamid, decodedstreamid); + result.push_back(Pair("streamid", decodedstreamid.c_str())); + result.push_back(Pair("firsttxid", firsttxid)); + result.push_back(Pair("firstseqid", (int)firstseqid)); + result.push_back(Pair("lastseqid", (int)lastseqid)); + if (fVerbose == true) { + result.push_back(Pair("data", blockdata)); + } } return result; } From 56afde8d171868f0892b25cf0f2427498bb07724 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:52:38 +0800 Subject: [PATCH 319/951] move block print --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index bbd5b6d56..94e140aa5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -430,7 +430,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) CBlockIndex* pindex = (*mi).second; if (chainActive.Contains(pindex)) { firsttxnHeight = pindex->nHeight; - printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); } } } @@ -442,6 +441,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); } else { + printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); From d647a00ba762de93ed5f7b63ac37fe009aa1be2b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 16:59:24 +0800 Subject: [PATCH 320/951] ready for a new chain --- src/rpcblockchain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 94e140aa5..a29464201 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -295,6 +295,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) "{\n" " \"streamid\" : \"string\", (string) the name of the stream.\n" " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" " \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n" @@ -302,6 +303,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) "\nResult (for verbose=false):\n" " \"streamid\" : \"string\", (string) the name of the stream.\n" " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" + " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"") @@ -446,6 +448,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); result.push_back(Pair("firsttxid", firsttxid)); + result.push_back(Pair("firstblockheight", (int)firsttxnHeight)); result.push_back(Pair("firstseqid", (int)firstseqid)); result.push_back(Pair("lastseqid", (int)lastseqid)); if (fVerbose == true) { From 8c0de51c083f0b222340d2fb4c8a5d144dbcdb56 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 17:00:35 +0800 Subject: [PATCH 321/951] fix --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a29464201..0bbba22a8 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -397,7 +397,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if (firsttxid.empty()) { firsttxid.append(idstr); } else if ( firsttxid != idstr ) { - printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); + printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n we are in a new stream here I think\n",firsttxid.c_str(),idstr.c_str()); } if ( seqid == (lastseqid + 1) || did1 == 0 ) { From c3a4829ba563f633ebbb72b2deb2e87ca98473ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 25 Oct 2018 17:46:09 +0800 Subject: [PATCH 322/951] try fix for calling getdata out of order --- src/rpcblockchain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0bbba22a8..6aa8ab384 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -398,6 +398,9 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.append(idstr); } else if ( firsttxid != idstr ) { printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n we are in a new stream here I think\n",firsttxid.c_str(),idstr.c_str()); + firsttxid.clear(); + firsttxid.append(idstr); + streamid.clear(); } if ( seqid == (lastseqid + 1) || did1 == 0 ) { From 9fbf73b63255c68d80652354f25a9e73afff0856 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Fri, 26 Oct 2018 01:08:26 +0200 Subject: [PATCH 323/951] comment out spamming addoracleeinputs print --- src/cc/oracles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 5a352afeb..1cd3be0d0 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -666,7 +666,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); + //fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 7700741e46a3197ef252defbd3d7954d94ff131b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 26 Oct 2018 23:08:26 +0800 Subject: [PATCH 324/951] try? --- src/rpcblockchain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 6aa8ab384..f52b3ac7c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -401,12 +401,13 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) firsttxid.clear(); firsttxid.append(idstr); streamid.clear(); + firsttxnHeight = 0; } if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { - result.push_back(Pair("error","chunck out of order in this block!")); + result.push_back(Pair("error","chunck out of order or missing in this block!")); result.push_back(Pair("lastvalidseqid", (int)lastseqid)); break; } From 8c552c067ccbd88c682eaaa21c3e76694e1f3c09 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 26 Oct 2018 23:23:49 +0800 Subject: [PATCH 325/951] debug --- src/rpcblockchain.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f52b3ac7c..ab9985b44 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -397,7 +397,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } else if (firsttxid.empty()) { firsttxid.append(idstr); } else if ( firsttxid != idstr ) { - printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n we are in a new stream here I think\n",firsttxid.c_str(),idstr.c_str()); + printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); firsttxid.clear(); firsttxid.append(idstr); streamid.clear(); @@ -430,10 +430,12 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); + printf("first stream id changed to: %s\n", firststreamid.c_str()); streamid.append(firststreamid.substr (8,64)); BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex* pindex = (*mi).second; + printf("found block height: %d\n",pindex->nHeight); if (chainActive.Contains(pindex)) { firsttxnHeight = pindex->nHeight; } @@ -447,7 +449,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) if ( failed == 1 || skippedtxs == i ) { result.push_back(Pair("error","there is no data in this block.")); } else { - printf("block hash: %s block height: %d\n",hash.ToString().c_str(),firsttxnHeight); std::string decodedstreamid; hex2ascii(streamid, decodedstreamid); result.push_back(Pair("streamid", decodedstreamid.c_str())); From db0fa8d71cacf5ded3d1f137e3f19b5377cdf50f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 26 Oct 2018 23:41:49 +0800 Subject: [PATCH 326/951] try? --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ab9985b44..e1877d058 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -430,8 +430,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - printf("first stream id changed to: %s\n", firststreamid.c_str()); streamid.append(firststreamid.substr (8,64)); + printf("first stream id changed to: %s\n", streamid.c_str()); BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex* pindex = (*mi).second; From b1727e55cb667e6291331537cb35278cbc4a9232 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:01:24 +0800 Subject: [PATCH 327/951] try --- src/rpcblockchain.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e1877d058..0b6bfc713 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -432,12 +432,16 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); printf("first stream id changed to: %s\n", streamid.c_str()); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - printf("found block height: %d\n",pindex->nHeight); - if (chainActive.Contains(pindex)) { - firsttxnHeight = pindex->nHeight; + if ( firstdeqid == 1 ) { + firsttxnHeight == block.nHeight; + } else { + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + printf("found block height: %d\n",pindex->nHeight); + if (chainActive.Contains(pindex)) { + firsttxnHeight = pindex->nHeight; + } } } } From 5e786e2e4cf3919ca6dfaaaa0f1f52022a3bdcbf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:07:45 +0800 Subject: [PATCH 328/951] fix --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0b6bfc713..e0597a541 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -432,8 +432,8 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); printf("first stream id changed to: %s\n", streamid.c_str()); - if ( firstdeqid == 1 ) { - firsttxnHeight == block.nHeight; + if ( firstseqid == 1 ) { + firsttxnHeight == pblockindex->nHeight; } else { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { From fd8fe7b404768508463745b6606fc54b3b01c60e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:13:26 +0800 Subject: [PATCH 329/951] try --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e0597a541..e383a87f7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -434,6 +434,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) printf("first stream id changed to: %s\n", streamid.c_str()); if ( firstseqid == 1 ) { firsttxnHeight == pblockindex->nHeight; + printf("first seq id is 1 and found height: %d\n",firsttxnHeight ); } else { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { From baa6c490848933b036e5fcb89569807b66010f46 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:29:21 +0800 Subject: [PATCH 330/951] try this --- src/rpcblockchain.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e383a87f7..53971e782 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -365,6 +365,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) int did1 = 0; int skippedtxs = 0; int failed = 0; + int getfirstblock = 0; static std::string streamid,firsttxid; static int firsttxnHeight; std::string blockdata; @@ -392,6 +393,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) ss >> seqid; if ( seqid == 1 ) { streamid = idstr; + getfirstblock = 1; } else if ( seqid == 2 ) { firsttxid = idstr; } else if (firsttxid.empty()) { @@ -403,7 +405,6 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) streamid.clear(); firsttxnHeight = 0; } - if ( seqid == (lastseqid + 1) || did1 == 0 ) { blockdata.append(data); } else { @@ -425,24 +426,22 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) } i = i + 1; } - if (streamid.empty()) { + if (streamid.empty() || getfirstblock == 1) { + if ( lastseqid == 1) { + firsttxid = block.vtx[1].GetHash().GetHex(); + } uint256 hash; CTransaction firsttx; uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); streamid.append(firststreamid.substr (8,64)); printf("first stream id changed to: %s\n", streamid.c_str()); - if ( firstseqid == 1 ) { - firsttxnHeight == pblockindex->nHeight; - printf("first seq id is 1 and found height: %d\n",firsttxnHeight ); - } else { - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - printf("found block height: %d\n",pindex->nHeight); - if (chainActive.Contains(pindex)) { - firsttxnHeight = pindex->nHeight; - } + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + printf("found block height: %d\n",pindex->nHeight); + if (chainActive.Contains(pindex)) { + firsttxnHeight = pindex->nHeight; } } } From 99196bfb15664b1db67731259aee4d8ab4fb2432 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 00:35:18 +0800 Subject: [PATCH 331/951] fix --- src/rpcblockchain.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 53971e782..07cf53ad2 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -433,8 +433,10 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) uint256 hash; CTransaction firsttx; uint256 firsttxid_256(uint256S(firsttxid)); if (GetTransaction(firsttxid_256,firsttx,hash,false)) { - std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - streamid.append(firststreamid.substr (8,64)); + if ( streamid.empty() ) { + std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); + streamid.append(firststreamid.substr (8,64)); + } printf("first stream id changed to: %s\n", streamid.c_str()); BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end() && (*mi).second) { From 8d50000c49a41820b09a697a88b9814c68699aa3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 27 Oct 2018 01:34:24 +0800 Subject: [PATCH 332/951] try send in chunks --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 07cf53ad2..0a00a614c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -382,7 +382,7 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp) skippedtxs = skippedtxs + 1; } else { std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); - // scriptPubKey is longer than 81, should mean its an OP_RETURN. + // scriptPubKey is longer than 81, should mean its an OP_RETURN, maybe also check vout == 0 ? if ( opretstr.size() > 81 ) { std::string idstr = opretstr.substr (8,64); // stream ID or txid std::string seqidstr = opretstr.substr (72,8); // sequence ID From 577cdc7da84b59aacdefdba9fef62d64e0e9a35f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 04:36:20 +0800 Subject: [PATCH 333/951] add num entropy to diceinfo ? --- src/cc/dice.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4271186da..95013944c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int64_t *entropytxs) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0; uint8_t funcid; std::vector > unspentOutputs; @@ -734,6 +734,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); + entropytxs = n; return(totalinputs); } @@ -826,7 +827,9 @@ UniValue DiceInfo(uint256 diceid) result.push_back(Pair("timeoutblocks",timeoutblocks)); cp = CCinit(&C,EVAL_DICE); dicepk = GetUnspendable(cp,0); - funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid); + int64_t entropytxs = 0; + funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid,entropytxs); + result.push_back(Pair("entropytxs",entropytxs)); sprintf(numstr,"%.8f",(double)funding/COIN); result.push_back(Pair("funding",numstr)); return(result); From 3c4a0b4f4d558f7684fcc75cce54693d6adadcb2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:16:59 +0800 Subject: [PATCH 334/951] fix --- src/cc/dice.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 95013944c..d92a1711d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int64_t *entropytxs) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int32_t *entropytxs) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0; uint8_t funcid; std::vector > unspentOutputs; @@ -827,7 +827,7 @@ UniValue DiceInfo(uint256 diceid) result.push_back(Pair("timeoutblocks",timeoutblocks)); cp = CCinit(&C,EVAL_DICE); dicepk = GetUnspendable(cp,0); - int64_t entropytxs = 0; + int32_t entropytxs = 0; funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid,entropytxs); result.push_back(Pair("entropytxs",entropytxs)); sprintf(numstr,"%.8f",(double)funding/COIN); @@ -958,7 +958,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid)) >= 2*bet*odds+txfee && entropyval != 0 ) + int32_t entropytxs; + if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs)) >= 2*bet*odds+txfee && entropyval != 0 ) { if ( myIsutxo_spentinmempool(entropytxid,0) != 0 ) { From 5ff09e4e1a72b2ff6a89a56959af5180313216e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:18:47 +0800 Subject: [PATCH 335/951] try --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index d92a1711d..1e5446486 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -734,7 +734,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); - entropytxs = n; + *entropytxs = n; return(totalinputs); } From d99b91584c2a681a292c7226db0d8f6493b2dd5d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:22:11 +0800 Subject: [PATCH 336/951] fix --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 1e5446486..6fafaa1fd 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK return(totalinputs); } -int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int32_t *entropytxs) +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid,int32_t &entropytxs) { char coinaddr[64],str[65]; uint64_t sbits; int64_t nValue,totalinputs = 0; uint256 hash,txid,proof,hashBlock,fundingtxid; CScript fundingPubKey; CTransaction tx,vinTx; int32_t vout,first=0,n=0; uint8_t funcid; std::vector > unspentOutputs; From dc28cc1a8530096dc3d922ad49ee90f5881c9151 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 28 Oct 2018 05:23:54 +0800 Subject: [PATCH 337/951] fix --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6fafaa1fd..c90ec0f06 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -734,7 +734,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); - *entropytxs = n; + entropytxs = n; return(totalinputs); } From 26623a35919323754b9862b34ef3904a6e6c5f86 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 30 Oct 2018 22:43:33 +0800 Subject: [PATCH 338/951] remove dupe --- src/rpcserver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index e8df01c53..653c786fe 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,7 +264,6 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "stop", &stop, true }, - { "control", "setpubkey", &setpubkey, true }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true }, From 53b0665f84928a97aa3f422ac27ff48bc015cb8e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 12:08:17 +0800 Subject: [PATCH 339/951] start of commit --- src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c456d3e44..569e29a5a 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; @@ -55,7 +55,7 @@ uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; +uint64_t ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index aedb6d3c2..445841596 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1561,7 +1561,10 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = GetArg("-ac_decay",0); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_freward",0); + ASSETCHAINS_OVERRIDE_ADDRESS = GetArg("-ac_address",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); + if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); exit(0); @@ -1595,8 +1598,8 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 0; printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } else if ( ASSETCHAINS_STREAM != 0) { - ASSETCHAINS_STREAM = 0; - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n"); + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); + exit(0); } if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SUPPLY == 10 ) { ASSETCHAINS_SUPPLY = 1000000; From e0235aa0367d000f37f10395a3bb9f58d4e590f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 12:20:06 +0800 Subject: [PATCH 340/951] Revert "Merge branch 'momom_printsonly' into master" This reverts commit e4e1c3874ee5e060d361489d2d75787cb093d623, reversing changes made to 9fbf73b63255c68d80652354f25a9e73afff0856. revert this stupid commit git made by accident! --- src/cc/import.cpp | 6 +----- src/crosschain.cpp | 6 +----- src/komodo.h | 34 +++++++++++++++++----------------- src/komodo_bitcoind.h | 17 ++++++++--------- src/notarisationdb.cpp | 8 ++++---- 5 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index b72124735..cc0c3b61f 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -79,11 +79,7 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - fprintf(stderr,"IMPORT momom: %s\n", momom.GetHex().data()); - FILE * fptr; - fptr = fopen("/home/cc/kmdmomom", "a+"); - fprintf(fptr, "%s\n", momom.GetHex().data()); - fclose(fptr); + printf("IMPORT momom: %s\n", momom.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 137e823ab..23416c682 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -162,11 +162,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); - FILE * fptr; - fptr = fopen("/home/cc/acmomom", "a+"); - fprintf(fptr, "%s\n", MoMoM.GetHex().data()); - fclose(fptr); + printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); // Find index of source MoM in MoMoM int nIndex; diff --git a/src/komodo.h b/src/komodo.h index 1846fd25c..fb40c1e09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -620,8 +620,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr notarized = 1; 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); + 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); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); if ( matched != 0 ) @@ -685,8 +685,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - //if ( matched != 0 ) - // printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); + if ( matched != 0 ) + printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); @@ -706,8 +706,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr 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); + 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); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -733,8 +733,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } } } - } //else if ( opretlen != 149 && height > 600000 && matched != 0 ) - //printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); + } else if ( opretlen != 149 && height > 600000 && matched != 0 ) + printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - //printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); + printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); @@ -856,7 +856,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%02x",scriptPubKey[k]); printf(" scriptPubKey doesnt match any notary vini.%d of %d\n",j,numvins); } - } //else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); + } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || @@ -880,7 +880,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - //printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; } @@ -917,20 +917,20 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { for (k=0; k 2 ) { @@ -959,8 +959,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); - //printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); - } //else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); + printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); + } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ebc6b0c7f..86ed8f7b3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -169,7 +169,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -198,7 +198,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -238,7 +238,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ @@ -1336,7 +1336,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); else bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) - if ( ASSETCHAINS_STAKED < 100 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1443,7 +1442,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( isPoS != 2 ) { - //fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); + fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS); isPoS = 0; } else @@ -1451,7 +1450,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { - //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); + fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index df17de2c7..68c00546b 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -41,10 +41,10 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int staked_era = STAKED_era(timestamp); - //printf("ERA.(%d) \n",staked_era); + printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization - //printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); + printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; } else { // pass era slection off to notaries_staked.cpp file @@ -52,12 +52,12 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } if (!CheckTxAuthority(tx, auth_STAKED)) continue; - //printf("Authorised notarisation data for %s \n",data.symbol); + printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - //printf("Added notarisation data for %s \n",data.symbol); + printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); From de707f9e1fd68602e75662a99fc5c6a30639a593 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 14:49:21 +0800 Subject: [PATCH 341/951] add some prints --- src/crosschain.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 23416c682..5ad4d69ee 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -68,6 +68,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh destNotarisationTxid = nota.first; else if (seenOwnNotarisations == 2) goto end; + fprintf(stderr, "kmd heigt notarisation added: %d\n",kmdHeight-i); break; } } @@ -75,8 +76,9 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (seenOwnNotarisations == 1) { BOOST_FOREACH(Notarisation& nota, notarisations) { if (GetSymbolAuthority(nota.second.symbol) == authority) - if (nota.second.ccId == targetCCid) - moms.push_back(nota.second.MoM); + if (nota.second.ccId == targetCCid) { + moms.push_back(nota.second.MoM); + fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); } } } @@ -162,7 +164,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ if (MoMoM.IsNull()) throw std::runtime_error("No MoMs found"); - printf("GetCrossChainProof MoMoM: %s\n", MoMoM.GetHex().data()); + printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); + FILE * fptr; + fptr = fopen("/home/cc/momom_on_kmd", "a+"); + fprintf(fptr, "%s\n", MoMoM.GetHex().data()); + fclose(fptr); // Find index of source MoM in MoMoM int nIndex; From f0cb2e1187d920e2b99bdf94c635474190378c3e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 14:51:23 +0800 Subject: [PATCH 342/951] fix --- src/crosschain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 5ad4d69ee..37908f38e 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -79,6 +79,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (nota.second.ccId == targetCCid) { moms.push_back(nota.second.MoM); fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); + } } } } From f46d51c08f5fbb05532c78b13abf6eb601e04b77 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 31 Oct 2018 15:16:06 +0800 Subject: [PATCH 343/951] fix? --- src/cc/import.cpp | 4 ++-- src/crosschain.cpp | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index cc0c3b61f..92e96fabb 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -78,8 +78,8 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp uint256 momom, target; if (!GetProofRoot(proof.first, momom)) return Invalid("coudnt-load-momom"); - - printf("IMPORT momom: %s\n", momom.GetHex().data()); + + fprintf(stderr,"IMPORT momom: %s\nKMD TX HASH: %s\n", momom.GetHex().data(),proof.first.GetHex().data()); target = proof.second.Exec(burnTx.GetHash()); if (momom != proof.second.Exec(burnTx.GetHash())) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 37908f38e..2e512806e 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -166,10 +166,6 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_ throw std::runtime_error("No MoMs found"); printf("[%s] GetCrossChainProof MoMoM: %s\n", targetSymbol,MoMoM.GetHex().data()); - FILE * fptr; - fptr = fopen("/home/cc/momom_on_kmd", "a+"); - fprintf(fptr, "%s\n", MoMoM.GetHex().data()); - fclose(fptr); // Find index of source MoM in MoMoM int nIndex; From d1e85c5128866355fe7e61832aee2754692991b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 1 Nov 2018 13:51:07 +0800 Subject: [PATCH 344/951] fix for notarisations in KMD more than 1 block. --- src/crosschain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 2e512806e..982f67d8b 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -69,7 +69,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh else if (seenOwnNotarisations == 2) goto end; fprintf(stderr, "kmd heigt notarisation added: %d\n",kmdHeight-i); - break; + //break; } } @@ -78,7 +78,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh if (GetSymbolAuthority(nota.second.symbol) == authority) if (nota.second.ccId == targetCCid) { moms.push_back(nota.second.MoM); - fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); + //fprintf(stderr, "added mom: %s\n",nota.second.MoM.GetHex().data()); } } } From 40fca878a2f3018f354e778da8a03648c2949dbe Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Thu, 1 Nov 2018 07:13:43 +0100 Subject: [PATCH 345/951] Add CFEK exception for testnet chains --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e2170ba94..a803eeead 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -101,7 +101,7 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); int is_STAKED(const char *chain_name) { int STAKED = 0; - if ( (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) + if ( (strncmp(chain_name, "CFEK", 4) == 0) || (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; return(STAKED); }; From a190053bda4132347b80f49029a82817c17ed5cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 1 Nov 2018 14:48:29 +0800 Subject: [PATCH 346/951] reset all eras to 2 years into future --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 526ad5f9b..10458d9ea 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -6,10 +6,10 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1537876325; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1537983525; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1538083525; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1548083525; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1604212834; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From 6055c2fe327f0d361ab20385b4f2d208b0d8dce9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 01:10:55 +0800 Subject: [PATCH 347/951] fix is_STAKED function --- src/notaries_staked.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a803eeead..5a544a2e8 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -101,8 +101,12 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); int is_STAKED(const char *chain_name) { int STAKED = 0; - if ( (strncmp(chain_name, "CFEK", 4) == 0) || (strncmp(chain_name, "STKD", 4) == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) + if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; + else if ( (strcmp(chain_name, "STKD") == 0) || (strncmp(chain_name, "STKD", 4) == 0) ) + STAKED = 2; + else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + STAKED = 3; return(STAKED); }; From 427ff12734b6911843964278ba7e5e286ca89d91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 01:42:23 +0800 Subject: [PATCH 348/951] add print to is_STAKED --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 5a544a2e8..264f2060a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,6 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; + fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From 600f580dc5729efcb273d55120bfba8459602412 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:24:54 +0800 Subject: [PATCH 349/951] try --- src/notaries_staked.cpp | 2 +- src/wallet/wallet.cpp | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 264f2060a..966b41850 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 47c93545b..0565d9ae4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -180,7 +180,7 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey) bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector &vchCryptedSecret) { - + if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret)) return false; if (!fFileBacked) @@ -520,7 +520,7 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er } catch (const boost::filesystem::filesystem_error&) { // failure is ok (well, not really, but it's not worse than what we started with) } - + // try again if (!bitdb.Open(GetDataDir())) { // if it still fails, it probably means we can't even create the database env @@ -529,14 +529,14 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er return true; } } - + if (GetBoolArg("-salvagewallet", false)) { // Recover readable keypairs: if (!CWalletDB::Recover(bitdb, walletFile, true)) return false; } - + if (boost::filesystem::exists(GetDataDir() / walletFile)) { CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover); @@ -550,7 +550,7 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er if (r == CDBEnv::RECOVER_FAIL) errorString += _("wallet.dat corrupt, salvage failed"); } - + return true; } @@ -1202,6 +1202,13 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { + int64_t totalvoutvalue = 0; + for (size_t i = 0; i < tx.vout.size() ; i++) { + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + fprintf(stderr, "total: %ld \nvout %d = %ld", totalvoutvalue, i, tx.vout[i].nValue); + } + + //if ( IsFromMe(tx) && tx.vout[0].value ) { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; @@ -2296,7 +2303,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const int nDepth = pcoin->GetDepthInMainChain(); if (nDepth < 0) continue; - + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { isminetype mine = IsMine(pcoin->vout[i]); @@ -2642,7 +2649,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC CReserveKey reservekey(this); CWalletTx wtx; - + if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, false)) return false; @@ -2708,7 +2715,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt txNew.nExpiryHeight = nextBlockHeight + expiryDelta; } } - + { LOCK2(cs_main, cs_wallet); { @@ -3194,7 +3201,7 @@ bool CWallet::SetDefaultKey(const CPubKey &vchPubKey) /** * Mark old keypool keys as used, - * and generate all new keys + * and generate all new keys */ bool CWallet::NewKeyPool() { @@ -3902,7 +3909,7 @@ void CWallet::GetFilteredNotes( if (ignoreUnspendable && !HaveSpendingKey(pa)) { continue; } - + // skip locked notes if (IsLockedNote(jsop.hash, jsop.js, jsop.n)) { continue; From 8616d8e5f773bd16a79013bc67376aaecf3c7cbc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:28:55 +0800 Subject: [PATCH 350/951] ld --- 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 0565d9ae4..a518674de 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1205,7 +1205,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %d = %ld", totalvoutvalue, i, tx.vout[i].nValue); + fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); } //if ( IsFromMe(tx) && tx.vout[0].value ) From a5b17840a6b77338f083179f443accd78665048c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:40:58 +0800 Subject: [PATCH 351/951] fix --- src/wallet/wallet.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a518674de..b5fe66476 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,13 +1202,6 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { - int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vout.size() ; i++) { - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); - } - - //if ( IsFromMe(tx) && tx.vout[0].value ) { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; @@ -1216,6 +1209,12 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl auto noteData = FindMyNotes(tx); if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { + int64_t totalvoutvalue = 0; + for (size_t i = 0; i < tx.vout.size() ; i++) { + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + } + CWalletTx wtx(this,tx); if (noteData.size() > 0) { From 3bbb29e600b5c0a7891f83f5a970cccf76b33dfd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:56:20 +0800 Subject: [PATCH 352/951] try print back --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 966b41850..264f2060a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From a2cec89073a02a16700da10c8b0c118a59d1465a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 05:59:49 +0800 Subject: [PATCH 353/951] fix era --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 10458d9ea..fbb3506ba 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From c0fa673964ffdfb1101ab9f3bd364fcea7a96afd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:05:24 +0800 Subject: [PATCH 354/951] remove print --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 264f2060a..966b41850 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From 203e3004f848e9d81956ea467927a35d991b103e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:13:32 +0800 Subject: [PATCH 355/951] try --- src/wallet/wallet.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b5fe66476..311264419 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1207,14 +1207,23 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); - if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) + bool mine = IsMine(tx); + bool isent = IsFromMe(tx); + + if ( isent ) + fprintf(stderr, "I sent this tx ?\n"); + + if (mine) + fprintf(stderr, "I reveived it ? \n"); + + if (fExisted || mine || isent || noteData.size() > 0) { int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + fprintf(stderr, "total: %ld \nvout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); } - + CWalletTx wtx(this,tx); if (noteData.size() > 0) { From 287ddc4a6b220a605d9137abd652d00a5b118bd5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:37:38 +0800 Subject: [PATCH 356/951] try --- src/wallet/wallet.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 311264419..9f7ba37c6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,18 +1210,19 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool mine = IsMine(tx); bool isent = IsFromMe(tx); - if ( isent ) - fprintf(stderr, "I sent this tx ?\n"); - - if (mine) - fprintf(stderr, "I reveived it ? \n"); - if (fExisted || mine || isent || noteData.size() > 0) { int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "total: %ld \nvout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); + if (IsChange(tx.vout[i])) { + fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); + } else { + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + + fprintf(stderr, "this is not change? total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + } + } CWalletTx wtx(this,tx); From 023ee98af06fe02dc612885b434bb0684e0030ee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:48:40 +0800 Subject: [PATCH 357/951] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9f7ba37c6..9269817c4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1219,8 +1219,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); } else { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - - fprintf(stderr, "this is not change? total: %ld \nvout %ld = %ld", totalvoutvalue, i, tx.vout[i].nValue); + + fprintf(stderr, "this is not change? vout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); } } From dbf49cd4d2c0d770711af73ae80fd886d8ebed49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 06:54:50 +0800 Subject: [PATCH 358/951] try --- src/wallet/wallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9269817c4..396f0d167 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1207,14 +1207,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); - bool mine = IsMine(tx); - bool isent = IsFromMe(tx); - if (fExisted || mine || isent || noteData.size() > 0) + if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + if ( IsMine(tx.vout[i].prevout) ) + fprintf(stderr, "prevout is mine? %s\n"); if (IsChange(tx.vout[i])) { fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); } else { From 0737f32e4d655c1c4748b224ef471281450b54c7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:07:32 +0800 Subject: [PATCH 359/951] try --- src/wallet/wallet.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 396f0d167..75d0a2d3e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,11 +1210,15 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { + + if ( IsMine(tx.vin[0].prevout) ) + fprintf(stderr, "prevout is mine? %s\n"); + + int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - if ( IsMine(tx.vout[i].prevout) ) - fprintf(stderr, "prevout is mine? %s\n"); + if (IsChange(tx.vout[i])) { fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); } else { From d83243962d41be4dc31d33cabed78caa88d101f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:10:39 +0800 Subject: [PATCH 360/951] a --- 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 75d0a2d3e..1b4395b9a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,7 +1211,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( IsMine(tx.vin[0].prevout) ) + if ( IsMine(tx) ) fprintf(stderr, "prevout is mine? %s\n"); From 08241004e190867981e1b6b7d02ae172ade02fa4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:23:48 +0800 Subject: [PATCH 361/951] try --- 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 1b4395b9a..10a46c547 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,7 +1212,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( IsMine(tx) ) - fprintf(stderr, "prevout is mine? %s\n"); + fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash..ToString().c_str()]); int64_t totalvoutvalue = 0; From 43104ff55c4c584bdb532fda26288b498495a459 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:30:46 +0800 Subject: [PATCH 362/951] oo --- 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 10a46c547..4ecc12d9d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,7 +1212,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( IsMine(tx) ) - fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash..ToString().c_str()]); + fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash.ToString().c_str()); int64_t totalvoutvalue = 0; From 6ea2be525feb60a679d0ce241d4536ddc4fcfa69 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 07:44:34 +0800 Subject: [PATCH 363/951] oops --- 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 4ecc12d9d..5b0b914ed 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1224,7 +1224,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } else { totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "this is not change? vout %ld = %ld\n", totalvoutvalue, i, tx.vout[i].nValue); + fprintf(stderr, "this is not change? vout %ld = %ld\n", i, tx.vout[i].nValue); } } From 0d9cf86b64a69c9b6b33ae8ce80910b80e0d8193 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:16:16 +0800 Subject: [PATCH 364/951] try --- src/wallet/wallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5b0b914ed..8b91e3c2a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,8 +1211,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( IsMine(tx) ) - fprintf(stderr, "prevout is mine? %s\n",tx.vin[0].prevout.hash.ToString().c_str()); + CTransaction tx; + uint256 hashBlock; + GetTransaction(tx.vin[0].prevout.hash,tx,hashBlock,false) + + fprintf(stderr, "vin 1 script pubkey : %s\n",tx.vout[0].scriptPubKey); int64_t totalvoutvalue = 0; From 4bce36c1ade6f550a8c181ffc27208538b548f99 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:22:42 +0800 Subject: [PATCH 365/951] try --- src/wallet/wallet.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8b91e3c2a..096966452 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,12 +1211,18 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - CTransaction tx; + CTransaction txin; uint256 hashBlock; - GetTransaction(tx.vin[0].prevout.hash,tx,hashBlock,false) + GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); - fprintf(stderr, "vin 1 script pubkey : %s\n",tx.vout[0].scriptPubKey); + fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey); + CTxDestination address; + ExtractDestination(txin.vout[0].scriptPubKey, address) + + LOCK(cs_wallet); + if (!mapAddressBook.count(address)) + fprintf(stderr, "vin 0 address is in my wallet \n" ); int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { From 05b2d67fc4e439173e9d1456f3f507e49beef981 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:24:55 +0800 Subject: [PATCH 366/951] fix --- 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 096966452..335861e72 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1215,7 +1215,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hashBlock; GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); - fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey); + fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); CTxDestination address; ExtractDestination(txin.vout[0].scriptPubKey, address) From db2460a381d0d1312462e63098983f4095048685 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:26:04 +0800 Subject: [PATCH 367/951] ; modified: src/wallet/wallet.cpp --- 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 335861e72..5b710a64c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1218,7 +1218,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); CTxDestination address; - ExtractDestination(txin.vout[0].scriptPubKey, address) + ExtractDestination(txin.vout[0].scriptPubKey, address); LOCK(cs_wallet); if (!mapAddressBook.count(address)) From 750f8351063034a30fa6a1ea2dfb2f17060c79c9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:29:36 +0800 Subject: [PATCH 368/951] try --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5b710a64c..afe2d8565 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1215,6 +1215,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl uint256 hashBlock; GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); + fprintf(stderr, "vin tx hash: %s\n", tx.vin[0].prevout.hash.ToString().c_str()); + fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); CTxDestination address; From aaab9bf85d304efec6cb49ec7af3d4c2df26a744 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:40:36 +0800 Subject: [PATCH 369/951] try this --- src/wallet/wallet.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index afe2d8565..65121caf8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,21 +1210,17 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - - CTransaction txin; - uint256 hashBlock; - GetTransaction(tx.vin[0].prevout.hash,txin,hashBlock,false); - - fprintf(stderr, "vin tx hash: %s\n", tx.vin[0].prevout.hash.ToString().c_str()); - - fprintf(stderr, "vin 0 script pubkey : %s\n",txin.vout[0].scriptPubKey.ToString().c_str()); - - CTxDestination address; - ExtractDestination(txin.vout[0].scriptPubKey, address); - - LOCK(cs_wallet); - if (!mapAddressBook.count(address)) - fprintf(stderr, "vin 0 address is in my wallet \n" ); + uint256 hash; CTransaction txin; + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + { + printf("CHECKING THE script pubkey\n"); + script = (uint8_t *)txin.vout[tx.vin[0].prevout.n].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,NOTARY_PUBKEY33,33) != 0 ) { + printf("vin 0 prevout is from some other kunt!\n"); + //return(-1); + } + printf("vin 0 prevvout is from our pubkey \n"); + } int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vout.size() ; i++) { From f8e62200d09478ea43a7dd12796ade80e0622800 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:42:30 +0800 Subject: [PATCH 370/951] delcare --- 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 65121caf8..f4b1ef2a8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,7 +1210,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - uint256 hash; CTransaction txin; + uint256 hash; CTransaction txin; uint8_t *script; if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { printf("CHECKING THE script pubkey\n"); From 151847b000ac63acf1fabbdb4dc25f2cf15ef509 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:44:30 +0800 Subject: [PATCH 371/951] fix --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f4b1ef2a8..b3d7ac2c0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1200,6 +1200,8 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * pblock is optional, but should be provided if the transaction is known to be in a block. * If fUpdate is true, existing transactions will be updated. */ +extern uint8_t NOTARY_PUBKEY33[33]; + bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { From 5fdb5772a80be2321c03ebf27dc102d4c0fef524 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 08:47:31 +0800 Subject: [PATCH 372/951] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b3d7ac2c0..ebad28293 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1220,8 +1220,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,NOTARY_PUBKEY33,33) != 0 ) { printf("vin 0 prevout is from some other kunt!\n"); //return(-1); - } - printf("vin 0 prevvout is from our pubkey \n"); + } else + printf("vin 0 prevvout is from our pubkey \n"); } int64_t totalvoutvalue = 0; From d21d7f6c798805aa521cc9a6ee2c6b8766268dcb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:10:19 +0800 Subject: [PATCH 373/951] try --- src/wallet/wallet.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ebad28293..fcb96dcab 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,16 +1212,13 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - uint256 hash; CTransaction txin; uint8_t *script; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + uint256 hash; CTransaction txin; CTxDestination address; + if (GetTransaction(tx.prevout.hash,txin,hash,false)) { - printf("CHECKING THE script pubkey\n"); - script = (uint8_t *)txin.vout[tx.vin[0].prevout.n].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,NOTARY_PUBKEY33,33) != 0 ) { - printf("vin 0 prevout is from some other kunt!\n"); - //return(-1); - } else - printf("vin 0 prevvout is from our pubkey \n"); + if (ExtractDestination(txin.vout[tx.prevout.n].scriptPubKey, address)) { + if (mapAddressBook.count(address)) + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); + } } int64_t totalvoutvalue = 0; From 580cea6efcad51799cf2487b75ce453a05897938 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:14:02 +0800 Subject: [PATCH 374/951] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fcb96dcab..697deff97 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,9 +1213,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.prevout.hash,txin,hash,false)) + if (GetTransaction(tx.vout[0].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.prevout.n].scriptPubKey, address)) { + if (ExtractDestination(txin.vout[tx.vout[0].prevout.n].scriptPubKey, address)) { if (mapAddressBook.count(address)) fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); } From 36957b0a7d9cb4491ac7a95def3138b31e2c2d22 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:17:09 +0800 Subject: [PATCH 375/951] fix vin --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 697deff97..0ca9a077d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,9 +1213,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vout[0].prevout.hash,txin,hash,false)) + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.vout[0].prevout.n].scriptPubKey, address)) { + if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { if (mapAddressBook.count(address)) fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); } From 496c0b2ac6396a3eb6c62b6737a4fc05f9416c52 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:18:39 +0800 Subject: [PATCH 376/951] fix --- 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 0ca9a077d..0f2ab284e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1217,7 +1217,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { if (mapAddressBook.count(address)) - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString()); + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } } From 0ea25a07b1bcd6727395d503199f07011468ea80 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:22:06 +0800 Subject: [PATCH 377/951] try --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0f2ab284e..6dcd9ecc2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1216,6 +1216,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); if (mapAddressBook.count(address)) fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } From 73c0dd2b2e9e8703ccd4941a252fa3d28baaa4b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 09:42:53 +0800 Subject: [PATCH 378/951] getting close --- src/wallet/wallet.cpp | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6dcd9ecc2..388f0e47b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1212,29 +1212,35 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) - { - if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if (mapAddressBook.count(address)) - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - } + int numvinIsOurs, numvoutIsOurs; int64_t totalvoutvalue; + for (size_t i = 0; i < tx.vin.size(); i++) { + uint256 hash; CTransaction txin; CTxDestination address; + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + { + if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + if (!mapAddressBook.count(address)) { + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + numvinIsOurs++; + } + } + } } - - int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vout.size() ; i++) { - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - - if (IsChange(tx.vout[i])) { - fprintf(stderr, "tx %ld is change of: %ld\n",i, tx.vout[i].nValue ); - } else { - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - - fprintf(stderr, "this is not change? vout %ld = %ld\n", i, tx.vout[i].nValue); - } - + if ( numvinIsOurs == 0 ) { + for (size_t i = 0; i < tx.vout.size() ; i++) { + CTxDestination address2; + if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { + if (!mapAddressBook.count(address2)) { + fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); + numvoutIsOurs++; + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + } + } + } + } else if ( numvinIsOurs < tx.vin.size() ) { + fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } + fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); CWalletTx wtx(this,tx); From b14b985d7d38d5d603ccad346e7589060982642b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:01:10 +0800 Subject: [PATCH 379/951] backwards --- 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 388f0e47b..95f36b801 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1230,7 +1230,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if (!mapAddressBook.count(address2)) { + if (mapAddressBook.count(address2)) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From 0ec91dd3a9e4ed7e757ac8d9a5a5f791a93c0242 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:23:56 +0800 Subject: [PATCH 380/951] try --- src/wallet/wallet.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 95f36b801..53d75c522 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,6 +1202,15 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; +bool RaddIsPubkey(char *address) { + char exaddress[18]; + pubkey2addr((char *)exaddress[i],(uint8_t *)NOTARY_PUBKEY33); + for (i=0; i<=17; i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return true; + return false +} + bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { @@ -1219,10 +1228,10 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if (!mapAddressBook.count(address)) { - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { numvinIsOurs++; - } + fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + } } } } @@ -1230,7 +1239,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if (mapAddressBook.count(address2)) { + if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From e836e146a3f196b0e36a38395313a341c1c15c31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:25:22 +0800 Subject: [PATCH 381/951] fix --- src/wallet/wallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 53d75c522..77bc46304 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1205,9 +1205,8 @@ extern uint8_t NOTARY_PUBKEY33[33]; bool RaddIsPubkey(char *address) { char exaddress[18]; pubkey2addr((char *)exaddress[i],(uint8_t *)NOTARY_PUBKEY33); - for (i=0; i<=17; i++) - if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) - return true; + if ( strcmp(coinaddr,exaddress) == 0 ) + return true; return false } From dd18452d2096335d05cb3c0e8aa415b1a3fe50d3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:27:19 +0800 Subject: [PATCH 382/951] fix? --- src/wallet/wallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 77bc46304..fc60c4bf0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,10 +1201,11 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool RaddIsPubkey(char *address) { char exaddress[18]; - pubkey2addr((char *)exaddress[i],(uint8_t *)NOTARY_PUBKEY33); + pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); if ( strcmp(coinaddr,exaddress) == 0 ) return true; return false From 958095444dfa50662fe13634293e1539ae2cf6ab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:28:43 +0800 Subject: [PATCH 383/951] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fc60c4bf0..e8c0af281 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1206,7 +1206,7 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool RaddIsPubkey(char *address) { char exaddress[18]; pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); - if ( strcmp(coinaddr,exaddress) == 0 ) + if ( strcmp(address,exaddress) == 0 ) return true; return false } @@ -1239,7 +1239,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { + if ( RaddIsPubkey(CBitcoinAddress(address2).ToString().c_str()) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From f699248ef187624a223ba69c7304f2e1932030e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:29:29 +0800 Subject: [PATCH 384/951] ; --- 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 e8c0af281..ea892d2ba 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1208,7 +1208,7 @@ bool RaddIsPubkey(char *address) { pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); if ( strcmp(address,exaddress) == 0 ) return true; - return false + return false; } bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) From 2d82fd3f29825265ee38ac6dd74c606ee6caded2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:30:49 +0800 Subject: [PATCH 385/951] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ea892d2ba..538eb3d54 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1228,7 +1228,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey(CBitcoinAddress(address).ToString().c_str()) == true ) { + if ( RaddIsPubkey((char *)CBitcoinAddress(address).ToString().c_str()) == true ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1239,7 +1239,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( RaddIsPubkey(CBitcoinAddress(address2).ToString().c_str()) == true ) { + if ( RaddIsPubkey((char *)CBitcoinAddress(address2).ToString().c_str()) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From 18b9025ffc566a1debb263e8a08772bfe4bbb6d6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:38:45 +0800 Subject: [PATCH 386/951] try --- src/wallet/wallet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 538eb3d54..a6c4a8486 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,7 +1201,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +bool pubkey2addr(char destaddr,uint8_t *pubkey33); bool RaddIsPubkey(char *address) { char exaddress[18]; @@ -1228,7 +1228,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey((char *)CBitcoinAddress(address).ToString().c_str()) == true ) { + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + if ( RaddIsPubkey(chraddress) == true ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1239,7 +1240,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( RaddIsPubkey((char *)CBitcoinAddress(address2).ToString().c_str()) == true ) { + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + if ( RaddIsPubkey(chraddress) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From ea856ec7b3281b3ebd5a4e31a8e9dfd4c81087d7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:40:15 +0800 Subject: [PATCH 387/951] try --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a6c4a8486..59bbf3731 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1228,7 +1228,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); if ( RaddIsPubkey(chraddress) == true ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); @@ -1240,7 +1240,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()) + char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); if ( RaddIsPubkey(chraddress) == true ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; From 997c7844a57b200d83e302efa8ac76f1dc82ef29 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:52:39 +0800 Subject: [PATCH 388/951] try this --- src/komodo_globals.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- src/wallet/wallet.cpp | 15 +++------------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 33d269793..133743c52 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 56793f78b..d9255ce70 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4989,7 +4989,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; + extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -5002,7 +5002,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); + string currentAddress = address.ToString() = NOTARY_ADDRESS; result.push_back(Pair("address", currentAddress)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 59bbf3731..d2767fa1e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,16 +1201,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; +extern std::string NOTARY_ADDRESS; bool pubkey2addr(char destaddr,uint8_t *pubkey33); -bool RaddIsPubkey(char *address) { - char exaddress[18]; - pubkey2addr((char *)exaddress,(uint8_t *)NOTARY_PUBKEY33); - if ( strcmp(address,exaddress) == 0 ) - return true; - return false; -} - bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { @@ -1228,8 +1221,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey(chraddress) == true ) { + if ( strcmp(CBitcoinAddress(address).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1240,8 +1232,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - char chraddress[18]; strcpy(chraddress,CBitcoinAddress(address).ToString().c_str()); - if ( RaddIsPubkey(chraddress) == true ) { + if ( strcmp(CBitcoinAddress(address2).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From 4b044d68f0da67b361abdabd6aebb34357c9bb87 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:54:51 +0800 Subject: [PATCH 389/951] fix --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d2767fa1e..085ee14ce 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1221,7 +1221,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); - if ( strcmp(CBitcoinAddress(address).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { + if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); } @@ -1232,7 +1232,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( strcmp(CBitcoinAddress(address2).ToString().c_str(),NOTARY_ADDRESS) == 0 ) { + if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; From cddd4eebf45b30f24e8427c5355da434a7e81000 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 10:57:52 +0800 Subject: [PATCH 390/951] oops --- 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 d9255ce70..2d5644ced 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5002,7 +5002,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = address.ToString() = NOTARY_ADDRESS; + string currentAddress = NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", currentAddress)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; From 5ecc6857c45998901841653710ad5bfaff828295 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 11:07:52 +0800 Subject: [PATCH 391/951] try --- src/wallet/wallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 085ee14ce..f27046767 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1223,7 +1223,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; - fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + fprintf(stderr, "address on prev vin is in wallet: %s and numvins ours so far is: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); } } } @@ -1233,16 +1233,16 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { - fprintf(stderr, "vout is to our address: %s\n",CBitcoinAddress(address2).ToString().c_str()); numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS,numvoutIsOurs,totalvoutvalue); } } } } else if ( numvinIsOurs < tx.vin.size() ) { fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } - fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); + //fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); CWalletTx wtx(this,tx); From 588b53717cbe1861c0990387914b7529961a1195 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 11:14:16 +0800 Subject: [PATCH 392/951] poo --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f27046767..637b98448 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - int numvinIsOurs, numvoutIsOurs; int64_t totalvoutvalue; + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) @@ -1235,7 +1235,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS,numvoutIsOurs,totalvoutvalue); + fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS.c_str(),numvoutIsOurs,totalvoutvalue); } } } From de3bc9d0c2410ce9a4b2db43713dbec079ab04ef Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 11:33:44 +0800 Subject: [PATCH 393/951] fix --- src/wallet/wallet.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 637b98448..2e1664188 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1220,29 +1220,34 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) { if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { - //fprintf(stderr, "address on prev vin is in wallet: %s\n",CBitcoinAddress(address).ToString().c_str()); + // This means we sent the tx.. if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; - fprintf(stderr, "address on prev vin is in wallet: %s and numvins ours so far is: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); } } } } + // No we know if it was a tx we sent, if it was all ours, we leave and let add to wallet. + fprintf(stderr, "address: %s sent vouts: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); if ( numvinIsOurs == 0 ) { for (size_t i = 0; i < tx.vout.size() ; i++) { CTxDestination address2; if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { + // this should be a received tx.. numvoutIsOurs++; totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - fprintf(stderr, "vout is to our address: %s num vout so far is: %d and total sats: %ld\n",NOTARY_ADDRESS.c_str(),numvoutIsOurs,totalvoutvalue); } } } + fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); + // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. + + } else if ( numvinIsOurs < tx.vin.size() ) { + // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and nothing else. fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } - //fprintf(stderr, "total sent from some other kunts to us is : %ldsats\n", totalvoutvalue); CWalletTx wtx(this,tx); From b9316f3b8d1e2ec6f8f16b484733d72cd3ad811a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 12:22:00 +0800 Subject: [PATCH 394/951] looking good --- src/wallet/wallet.cpp | 68 ++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2e1664188..5a0014ed4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,39 +1214,47 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vin.size(); i++) { - uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) - { - if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { - // This means we sent the tx.. - if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { - numvinIsOurs++; - } - } - } - } - // No we know if it was a tx we sent, if it was all ours, we leave and let add to wallet. - fprintf(stderr, "address: %s sent vouts: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs); - if ( numvinIsOurs == 0 ) { - for (size_t i = 0; i < tx.vout.size() ; i++) { - CTxDestination address2; - if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { - // this should be a received tx.. - numvoutIsOurs++; - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; - } + if ( NOTARY_ADDRESS != "" ) + { + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; + for (size_t i = 0; i < tx.vin.size(); i++) { + uint256 hash; CTransaction txin; CTxDestination address; + if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + { + if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + // This means we sent the tx.. + if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { + numvinIsOurs++; + } + } } } - fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); - // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. + // Now we know if it was a tx we sent, if it was all ours, we leave and let add to wallet. + fprintf(stderr, "address: %s sent vouts: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + if ( numvinIsOurs == 0 ) { + for (size_t i = 0; i < tx.vout.size() ; i++) { + CTxDestination address2; + if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { + if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { + // this should be a received tx.. + numvoutIsOurs++; + totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + } + } + } + fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); + // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. + int64_t avgVoutSize = totalvoutvalue \ numvoutIsOurs; + if ( avgVoutSize < 100000000 ) { + // average vout size is less than 1 coin, we will ignore it + fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); + return false; + } - - } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and nothing else. - fprintf(stderr, "There are vins that are not ours, notarisation?\n"); + } else if ( numvinIsOurs < tx.vin.size() ) { + // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and do nothing else. + fprintf(stderr, "There are vins that are not ours, notarisation?\n"); + } } CWalletTx wtx(this,tx); From 8649c79024f321e96393af9f2bcebc312b54f6d9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 12:23:01 +0800 Subject: [PATCH 395/951] / --- 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 5a0014ed4..6731d40f0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1244,7 +1244,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. - int64_t avgVoutSize = totalvoutvalue \ numvoutIsOurs; + int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; if ( avgVoutSize < 100000000 ) { // average vout size is less than 1 coin, we will ignore it fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); From c800e8f376240d343c664d40f48281840471800b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:27:27 +0800 Subject: [PATCH 396/951] try add Raddress for -pubkey --- src/komodo_utils.h | 6 +++++- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ef33bd56b..4153aebca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1485,6 +1485,10 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; + char Raddress[18]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + //CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = Raddress.ToString(); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } @@ -1564,7 +1568,7 @@ void komodo_args(char *argv0) ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_freward",0); ASSETCHAINS_OVERRIDE_ADDRESS = GetArg("-ac_address",""); ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - + if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); exit(0); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2d5644ced..862df0c0f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5002,8 +5002,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = NOTARY_ADDRESS = address.ToString(); - result.push_back(Pair("address", currentAddress)); + NOTARY_ADDRESS = address.ToString(); + result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); From 0e848a2fd44847951f1439a209b41141223031eb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:30:58 +0800 Subject: [PATCH 397/951] nopiie --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4153aebca..f10f4e1c1 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1487,8 +1487,8 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) pubkeystr[66] = 0; char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - //CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = Raddress.ToString(); + CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = address.ToString(); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From 2e750b76da4204d6b50b24ff5196e84389f1c83d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:33:31 +0800 Subject: [PATCH 398/951] try --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f10f4e1c1..1cede9279 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1487,8 +1487,8 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) pubkeystr[66] = 0; char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = address.ToString(); + //CBitcoinAddress address(Raddress); + NOTARY_ADDRESS.assign(Raddress); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From b71d83e7b01db09f5f58168f41574da7de4e8169 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:34:36 +0800 Subject: [PATCH 399/951] fix --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1cede9279..c484accc5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1478,6 +1478,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From b74d98e6bb6afcd5a23fe4213e4fd2ad463ba47d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:36:58 +0800 Subject: [PATCH 400/951] fix --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c484accc5..6d9777b73 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1478,7 +1478,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +extern bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From 2ff5d746dc2f7f318c70b46236177ba9d1576040 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:41:56 +0800 Subject: [PATCH 401/951] :S --- src/komodo_utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6d9777b73..2dcdd215d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,6 +13,7 @@ * * ******************************************************************************/ #include "komodo_defs.h" +#include "komodo_globals.h" #ifdef _WIN32 #include @@ -1478,8 +1479,6 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -extern bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; From 97c7042ce83548aaec91ccc23897532fb3d3641e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:45:36 +0800 Subject: [PATCH 402/951] fix --- src/komodo_utils.h | 3 ++- src/wallet/wallet.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2dcdd215d..c734e7add 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,7 +13,6 @@ * * ******************************************************************************/ #include "komodo_defs.h" -#include "komodo_globals.h" #ifdef _WIN32 #include @@ -1479,6 +1478,8 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +bool pubkey2addr(char destaddr,uint8_t *pubkey33); + int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6731d40f0..a8d287bac 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,7 +1202,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -bool pubkey2addr(char destaddr,uint8_t *pubkey33); + bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { From 387466a273c0848131ccdda31f88da300b31d0b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 13:48:31 +0800 Subject: [PATCH 403/951] try --- src/cc/utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/utils.h b/src/cc/utils.h index f0b91962d..8762cbaf1 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -23,6 +23,7 @@ /* * Serialisation boilerplate */ +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); template std::vector SerializeF(const T f) From c6976b687703a9a9c1f8c3f50aa80ac9a76eedea Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:03:02 +0800 Subject: [PATCH 404/951] try --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c734e7add..c484accc5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1478,7 +1478,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char destaddr,uint8_t *pubkey33); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From 0f9b4c1d8107f67ee3066602ee7ef5f629856c5f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:11:35 +0800 Subject: [PATCH 405/951] try --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c484accc5..c774dba9b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,6 +13,8 @@ * * ******************************************************************************/ #include "komodo_defs.h" +#include "cc/utils.h" +#include "cc/CCutils.cpp" #ifdef _WIN32 #include @@ -1478,8 +1480,6 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; From 5d64fdd67d4ef40053ae5c807884f172cf339fc9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:18:11 +0800 Subject: [PATCH 406/951] try again --- src/komodo_utils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c774dba9b..02f226028 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -14,7 +14,6 @@ ******************************************************************************/ #include "komodo_defs.h" #include "cc/utils.h" -#include "cc/CCutils.cpp" #ifdef _WIN32 #include From 3c612cfc9e31c24ee2b2038c93806c4ba4f43325 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:19:47 +0800 Subject: [PATCH 407/951] try --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 6164cf463..19aa87fe4 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,6 +9,7 @@ #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" +#include "cc/utils.h" #include #include From 3b8bc700b3dcfe2877c7b56668fe39651025a5ec Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:22:51 +0800 Subject: [PATCH 408/951] try --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 19aa87fe4..ebf8d5660 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,7 +9,7 @@ #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" -#include "cc/utils.h" +#include "cc/CCutils.cpp" #include #include From f32a8a151e520a756b092aa6bfb4bbd0a2886fd7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:24:05 +0800 Subject: [PATCH 409/951] try again --- src/bitcoin-cli.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index ebf8d5660..d70638d89 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,7 +9,7 @@ #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" -#include "cc/CCutils.cpp" + #include #include @@ -24,6 +24,7 @@ using namespace std; int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t komodo_maxallowed(int32_t baseid) { return(100000000LL * 1000000); } // stub +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900; From 9da9b21de773e0e2cba8c5b0484b34cea18edebd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:27:55 +0800 Subject: [PATCH 410/951] try again --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index d70638d89..ea72bbc14 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -24,7 +24,6 @@ using namespace std; int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t komodo_maxallowed(int32_t baseid) { return(100000000LL * 1000000); } // stub -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900; @@ -78,6 +77,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From 3a20421a0553816abcd4172a4aead07576d14c57 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:30:26 +0800 Subject: [PATCH 411/951] again --- src/cc/CCinclude.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 8be4bce29..ab320e58a 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h all of the above are the standard bitcoin vout types and there should be plenty of materials about it Encrypted by a verified device what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. - + but it gets more interesting each CC script has an evalcode this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different @@ -149,6 +149,7 @@ bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t n bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int64_t CCduration(int32_t &numblocks,uint256 txid); bool isCCTxNotarizedConfirmed(uint256 txid); // CCtx From c75cdae8c69a37e63e1d12a596f944477c3f7d66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:33:52 +0800 Subject: [PATCH 412/951] oops --- src/bitcoin-cli.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index ea72bbc14..e44be663c 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,7 +77,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From 0da06744056072e82fe48ddbb84be680818548b8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:35:15 +0800 Subject: [PATCH 413/951] try --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e44be663c..f1b75fb42 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,6 +77,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From be4539034e5702a1e2d9a28d0da37219ab3d91a2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:38:23 +0800 Subject: [PATCH 414/951] try again --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f1b75fb42..527765094 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -70,7 +70,7 @@ public: #include "uint256.h" #include "arith_uint256.h" -#include "komodo_structs.h" +//#include "komodo_structs.h" #include "komodo_globals.h" #include "komodo_utils.h" From 9d44f850bf567646cd6412b114eb6979aa751572 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 14:59:26 +0800 Subject: [PATCH 415/951] try --- src/bitcoin-cli.cpp | 2 +- src/cc/utils.h | 1 - src/komodo_globals.h | 1 - src/wallet/wallet.cpp | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 527765094..f1b75fb42 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -70,7 +70,7 @@ public: #include "uint256.h" #include "arith_uint256.h" -//#include "komodo_structs.h" +#include "komodo_structs.h" #include "komodo_globals.h" #include "komodo_utils.h" diff --git a/src/cc/utils.h b/src/cc/utils.h index 8762cbaf1..f0b91962d 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -23,7 +23,6 @@ /* * Serialisation boilerplate */ -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); template std::vector SerializeF(const T f) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 133743c52..a09008824 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,7 +29,6 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a8d287bac..4fea5dae7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1203,7 +1203,6 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; - bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { From af21a290f3743722374e3a8371b82443fd0f1dbe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:14:11 +0800 Subject: [PATCH 416/951] fix --- src/bitcoin-cli.cpp | 1 - src/main.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f1b75fb42..e44be663c 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,7 +77,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { diff --git a/src/main.cpp b/src/main.cpp index 91ec53faf..c7b0e0e9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,7 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); void komodo_broadcast(CBlock *pblock,int32_t limit); void komodo_broadcast(CBlock *pblock,int32_t limit); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); BlockMap mapBlockIndex; CChain chainActive; From b61cf9dd216af09e073458b1093538f92827c830 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:18:14 +0800 Subject: [PATCH 417/951] try --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e44be663c..5abc9eba3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -77,6 +77,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From b9923c1dcae33e511e931da0c630d23f8b91e2af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:30:11 +0800 Subject: [PATCH 418/951] try --- src/bitcoin-cli.cpp | 4 +++- src/komodo_utils.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 5abc9eba3..d82049cf3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -73,11 +73,13 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" +##include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 02f226028..61c2f8c6a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -742,6 +742,8 @@ uint32_t calc_crc32(uint32_t crc,const void *buf,size_t size) return crc ^ ~0U; } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) { bits256 hash; From 8963872dca12d7c7a6f74b54cb0ff18ad4616c5d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:31:33 +0800 Subject: [PATCH 419/951] lol --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index d82049cf3..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -73,7 +73,7 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -##include "cc/utils.h" +#include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" From 02da812eb6e5e411a3007900a974d76c69ed643c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:37:11 +0800 Subject: [PATCH 420/951] wtf --- src/komodo_globals.h | 1 + src/komodo_utils.h | 10 ++++++++-- src/main.cpp | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a09008824..133743c52 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,6 +29,7 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 61c2f8c6a..1cd7fc219 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -742,8 +742,6 @@ uint32_t calc_crc32(uint32_t crc,const void *buf,size_t size) return crc ^ ~0U; } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) { bits256 hash; @@ -1481,6 +1479,14 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); +} + int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { int32_t i,notaryid; diff --git a/src/main.cpp b/src/main.cpp index c7b0e0e9b..91ec53faf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,7 +64,6 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); void komodo_broadcast(CBlock *pblock,int32_t limit); void komodo_broadcast(CBlock *pblock,int32_t limit); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); BlockMap mapBlockIndex; CChain chainActive; From 7a306f46f8e0097cba9a442c98f3cd390d5491b5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:42:07 +0800 Subject: [PATCH 421/951] try --- src/komodo_utils.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1cd7fc219..48ddd8682 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1480,12 +1480,6 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; bool pubkey2addr(char *destaddr,uint8_t *pubkey33) -{ - std::vectorpk; int32_t i; - for (i=0; i<33; i++) - pk.push_back(pubkey33[i]); - return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); -} int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { From 08548dc9e2ee04f15f26bfbf1dc129eede5bff53 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 15:43:43 +0800 Subject: [PATCH 422/951] try --- src/komodo_utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 48ddd8682..f4e03387f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1479,10 +1479,11 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33) + int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { + bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); From ce5285f7e92a6899ca46271523a6c3e05511f6f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:06:49 +0800 Subject: [PATCH 423/951] try that --- src/komodo_utils.h | 5 ----- src/wallet/wallet.cpp | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f4e03387f..a9d16fd52 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1483,15 +1483,10 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { - bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; - char Raddress[18]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - //CBitcoinAddress address(Raddress); - NOTARY_ADDRESS.assign(Raddress); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4fea5dae7..5a776c6e6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,9 +1202,17 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { + static bool didNA; + if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_PUBKEY.empty() ) { + char Raddress[18]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + NOTARY_ADDRESS.assign(Raddress); + didNA == true; + } { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; From cfa4c9731d20ccabb721eb62055e91d4d1505f61 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:09:05 +0800 Subject: [PATCH 424/951] fix --- 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 5a776c6e6..cf253db5f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1207,7 +1207,7 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { static bool didNA; - if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_PUBKEY.empty() ) { + if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); From 861c5d5553eb2d9432db8fa27fe5748c6056e745 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:14:14 +0800 Subject: [PATCH 425/951] 7 --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index cf253db5f..6b98df5d0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1209,6 +1209,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl static bool didNA; if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { char Raddress[18]; + fprintf(stderr, "test thing\n"); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); didNA == true; From 334314cef42ca343ae2ab7b5e12f903643ad1aba Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:16:53 +0800 Subject: [PATCH 426/951] try --- src/wallet/wallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6b98df5d0..65dc60f8d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,14 +1202,13 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +bool pubkey2addr(char destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { static bool didNA; if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { char Raddress[18]; - fprintf(stderr, "test thing\n"); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); didNA == true; From eba1ffb18c8ea0dc3db842c93e7d1ba6c278e6a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:43:22 +0800 Subject: [PATCH 427/951] fix eras --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 10458d9ea..fbb3506ba 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1604212834; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; From f48342ba788204b1270ab3321e9026949b899a64 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 16:45:14 +0800 Subject: [PATCH 428/951] remove flooding print --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 264f2060a..966b41850 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -107,7 +107,7 @@ int is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; From 85bbfadd2f94f7e6940be3a17a40319c3cd4ac63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:40:04 +0800 Subject: [PATCH 429/951] attempt to add Raddress array --- src/komodo_globals.h | 4 ++-- src/komodo_notary.h | 40 ++++++++++++++++++++++++++++++++-------- src/main.cpp | 9 +++++---- src/notaries_staked.cpp | 35 +++++++++++++++++++++++++++++++++++ src/notaries_staked.h | 2 ++ src/wallet/wallet.cpp | 15 ++++----------- 6 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 133743c52..48071e072 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,12 +45,12 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8e2fdf6fc..033fe8bba 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,6 +22,8 @@ #define KOMODO_MAINNET_START 178999 +extern NOTARYADDRS[18][64]; + //extern const char *notaries_STAKED[][2]; //extern const int num_notaries_STAKED; @@ -226,8 +228,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam if ( did0 == 0 ) { n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i STAKED_ERA ) + STAKED_ERA = era; return(era); }; +extern NOTARYADDRS[18][64]; + +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { + int8_t notaryID = -1; + if ( STAKED_ERA != 0 ) { + switch (STAKED_ERA) { + case 1: + notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname); + break; + case 2: + notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname); + break; + case 3: + notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname); + break; + case 4: + notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname); + break; + } + } + return(notaryID); +} + +int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { + for (size_t i = 0; i < num_notaries; i++) { + if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { + notaryname.assign(notaries_chosen[i][0]); + return(i); + } + } + return(-1) +} + CrosschainAuthority Choose_auth_STAKED(int chosen_era) { CrosschainAuthority auth; switch (chosen_era) { diff --git a/src/notaries_staked.h b/src/notaries_staked.h index fbb3506ba..d3927e68f 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -25,6 +25,8 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); +int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); CrosschainAuthority Choose_auth_STAKED(int chosen_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 65dc60f8d..a73ea31fe 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,17 +1202,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -bool pubkey2addr(char destaddr,uint8_t *pubkey33); bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { - static bool didNA; - if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) { - char Raddress[18]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - NOTARY_ADDRESS.assign(Raddress); - didNA == true; - } { AssertLockHeld(cs_wallet); bool fExisted = mapWallet.count(tx.GetHash()) != 0; @@ -1226,9 +1218,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; - if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false)) + if (GetTransaction(tx.vin[i].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) { + if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) { // This means we sent the tx.. if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { numvinIsOurs++; @@ -1259,7 +1251,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, we wil remove the utxo we spent from our wallet and do nothing else. + // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, + // IF there exisited a function for that. fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 2d1a27fddf7b4c57f101a0bd6df84193ada5b6dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:43:46 +0800 Subject: [PATCH 430/951] fix --- src/notaries_staked.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 775f9c9cd..1066d18d0 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -130,7 +130,8 @@ int STAKED_era(int timestamp) return(era); }; -extern NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64]; +extern int32_t STAKED_ERA; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; @@ -160,7 +161,7 @@ int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *R return(i); } } - return(-1) + return(-1); } CrosschainAuthority Choose_auth_STAKED(int chosen_era) { From 351405ce375de6eb40b81c7ab9cd5c86423c56d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:47:50 +0800 Subject: [PATCH 431/951] more fix --- src/komodo_notary.h | 2 +- src/notaries_staked.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 033fe8bba..5f96e9145 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,7 +22,7 @@ #define KOMODO_MAINNET_START 178999 -extern NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64]; //extern const char *notaries_STAKED[][2]; //extern const int num_notaries_STAKED; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 1066d18d0..9d413fd5d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -3,6 +3,9 @@ #include "crosschain.h" #include +extern char NOTARYADDRS[18][64]; +extern int32_t STAKED_ERA; + // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = { @@ -130,9 +133,6 @@ int STAKED_era(int timestamp) return(era); }; -extern char NOTARYADDRS[18][64]; -extern int32_t STAKED_ERA; - int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; if ( STAKED_ERA != 0 ) { From 234da7a784ce1b0b8822f048c7c451b1ce22d0b0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 18:51:41 +0800 Subject: [PATCH 432/951] fix --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cd6cf11d6..7ea4f85e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } -extern NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64]; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { @@ -1062,7 +1062,7 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only } didinit = 1; } */ - for (i=0; i<=64; i++) + for (int32_t i=0; i<=64; i++) if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) return(1); return(0); From 65c77d6ffc9157a1529e3649a4d09161c370dd55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:13:38 +0800 Subject: [PATCH 433/951] fix --- src/cc/CCinclude.h | 4 +++- src/komodo_structs.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index ab320e58a..2e447f485 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -55,9 +55,11 @@ extern std::string CCerror; #define SMALLVAL 0.000000000000001 #define MIN_NOTARIZATION_CONFIRMS 2 +#ifndef _BITS256 +#define _BITS256 union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; typedef union _bits256 bits256; - +#endif struct CC_utxo { uint256 txid; diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 3d8f50718..470eeda09 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -47,10 +47,11 @@ #define KOMODO_KVBINARY 2 #define KOMODO_KVDURATION 1440 #define KOMODO_ASSETCHAIN_MAXLEN 65 - +#ifndef _BITS256 +#define _BITS256 union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; typedef union _bits256 bits256; - +#endif union _bits320 { uint8_t bytes[40]; uint16_t ushorts[20]; uint32_t uints[10]; uint64_t ulongs[5]; uint64_t txid; }; typedef union _bits320 bits320; From 8207ebdaa1aee995634ba09081951bab2e79379e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:16:27 +0800 Subject: [PATCH 434/951] try --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..deb956a1a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,7 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" - +#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) From 37c7d4108dc52d567e072f2f6e6e3f247df08c6b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:17:35 +0800 Subject: [PATCH 435/951] cpp include? --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index deb956a1a..717717a53 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,7 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCinclude.h" +#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) From 0b8cb81d2ce86247761360c616660988318044ab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:23:11 +0800 Subject: [PATCH 436/951] try --- src/cc/CCutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 491798a98..0270a09ff 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCinclude.h" - +#include "../standard.h" /* CCutils has low level functions that are universally useful for all contracts. */ From e1b67809d9432dfb3fe7d94feaef9cd844120289 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:25:12 +0800 Subject: [PATCH 437/951] script --- src/cc/CCutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 0270a09ff..b586f5fcf 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCinclude.h" -#include "../standard.h" +#include "../script/standard.h" /* CCutils has low level functions that are universally useful for all contracts. */ From 5f81cde8f71ca894e0ec431d425ade4ef04eabbd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:35:05 +0800 Subject: [PATCH 438/951] guessing --- src/bitcoin-cli.cpp | 1 - src/cc/utils.cpp | 22 ++++++++++++++++++++++ src/cc/utils.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 717717a53..a886c27f2 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,7 +78,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/cc/utils.cpp b/src/cc/utils.cpp index e69de29bb..e13c6054d 100644 --- a/src/cc/utils.cpp +++ b/src/cc/utils.cpp @@ -0,0 +1,22 @@ +#include "../script/standard.h" +#include "../base58.h" + +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) +{ + CTxDestination address; txnouttype whichType; + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); + return(true); + } + fprintf(stderr,"ExtractDestination failed\n"); + return(false); +} + +bool pubkey2addr(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); +} diff --git a/src/cc/utils.h b/src/cc/utils.h index f0b91962d..6a70b6828 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -42,6 +42,8 @@ bool DeserializeF(const std::vector vIn, T f) } catch(...) {} return false; } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); #define E_MARSHAL(body) SerializeF([&] (CDataStream &ss) {body;}) #define E_UNMARSHAL(params, body) DeserializeF(params, [&] (CDataStream &ss) {body;}) From e75e7e21c6dea8ffeddaad5b180de405b6c1aad6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:39:58 +0800 Subject: [PATCH 439/951] try again --- src/komodo_notary.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5f96e9145..b4b8edc4b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,6 +20,8 @@ #include "notaries_staked.h" +#include "cc/utils.cpp" + #define KOMODO_MAINNET_START 178999 extern char NOTARYADDRS[18][64]; @@ -206,6 +208,8 @@ const char *Notaries_elected1[][2] = }; #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; From c4e4197a659df34a058481fe8fd18c72caf6ec6f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:44:52 +0800 Subject: [PATCH 440/951] guess --- src/cc/utils.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cc/utils.cpp b/src/cc/utils.cpp index e13c6054d..fb41aaabf 100644 --- a/src/cc/utils.cpp +++ b/src/cc/utils.cpp @@ -1,6 +1,4 @@ -#include "../script/standard.h" -#include "../base58.h" - +#include "../main.h" bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { CTxDestination address; txnouttype whichType; From 54054b83970ff5bb190050c41d97ff6a308db716 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:47:16 +0800 Subject: [PATCH 441/951] try again --- src/bitcoin-cli.cpp | 2 ++ src/cc/utils.cpp | 20 -------------------- src/cc/utils.h | 3 +-- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index a886c27f2..420123d93 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,6 +78,8 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "main.h" +#include "cc/CCutils.cpp" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/cc/utils.cpp b/src/cc/utils.cpp index fb41aaabf..e69de29bb 100644 --- a/src/cc/utils.cpp +++ b/src/cc/utils.cpp @@ -1,20 +0,0 @@ -#include "../main.h" -bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) -{ - CTxDestination address; txnouttype whichType; - if ( ExtractDestination(scriptPubKey,address) != 0 ) - { - strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); - return(true); - } - fprintf(stderr,"ExtractDestination failed\n"); - return(false); -} - -bool pubkey2addr(char *destaddr,uint8_t *pubkey33) -{ - std::vectorpk; int32_t i; - for (i=0; i<33; i++) - pk.push_back(pubkey33[i]); - return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); -} diff --git a/src/cc/utils.h b/src/cc/utils.h index 6a70b6828..69410adbb 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -20,6 +20,7 @@ #include "version.h" + /* * Serialisation boilerplate */ @@ -42,8 +43,6 @@ bool DeserializeF(const std::vector vIn, T f) } catch(...) {} return false; } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); -bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); #define E_MARSHAL(body) SerializeF([&] (CDataStream &ss) {body;}) #define E_UNMARSHAL(params, body) DeserializeF(params, [&] (CDataStream &ss) {body;}) From d0e0ae97ba7203daeb1bca363b44b1fe52d60c45 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:49:55 +0800 Subject: [PATCH 442/951] wtf --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 420123d93..a1f06525c 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -79,7 +79,7 @@ public: #include "komodo_notary.h" #include "notaries_staked.cpp" #include "main.h" -#include "cc/CCutils.cpp" +#include "cc/CCinclude.h" void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) From 20c46df9be2a4bef8b94519d5f0b299ec5034248 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 22:53:57 +0800 Subject: [PATCH 443/951] dead --- src/bitcoin-cli.cpp | 3 +-- src/cc/CCutils.cpp | 2 +- src/komodo_notary.h | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index a1f06525c..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,8 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#include "main.h" -#include "cc/CCinclude.h" + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index b586f5fcf..491798a98 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -14,7 +14,7 @@ ******************************************************************************/ #include "CCinclude.h" -#include "../script/standard.h" + /* CCutils has low level functions that are universally useful for all contracts. */ diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b4b8edc4b..c67d62342 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,7 +20,8 @@ #include "notaries_staked.h" -#include "cc/utils.cpp" +#include "main.h" +#include "cc/CCinclude.h" #define KOMODO_MAINNET_START 178999 From 7ccc6fe7ed4699ebdf806389ae38eb1f88240e01 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 23:26:07 +0800 Subject: [PATCH 444/951] try --- src/komodo_globals.h | 1 - src/komodo_notary.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 48071e072..bf96cfa44 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,7 +29,6 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c67d62342..d5c54aeaf 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,6 +22,7 @@ #include "main.h" #include "cc/CCinclude.h" +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); #define KOMODO_MAINNET_START 178999 From 099b691e24767b74be11f15fe302617166d3fd78 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 2 Nov 2018 23:33:41 +0800 Subject: [PATCH 445/951] hacky fix --- src/komodo_notary.h | 16 +++++++--------- src/main.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d5c54aeaf..cc841bc9d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,9 +20,7 @@ #include "notaries_staked.h" -#include "main.h" -#include "cc/CCinclude.h" -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; #define KOMODO_MAINNET_START 178999 @@ -237,7 +235,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam for (i=0; i Date: Fri, 2 Nov 2018 23:40:20 +0800 Subject: [PATCH 446/951] fix not compile --- src/wallet/rpcwallet.cpp | 69 ++-------------------------------------- 1 file changed, 3 insertions(+), 66 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 153a87dc7..f2cfae5a6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4565,7 +4565,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); if (!EnsureWalletIsAvailable(0)) return 0; - + const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4728,7 +4728,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; - + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); @@ -5029,69 +5029,6 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) return(result); } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -UniValue setpubkey(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); - if ( fHelp || params.size() != 1 ) - throw runtime_error( - "setpubkey\n" - "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" - "\nArguments:\n" - "1. \"pubkey\" (string) pubkey to set.\n" - "\nResult:\n" - " {\n" - " \"pubkey\" : \"pubkey\", (string) The pubkey\n" - " \"ismine\" : \"true/false\", (bool)\n" - " \"R-address\" : \"R address\", (string) The pubkey\n" - " }\n" - "\nExamples:\n" - + HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") - ); - -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK(cs_main); -#endif - - char Raddress[18]; - uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { - result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { - CBitcoinAddress address(Raddress); - bool isValid = address.IsValid(); - if (isValid) - { - CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - result.push_back(Pair("address", currentAddress)); -#ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); -#endif - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } - } else { - result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); - } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); - return result; -} UniValue oraclesaddress(const UniValue& params, bool fHelp) { @@ -6769,7 +6706,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); CTxDestination address; if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + const CKeyStore& keystore = *pwalletMain; CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid; assert(pwalletMain != NULL); From 885f304f9c325957792acece4a134ae02a3a003c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 00:47:19 +0800 Subject: [PATCH 447/951] try --- src/main.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.h b/src/main.h index fd418502a..0dd5e35c2 100644 --- a/src/main.h +++ b/src/main.h @@ -180,11 +180,11 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals); /** Unregister a network node */ void UnregisterNodeSignals(CNodeSignals& nodeSignals); -/** +/** * Process an incoming block. This only returns after the best known valid * block is made active. Note that it does not, however, guarantee that the * specific block passed to it has been checked for validity! - * + * * @param[out] state This may be set to an Error state if any error occurred processing it, including during validation/connection/etc of otherwise unrelated blocks during reorganisation; or it may be set to an Invalid state if pblock is itself invalid (but this is not guaranteed even when the block is checked). If you want to *possibly* get feedback on whether pblock is valid, you must also install a CValidationInterface (see validationinterface.h) - this will have its BlockChecked method called whenever *any* block completes validation. * @param[in] pfrom The node which we are receiving the block from; it is added to mapBlockSource and may be penalised if the block is invalid. * @param[in] pblock The block we want to process. @@ -269,6 +269,7 @@ void PruneAndFlush(); bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectAbsurdFee=false); +int32_t pubkey2address(char *destaddr,uint8_t *pubkey33); struct CNodeStateStats { int nMisbehavior; @@ -640,7 +641,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF /** * Check transaction inputs, and make sure any * pay-to-script-hash transactions are evaluating IsStandard scripts - * + * * Why bother? To avoid denial-of-service attacks; an attacker * can submit a standard HASH... OP_EQUAL transaction, * which will get accepted into blocks. The redemption @@ -649,14 +650,14 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF * DUP CHECKSIG DROP ... repeated 100 times... OP_1 */ -/** +/** * Check for standard transaction types * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return True if all inputs (scriptSigs) use only standard transaction forms */ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, uint32_t consensusBranchId); -/** +/** * Count ECDSA signature operations the old-fashioned (pre-0.6) way * @return number of sigops this transaction's outputs will produce when spent * @see CTransaction::FetchInputs @@ -665,7 +666,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx); /** * Count ECDSA signature operations in pay-to-script-hash inputs. - * + * * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return maximum number of sigops required to validate this transaction's inputs * @see CTransaction::FetchInputs @@ -732,9 +733,9 @@ bool IsExpiredTx(const CTransaction &tx, int nBlockHeight); */ bool CheckFinalTx(const CTransaction &tx, int flags = -1); -/** +/** * Closure representing one script verification - * Note that this stores references to the spending transaction + * Note that this stores references to the spending transaction */ class CScriptCheck { From 943026456e03552914bae5b7e93328db4d6818c2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:22:18 +0800 Subject: [PATCH 448/951] try this arr --- src/main.h | 1 - src/rpcrawtransaction.cpp | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.h b/src/main.h index 0dd5e35c2..76e0f73ae 100644 --- a/src/main.h +++ b/src/main.h @@ -269,7 +269,6 @@ void PruneAndFlush(); bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectAbsurdFee=false); -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33); struct CNodeStateStats { int nMisbehavior; diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index a870d526c..6d874f420 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -480,7 +480,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid uint256 hashBlock; if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) return(-1); - else if ( n < tx.vout.size() ) + else if ( n < tx.vout.size() ) { ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); @@ -492,6 +492,13 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid return(-1); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + +int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) +{ + pubkey2addr((char *)destaddr,(uint8_t *)pubkey33); +} + UniValue gettxoutproof(const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 1 && params.size() != 2)) @@ -1155,7 +1162,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) } } else if (fHaveChain) { throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); - } + } RelayTransaction(tx); return hashTx.GetHex(); From 43b7d6c90a37fd24a9eaa4c5ac4d188bb1e51435 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:27:11 +0800 Subject: [PATCH 449/951] try again --- src/main.cpp | 6 ------ src/rpcrawtransaction.cpp | 21 +++++++++++++++++---- src/rpcserver.h | 3 +++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c1c7b0936..7ea4f85e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1045,7 +1045,6 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, } } extern char NOTARYADDRS[18][64]; -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { @@ -1069,11 +1068,6 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only return(0); } -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) -{ - pubkey2addr((char *)destaddr,(uint8_t *)pubkey33); -} - bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state) { // Basic checks that don't depend on any context diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 6d874f420..5710e502f 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -492,11 +492,24 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid return(-1); } -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) { - pubkey2addr((char *)destaddr,(uint8_t *)pubkey33); + CTxDestination address; txnouttype whichType; + if ( ExtractDestination(scriptPubKey,address) != 0 ) + { + strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); + return(true); + } + fprintf(stderr,"ExtractDestination failed\n"); + return(false); +} + +bool pubkey2address(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); } UniValue gettxoutproof(const UniValue& params, bool fHelp) diff --git a/src/rpcserver.h b/src/rpcserver.h index 81ca8a8b9..372d84392 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -287,6 +287,9 @@ extern UniValue FSMlist(const UniValue& params, bool fHelp); extern UniValue FSMinfo(const UniValue& params, bool fHelp); extern UniValue auctionaddress(const UniValue& params, bool fHelp); +extern bool pubkey2address(char *destaddr,uint8_t *pubkey33); +extern bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); + extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp //extern UniValue getnewaddress64(const UniValue& params, bool fHelp); // in rpcwallet.cpp extern UniValue getaccountaddress(const UniValue& params, bool fHelp); From cd477f81781eb73c7a51784d8becfe374c41c9bb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:31:50 +0800 Subject: [PATCH 450/951] try --- src/rpcrawtransaction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 5710e502f..cf8aa8fb8 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -24,6 +24,7 @@ #endif #include "komodo_defs.h" +#include "komodo_notary.h" #include From c87ce0d841612bf9d1e4dc94a4cef49721f5035c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:37:39 +0800 Subject: [PATCH 451/951] why not --- src/komodo_notary.h | 2 +- src/rpcrawtransaction.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index cc841bc9d..6291c8e1a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,7 +20,7 @@ #include "notaries_staked.h" -int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; +extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; #define KOMODO_MAINNET_START 178999 diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index cf8aa8fb8..5710e502f 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -24,7 +24,6 @@ #endif #include "komodo_defs.h" -#include "komodo_notary.h" #include From 0a598aeea7526552272e99a3ca0ce7f9ded9cd76 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:41:03 +0800 Subject: [PATCH 452/951] extreme lengths --- src/komodo_notary.h | 709 -------------------------------------------- 1 file changed, 709 deletions(-) delete mode 100644 src/komodo_notary.h diff --git a/src/komodo_notary.h b/src/komodo_notary.h deleted file mode 100644 index 6291c8e1a..000000000 --- a/src/komodo_notary.h +++ /dev/null @@ -1,709 +0,0 @@ -/****************************************************************************** - * Copyright © 2014-2018 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - - -#include "komodo_defs.h" - -#include "komodo_cJSON.h" - -#include "notaries_staked.h" - -extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; - -#define KOMODO_MAINNET_START 178999 - -extern char NOTARYADDRS[18][64]; - -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - -const char *Notaries_genesis[][2] = -{ - { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, - { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, - { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 - { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, - { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, - { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, - { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, -}; - -const char *Notaries_elected0[][2] = -{ - { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 - { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, - { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, - { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 - { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, - { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, - { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, - { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, - { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 - { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, - { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, - { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, - { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 - { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, - { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, - { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, - { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, - { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, - { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, - { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 - { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 - { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, - { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, - { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, - { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, - { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, - { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 - { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, - { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, - { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } -}; - -#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 -#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) - -const char *Notaries_elected1[][2] = -{ - {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, - {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, - {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, - {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, - {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 - {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, - {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, - {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, - {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, - {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, - {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, - {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, - {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, - {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, - {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 - {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, - {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, - {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, - {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, - {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, - {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, - {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, - {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 - {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, - {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, - {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, - {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, - {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, - {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, - {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, - {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 - {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, - {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, - {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, - {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, - {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, - {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, - {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, - {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 - {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, - {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, - {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, - {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, - {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, - {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, - {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, - {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, -}; -#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" - -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) -{ - static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33] = {0}; - int staked_era; - int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) - timestamp = 0; - // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) - { - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - if ( Pubkeys == 0 ) - { - komodo_init(height); - //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); - } - pthread_mutex_lock(&komodo_mutex); - n = Pubkeys[htind].numnotaries; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); - HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) - { - if ( kp->notaryid < n ) - { - mask |= (1LL << kp->notaryid); - memcpy(pubkeys[kp->notaryid],kp->pubkey,33); - } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); - } - pthread_mutex_unlock(&komodo_mutex); - if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) - return(n); - printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); - return(-1); -} - -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) -{ - int32_t i,n; uint8_t pubkeys[64][33]; - n = komodo_notaries(pubkeys,height,timestamp); - *numnotariesp = n; - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) -{ - static int32_t hwmheight; - int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; - if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); - memset(&N,0,sizeof(N)); - if ( origheight > 0 ) - { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); - } else htind = 0; - pthread_mutex_lock(&komodo_mutex); - for (k=0; kpubkey,pubkeys[k],33); - kp->notaryid = k; - HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) - { - for (i=0; i<33; i++) - printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); - } - } - N.numnotaries = num; - for (i=htind; i hwmheight ) - hwmheight = origheight; -} - -int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) -{ - // -1 if not notary, 0 if notary, 1 if special notary - struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; - *notaryidp = -1; - if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) - { - printf("komodo_chosennotary ht.%d illegal\n",height); - return(-1); - } - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) - { - modval = ((height % numnotaries) == *notaryidp); - return(modval); - } - } - if ( height >= 250000 ) - return(-1); - if ( Pubkeys == 0 ) - komodo_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); - if ( kp != 0 ) - { - if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) - { - *notaryidp = kp->notaryid; - modval = ((height % numnotaries) == kp->notaryid); - //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); - } else printf("unexpected zero notaries at height.%d\n",height); - } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); - //int32_t i; for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); - return(modval); -} - -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); - -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - *idx = i; - np = &sp->NPOINTS[i]; - if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) - return(np); - } - } - *idx = -1; - return(0); -} - -struct notarized_checkpoint *komodo_npptr(int32_t height) -{ - int idx; - return komodo_npptr_for_height(height, &idx); -} - -struct notarized_checkpoint *komodo_npptr_at(int idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - if (idx < sp->NUM_NPOINTS) - return &sp->NPOINTS[idx]; - return(0); -} - -int32_t komodo_prevMoMheight() -{ - static uint256 zero; - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - np = &sp->NPOINTS[i]; - if ( np->MoM != zero ) - return(np->notarized_height); - } - } - return(0); -} - -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); - return(sp->NOTARIZED_HEIGHT); - } - else - { - *prevMoMheightp = 0; - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} - -int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NOTARIZED_HEIGHT > 0 ) - { - if ( txheight < sp->NOTARIZED_HEIGHT ) - return(numconfs); - else return(1); - } - } - return(numconfs); -} - -int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) -{ - struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) - { - *notarized_htp = np->notarized_height; - *MoMp = np->MoM; - *kmdtxidp = np->notarized_desttxid; - *MoMoMp = np->MoMoM; - *MoMoMoffsetp = np->MoMoMoffset; - *MoMoMdepthp = np->MoMoMdepth; - *kmdstartip = np->kmdstarti; - *kmdendip = np->kmdendi; - return(np->MoMdepth & 0xffff); - } - *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; - memset(MoMp,0,sizeof(*MoMp)); - memset(MoMoMp,0,sizeof(*MoMoMp)); - memset(kmdtxidp,0,sizeof(*kmdtxidp)); - return(0); -} - -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) -{ - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NUM_NPOINTS > 0 ) - { - flag = 0; - if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) - { - np = &sp->NPOINTS[sp->last_NPOINTSi-1]; - if ( np->nHeight < nHeight ) - { - for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); - flag = 1; - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( flag == 0 ) - { - np = 0; - for (i=0; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( np != 0 ) - { - //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); - if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) - printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); - } - } - memset(notarized_hashp,0,sizeof(*notarized_hashp)); - memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); - return(0); -} - -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - -void komodo_init(int32_t height) -{ - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); - memset(&zero,0,sizeof(zero)); - if ( didinit == 0 ) - { - pthread_mutex_init(&komodo_mutex,NULL); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - if ( height >= 0 ) - { - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k Date: Sat, 3 Nov 2018 01:41:39 +0800 Subject: [PATCH 453/951] oops --- src/main.cpp | 711 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 711 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 7ea4f85e8..c8e67f8b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1068,6 +1068,717 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only return(0); } +/****************************************************************************** + * Copyright © 2014-2018 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + +#include "komodo_defs.h" + +#include "komodo_cJSON.h" + +#include "notaries_staked.h" + +extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; + +#define KOMODO_MAINNET_START 178999 + +extern char NOTARYADDRS[18][64]; + +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; + +const char *Notaries_genesis[][2] = +{ + { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, + { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, + { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 + { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, + { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, + { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, + { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, +}; + +const char *Notaries_elected0[][2] = +{ + { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 + { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, + { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, + { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 + { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, + { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, + { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, + { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, + { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 + { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, + { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, + { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 + { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, + { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, + { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, + { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, + { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, + { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, + { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 + { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 + { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, + { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, + { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, + { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, + { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, + { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 + { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, + { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } +}; + +#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 +#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) + +const char *Notaries_elected1[][2] = +{ + {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, + {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, + {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, + {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, + {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 + {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, + {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, + {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, + {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, + {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, + {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, + {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, + {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, + {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, + {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 + {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, + {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, + {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, + {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, + {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, + {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, + {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, + {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 + {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, + {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, + {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, + {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, + {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, + {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, + {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, + {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 + {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, + {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, + {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, + {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, + {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, + {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, + {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, + {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 + {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, + {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, + {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, + {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, + {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, + {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, + {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, + {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; +#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" + +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) +{ + static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; + static uint8_t null_pubkeys[64][33] = {0}; + int staked_era; + int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = komodo_heightstamp(height); + else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + timestamp = 0; + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. + if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) + { + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + if ( Pubkeys == 0 ) + { + komodo_init(height); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + } + pthread_mutex_lock(&komodo_mutex); + n = Pubkeys[htind].numnotaries; + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); + HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) + { + if ( kp->notaryid < n ) + { + mask |= (1LL << kp->notaryid); + memcpy(pubkeys[kp->notaryid],kp->pubkey,33); + } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); + } + pthread_mutex_unlock(&komodo_mutex); + if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) + return(n); + printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); + return(-1); +} + +int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +{ + int32_t i,n; uint8_t pubkeys[64][33]; + n = komodo_notaries(pubkeys,height,timestamp); + *numnotariesp = n; + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + numnotaries = Pubkeys[htind].numnotaries; + for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) + return(1); + else return(0); +} + +void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +{ + static int32_t hwmheight; + int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; + if ( Pubkeys == 0 ) + Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + memset(&N,0,sizeof(N)); + if ( origheight > 0 ) + { + height = (origheight + KOMODO_ELECTION_GAP/2); + height /= KOMODO_ELECTION_GAP; + height = ((height + 1) * KOMODO_ELECTION_GAP); + htind = (height / KOMODO_ELECTION_GAP); + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); + } else htind = 0; + pthread_mutex_lock(&komodo_mutex); + for (k=0; kpubkey,pubkeys[k],33); + kp->notaryid = k; + HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); + if ( 0 && height > 10000 ) + { + for (i=0; i<33; i++) + printf("%02x",pubkeys[k][i]); + printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); + } + } + N.numnotaries = num; + for (i=htind; i hwmheight ) + hwmheight = origheight; +} + +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) +{ + // -1 if not notary, 0 if notary, 1 if special notary + struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + *notaryidp = -1; + if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) + { + printf("komodo_chosennotary ht.%d illegal\n",height); + return(-1); + } + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + { + modval = ((height % numnotaries) == *notaryidp); + return(modval); + } + } + if ( height >= 250000 ) + return(-1); + if ( Pubkeys == 0 ) + komodo_init(0); + htind = height / KOMODO_ELECTION_GAP; + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + pthread_mutex_lock(&komodo_mutex); + HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); + pthread_mutex_unlock(&komodo_mutex); + if ( kp != 0 ) + { + if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) + { + *notaryidp = kp->notaryid; + modval = ((height % numnotaries) == kp->notaryid); + //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); + } else printf("unexpected zero notaries at height.%d\n",height); + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); + //int32_t i; for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); + return(modval); +} + +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); + +struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + *idx = i; + np = &sp->NPOINTS[i]; + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) + return(np); + } + } + *idx = -1; + return(0); +} + +struct notarized_checkpoint *komodo_npptr(int32_t height) +{ + int idx; + return komodo_npptr_for_height(height, &idx); +} + +struct notarized_checkpoint *komodo_npptr_at(int idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if (idx < sp->NUM_NPOINTS) + return &sp->NPOINTS[idx]; + return(0); +} + +int32_t komodo_prevMoMheight() +{ + static uint256 zero; + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoM != zero ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevMoMheightp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) +{ + struct notarized_checkpoint *np = 0; + if ( (np= komodo_npptr(height)) != 0 ) + { + *notarized_htp = np->notarized_height; + *MoMp = np->MoM; + *kmdtxidp = np->notarized_desttxid; + *MoMoMp = np->MoMoM; + *MoMoMoffsetp = np->MoMoMoffset; + *MoMoMdepthp = np->MoMoMdepth; + *kmdstartip = np->kmdstarti; + *kmdendip = np->kmdendi; + return(np->MoMdepth & 0xffff); + } + *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; + memset(MoMp,0,sizeof(*MoMp)); + memset(MoMoMp,0,sizeof(*MoMoMp)); + memset(kmdtxidp,0,sizeof(*kmdtxidp)); + return(0); +} + +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +{ + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NUM_NPOINTS > 0 ) + { + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) + { + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + if ( np->nHeight < nHeight ) + { + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( np != 0 ) + { + //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); + if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) + printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); + } + } + memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); + return(0); +} + +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); +} + +void komodo_init(int32_t height) +{ + static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + if ( 0 && height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); + memset(&zero,0,sizeof(zero)); + if ( didinit == 0 ) + { + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + if ( height >= 0 ) + { + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k Date: Sat, 3 Nov 2018 01:43:55 +0800 Subject: [PATCH 454/951] unikely --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..bd39318c3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,7 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "komodo_notary.h" +//#include "komodo_notary.h" #include "notaries_staked.cpp" diff --git a/src/komodo.h b/src/komodo.h index d2d0231f3..94a50a337 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -48,7 +48,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" -#include "komodo_notary.h" +//#include "komodo_notary.h" int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" From f8889dbe6d326f933d7877ef673870a454725269 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 01:46:19 +0800 Subject: [PATCH 455/951] main.h? --- src/main.cpp | 711 --------------------------------------------------- src/main.h | 708 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 708 insertions(+), 711 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c8e67f8b4..7ea4f85e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1068,717 +1068,6 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only return(0); } -/****************************************************************************** - * Copyright © 2014-2018 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - - -#include "komodo_defs.h" - -#include "komodo_cJSON.h" - -#include "notaries_staked.h" - -extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; - -#define KOMODO_MAINNET_START 178999 - -extern char NOTARYADDRS[18][64]; - -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - -const char *Notaries_genesis[][2] = -{ - { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, - { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, - { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 - { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, - { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, - { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, - { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, -}; - -const char *Notaries_elected0[][2] = -{ - { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, - { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, - { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, - { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, - { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 - { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, - { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, - { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, - { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, - { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 - { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, - { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, - { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, - { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, - { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 - { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, - { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, - { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, - { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, - { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, - { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 - { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, - { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, - { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, - { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, - { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, - { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, - { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, - { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, - { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 - { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, - { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, - { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, - { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, - { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, - { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, - { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, - { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 - { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, - { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, - { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, - { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, - { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, - { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, - { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, - { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, - { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, - { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 - { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, - { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, - { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } -}; - -#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 -#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) - -const char *Notaries_elected1[][2] = -{ - {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, - {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, - {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, - {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, - {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, - {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, - {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, - {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, - {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, - {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 - {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, - {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, - {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, - {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, - {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, - {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, - {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, - {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, - {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, - {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 - {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, - {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, - {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, - {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, - {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, - {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, - {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, - {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 - {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, - {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, - {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, - {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, - {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, - {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, - {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, - {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, - {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 - {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, - {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, - {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, - {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, - {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, - {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, - {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, - {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 - {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, - {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, - {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, - {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, - {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, - {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, - {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, - {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, - {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 - {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, - {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, - {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, -}; -#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" - -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - -int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) -{ - static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33] = {0}; - int staked_era; - int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) - timestamp = 0; - // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) - { - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - if ( Pubkeys == 0 ) - { - komodo_init(height); - //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); - } - pthread_mutex_lock(&komodo_mutex); - n = Pubkeys[htind].numnotaries; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); - HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) - { - if ( kp->notaryid < n ) - { - mask |= (1LL << kp->notaryid); - memcpy(pubkeys[kp->notaryid],kp->pubkey,33); - } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); - } - pthread_mutex_unlock(&komodo_mutex); - if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) - return(n); - printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); - return(-1); -} - -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) -{ - int32_t i,n; uint8_t pubkeys[64][33]; - n = komodo_notaries(pubkeys,height,timestamp); - *numnotariesp = n; - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) -{ - static int32_t hwmheight; - int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; - if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); - memset(&N,0,sizeof(N)); - if ( origheight > 0 ) - { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); - } else htind = 0; - pthread_mutex_lock(&komodo_mutex); - for (k=0; kpubkey,pubkeys[k],33); - kp->notaryid = k; - HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) - { - for (i=0; i<33; i++) - printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); - } - } - N.numnotaries = num; - for (i=htind; i hwmheight ) - hwmheight = origheight; -} - -int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) -{ - // -1 if not notary, 0 if notary, 1 if special notary - struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; - *notaryidp = -1; - if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) - { - printf("komodo_chosennotary ht.%d illegal\n",height); - return(-1); - } - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) - { - modval = ((height % numnotaries) == *notaryidp); - return(modval); - } - } - if ( height >= 250000 ) - return(-1); - if ( Pubkeys == 0 ) - komodo_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); - if ( kp != 0 ) - { - if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) - { - *notaryidp = kp->notaryid; - modval = ((height % numnotaries) == kp->notaryid); - //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); - } else printf("unexpected zero notaries at height.%d\n",height); - } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); - //int32_t i; for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); - return(modval); -} - -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); - -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - *idx = i; - np = &sp->NPOINTS[i]; - if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) - return(np); - } - } - *idx = -1; - return(0); -} - -struct notarized_checkpoint *komodo_npptr(int32_t height) -{ - int idx; - return komodo_npptr_for_height(height, &idx); -} - -struct notarized_checkpoint *komodo_npptr_at(int idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - if (idx < sp->NUM_NPOINTS) - return &sp->NPOINTS[idx]; - return(0); -} - -int32_t komodo_prevMoMheight() -{ - static uint256 zero; - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - np = &sp->NPOINTS[i]; - if ( np->MoM != zero ) - return(np->notarized_height); - } - } - return(0); -} - -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); - return(sp->NOTARIZED_HEIGHT); - } - else - { - *prevMoMheightp = 0; - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} - -int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NOTARIZED_HEIGHT > 0 ) - { - if ( txheight < sp->NOTARIZED_HEIGHT ) - return(numconfs); - else return(1); - } - } - return(numconfs); -} - -int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) -{ - struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) - { - *notarized_htp = np->notarized_height; - *MoMp = np->MoM; - *kmdtxidp = np->notarized_desttxid; - *MoMoMp = np->MoMoM; - *MoMoMoffsetp = np->MoMoMoffset; - *MoMoMdepthp = np->MoMoMdepth; - *kmdstartip = np->kmdstarti; - *kmdendip = np->kmdendi; - return(np->MoMdepth & 0xffff); - } - *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; - memset(MoMp,0,sizeof(*MoMp)); - memset(MoMoMp,0,sizeof(*MoMoMp)); - memset(kmdtxidp,0,sizeof(*kmdtxidp)); - return(0); -} - -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) -{ - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NUM_NPOINTS > 0 ) - { - flag = 0; - if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) - { - np = &sp->NPOINTS[sp->last_NPOINTSi-1]; - if ( np->nHeight < nHeight ) - { - for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); - flag = 1; - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( flag == 0 ) - { - np = 0; - for (i=0; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( np != 0 ) - { - //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); - if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) - printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); - } - } - memset(notarized_hashp,0,sizeof(*notarized_hashp)); - memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); - return(0); -} - -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - -void komodo_init(int32_t height) -{ - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); - memset(&zero,0,sizeof(zero)); - if ( didinit == 0 ) - { - pthread_mutex_init(&komodo_mutex,NULL); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - if ( height >= 0 ) - { - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + if ( Pubkeys == 0 ) + { + komodo_init(height); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + } + pthread_mutex_lock(&komodo_mutex); + n = Pubkeys[htind].numnotaries; + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); + HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) + { + if ( kp->notaryid < n ) + { + mask |= (1LL << kp->notaryid); + memcpy(pubkeys[kp->notaryid],kp->pubkey,33); + } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); + } + pthread_mutex_unlock(&komodo_mutex); + if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) + return(n); + printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); + return(-1); +} + +int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +{ + int32_t i,n; uint8_t pubkeys[64][33]; + n = komodo_notaries(pubkeys,height,timestamp); + *numnotariesp = n; + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + numnotaries = Pubkeys[htind].numnotaries; + for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) + return(1); + else return(0); +} + +void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +{ + static int32_t hwmheight; + int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; + if ( Pubkeys == 0 ) + Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + memset(&N,0,sizeof(N)); + if ( origheight > 0 ) + { + height = (origheight + KOMODO_ELECTION_GAP/2); + height /= KOMODO_ELECTION_GAP; + height = ((height + 1) * KOMODO_ELECTION_GAP); + htind = (height / KOMODO_ELECTION_GAP); + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); + } else htind = 0; + pthread_mutex_lock(&komodo_mutex); + for (k=0; kpubkey,pubkeys[k],33); + kp->notaryid = k; + HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); + if ( 0 && height > 10000 ) + { + for (i=0; i<33; i++) + printf("%02x",pubkeys[k][i]); + printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); + } + } + N.numnotaries = num; + for (i=htind; i hwmheight ) + hwmheight = origheight; +} + +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) +{ + // -1 if not notary, 0 if notary, 1 if special notary + struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + *notaryidp = -1; + if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) + { + printf("komodo_chosennotary ht.%d illegal\n",height); + return(-1); + } + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + { + modval = ((height % numnotaries) == *notaryidp); + return(modval); + } + } + if ( height >= 250000 ) + return(-1); + if ( Pubkeys == 0 ) + komodo_init(0); + htind = height / KOMODO_ELECTION_GAP; + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + pthread_mutex_lock(&komodo_mutex); + HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); + pthread_mutex_unlock(&komodo_mutex); + if ( kp != 0 ) + { + if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) + { + *notaryidp = kp->notaryid; + modval = ((height % numnotaries) == kp->notaryid); + //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); + } else printf("unexpected zero notaries at height.%d\n",height); + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); + //int32_t i; for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); + return(modval); +} + +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); + +struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + *idx = i; + np = &sp->NPOINTS[i]; + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) + return(np); + } + } + *idx = -1; + return(0); +} + +struct notarized_checkpoint *komodo_npptr(int32_t height) +{ + int idx; + return komodo_npptr_for_height(height, &idx); +} + +struct notarized_checkpoint *komodo_npptr_at(int idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if (idx < sp->NUM_NPOINTS) + return &sp->NPOINTS[idx]; + return(0); +} + +int32_t komodo_prevMoMheight() +{ + static uint256 zero; + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoM != zero ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevMoMheightp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) +{ + struct notarized_checkpoint *np = 0; + if ( (np= komodo_npptr(height)) != 0 ) + { + *notarized_htp = np->notarized_height; + *MoMp = np->MoM; + *kmdtxidp = np->notarized_desttxid; + *MoMoMp = np->MoMoM; + *MoMoMoffsetp = np->MoMoMoffset; + *MoMoMdepthp = np->MoMoMdepth; + *kmdstartip = np->kmdstarti; + *kmdendip = np->kmdendi; + return(np->MoMdepth & 0xffff); + } + *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; + memset(MoMp,0,sizeof(*MoMp)); + memset(MoMoMp,0,sizeof(*MoMoMp)); + memset(kmdtxidp,0,sizeof(*kmdtxidp)); + return(0); +} + +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +{ + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NUM_NPOINTS > 0 ) + { + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) + { + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + if ( np->nHeight < nHeight ) + { + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( np != 0 ) + { + //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); + if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) + printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); + } + } + memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); + return(0); +} + +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); +} + +void komodo_init(int32_t height) +{ + static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + if ( 0 && height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); + memset(&zero,0,sizeof(zero)); + if ( didinit == 0 ) + { + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + if ( height >= 0 ) + { + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k Date: Sat, 3 Nov 2018 01:48:53 +0800 Subject: [PATCH 456/951] try --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index bd39318c3..2cababe69 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,7 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -//#include "komodo_notary.h" +#include "main.h" #include "notaries_staked.cpp" diff --git a/src/komodo.h b/src/komodo.h index 94a50a337..46338b705 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -48,7 +48,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" -//#include "komodo_notary.h" +#include "main.h" int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" From 98a8eea3fa339f9596d354775d0f0f49238fae76 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 02:06:19 +0800 Subject: [PATCH 457/951] revert that --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 2 +- src/komodo_notary.h | 709 ++++++++++++++++++++++++++++++++++++++++++++ src/main.h | 708 ------------------------------------------- 4 files changed, 711 insertions(+), 710 deletions(-) create mode 100644 src/komodo_notary.h diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 2cababe69..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,7 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "main.h" +#include "komodo_notary.h" #include "notaries_staked.cpp" diff --git a/src/komodo.h b/src/komodo.h index 46338b705..d2d0231f3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -48,7 +48,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" -#include "main.h" +#include "komodo_notary.h" int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" diff --git a/src/komodo_notary.h b/src/komodo_notary.h new file mode 100644 index 000000000..6291c8e1a --- /dev/null +++ b/src/komodo_notary.h @@ -0,0 +1,709 @@ +/****************************************************************************** + * Copyright © 2014-2018 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + + +#include "komodo_defs.h" + +#include "komodo_cJSON.h" + +#include "notaries_staked.h" + +extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; + +#define KOMODO_MAINNET_START 178999 + +extern char NOTARYADDRS[18][64]; + +//extern const char *notaries_STAKED[][2]; +//extern const int num_notaries_STAKED; + +const char *Notaries_genesis[][2] = +{ + { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" }, + { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" }, + { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10 + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15 + { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" }, + { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, + { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20 + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" }, + { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, +}; + +const char *Notaries_elected0[][2] = +{ + { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, + { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, + { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" }, + { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10 + { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, + { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" }, + { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" }, + { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" }, + { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15 + { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" }, + { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" }, + { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" }, + { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" }, + { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20 + { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" }, + { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" }, + { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" }, + { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" }, + { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30 + { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" }, + { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" }, + { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" }, + { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" }, + { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" }, + { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" }, + { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" }, + { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" }, + { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40 + { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" }, + { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" }, + { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" }, + { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" }, + { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" }, + { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" }, + { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" }, + { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50 + { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" }, + { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" }, + { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" }, + { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" }, + { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" }, + { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" }, + { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" }, + { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" }, + { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, + { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60 + { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, + { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" }, + { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" } +}; + +#define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017 +#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP) + +const char *Notaries_elected1[][2] = +{ + {"0dev1_jl777", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + {"0dev2_kolo", "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" }, + {"0dev3_kolo", "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" }, + {"0dev4_decker", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" }, + {"a-team_SH", "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" }, + {"artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, + {"artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, + {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, + {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, + {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, + {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 + {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, + {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, + {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, + {"chainmakers_EU", "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" }, + {"chainmakers_NA", "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" }, + {"chainstrike_SH", "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" }, + {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, + {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, + {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, + {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 + {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, + {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, + {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, + {"fullmoon_AR", "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" }, + {"fullmoon_NA", "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" }, + {"fullmoon_SH", "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" }, + {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, + {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 + {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, + {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, + {"karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, + {"komodoninja_EU", "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" }, + {"komodoninja_SH", "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" }, + {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, + {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, + {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, + {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 + {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, + {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, + {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + {"metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, + {"patchkez_SH", "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" }, + {"pbca26_NA", "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" }, + {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, + {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, + {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, + {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 + {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, + {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, + {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, + {"popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" }, + {"popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, + {"alien_AR", "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" }, + {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, + {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, + {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 + {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, + {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, + {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, +}; +#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" + +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); + +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) +{ + static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; + static uint8_t null_pubkeys[64][33] = {0}; + int staked_era; + int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = komodo_heightstamp(height); + else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + timestamp = 0; + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. + if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) + { + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + if ( Pubkeys == 0 ) + { + komodo_init(height); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + } + pthread_mutex_lock(&komodo_mutex); + n = Pubkeys[htind].numnotaries; + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); + HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) + { + if ( kp->notaryid < n ) + { + mask |= (1LL << kp->notaryid); + memcpy(pubkeys[kp->notaryid],kp->pubkey,33); + } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); + } + pthread_mutex_unlock(&komodo_mutex); + if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) + return(n); + printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); + return(-1); +} + +int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) +{ + int32_t i,n; uint8_t pubkeys[64][33]; + n = komodo_notaries(pubkeys,height,timestamp); + *numnotariesp = n; + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + numnotaries = Pubkeys[htind].numnotaries; + for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) + return(1); + else return(0); +} + +void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) +{ + static int32_t hwmheight; + int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; + if ( Pubkeys == 0 ) + Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + memset(&N,0,sizeof(N)); + if ( origheight > 0 ) + { + height = (origheight + KOMODO_ELECTION_GAP/2); + height /= KOMODO_ELECTION_GAP; + height = ((height + 1) * KOMODO_ELECTION_GAP); + htind = (height / KOMODO_ELECTION_GAP); + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); + } else htind = 0; + pthread_mutex_lock(&komodo_mutex); + for (k=0; kpubkey,pubkeys[k],33); + kp->notaryid = k; + HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); + if ( 0 && height > 10000 ) + { + for (i=0; i<33; i++) + printf("%02x",pubkeys[k][i]); + printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); + } + } + N.numnotaries = num; + for (i=htind; i hwmheight ) + hwmheight = origheight; +} + +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) +{ + // -1 if not notary, 0 if notary, 1 if special notary + struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + *notaryidp = -1; + if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) + { + printf("komodo_chosennotary ht.%d illegal\n",height); + return(-1); + } + if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) + { + modval = ((height % numnotaries) == *notaryidp); + return(modval); + } + } + if ( height >= 250000 ) + return(-1); + if ( Pubkeys == 0 ) + komodo_init(0); + htind = height / KOMODO_ELECTION_GAP; + if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) + htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + pthread_mutex_lock(&komodo_mutex); + HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); + pthread_mutex_unlock(&komodo_mutex); + if ( kp != 0 ) + { + if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) + { + *notaryidp = kp->notaryid; + modval = ((height % numnotaries) == kp->notaryid); + //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); + } else printf("unexpected zero notaries at height.%d\n",height); + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); + //int32_t i; for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); + return(modval); +} + +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); + +struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + *idx = i; + np = &sp->NPOINTS[i]; + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) + return(np); + } + } + *idx = -1; + return(0); +} + +struct notarized_checkpoint *komodo_npptr(int32_t height) +{ + int idx; + return komodo_npptr_for_height(height, &idx); +} + +struct notarized_checkpoint *komodo_npptr_at(int idx) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if (idx < sp->NUM_NPOINTS) + return &sp->NPOINTS[idx]; + return(0); +} + +int32_t komodo_prevMoMheight() +{ + static uint256 zero; + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoM != zero ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevMoMheightp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) +{ + struct notarized_checkpoint *np = 0; + if ( (np= komodo_npptr(height)) != 0 ) + { + *notarized_htp = np->notarized_height; + *MoMp = np->MoM; + *kmdtxidp = np->notarized_desttxid; + *MoMoMp = np->MoMoM; + *MoMoMoffsetp = np->MoMoMoffset; + *MoMoMdepthp = np->MoMoMdepth; + *kmdstartip = np->kmdstarti; + *kmdendip = np->kmdendi; + return(np->MoMdepth & 0xffff); + } + *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; + memset(MoMp,0,sizeof(*MoMp)); + memset(MoMoMp,0,sizeof(*MoMoMp)); + memset(kmdtxidp,0,sizeof(*kmdtxidp)); + return(0); +} + +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) +{ + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NUM_NPOINTS > 0 ) + { + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) + { + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + if ( np->nHeight < nHeight ) + { + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + } + if ( np != 0 ) + { + //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); + if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) + printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); + } + } + memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); + return(0); +} + +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); +} + +void komodo_init(int32_t height) +{ + static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + if ( 0 && height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); + memset(&zero,0,sizeof(zero)); + if ( didinit == 0 ) + { + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + if ( height >= 0 ) + { + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - if ( Pubkeys == 0 ) - { - komodo_init(height); - //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); - } - pthread_mutex_lock(&komodo_mutex); - n = Pubkeys[htind].numnotaries; - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s height.%d t.%u genesis.%d\n",ASSETCHAINS_SYMBOL,height,timestamp,n); - HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) - { - if ( kp->notaryid < n ) - { - mask |= (1LL << kp->notaryid); - memcpy(pubkeys[kp->notaryid],kp->pubkey,33); - } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n); - } - pthread_mutex_unlock(&komodo_mutex); - if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) ) - return(n); - printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); - return(-1); -} - -int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) -{ - int32_t i,n; uint8_t pubkeys[64][33]; - n = komodo_notaries(pubkeys,height,timestamp); - *numnotariesp = n; - for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - numnotaries = Pubkeys[htind].numnotaries; - for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) - return(1); - else return(0); -} - -void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) -{ - static int32_t hwmheight; - int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; - if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); - memset(&N,0,sizeof(N)); - if ( origheight > 0 ) - { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); - } else htind = 0; - pthread_mutex_lock(&komodo_mutex); - for (k=0; kpubkey,pubkeys[k],33); - kp->notaryid = k; - HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) - { - for (i=0; i<33; i++) - printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP); - } - } - N.numnotaries = num; - for (i=htind; i hwmheight ) - hwmheight = origheight; -} - -int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp) -{ - // -1 if not notary, 0 if notary, 1 if special notary - struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; - *notaryidp = -1; - if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS ) - { - printf("komodo_chosennotary ht.%d illegal\n",height); - return(-1); - } - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (*notaryidp= komodo_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 ) - { - modval = ((height % numnotaries) == *notaryidp); - return(modval); - } - } - if ( height >= 250000 ) - return(-1); - if ( Pubkeys == 0 ) - komodo_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); - pthread_mutex_unlock(&komodo_mutex); - if ( kp != 0 ) - { - if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 ) - { - *notaryidp = kp->notaryid; - modval = ((height % numnotaries) == kp->notaryid); - //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); - } else printf("unexpected zero notaries at height.%d\n",height); - } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); - //int32_t i; for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); - return(modval); -} - -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); - -struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - *idx = i; - np = &sp->NPOINTS[i]; - if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) - return(np); - } - } - *idx = -1; - return(0); -} - -struct notarized_checkpoint *komodo_npptr(int32_t height) -{ - int idx; - return komodo_npptr_for_height(height, &idx); -} - -struct notarized_checkpoint *komodo_npptr_at(int idx) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - if (idx < sp->NUM_NPOINTS) - return &sp->NPOINTS[idx]; - return(0); -} - -int32_t komodo_prevMoMheight() -{ - static uint256 zero; - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - for (i=sp->NUM_NPOINTS-1; i>=0; i--) - { - np = &sp->NPOINTS[i]; - if ( np->MoM != zero ) - return(np->notarized_height); - } - } - return(0); -} - -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - *prevMoMheightp = komodo_prevMoMheight(); - return(sp->NOTARIZED_HEIGHT); - } - else - { - *prevMoMheightp = 0; - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} - -int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NOTARIZED_HEIGHT > 0 ) - { - if ( txheight < sp->NOTARIZED_HEIGHT ) - return(numconfs); - else return(1); - } - } - return(numconfs); -} - -int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) -{ - struct notarized_checkpoint *np = 0; - if ( (np= komodo_npptr(height)) != 0 ) - { - *notarized_htp = np->notarized_height; - *MoMp = np->MoM; - *kmdtxidp = np->notarized_desttxid; - *MoMoMp = np->MoMoM; - *MoMoMoffsetp = np->MoMoMoffset; - *MoMoMdepthp = np->MoMoMdepth; - *kmdstartip = np->kmdstarti; - *kmdendip = np->kmdendi; - return(np->MoMdepth & 0xffff); - } - *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; - memset(MoMp,0,sizeof(*MoMp)); - memset(MoMoMp,0,sizeof(*MoMoMp)); - memset(kmdtxidp,0,sizeof(*kmdtxidp)); - return(0); -} - -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) -{ - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( sp->NUM_NPOINTS > 0 ) - { - flag = 0; - if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 ) - { - np = &sp->NPOINTS[sp->last_NPOINTSi-1]; - if ( np->nHeight < nHeight ) - { - for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS); - flag = 1; - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( flag == 0 ) - { - np = 0; - for (i=0; iNUM_NPOINTS; i++) - { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - { - //printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight); - break; - } - np = &sp->NPOINTS[i]; - sp->last_NPOINTSi = i; - } - } - } - if ( np != 0 ) - { - //char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height); - if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) ) - printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); - } - } - memset(notarized_hashp,0,sizeof(*notarized_hashp)); - memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); - return(0); -} - -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - -void komodo_init(int32_t height) -{ - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( 0 && height != 0 ) - printf("komodo_init ht.%d didinit.%d\n",height,didinit); - memset(&zero,0,sizeof(zero)); - if ( didinit == 0 ) - { - pthread_mutex_init(&komodo_mutex,NULL); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - if ( height >= 0 ) - { - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k Date: Sat, 3 Nov 2018 02:22:53 +0800 Subject: [PATCH 458/951] fix dupe --- src/rpcrawtransaction.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 5710e502f..f446756f2 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -492,26 +492,6 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid return(-1); } -bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) -{ - CTxDestination address; txnouttype whichType; - if ( ExtractDestination(scriptPubKey,address) != 0 ) - { - strcpy(destaddr,(char *)CBitcoinAddress(address).ToString().c_str()); - return(true); - } - fprintf(stderr,"ExtractDestination failed\n"); - return(false); -} - -bool pubkey2address(char *destaddr,uint8_t *pubkey33) -{ - std::vectorpk; int32_t i; - for (i=0; i<33; i++) - pk.push_back(pubkey33[i]); - return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); -} - UniValue gettxoutproof(const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 1 && params.size() != 2)) From e024ec35fc8f106436b813f3567ff5ee11f83ed3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 03:01:39 +0800 Subject: [PATCH 459/951] last tim --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..6d6ecf77f 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -78,6 +78,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" +#include "cc/CCutils.cpp" From cfa9c3c640a130e764ed147e03f0762b1b950e36 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 14:49:09 +0800 Subject: [PATCH 460/951] try this first --- src/Makefile.am | 4 ++-- src/komodo_notary.h | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 0559230c0..f18c192e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -246,8 +246,8 @@ obj/build.h: FORCE libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: zcashd -libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER +libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSEVER libbitcoin_server_a_SOURCES = \ sendalert.cpp \ addrman.cpp \ diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6291c8e1a..8169d6117 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -20,8 +20,6 @@ #include "notaries_staked.h" -extern int32_t pubkey2address(char *destaddr,uint8_t *pubkey33) ; - #define KOMODO_MAINNET_START 178999 extern char NOTARYADDRS[18][64]; @@ -234,9 +232,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); for (i=0; i Date: Sat, 3 Nov 2018 14:54:57 +0800 Subject: [PATCH 461/951] modified: src/komodo_notary.h --- src/komodo_notary.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8169d6117..febc7e40c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -234,7 +234,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -281,7 +281,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -302,7 +302,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -322,7 +322,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -341,7 +341,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2address((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif } From be77469369ca30003afe7f36cf4a1d85d4f84202 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 14:58:50 +0800 Subject: [PATCH 462/951] unneded include --- src/bitcoin-cli.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 6d6ecf77f..37ed26572 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,11 +76,7 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "komodo_notary.h" #include "notaries_staked.cpp" -#include "cc/CCutils.cpp" - - void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From f876160b78e9f9c3dc780ac787b37ec2bc47e4d0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:02:27 +0800 Subject: [PATCH 463/951] hhmmm --- src/bitcoin-cli.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 37ed26572..aead9fb7a 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,8 +76,11 @@ public: #include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" +#include "komodo_notary.h" #include "notaries_staked.cpp" + + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { From 55fd0444f6b4c5e6d5f702a4bf93d408134f3268 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:15:34 +0800 Subject: [PATCH 464/951] try --- src/komodo_notary.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index febc7e40c..1c90b689a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -281,6 +281,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); + fprintf(stderr, "pubkey?: %s\n", notaries_STAKED1[i][1]); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); pthread_mutex_unlock(&komodo_mutex); #endif From e126f4cecf9c4f241414af59a999c66cb4abe1ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:27:44 +0800 Subject: [PATCH 465/951] try --- src/script/standard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index fde836154..b2e98bf2c 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,6 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); + fprintf(stderr, "pubkey in exdest: %s\n",pubKey.GetHash().ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); @@ -263,7 +264,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) addressRet = CScriptID(uint160(vSolutions[0])); return true; } - + else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION) { addressRet = CKeyID(uint160(vSolutions[0])); From 302427b0791768ec54f15f9fbe758b951c84d900 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:39:31 +0800 Subject: [PATCH 466/951] try this --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index b2e98bf2c..9707b8c2e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",pubKey.GetHash().ToString().c_str()); + fprintf(stderr, "pubkey in exdest: %s\n",pubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); From 4c93a4dd7b5e7b1ca94f70dbf8cce78e3683a1c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:40:32 +0800 Subject: [PATCH 467/951] try --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 9707b8c2e..d24d278f3 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",pubKey.ToString().c_str()); + fprintf(stderr, "pubkey in exdest: %s\n",pubKey.CPubKey().ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); From ca7f0b86431378025e3f9af993fa3058be1f49dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:42:02 +0800 Subject: [PATCH 468/951] try --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d24d278f3..2c3f4afc7 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",pubKey.CPubKey().ToString().c_str()); + fprintf(stderr, "pubkey in exdest: %s\n",scriptPubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); From c52c8d2a37c299d5b1569174d53db9b90cb0e459 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 15:44:45 +0800 Subject: [PATCH 469/951] fix --- src/komodo_notary.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1c90b689a..dafcbe820 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -281,8 +281,8 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - fprintf(stderr, "pubkey?: %s\n", notaries_STAKED1[i][1]); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]); + fprintf(stderr, "pubkey?: %s\n",staked_pubkeys1[i]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif } From 4d857068593b9da3c19bb1c211f3ec34138d03dc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 16:35:51 +0800 Subject: [PATCH 470/951] is this working now? --- src/komodo_notary.h | 11 +++++------ src/script/standard.cpp | 1 - src/wallet/rpcwallet.cpp | 16 ++++++++++++++-- src/wallet/wallet.cpp | 6 ++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index dafcbe820..e02860414 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -234,7 +234,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys0[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -281,7 +281,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - fprintf(stderr, "pubkey?: %s\n",staked_pubkeys1[i]); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif @@ -303,7 +302,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -323,7 +322,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -342,7 +341,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]); pthread_mutex_unlock(&komodo_mutex); #endif } diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 2c3f4afc7..9aa02bfb7 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,6 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",scriptPubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 862df0c0f..dc0b19ecc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4959,6 +4959,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +extern int32_t IS_KOMODO_NOTARY; UniValue setpubkey(const UniValue& params, bool fHelp) { @@ -5005,9 +5006,20 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); + isminetype mine = pwalletMain; + if ( IsMine(*pwalletMain, dest) == ISMINE_NO ) { + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + } else { + result.push_back(Pair("ismine", "true")); + std::string notaryname; + if ( StakedNotaryID(notaryname, Raddress) != -1 ) { + IS_KOMODO_NOTARY = 1; + result.push_back(Pair("IsNotary", notaryname)); + } + } #endif + } else { + result.push_back(Pair("error", "pubkey entered is invalid.")); } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a73ea31fe..8a8f96d8f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,7 +1213,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" ) + if ( NOTARY_ADDRESS != "" && IS_KOMODO_NOTARY == 1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { @@ -1252,7 +1252,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } else if ( numvinIsOurs < tx.vin.size() ) { // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, - // IF there exisited a function for that. + // IF there exisited a function for that. + // Maybe check if there are any vouts unspetn in this TX + // then purge the TX from wallet if all spent? fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 2a91d7e00270bee2bccb752c13564337e1d9cd2f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 16:40:57 +0800 Subject: [PATCH 471/951] fix --- src/wallet/rpcwallet.cpp | 8 ++++---- src/wallet/wallet.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dc0b19ecc..36ebb1893 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4960,6 +4960,8 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) bool pubkey2addr(char *destaddr,uint8_t *pubkey33); extern int32_t IS_KOMODO_NOTARY; +extern uint8_t NOTARY_PUBKEY33[]; +extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; UniValue setpubkey(const UniValue& params, bool fHelp) { @@ -4989,8 +4991,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -5006,8 +5006,8 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET - isminetype mine = pwalletMain; - if ( IsMine(*pwalletMain, dest) == ISMINE_NO ) { + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + if ( mine == ISMINE_NO ) { result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8a8f96d8f..50a825cc6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,6 +1202,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; +extern int32_t IS_KOMODO_NOTARY; bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { @@ -1254,7 +1255,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, // IF there exisited a function for that. // Maybe check if there are any vouts unspetn in this TX - // then purge the TX from wallet if all spent? + // then purge the TX from wallet if all spent? fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From a673e42f9525069be6a668a672ef4ccafe1ec04b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 16:43:39 +0800 Subject: [PATCH 472/951] include --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 36ebb1893..292f4666c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -20,6 +20,7 @@ #include "primitives/transaction.h" #include "zcbenchmarks.h" #include "script/interpreter.h" +#include "notaries_staked.h" #include "utiltime.h" #include "asyncrpcoperation.h" From 102b0839f846bc76e175ce1223a028e0bf82ae4b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:09:13 +0800 Subject: [PATCH 473/951] do addresss for -pubkey? --- src/komodo_utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a9d16fd52..732b1ecdb 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1483,10 +1483,13 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { - int32_t i,notaryid; + int32_t i,notaryid; char Raddress[18]; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = address.ToString(); komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From f307fe52bf7a44bbedad2972a60072130053ef93 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:11:36 +0800 Subject: [PATCH 474/951] try --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 732b1ecdb..f248d96f5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -14,6 +14,7 @@ ******************************************************************************/ #include "komodo_defs.h" #include "cc/utils.h" +#include "cc/CCinclude.h" #ifdef _WIN32 #include From eb36c662f6a8ebb2a31454768e384a1da9e124ac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:13:37 +0800 Subject: [PATCH 475/951] define --- src/komodo_utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f248d96f5..3c366770c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1488,9 +1488,11 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; +#ifdef SERVER pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); +#endif komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From f36ad447b8fdf242546fca23ee0586a52ce176fc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:40:27 +0800 Subject: [PATCH 476/951] fix --- src/komodo_notary.h | 6 ++++++ src/komodo_utils.h | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e02860414..668378eef 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -700,6 +700,12 @@ void komodo_init(int32_t height) { pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); +#ifdef SERVER + char Raddress[18]; + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + CBitcoinAddress address(Raddress); + NOTARY_ADDRESS = address.ToString(); +#endif if ( height >= 0 ) { n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3c366770c..85d18f169 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1484,15 +1484,10 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) { - int32_t i,notaryid; char Raddress[18]; + int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; -#ifdef SERVER - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = address.ToString(); -#endif komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp); return(notaryid); } From 798999bdae40cdeb8d3e6c029f1ccae27d98158a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:43:54 +0800 Subject: [PATCH 477/951] try print --- src/komodo_notary.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 668378eef..d180f114f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -703,6 +703,7 @@ void komodo_init(int32_t height) #ifdef SERVER char Raddress[18]; pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + printf("address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); #endif From 02cc6355d9037e9a398706add5287a939e55073e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:47:51 +0800 Subject: [PATCH 478/951] try --- src/komodo_notary.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d180f114f..de255ca8f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -701,8 +701,9 @@ void komodo_init(int32_t height) pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); #ifdef SERVER - char Raddress[18]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + char Raddress[18]; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); printf("address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); From 5f5a803d5176040a1f1f7b6b7611432c95982d67 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:51:06 +0800 Subject: [PATCH 479/951] fix prit --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index de255ca8f..18b21d37e 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -704,7 +704,7 @@ void komodo_init(int32_t height) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - printf("address: %s\n",Raddress); + fprintf(stderr,"address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); #endif From 5349a582ba28ce82cc4b50a0d27aaae9fcf2ffaa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 17:59:33 +0800 Subject: [PATCH 480/951] try --- src/wallet/rpcwallet.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 292f4666c..6cfa3fed5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5031,7 +5031,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + if ( NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() == false ) { + result.push_back(Pair("address", NOTARY_ADDRESS)); + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } return result; } From 20d6d163994462a1e4e056725354370b9545a6cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:32:05 +0800 Subject: [PATCH 481/951] add -stakednotary daemon flag --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 10 +++++++++- src/komodo_utils.h | 3 ++- src/rpcmisc.cpp | 13 ++++++++++--- src/wallet/wallet.cpp | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index bf96cfa44..eb4597011 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 18b21d37e..9a866a5eb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -704,9 +704,17 @@ void komodo_init(int32_t height) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - fprintf(stderr,"address: %s\n",Raddress); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); + if ( IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.empty() != 0 ) { + std::string notaryname; + if (StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) != -1 ) { + IS_STAKED_NOTARY = 1; + IS_KOMODO_NOTARY = 0; + } else { + IS_STAKED_NOTARY = 0; + } + } #endif if ( height >= 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 85d18f169..4fb95dcca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1508,6 +1508,7 @@ void komodo_args(char *argv0) extern const char *Notaries_elected1[][2]; std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); + IS_STAKED_NOTARY = GetBoolArg("-stakednotary", false); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; @@ -1515,7 +1516,7 @@ void komodo_args(char *argv0) fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); DONATION_PUBKEY = GetArg("-donation", ""); NOTARY_PUBKEY = GetArg("-pubkey", ""); - if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) + if ( strlen(NOTARY_PUBKEY.c_str()) == 66 || IS_STAKED_NOTARY == false ) { USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a1d576d58..824758b26 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -13,6 +13,7 @@ #include "timedata.h" #include "txmempool.h" #include "util.h" +#include "notaries_staked.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #include "wallet/walletdb.h" @@ -50,11 +51,12 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); #define KOMODO_VERSION "0.2.1" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; @@ -152,13 +154,18 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); { - char pubkeystr[65]; int32_t notaryid; - if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) + char pubkeystr[65]; int32_t notaryid; std::string notaryname; + if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_STAKED_NOTARY == 0 )) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.emtpy() == false ) { + notaryid = StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("notaryname", notaryname)); + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } else if ( NOTARY_PUBKEY33[0] != 0 ) { obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 50a825cc6..f770c8e18 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" && IS_KOMODO_NOTARY == 1 ) + if ( NOTARY_ADDRESS != "" && IS_STAKED_NOTARY == 1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { From 793ebde434ac68e6da56d1a92c6a560b9a8b4c1d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:42:13 +0800 Subject: [PATCH 482/951] fix --- src/komodo_notary.h | 2 +- src/wallet/wallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9a866a5eb..c9696e34f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -708,7 +708,7 @@ void komodo_init(int32_t height) NOTARY_ADDRESS = address.ToString(); if ( IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.empty() != 0 ) { std::string notaryname; - if (StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) != -1 ) { + if (StakedNotaryID(notaryname, Raddress) != -1 ) { IS_STAKED_NOTARY = 1; IS_KOMODO_NOTARY = 0; } else { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f770c8e18..26689cfde 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1202,7 +1202,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) */ extern uint8_t NOTARY_PUBKEY33[33]; extern std::string NOTARY_ADDRESS; -extern int32_t IS_KOMODO_NOTARY; +extern int32_t IS_STAKED_NOTARY; bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { From 0b5ef8057fb728fcf801a56cf250ec6f3b391b13 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:43:31 +0800 Subject: [PATCH 483/951] fix last --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 824758b26..2e4613ac6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -66,7 +66,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; - extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" From 7eca3743c80821e8d277967cc5056e4f2e13fc00 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:50:08 +0800 Subject: [PATCH 484/951] fix --- src/rpcmisc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 2e4613ac6..083955db2 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -154,7 +154,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); { - char pubkeystr[65]; int32_t notaryid; std::string notaryname; + char pubkeystr[65]; int32_t notaryid; std::string notaryname; char *Raddress; if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_STAKED_NOTARY == 0 )) { obj.push_back(Pair("notaryid", notaryid)); @@ -162,7 +162,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.emtpy() == false ) { - notaryid = StakedNotaryID(notaryname, NOTARY_ADDRESS.c_str()) + Raddress = NOTARY_ADDRESS.c_str(); + notaryid = StakedNotaryID(notaryname, Raddress) obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); From 8df94887b3215d2898ce09cd749ab7d65b390327 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:51:31 +0800 Subject: [PATCH 485/951] fix better --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 083955db2..e656ab72a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -161,7 +161,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.emtpy() == false ) { + } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { Raddress = NOTARY_ADDRESS.c_str(); notaryid = StakedNotaryID(notaryname, Raddress) obj.push_back(Pair("notaryid", notaryid)); From ac99a6b738609de933cb9a67941d522f2f7f2b31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:52:06 +0800 Subject: [PATCH 486/951] ; --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e656ab72a..0f8669757 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -163,7 +163,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { Raddress = NOTARY_ADDRESS.c_str(); - notaryid = StakedNotaryID(notaryname, Raddress) + notaryid = StakedNotaryID(notaryname, Raddress); obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); From 59d1c8e2ae8f3943b4da4d19f5dd88f3af782978 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:53:30 +0800 Subject: [PATCH 487/951] ? --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 0f8669757..fbb183717 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -162,7 +162,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( KOMODO_LASTMINED != 0 ) obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { - Raddress = NOTARY_ADDRESS.c_str(); + Raddress = (char *)NOTARY_ADDRESS.c_str(); notaryid = StakedNotaryID(notaryname, Raddress); obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); From 2dd5abbcdf997fe970c4a2866435bac35646d36b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 18:59:59 +0800 Subject: [PATCH 488/951] try --- src/rpcmisc.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index fbb183717..f0062ebc4 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -51,7 +51,7 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); @@ -155,18 +155,17 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); { char pubkeystr[65]; int32_t notaryid; std::string notaryname; char *Raddress; - if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_STAKED_NOTARY == 0 )) - { - obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("pubkey", pubkeystr)); - if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } else if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY != 0 ) { + if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY == 1 ) { Raddress = (char *)NOTARY_ADDRESS.c_str(); notaryid = StakedNotaryID(notaryname, Raddress); obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_KOMODO_NOTARY == 1 ) ) { + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("pubkey", pubkeystr)); + if ( KOMODO_LASTMINED != 0 ) + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } else if ( NOTARY_PUBKEY33[0] != 0 ) { obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } From 482f2dcb744a8a41e098bd07f4c73509be617d3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:04:31 +0800 Subject: [PATCH 489/951] try fix --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c9696e34f..f9ad785bf 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -706,7 +706,7 @@ void komodo_init(int32_t height) pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); - if ( IS_STAKED_NOTARY != 0 && NOTARY_ADDRESS.empty() != 0 ) { + if ( IS_STAKED_NOTARY != 0 || NOTARY_ADDRESS.empty() != 0 ) { std::string notaryname; if (StakedNotaryID(notaryname, Raddress) != -1 ) { IS_STAKED_NOTARY = 1; From dd80445e563d4058185e106d695bbebab21671a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:12:36 +0800 Subject: [PATCH 490/951] fix :Wq qqq --- src/komodo_notary.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f9ad785bf..60655f41d 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -706,14 +706,12 @@ void komodo_init(int32_t height) pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); - if ( IS_STAKED_NOTARY != 0 || NOTARY_ADDRESS.empty() != 0 ) { - std::string notaryname; - if (StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_STAKED_NOTARY = 1; - IS_KOMODO_NOTARY = 0; - } else { - IS_STAKED_NOTARY = 0; - } + std::string notaryname; + if (StakedNotaryID(notaryname, Raddress) != -1 ) { + IS_STAKED_NOTARY = 1; + IS_KOMODO_NOTARY = 0; + } else { + IS_STAKED_NOTARY = 0; } #endif if ( height >= 0 ) From 00c9e899f12826e7caacf367811d4bd731baf1db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:20:54 +0800 Subject: [PATCH 491/951] try --- src/rpcmisc.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f0062ebc4..3b897e892 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -154,10 +154,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); { - char pubkeystr[65]; int32_t notaryid; std::string notaryname; char *Raddress; - if ( NOTARY_PUBKEY33[0] != 0 && IS_STAKED_NOTARY == 1 ) { - Raddress = (char *)NOTARY_ADDRESS.c_str(); - notaryid = StakedNotaryID(notaryname, Raddress); + char pubkeystr[65]; int32_t notaryid; std::string notaryname; + if ( (NOTARY_PUBKEY33[0] != 0) && (notaryid = StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); From 6b62237c9149361058c1bc7155521f5e2eb216bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:27:33 +0800 Subject: [PATCH 492/951] try --- src/wallet/rpcwallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6cfa3fed5..cdfd5633d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5005,7 +5005,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp) { CTxDestination dest = address.Get(); NOTARY_ADDRESS = address.ToString(); - result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { @@ -5014,7 +5013,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) result.push_back(Pair("ismine", "true")); std::string notaryname; if ( StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_KOMODO_NOTARY = 1; + IS_STAKED_NOTARY = 1; result.push_back(Pair("IsNotary", notaryname)); } } From 44ebe794f78aeca589340e4a1737e45f6718fb9b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:28:50 +0800 Subject: [PATCH 493/951] try --- 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 cdfd5633d..88f4ece82 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4960,7 +4960,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); -extern int32_t IS_KOMODO_NOTARY; +extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; From 72bbdaef489b2dead6fc066dd7856d526110df9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:32:54 +0800 Subject: [PATCH 494/951] add print --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9d413fd5d..c97a03dee 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,6 +156,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { + fprintf(stderr, "%s\n", NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); return(i); From 023adb99c2b5d85fee6624e3177285ccec6632a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:37:57 +0800 Subject: [PATCH 495/951] fix --- src/rpcmisc.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 3b897e892..1c044c030 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -153,20 +153,17 @@ UniValue getinfo(const UniValue& params, bool fHelp) #endif obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); - { + if ( NOTARY_PUBKEY33[0] != 0 ) { char pubkeystr[65]; int32_t notaryid; std::string notaryname; - if ( (NOTARY_PUBKEY33[0] != 0) && (notaryid = StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { + if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); - obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); - } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 && ( IS_KOMODO_NOTARY == 1 ) ) { + } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("pubkey", pubkeystr)); if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } else if ( NOTARY_PUBKEY33[0] != 0 ) { - obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); } + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); } if ( ASSETCHAINS_CC != 0 ) obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); From 4cfe878d46a0a0204e0876c0a544ea720ecea4f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:42:59 +0800 Subject: [PATCH 496/951] try --- src/notaries_staked.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c97a03dee..2d3bd9e63 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,9 +156,10 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "%s\n", NOTARYADDRS[i]); + fprintf(stderr, "%ld :: %s\n",i, NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); + fprintf(stderr, "FOUND: %ld :: %s\n",i,notaryname.c_str()); return(i); } } From 152d34f3a468159808702e4758828e263d9b5ab7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 19:47:18 +0800 Subject: [PATCH 497/951] fix --- src/notaries_staked.cpp | 2 -- src/rpcmisc.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 2d3bd9e63..9d413fd5d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,10 +156,8 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "%ld :: %s\n",i, NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - fprintf(stderr, "FOUND: %ld :: %s\n",i,notaryname.c_str()); return(i); } } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1c044c030..37e5bc901 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -155,7 +155,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); if ( NOTARY_PUBKEY33[0] != 0 ) { char pubkeystr[65]; int32_t notaryid; std::string notaryname; - if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str()) != -1 )) { + if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str())) != -1 ) { obj.push_back(Pair("notaryid", notaryid)); obj.push_back(Pair("notaryname", notaryname)); } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { From 16b97d7f2200507805e9f79c4ab3e9cbc87ce08b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 20:42:59 +0800 Subject: [PATCH 498/951] make function, so IS notaty can update on era change --- src/komodo_notary.h | 8 +------- src/notaries_staked.cpp | 20 ++++++++++++++++++-- src/notaries_staked.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 60655f41d..596ee69d1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -706,13 +706,7 @@ void komodo_init(int32_t height) pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); CBitcoinAddress address(Raddress); NOTARY_ADDRESS = address.ToString(); - std::string notaryname; - if (StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_STAKED_NOTARY = 1; - IS_KOMODO_NOTARY = 0; - } else { - IS_STAKED_NOTARY = 0; - } + updateStakedNotary(); #endif if ( height >= 0 ) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9d413fd5d..594a31d77 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,8 @@ #include extern char NOTARYADDRS[18][64]; -extern int32_t STAKED_ERA; +extern std::string NOTARY_ADDRESS; +extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = @@ -114,6 +115,19 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; +int updateStakedNotary() { + std::string notaryname; + pthread_mutex_lock(&komodo_mutex); + if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { + IS_STAKED_NOTARY = 1; + IS_KOMODO_NOTARY = 0; + } else { + IS_STAKED_NOTARY = 0; + } + pthread_mutex_unlock(&komodo_mutex); + return(0); +} + int STAKED_era(int timestamp) { int era; @@ -128,8 +142,10 @@ int STAKED_era(int timestamp) else era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - if ( era > STAKED_ERA ) + if ( era > STAKED_ERA ) { STAKED_ERA = era; + updateStakedNotary(); + } return(era); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index d3927e68f..8f0802eb3 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -25,6 +25,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); +void updateStakedNotary(); int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); From 0f6dac83806a356a18cf1fcb4cdb0c155ae19a15 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 20:47:50 +0800 Subject: [PATCH 499/951] fix --- src/notaries_staked.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 594a31d77..bd404ab33 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -6,6 +6,7 @@ extern char NOTARYADDRS[18][64]; extern std::string NOTARY_ADDRESS; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; +extern pthread_mutex_t komodo_mutex; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = @@ -115,7 +116,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -int updateStakedNotary() { +void updateStakedNotary() { std::string notaryname; pthread_mutex_lock(&komodo_mutex); if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { From 1a5c39bcfdaf094844269f108db09bdf69e462e2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 20:48:41 +0800 Subject: [PATCH 500/951] return --- src/notaries_staked.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index bd404ab33..3fec522f7 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -126,7 +126,6 @@ void updateStakedNotary() { IS_STAKED_NOTARY = 0; } pthread_mutex_unlock(&komodo_mutex); - return(0); } int STAKED_era(int timestamp) From 818f6fc43b1db3d7de54a8bd97e649424737093f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 21:15:01 +0800 Subject: [PATCH 501/951] dupe --- src/notaries_staked.cpp | 4 +-- src/wallet/rpcwallet.cpp | 70 ++-------------------------------------- 2 files changed, 5 insertions(+), 69 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3fec522f7..bf59a68b7 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,14 +118,14 @@ int is_STAKED(const char *chain_name) { void updateStakedNotary() { std::string notaryname; - pthread_mutex_lock(&komodo_mutex); + //pthread_mutex_lock(&komodo_mutex); if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { IS_STAKED_NOTARY = 1; IS_KOMODO_NOTARY = 0; } else { IS_STAKED_NOTARY = 0; } - pthread_mutex_unlock(&komodo_mutex); + //pthread_mutex_unlock(&komodo_mutex); } int STAKED_era(int timestamp) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a0d88dc48..7e2109329 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4566,7 +4566,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); if (!EnsureWalletIsAvailable(0)) return 0; - + const CKeyStore& keystore = *pwalletMain; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4729,7 +4729,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; - + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); @@ -4939,70 +4939,6 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorcs_wallet : NULL); -#else - LOCK(cs_main); -#endif - - char Raddress[18]; - uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { - decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { - result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { - CBitcoinAddress address(Raddress); - bool isValid = address.IsValid(); - if (isValid) - { - CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - result.push_back(Pair("address", currentAddress)); -#ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); -#endif - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } - } else { - result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); - } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); - return result; -} - UniValue channelsaddress(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector destpubkey; CPubKey pk,pk2; char destaddr[64]; @@ -6784,7 +6720,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR); CTxDestination address; if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; - + const CKeyStore& keystore = *pwalletMain; CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid; assert(pwalletMain != NULL); From afcd147d30af68e4ce960d2efc84cd47e9b46ee7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 3 Nov 2018 21:24:23 +0800 Subject: [PATCH 502/951] dupe modified: src/komodo_globals.h --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 4c3c08af0..2070e1240 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64]; From fd31d05ab581218c86469786db1c36716f282d8b Mon Sep 17 00:00:00 2001 From: Alrighttt <36680730+Alrighttt@users.noreply.github.com> Date: Sat, 3 Nov 2018 09:31:22 -0400 Subject: [PATCH 503/951] Update assetchains.json --- src/assetchains.json | 82 +++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 54 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index aa7c8bfb4..454852efe 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -1,84 +1,58 @@ [ { - "ac_name": "STAKEDB1", + "ac_name": "CFEK", "ac_supply": "100000", - "ac_reward" : "1000000000", - "ac_cc": "667", + "ac_reward": "10000000000000", + "ac_staked": "51", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDW1", - "ac_supply": "100000", - "ac_reward" : "1000000000", - "ac_cc": "667", + "ac_name": "CFEKED", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDPERC", - "ac_supply": "1000000", - "ac_reward" : "1000000000", - "ac_cc": "667", - "ac_perc": "10000000", - "ac_pubkey": "03bd221868abc063b54a3fceafb9898b1931ed767298a17ac0c9923500a7c60e4b", + "ac_name": "CFEKING", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDS1", - "ac_supply": "1000000", - "ac_reward" : "1000000000", - "ac_cc": "667", - "ac_staked": "10", + "ac_name": "CFEKLF", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" ] }, { - "ac_name": "STAKEDS9", - "ac_supply": "1000000", - "ac_reward" : "1000000000", - "ac_cc": "667", - "ac_staked": "90", - "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "STAKEDED", - "ac_supply": "1072452", - "ac_reward" : "1000000000", - "ac_cc": "667", - "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "STAKEDPRIV", - "ac_supply": "1000000", - "ac_reward" : "10000000000", - "ac_private": "1", - "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "STAKEDCCP", - "ac_supply": "1000000", - "ac_reward" : "10000000000", - "ac_private": "1", - "ac_cc": "667", + "ac_name": "CFEKMLT", + "ac_supply": "1000", + "ac_end": "1", + "ac_reward": "1", + "ac_staked": "1", + "ac_cc": "102", "addnode": [ "195.201.137.5", "195.201.20.230" From 565a17dc86b73fd9d84425f3672235f24947e740 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 15:53:30 +0800 Subject: [PATCH 504/951] try this please work --- src/komodo_notary.h | 8 -------- src/komodo_utils.h | 7 ++++--- src/notaries_staked.cpp | 42 ++++++++++++++++++++++++++-------------- src/notaries_staked.h | 3 ++- src/wallet/rpcwallet.cpp | 26 ++++++++++++------------- src/wallet/wallet.cpp | 2 +- 6 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 596ee69d1..e02860414 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -700,14 +700,6 @@ void komodo_init(int32_t height) { pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); -#ifdef SERVER - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - CBitcoinAddress address(Raddress); - NOTARY_ADDRESS = address.ToString(); - updateStakedNotary(); -#endif if ( height >= 0 ) { n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 36c93cedd..2a0452f1f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1508,7 +1508,7 @@ void komodo_args(char *argv0) extern const char *Notaries_elected1[][2]; std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); - IS_STAKED_NOTARY = GetBoolArg("-stakednotary", false); + IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; @@ -1516,7 +1516,7 @@ void komodo_args(char *argv0) fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); DONATION_PUBKEY = GetArg("-donation", ""); NOTARY_PUBKEY = GetArg("-pubkey", ""); - if ( strlen(NOTARY_PUBKEY.c_str()) == 66 || IS_STAKED_NOTARY == false ) + if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) { USE_EXTERNAL_PUBKEY = 1; if ( IS_KOMODO_NOTARY == 0 ) @@ -1525,11 +1525,12 @@ void komodo_args(char *argv0) if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 ) { IS_KOMODO_NOTARY = 1; + IS_STAKED_NOTARY = -1; fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } } - //KOMODO_PAX = 1; + //KOMODO_PAX = 1; } //else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name",""); if ( argv0 != 0 ) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index bf59a68b7..c10d21a8f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -1,6 +1,7 @@ #include "notaries_staked.h" #include "crosschain.h" +#include "cc/CCinclude.h" #include extern char NOTARYADDRS[18][64]; @@ -116,21 +117,21 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -void updateStakedNotary() { +int8_t updateStakedNotary() { std::string notaryname; - //pthread_mutex_lock(&komodo_mutex); - if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) { - IS_STAKED_NOTARY = 1; - IS_KOMODO_NOTARY = 0; - } else { - IS_STAKED_NOTARY = 0; - } - //pthread_mutex_unlock(&komodo_mutex); + char Raddress[18]; uint8_t pubkey33[33]; + pthread_mutex_lock(&komodo_mutex); + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + NOTARY_ADDRESS.clear(); + NOTARY_ADDRESS.assign(Raddress); + pthread_mutex_unlock(&komodo_mutex); + return(StakedNotaryID(notaryname,Raddress)); } int STAKED_era(int timestamp) { - int era; + int8_t era, didera; if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -142,9 +143,18 @@ int STAKED_era(int timestamp) else era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - if ( era > STAKED_ERA ) { - STAKED_ERA = era; - updateStakedNotary(); + if ( era > STAKED_ERA || didera == 0 ) + { + STAKED_ERA = era; + if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) + { + if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + { + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "INIT.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + } + didera++; + } } return(era); }; @@ -171,13 +181,15 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { } int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { + int found = -1; for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - return(i); + found = i; } + fprintf(stderr, "[%ld] %s\n",i,NOTARYADDRS[i]); } - return(-1); + return(found); } CrosschainAuthority Choose_auth_STAKED(int chosen_era) { diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 8f0802eb3..de502eb6d 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -3,6 +3,7 @@ #define NOTARIES_STAKED #include "crosschain.h" +#include "cc/CCinclude.h" static const int STAKED_ERA_GAP = 777; @@ -25,7 +26,7 @@ extern int num_notaries_STAKED4; int is_STAKED(const char *chain_name); int STAKED_era(int timestamp); -void updateStakedNotary(); +int8_t updateStakedNotary(); int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7e2109329..c56d60a40 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4967,7 +4967,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); -extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY; +extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; @@ -4994,7 +4994,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) #ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); #else - LOCK(cs_main); + LOCK2(cs_main); #endif char Raddress[18]; @@ -5018,18 +5018,18 @@ UniValue setpubkey(const UniValue& params, bool fHelp) result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); - std::string notaryname; - if ( StakedNotaryID(notaryname, Raddress) != -1 ) { - IS_STAKED_NOTARY = 1; - result.push_back(Pair("IsNotary", notaryname)); - } - } #endif - } else { + std::string notaryname; + if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { + result.push_back(Pair("IsNotary", notaryname)); + IS_KOMODO_NOTARY = 0; + USE_EXTERNAL_PUBKEY = 1; + } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + } + } else result.push_back(Pair("error", "pubkey entered is invalid.")); - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); @@ -5037,7 +5037,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - if ( NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() == false ) { + if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { result.push_back(Pair("address", NOTARY_ADDRESS)); result.push_back(Pair("pubkey", NOTARY_PUBKEY)); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 26689cfde..b4d61fddc 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" && IS_STAKED_NOTARY == 1 ) + if ( !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { From d986a9be49cbdf1a8a1a0e56876bb3109759d97a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:37:22 +0800 Subject: [PATCH 505/951] fix --- src/notaries_staked.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c10d21a8f..868763cc0 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -5,9 +5,10 @@ #include extern char NOTARYADDRS[18][64]; -extern std::string NOTARY_ADDRESS; +extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t komodo_mutex; +extern uint8_t NOTARY_PUBKEY33[33]; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = From c9c5655377a8466e13b76a06e91dfde50cefa480 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:39:59 +0800 Subject: [PATCH 506/951] fix --- src/notaries_staked.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 868763cc0..3fcd6c418 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,6 +118,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; +#ifdef SERVER0 int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; @@ -129,6 +130,7 @@ int8_t updateStakedNotary() { pthread_mutex_unlock(&komodo_mutex); return(StakedNotaryID(notaryname,Raddress)); } +#endif int STAKED_era(int timestamp) { From bf743f3e9397792c39866f0d23f0ba8ce782a7a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:44:05 +0800 Subject: [PATCH 507/951] try --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3fcd6c418..c0972213f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,7 +118,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -#ifdef SERVER0 +#ifdef SERVER int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; From 5c3d966b17a13a60a5104b44dab2347455317248 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:45:51 +0800 Subject: [PATCH 508/951] try --- src/notaries_staked.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c0972213f..06ec4abfe 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -130,6 +130,10 @@ int8_t updateStakedNotary() { pthread_mutex_unlock(&komodo_mutex); return(StakedNotaryID(notaryname,Raddress)); } +#else +int8_t updateStakedNotary() { + return(-1) +} #endif int STAKED_era(int timestamp) From 93c2aac037e2685d5b19550a8b1a58f81b8f1a80 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:46:41 +0800 Subject: [PATCH 509/951] ; --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 06ec4abfe..4b50c01b4 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -132,7 +132,7 @@ int8_t updateStakedNotary() { } #else int8_t updateStakedNotary() { - return(-1) + return(-1); } #endif From e32a1ae447fa3f930afe3e04396cf757a5faefee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 16:54:31 +0800 Subject: [PATCH 510/951] prints fix --- src/notaries_staked.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 4b50c01b4..d44dad31d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -138,7 +138,8 @@ int8_t updateStakedNotary() { int STAKED_era(int timestamp) { - int8_t era, didera; + int8_t era = 0; + static int didera; if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -158,7 +159,7 @@ int STAKED_era(int timestamp) if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "INIT.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); } didera++; } @@ -188,15 +189,13 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { } int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { - int found = -1; for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - found = i; + return(i); } - fprintf(stderr, "[%ld] %s\n",i,NOTARYADDRS[i]); } - return(found); + return(-1); } CrosschainAuthority Choose_auth_STAKED(int chosen_era) { From 629d69debe6e514d2b0bd34bd0436c0a781b25c7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:02:08 +0800 Subject: [PATCH 511/951] print --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d44dad31d..07f7b3dee 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -125,6 +125,7 @@ int8_t updateStakedNotary() { pthread_mutex_lock(&komodo_mutex); decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + fprintf(stderr, "Raddress: %s\n",Raddress); NOTARY_ADDRESS.clear(); NOTARY_ADDRESS.assign(Raddress); pthread_mutex_unlock(&komodo_mutex); From e712367feae426ff6ef232d3be10c294cd8700e6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:08:51 +0800 Subject: [PATCH 512/951] i --- src/notaries_staked.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 07f7b3dee..d1640403b 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -125,7 +125,6 @@ int8_t updateStakedNotary() { pthread_mutex_lock(&komodo_mutex); decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - fprintf(stderr, "Raddress: %s\n",Raddress); NOTARY_ADDRESS.clear(); NOTARY_ADDRESS.assign(Raddress); pthread_mutex_unlock(&komodo_mutex); @@ -152,11 +151,15 @@ int STAKED_era(int timestamp) else era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. + + fprintf(stderr, "era.%d stakedEra.%s didea.%d\n",era,STAKED_ER,didera); if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; + fprintf(stderr, "NUMBER 2 era.%d stakedEra.%s\n",era,STAKED_ERA); if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { + fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; @@ -193,6 +196,7 @@ int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *R for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); + printf("notary number: %ld\n",i ); return(i); } } From 955510333cfb5fa76d162f40437fa34585e65c32 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:16:18 +0800 Subject: [PATCH 513/951] fix --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d1640403b..c22168aaf 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -152,11 +152,11 @@ int STAKED_era(int timestamp) era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - fprintf(stderr, "era.%d stakedEra.%s didea.%d\n",era,STAKED_ER,didera); + fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera); if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - fprintf(stderr, "NUMBER 2 era.%d stakedEra.%s\n",era,STAKED_ERA); + fprintf(stderr, "NUMBER 2 era.%d stakedEra.%d\n",era,STAKED_ERA); if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); From ec87ec9af5b7cb61d786ee77bac354adeb8a5247 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:19:50 +0800 Subject: [PATCH 514/951] fix --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c22168aaf..82323513d 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -152,7 +152,7 @@ int STAKED_era(int timestamp) era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera); + //fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera); if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; @@ -160,7 +160,7 @@ int STAKED_era(int timestamp) if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); - if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + if ( ( IS_STAKED_NOTARY= updateStakedNotary() > -1 ) ) { IS_KOMODO_NOTARY = 0; fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); From e30bbc5dd7de8632b86582c478dc70dbbca99ac2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:25:23 +0800 Subject: [PATCH 515/951] try this --- src/notaries_staked.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 82323513d..7bb1ee003 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,11 +156,10 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - fprintf(stderr, "NUMBER 2 era.%d stakedEra.%d\n",era,STAKED_ERA); if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { - fprintf(stderr, "PUBKEY AND ARRDESS ARRAY SET!\n"); - if ( ( IS_STAKED_NOTARY= updateStakedNotary() > -1 ) ) + IS_STAKED_NOTARY= updateStakedNotary(); + if ( IS_STAKED_NOTARY > -1 ) { IS_KOMODO_NOTARY = 0; fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); @@ -194,6 +193,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { + fprintf(stderr, "Raddress: %s Array address: %s\n",Raddress,NOTARYADDRS[13]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); printf("notary number: %ld\n",i ); From 366554f203ca14accce8ceac5156c4d1700b9f9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:26:24 +0800 Subject: [PATCH 516/951] try --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 7bb1ee003..be1505d54 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -159,6 +159,7 @@ int STAKED_era(int timestamp) if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) { IS_STAKED_NOTARY= updateStakedNotary(); + fprintf(stderr, "notary number: %d\n", IS_STAKED_NOTARY); if ( IS_STAKED_NOTARY > -1 ) { IS_KOMODO_NOTARY = 0; From 82628b5640050276e49b11ce8d921229a4edb071 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:37:56 +0800 Subject: [PATCH 517/951] aok --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index be1505d54..f551f6d51 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -156,7 +156,7 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 ) + if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 ) { IS_STAKED_NOTARY= updateStakedNotary(); fprintf(stderr, "notary number: %d\n", IS_STAKED_NOTARY); From c9ba061ecb3415e2b64e95ec2c2d49b571e602f8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 17:41:58 +0800 Subject: [PATCH 518/951] workdin? --- src/notaries_staked.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index f551f6d51..7e690fab3 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -158,9 +158,7 @@ int STAKED_era(int timestamp) STAKED_ERA = era; if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 ) { - IS_STAKED_NOTARY= updateStakedNotary(); - fprintf(stderr, "notary number: %d\n", IS_STAKED_NOTARY); - if ( IS_STAKED_NOTARY > -1 ) + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); @@ -194,10 +192,9 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "Raddress: %s Array address: %s\n",Raddress,NOTARYADDRS[13]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); - printf("notary number: %ld\n",i ); + //printf("notary number: %ld\n",i ); return(i); } } From d6dfe034855bb552c07e52346014c33c5a9a5b68 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:18:34 +0800 Subject: [PATCH 519/951] here we go :D --- src/komodo_notary.h | 74 ++++++++------------------------------ src/komodo_utils.h | 13 ++++--- src/notaries_staked.cpp | 78 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 94 insertions(+), 71 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e02860414..88ce299f7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -22,11 +22,6 @@ #define KOMODO_MAINNET_START 178999 -extern char NOTARYADDRS[18][64]; - -//extern const char *notaries_STAKED[][2]; -//extern const int num_notaries_STAKED; - const char *Notaries_genesis[][2] = { { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, @@ -206,8 +201,6 @@ const char *Notaries_elected1[][2] = }; #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); - int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; @@ -220,6 +213,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam timestamp = komodo_heightstamp(height); else if ( ASSETCHAINS_SYMBOL[0] == 0 ) timestamp = 0; + // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) { @@ -232,11 +226,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); for (i=0; i STAKED_ERA || didera == 0 ) { + pthread_mutex_lock(&komodo_mutex); STAKED_ERA = era; - if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 ) + if ( NOTARY_PUBKEY33[0] != 0 ) { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); + fprintf(stderr, "Staked Notary Protection Active! INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); } didera++; } + pthread_mutex_unlock(&komodo_mutex); } return(era); }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; + static char ChainName[65]; + + if ( ChainName[0] == 0 ) { + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + strcpy(ChainName,"KMD"); + else + strcpy(ChainName,ASSETCHAINS_SYMBOL); + } + if ( STAKED_ERA != 0 ) { switch (STAKED_ERA) { case 1: + if ( didstaked1 == 0 ) { + for (i=0; i Date: Sun, 4 Nov 2018 20:38:06 +0800 Subject: [PATCH 520/951] i --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index b758a74a8..c327f11e4 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -169,7 +169,7 @@ int STAKED_era(int timestamp) }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - int8_t notaryID = -1; + int8_t notaryID = -1; int i; static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static char ChainName[65]; From 87542679855527ad6957b9f494f167d02a9fc0a3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:45:23 +0800 Subject: [PATCH 521/951] disable mutex --- src/notaries_staked.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c327f11e4..0951e130a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -152,7 +152,7 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { - pthread_mutex_lock(&komodo_mutex); + //pthread_mutex_lock(&komodo_mutex); STAKED_ERA = era; if ( NOTARY_PUBKEY33[0] != 0 ) { @@ -163,7 +163,7 @@ int STAKED_era(int timestamp) } didera++; } - pthread_mutex_unlock(&komodo_mutex); + //pthread_mutex_unlock(&komodo_mutex); } return(era); }; From 26a2155af5964d7a13046b7483e35f69b383bcc7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:50:50 +0800 Subject: [PATCH 522/951] fix --- src/notaries_staked.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 0951e130a..41e707f7f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[18][64]; +extern char NOTARYADDRS[18][64],ASSETCHAINS_SYMBOL; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t komodo_mutex; @@ -152,7 +152,6 @@ int STAKED_era(int timestamp) if ( era > STAKED_ERA || didera == 0 ) { - //pthread_mutex_lock(&komodo_mutex); STAKED_ERA = era; if ( NOTARY_PUBKEY33[0] != 0 ) { @@ -163,7 +162,6 @@ int STAKED_era(int timestamp) } didera++; } - //pthread_mutex_unlock(&komodo_mutex); } return(era); }; @@ -175,7 +173,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { static char ChainName[65]; if ( ChainName[0] == 0 ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) strcpy(ChainName,"KMD"); else strcpy(ChainName,ASSETCHAINS_SYMBOL); From d41373edec9e6dad7ab288aa026748348ede585a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 4 Nov 2018 20:52:03 +0800 Subject: [PATCH 523/951] again --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 41e707f7f..1f6cb71c7 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[18][64],ASSETCHAINS_SYMBOL; +extern char NOTARYADDRS[18][64]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t komodo_mutex; From f07284c6820b2fdad11109d8dd50fb4cee85e4f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 14:28:43 +0800 Subject: [PATCH 524/951] Move 99% of staked notary code to its own file --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 87 ++++++++-------------------- src/komodo_utils.h | 4 +- src/notaries_staked.cpp | 124 +++++++++++++++++++++++++--------------- src/notaries_staked.h | 1 + src/wallet/wallet.cpp | 14 +++-- 6 files changed, 115 insertions(+), 117 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 2070e1240..50952af69 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -30,7 +30,7 @@ int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); -pthread_mutex_t komodo_mutex; +pthread_mutex_t komodo_mutex,staked_mutex; #define KOMODO_ELECTION_GAP 2000 //((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100) #define KOMODO_ASSETCHAIN_MAXLEN 65 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 88ce299f7..48eeb6cba 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -204,15 +204,17 @@ const char *Notaries_elected1[][2] = int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; static int32_t ns1,ns2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; static int32_t ns3,ns4; - static uint8_t null_pubkeys[64][33] = {0}; - int staked_era; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( timestamp == 0 ) timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { + // Here we run the staked notaries function to populate the Notary Address's global var on KMD. + if ( IS_STAKED_NOTARY != -1 ) { + uint8_t tmp_pubkeys[64][33]; + numStakedNotaries(tmp_pubkeys,is_STAKED(timestamp)); + } timestamp = 0; + } // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) @@ -253,67 +255,26 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } else { // here we can activate our pubkeys for STAKED chains by era. - if (timestamp != 0) - { - staked_era = STAKED_era(timestamp); - if (staked_era == 1) + if (timestamp != 0) { - if (didstaked1 == 0) + int staked_era; int32_t numSN; + uint8_t staked_pubkeys[64][33]; uint8_t null_pubkeys[64][33] = {0}; + staked_era = STAKED_era(timestamp); + + if (staked_era != 0) { - ns1 = num_notaries_STAKED1; - for (i=0; i STAKED_ERA || didera == 0 ) { STAKED_ERA = era; - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( NOTARYADDRS[0][0] != 0 ) { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + if ( NOTARY_PUBKEY33[0] != 0 ) { - IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera); + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + { + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + } } didera++; } @@ -167,89 +170,120 @@ int STAKED_era(int timestamp) }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - int8_t notaryID = -1; int i; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; - static char ChainName[65]; + int8_t notaryID = -1; + if ( STAKED_ERA != 0 ) { + switch (STAKED_ERA) { + case 1: + notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname); + break; + case 2: + notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname); + break; + case 3: + notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname); + break; + case 4: + notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname); + break; + } + } + return(notaryID); +} - if ( ChainName[0] == 0 ) { +int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { + int i; int8_t retval = 0; + static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; + static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; + static char ChainName[65]; + + if ( ChainName[0] == 0 ) + { + pthread_mutex_init(&staked_mutex,NULL); if ( ASSETCHAINS_SYMBOL[0] == 0 ) strcpy(ChainName,"KMD"); else strcpy(ChainName,ASSETCHAINS_SYMBOL); } - if ( STAKED_ERA != 0 ) { - switch (STAKED_ERA) { + if ( era != 0 ) { + switch (era) { case 1: - if ( didstaked1 == 0 ) { - for (i=0; i Date: Mon, 5 Nov 2018 14:30:36 +0800 Subject: [PATCH 525/951] fix --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 48eeb6cba..9b14060a6 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -211,7 +211,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam // Here we run the staked notaries function to populate the Notary Address's global var on KMD. if ( IS_STAKED_NOTARY != -1 ) { uint8_t tmp_pubkeys[64][33]; - numStakedNotaries(tmp_pubkeys,is_STAKED(timestamp)); + numStakedNotaries(tmp_pubkeys,STAKED_era(timestamp)); } timestamp = 0; } From 64c4af2756bd2e55d22973c8ad643a1bc5cdc628 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 14:51:05 +0800 Subject: [PATCH 526/951] fix --- 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 c56d60a40..bcd490915 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5011,14 +5011,14 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - NOTARY_ADDRESS = address.ToString(); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { - result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); #endif + NOTARY_ADDRESS = address.ToString(); std::string notaryname; if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { result.push_back(Pair("IsNotary", notaryname)); From 068c48214d1b5c33cccc7961587f826700a9f2de Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 15:36:47 +0800 Subject: [PATCH 527/951] remove unneeded things --- src/bitcoin-cli.cpp | 1 - src/rpcserver.h | 3 --- src/wallet/rpcwallet.cpp | 6 ------ src/wallet/wallet.cpp | 12 +++++++----- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aead9fb7a..d7c906669 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -73,7 +73,6 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -#include "cc/utils.h" #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" diff --git a/src/rpcserver.h b/src/rpcserver.h index 372d84392..81ca8a8b9 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -287,9 +287,6 @@ extern UniValue FSMlist(const UniValue& params, bool fHelp); extern UniValue FSMinfo(const UniValue& params, bool fHelp); extern UniValue auctionaddress(const UniValue& params, bool fHelp); -extern bool pubkey2address(char *destaddr,uint8_t *pubkey33); -extern bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); - extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp //extern UniValue getnewaddress64(const UniValue& params, bool fHelp); // in rpcwallet.cpp extern UniValue getaccountaddress(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bcd490915..fe21544dc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4991,11 +4991,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); -#ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK2(cs_main); -#endif char Raddress[18]; uint8_t pubkey33[33]; @@ -5011,13 +5007,11 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); -#ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); -#endif NOTARY_ADDRESS = address.ToString(); std::string notaryname; if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f21c23810..a340ecfae 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1230,7 +1230,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } // Now we know if it was a tx sent to us, that wasnt from ourself. - fprintf(stderr, "We sent from address: %s vouts: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + if ( numvinIsOurs != 0 ) + fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); // Count vouts, check if OUR notary address is the receiver. if ( numvinIsOurs == 0 ) { for (size_t i = 0; i < tx.vout.size() ; i++) { @@ -1244,8 +1245,10 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } } // If no vouts are to the notary address we will ignore them. - if ( numvoutIsOurs == 0 ) + if ( numvoutIsOurs == 0 ) { + fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); return false; + } fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; @@ -1254,10 +1257,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); return false; } - } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, ideally we would remove the utxo we spent from our wallet, but you cant do that. - // this will be removed later... RPC call PurgeWalletSpents will be created instead. + // this means we were in a multi sig, ideally we would remove the utxo we spent from our wallet, but you cant do that, unless all the tx's vouts are also spent. + // RPC call PurgeWalletSpents will be created to clean all fully spent tx's instead. fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 623ec7787750409ed5dfd7bc01ea4d0f32f321cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:06:53 +0800 Subject: [PATCH 528/951] more --- src/komodo_utils.h | 2 -- src/main.cpp | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 07296466b..546fa8a13 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,8 +13,6 @@ * * ******************************************************************************/ #include "komodo_defs.h" -#include "cc/utils.h" -#include "cc/CCinclude.h" #ifdef _WIN32 #include diff --git a/src/main.cpp b/src/main.cpp index e272adff8..c5d2db923 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1062,9 +1062,12 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only } didinit = 1; } */ - for (int32_t i=0; i<=64; i++) - if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) - return(1); + if ( NOTARYADDRS[0][0] != 0 ) + { + for (int32_t i=0; i<=64; i++) + if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) + return(1); + } return(0); } @@ -1218,7 +1221,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio } } } - + // Ensure input values do not exceed MAX_MONEY // We have not resolved the txin values at this stage, // but we do know what the joinsplits claim to add From f0b07a30a7c7346dda0e5a805ca203211885ced3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:16:49 +0800 Subject: [PATCH 529/951] fix notaryaddrs var ? --- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- src/notaries_staked.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 50952af69..783a3bafc 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -49,7 +49,7 @@ int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JU std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][18]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; diff --git a/src/main.cpp b/src/main.cpp index c5d2db923..53067481e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } -extern char NOTARYADDRS[18][64]; +extern char NOTARYADDRS[64][18]; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 6d98b480c..23b1eaa9c 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[18][64]; +extern char NOTARYADDRS[64][18]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; @@ -283,6 +283,11 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { break; } } + else + { + // era is zero so we need to null ut the notary address's + //NOTARYADDRS[64][18] + } return(retval); } From 2c795c0f1c540c6cf22fdcb4866de7deba93ad74 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:30:08 +0800 Subject: [PATCH 530/951] fix --- src/komodo_globals.h | 2 +- src/main.cpp | 2 +- src/notaries_staked.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 783a3bafc..b91a6666e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -49,7 +49,7 @@ int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JU std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; -char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][18]; +char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; diff --git a/src/main.cpp b/src/main.cpp index 53067481e..ea4bc1234 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,7 +1044,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } -extern char NOTARYADDRS[64][18]; +extern char NOTARYADDRS[64][36]; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 23b1eaa9c..790fe5ece 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -4,7 +4,7 @@ #include "cc/CCinclude.h" #include -extern char NOTARYADDRS[64][18]; +extern char NOTARYADDRS[64][36]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; @@ -216,6 +216,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&staked_mutex); + fprintf(stderr, "copied address [%d]: %s\n",i,NOTARYADDRS[i]); #endif } didstaked1 = 1; @@ -224,6 +225,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { didstaked4 = 0; printf("%s is a STAKED chain in era 1 \n",ChainName); } + memcpy(pubkeys,staked_pubkeys1,num_notaries_STAKED1 * 33); retval = num_notaries_STAKED1; break; From 1c497de1facad745c5d3bd8807a3b9931b6262c2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 16:34:55 +0800 Subject: [PATCH 531/951] test --- src/notaries_staked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 790fe5ece..e6ae00961 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -219,6 +219,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { fprintf(stderr, "copied address [%d]: %s\n",i,NOTARYADDRS[i]); #endif } + fprintf(stderr, "size of notaryaddrs array: %ld\n",sizeof(NOTARYADDRS)); didstaked1 = 1; didstaked2 = 0; didstaked3 = 0; From 8d687f0312495a94d66c55cab13fd782d688015c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:11:32 +0800 Subject: [PATCH 532/951] add num notaris golbal, and reset notaries on era 0 --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 4 ++-- src/main.cpp | 48 +++++++++++++++++++++++++---------------- src/notaries_staked.cpp | 15 ++++++++----- src/notaries_staked.h | 2 +- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b91a6666e..05af4edd8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9b14060a6..d032475bb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -258,7 +258,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam if (timestamp != 0) { int staked_era; int32_t numSN; - uint8_t staked_pubkeys[64][33]; uint8_t null_pubkeys[64][33] = {0}; + uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); if (staked_era != 0) @@ -271,7 +271,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - memcpy(pubkeys,null_pubkeys,64 * 33); + memset(pubkeys,0,sizeof(pubkeys)); return(64); } } diff --git a/src/main.cpp b/src/main.cpp index ea4bc1234..386eb122e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1044,29 +1044,39 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, return true; } } + extern char NOTARYADDRS[64][36]; +extern uint8_t NUM_NOTARIES; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - /*static int32_t didinit; - int32_t i; - if ( didinit == 0 ) - { - uint8_t pubkey33[33]; - for (i=0; i<=17; i++) - { - if ( i < 17 ) - decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - didinit = 1; - } */ - if ( NOTARYADDRS[0][0] != 0 ) - { - for (int32_t i=0; i<=64; i++) - if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) - return(1); + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { + for (int32_t i=0; i<=NUM_NOTARIES; i++) + if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) + return(1); + } + } + else + { + static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + int32_t i; + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + { + if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) + decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; + } + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return(1); } return(0); } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e6ae00961..baf090bbf 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -8,7 +8,7 @@ extern char NOTARYADDRS[64][36]; extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY; extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; -extern uint8_t NOTARY_PUBKEY33[33]; +extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = @@ -215,11 +215,10 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); + NUM_NOTARIES = num_notaries_STAKED1; pthread_mutex_unlock(&staked_mutex); - fprintf(stderr, "copied address [%d]: %s\n",i,NOTARYADDRS[i]); #endif } - fprintf(stderr, "size of notaryaddrs array: %ld\n",sizeof(NOTARYADDRS)); didstaked1 = 1; didstaked2 = 0; didstaked3 = 0; @@ -238,6 +237,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]); + NUM_NOTARIES = num_notaries_STAKED2; pthread_mutex_unlock(&staked_mutex); #endif } @@ -257,6 +257,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]); + NUM_NOTARIES = num_notaries_STAKED3; pthread_mutex_unlock(&staked_mutex); #endif } @@ -275,6 +276,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #ifdef SERVER pthread_mutex_lock(&staked_mutex); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]); + NUM_NOTARIES = num_notaries_STAKED4; pthread_mutex_unlock(&staked_mutex); #endif } @@ -288,8 +290,11 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { } else { - // era is zero so we need to null ut the notary address's - //NOTARYADDRS[64][18] + // era is zero so we need to null out the notary address's + pthread_mutex_lock(&staked_mutex); + memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); + NUM_NOTARIES = 0; + pthread_mutex_unlock(&staked_mutex); } return(retval); } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 6aedbdbe1..9944c8465 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -8,7 +8,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541409634; static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; From 51442c510db7555335576d94825ae8aec3384c69 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:14:49 +0800 Subject: [PATCH 533/951] fix test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d032475bb..39263f579 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -271,7 +271,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - memset(pubkeys,0,sizeof(pubkeys)); + memset(pubkeys,0,64 * 33); return(64); } } From fec7d5f7fc927486f4b02be9d3b3952ecc6b319e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:23:02 +0800 Subject: [PATCH 534/951] test.. changed wrong era --- src/notaries_staked.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9944c8465..9a8fc2a50 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,8 +7,8 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541409634; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604233000; static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; From a22a25ed89b281a3c080be524b75412e3a8b54f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:34:24 +0800 Subject: [PATCH 535/951] try --- src/notaries_staked.cpp | 1 + src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index baf090bbf..ac983d1ac 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -302,6 +302,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { + fprintf(stderr, "address [%d]: %s\n",i,NOTARYADDRS[i]); notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); return(i); diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9a8fc2a50..06d1c53f2 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -8,7 +8,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604233000; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541411534; static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; From ae338198b4a94d8fab00d9fd916ba426e0b7f214 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:35:44 +0800 Subject: [PATCH 536/951] fix --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ac983d1ac..3ccf4c5b9 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -302,7 +302,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - fprintf(stderr, "address [%d]: %s\n",i,NOTARYADDRS[i]); + fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); return(i); From becfd7b0c7fbad44f6a091acd9a18512ce21108b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:42:10 +0800 Subject: [PATCH 537/951] fix print --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3ccf4c5b9..7c39f3f62 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -301,8 +301,8 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { + fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); return(i); From 0f712b6074686e95a6e494ea3d370049d03dfb16 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:44:23 +0800 Subject: [PATCH 538/951] tests era 3 --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 06d1c53f2..82988c1fc 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -9,7 +9,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; static const int STAKED_NOTARIES_TIMESTAMP2 = 1541411534; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541412000; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 102e221887478c1ea1cbbefd632342530c76a0e0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 17:58:23 +0800 Subject: [PATCH 539/951] test eras again --- src/komodo_notary.h | 17 +++-------------- src/notaries_staked.cpp | 5 ++++- src/notaries_staked.h | 6 +++--- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 39263f579..4e40dc6e7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -260,20 +260,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int staked_era; int32_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); - - if (staked_era != 0) - { - numSN = numStakedNotaries(staked_pubkeys,staked_era); - memcpy(pubkeys,staked_pubkeys,numSN * 33); - return(numSN); - } - else - { - // this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell. - printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); - memset(pubkeys,0,64 * 33); - return(64); - } + numSN = numStakedNotaries(staked_pubkeys,staked_era); + memcpy(pubkeys,staked_pubkeys,numSN * 33); + return(numSN); } } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 7c39f3f62..257076999 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -290,11 +290,14 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { } else { - // era is zero so we need to null out the notary address's + // era is zero so we need to null out the notary address's and pubkeys. pthread_mutex_lock(&staked_mutex); memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); NUM_NOTARIES = 0; + memset(pubkeys,0,64 * 33); pthread_mutex_unlock(&staked_mutex); + printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL); + return(64); } return(retval); } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 82988c1fc..e7ee0a395 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541410234; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541411534; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541412000; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541412157; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541413657; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 8aee84c5b3e0048ec9eb60ffcf7f312668692568 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:23:59 +0800 Subject: [PATCH 540/951] fix --- src/komodo.h | 1 - src/notaries_staked.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d2d0231f3..e406e565a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 257076999..31e88e414 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -208,7 +208,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { if ( era != 0 ) { switch (era) { case 1: - if ( didstaked1 == 0 ) + if ( didstaked1 == 0 || NOTARYADDRS[0][0] == 0 ) { for (i=0; i Date: Mon, 5 Nov 2018 18:27:08 +0800 Subject: [PATCH 541/951] too slow --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index e7ee0a395..cbd746bf3 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -9,7 +9,7 @@ static const int STAKED_ERA_GAP = 777; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541412157; static const int STAKED_NOTARIES_TIMESTAMP2 = 1541413657; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541414977; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 21aa805a693d1e37b8190ce4dafc996c7d7712f1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:29:45 +0800 Subject: [PATCH 542/951] fix --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index cbd746bf3..97cf8f7b1 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541412157; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541413657; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541414977; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541413921; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541414898; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541415875; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From d5593b354c3909e4012144292f89775c00ef0252 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:48:10 +0800 Subject: [PATCH 543/951] try this --- src/notaries_staked.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 31e88e414..18b8f8801 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -146,8 +146,9 @@ int STAKED_era(int timestamp) era = 3; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; - else - era = 0; + else { + era = 0; didera = 0; + } // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. if ( era > STAKED_ERA || didera == 0 ) From 76eb9a496eb866bb471d19002a5e7a0c37788b1f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 18:50:25 +0800 Subject: [PATCH 544/951] new eras test --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 97cf8f7b1..9c2b5d811 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541413921; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541414898; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541415875; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541415367; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541416544; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541417721; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 96c7f474b9f987ec3d9f20977b32cef35b7b2d38 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 19:48:36 +0800 Subject: [PATCH 545/951] try print --- src/komodo.h | 1 + src/komodo_notary.h | 2 +- src/notaries_staked.cpp | 33 +++++++++++++++++---------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e406e565a..2cf18d24e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,6 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { + printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4e40dc6e7..f9534ac18 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam } } else - { // here we can activate our pubkeys for STAKED chains by era. + { // here we can activate our pubkeys for STAKED chains everythig is in notaries_staked.cpp if (timestamp != 0) { int staked_era; int32_t numSN; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 18b8f8801..1bcc6ce93 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -118,22 +118,6 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -#ifdef SERVER -int8_t updateStakedNotary() { - std::string notaryname; - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - NOTARY_ADDRESS.clear(); - NOTARY_ADDRESS.assign(Raddress); - return(StakedNotaryID(notaryname,Raddress)); -} -#else -int8_t updateStakedNotary() { - return(-1); -} -#endif - int STAKED_era(int timestamp) { int8_t era = 0; @@ -170,6 +154,23 @@ int STAKED_era(int timestamp) return(era); }; +#ifdef SERVER +int8_t updateStakedNotary() { + if ( NOTARY_ADDRESS.empty() ) { + std::string notaryname; + char Raddress[18]; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + NOTARY_ADDRESS.assign(Raddress); + } + return(StakedNotaryID(notaryname,Raddress)); +} +#else +int8_t updateStakedNotary() { + return(-1); +} +#endif + int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t notaryID = -1; if ( STAKED_ERA != 0 ) { From dfe8e4a6cdae8d99b64b90b3fb72939356d2c0b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 20:44:37 +0800 Subject: [PATCH 546/951] test --- src/komodo.h | 2 +- src/komodo_notary.h | 1 + src/notaries_staked.cpp | 6 ++++++ src/notaries_staked.h | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2cf18d24e..bc691eb81 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),pindex->nTime,ASSETCHAINS_SYMBOL); + printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f9534ac18..ff7bc5cc3 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -205,6 +205,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; + if ( timestamp == 0 ) timestamp = komodo_heightstamp(height); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 1bcc6ce93..3343ef716 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -121,7 +121,12 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int8_t era = 0; + static uint32_t lasttimestamp; static int didera; + // test this, seems to sometimes get called into the past? + if ( timestamp < lasttimestamp ) + timestamp = lasttimestamp; + if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -151,6 +156,7 @@ int STAKED_era(int timestamp) didera++; } } + lasttimestamp = timestamp; return(era); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9c2b5d811..a4e381a45 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541415367; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541416544; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541417721; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541422105; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541423282; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541424459; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 1102a73bf817190c95ccc3f526c270cee43e20b4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 20:48:08 +0800 Subject: [PATCH 547/951] cant do that --- src/notaries_staked.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 3343ef716..a3d37690e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -162,13 +162,12 @@ int STAKED_era(int timestamp) #ifdef SERVER int8_t updateStakedNotary() { - if ( NOTARY_ADDRESS.empty() ) { - std::string notaryname; - char Raddress[18]; uint8_t pubkey33[33]; - decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); - pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - NOTARY_ADDRESS.assign(Raddress); - } + std::string notaryname; + char Raddress[18]; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str()); + pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); + NOTARY_ADDRESS.clear(); + NOTARY_ADDRESS.assign(Raddress); return(StakedNotaryID(notaryname,Raddress)); } #else From f4f9c03cb4c957808cc77ebe7b25f8b7cb8e2378 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 20:51:20 +0800 Subject: [PATCH 548/951] fix? --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index bc691eb81..c30e41af5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -832,7 +832,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP %s getblocktime: %d pindex->nTime : %d\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); + printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); From 73a83354dcaf5ac7b0f7580cd2b01161377201a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 21:32:37 +0800 Subject: [PATCH 549/951] fast --- src/komodo.h | 4 ++-- src/notaries_staked.cpp | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c30e41af5..ba69a2761 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -831,8 +831,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; iGetBlockTime()) == 0)) { - printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); + if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era((uint32_t)pindex->nTime) == 0)) { + //printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); continue; } txhash = block.vtx[i].GetHash(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index a3d37690e..cc3869835 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -227,9 +227,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #endif } didstaked1 = 1; - didstaked2 = 0; - didstaked3 = 0; - didstaked4 = 0; printf("%s is a STAKED chain in era 1 \n",ChainName); } @@ -249,8 +246,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #endif } didstaked2 = 1; - didstaked3 = 0; - didstaked4 = 0; printf("%s is a STAKED chain in era 2 \n",ChainName); } memcpy(pubkeys,staked_pubkeys2,num_notaries_STAKED2 * 33); @@ -269,7 +264,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { #endif } didstaked3 = 1; - didstaked4 = 0; printf("%s is a STAKED chain in era 3 \n",ChainName); } memcpy(pubkeys,staked_pubkeys3,num_notaries_STAKED3 * 33); From 6556f635f0bda6b35fe2380cad61f00a9fdddfea Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 23:35:28 +0800 Subject: [PATCH 550/951] Add maximum priority for notarisations. --- src/komodo_globals.h | 2 +- src/miner.cpp | 24 ++++++++++++++++++++++-- src/notaries_staked.cpp | 2 +- src/wallet/wallet.cpp | 4 ++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 05af4edd8..9dfcf0546 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; -int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; +int32_t KOMODO_INSYNC,KOMODO_LASTMINED,KOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; diff --git a/src/miner.cpp b/src/miner.cpp index 6c25a5007..5aef46148 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -108,11 +108,11 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); -extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],NUM_NOTARIES; uint32_t Mining_start,Mining_height; int32_t My_notaryid = -1; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); @@ -206,12 +206,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) double dPriority = 0; CAmount nTotalIn = 0; bool fMissingInputs = false; + bool fNotarisation = false; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { + int numNotaryVins = 0; BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -250,8 +252,23 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) int nConf = nHeight - coins->nHeight; + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if (GetTransaction(txin.prevout.hash,tx1,hash,false)) + { + if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { + for (int i = 0; i < NUM_NOTARIES; i++) { + if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) + numNotaryVins++; + } + } + } + } dPriority += (double)nValueIn * nConf; } + if ( numNotaryVins > NUM_NOTARIES / 5 ) + fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); } @@ -266,6 +283,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + if (fNotarisation) + dPriority = 1e16; + if (porphan) { porphan->dPriority = dPriority; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index cc3869835..b528df512 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -305,7 +305,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); + //fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a340ecfae..0133d6895 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { @@ -1240,7 +1240,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { // this should be a received tx.. numvoutIsOurs++; - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + totalvoutvalue += tx.vout[i].nValue; } } } From ab27a044a00ea68f5ca67bcba23278203f62f5bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 5 Nov 2018 23:37:40 +0800 Subject: [PATCH 551/951] oops --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9dfcf0546..05af4edd8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; -int32_t KOMODO_INSYNC,KOMODO_LASTMINED,KOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; +int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; From 68ae8e0468c1f020a082a62db8ba53ecfb2f79ed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 16:26:08 +0800 Subject: [PATCH 552/951] move initalise notaryaddrs to connect block to stop it being called out of order --- src/komodo.h | 29 +++++++++++-- src/notaries_staked.cpp | 96 +++++++++++++++-------------------------- src/notaries_staked.h | 1 + 3 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ba69a2761..d27981250 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -797,6 +797,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; + int8_t StakedEra; static int8_t lastStakedEra; + uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; @@ -809,6 +811,27 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY != -1 ) { + staked_era = STAKED_era(pindex->GetBlockTime()); + if ( staked_era != lastStakedEra ) { + uint8_t tmp_pubkeys[64][33]; + int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); + UpdateNotaryAddrs(tmp_pubkeys,numSN); + STAKED_ERA = staked_era; + if ( NOTARYADDRS[0][0] != 0 ) + { + if ( NOTARY_PUBKEY33[0] != 0 ) + { + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) + { + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + } + } + } + } + lastStakedEra = staked_era; + } numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -831,9 +854,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; inTime) == 0)) { - //printf("ERA 0 SKIP getblocktime: %ld pindex->nTime : %d for %s\n",pindex->GetBlockTime(),(uint32_t)pindex->nTime,ASSETCHAINS_SYMBOL); - continue; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 && staked_era == 0 ) { + // in era gap no point checking any invlaid notarisations. + break; } txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index b528df512..ec0f2054e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -121,12 +121,6 @@ int is_STAKED(const char *chain_name) { int STAKED_era(int timestamp) { int8_t era = 0; - static uint32_t lasttimestamp; - static int didera; - // test this, seems to sometimes get called into the past? - if ( timestamp < lasttimestamp ) - timestamp = lasttimestamp; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) era = 1; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) @@ -135,28 +129,9 @@ int STAKED_era(int timestamp) era = 3; else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) era = 4; - else { - era = 0; didera = 0; - } + else + era = 0; // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - - if ( era > STAKED_ERA || didera == 0 ) - { - STAKED_ERA = era; - if ( NOTARYADDRS[0][0] != 0 ) - { - if ( NOTARY_PUBKEY33[0] != 0 ) - { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) - { - IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); - } - } - didera++; - } - } - lasttimestamp = timestamp; return(era); }; @@ -205,7 +180,6 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { if ( ChainName[0] == 0 ) { - pthread_mutex_init(&staked_mutex,NULL); if ( ASSETCHAINS_SYMBOL[0] == 0 ) strcpy(ChainName,"KMD"); else @@ -215,35 +189,22 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { if ( era != 0 ) { switch (era) { case 1: - if ( didstaked1 == 0 || NOTARYADDRS[0][0] == 0 ) + if ( didstaked1 == 0 ) { for (i=0; i Date: Tue, 6 Nov 2018 16:30:35 +0800 Subject: [PATCH 553/951] fix --- src/notaries_staked.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ec0f2054e..f061810ab 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -268,8 +268,10 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { // staked era is set. #ifdef SERVER pthread_mutex_lock(&staked_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)pubkeys[i]); - NUM_NOTARIES = numNotaries; + for (int i = 0; i Date: Tue, 6 Nov 2018 16:31:51 +0800 Subject: [PATCH 554/951] typo --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d27981250..515185ef3 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -797,7 +797,7 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; - int8_t StakedEra; static int8_t lastStakedEra; + int8_t staked_era; static int8_t lastStakedEra; uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; @@ -855,7 +855,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; i Date: Tue, 6 Nov 2018 16:32:46 +0800 Subject: [PATCH 555/951] another --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 515185ef3..2a4a1252a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,7 +825,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era); + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); } } } From 120b7c3b02224d96b5653c44884f99abf3557e5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 16:43:41 +0800 Subject: [PATCH 556/951] test new era logic --- src/komodo.h | 11 ++++------- src/notaries_staked.h | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2a4a1252a..e8dab9c77 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -818,15 +818,12 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); UpdateNotaryAddrs(tmp_pubkeys,numSN); STAKED_ERA = staked_era; - if ( NOTARYADDRS[0][0] != 0 ) + if ( NOTARYADDRS[0][0] != 0 && NOTARY_PUBKEY33[0] != 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 ) + if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { - if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) - { - IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); - } + IS_KOMODO_NOTARY = 0; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); } } } diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 5a63861d7..0e590e19b 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,11 +5,11 @@ #include "crosschain.h" #include "cc/CCinclude.h" -static const int STAKED_ERA_GAP = 777; +static const int STAKED_ERA_GAP = 300; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541422105; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541423282; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541424459; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541494052; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541494052; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541494052; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From b09c8e9f4701385e0b162d7cd3dc70cbc3f4e95f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 17:12:48 +0800 Subject: [PATCH 557/951] add STAKED_ERA to getinfo .. clean code up --- src/rpcmisc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 9a578e1a5..af4eb0ee2 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -51,7 +51,7 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); @@ -62,12 +62,11 @@ extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; -extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[]; +extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; - extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -171,6 +170,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + obj.push_back(Pair("StakedEra", STAKED_ERA)); //obj.push_back(Pair("name", ASSETCHAINS_SYMBOL)); obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); From 75479b3253a02dd1237b72527aa197d7a4168d19 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 17:26:54 +0800 Subject: [PATCH 558/951] test eras again --- src/notaries_staked.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 0e590e19b..2f368b163 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,11 +5,11 @@ #include "crosschain.h" #include "cc/CCinclude.h" -static const int STAKED_ERA_GAP = 300; +static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541494052; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541494052; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541494052; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541496946; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541497546; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541498546; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 0a7c652d842f57c30e8c0dc060144643d95a563a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 6 Nov 2018 17:47:38 +0800 Subject: [PATCH 559/951] fix --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 2f368b163..caee446e7 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541496946; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541497546; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541498546; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1541498901; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1541500201; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1541501501; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 863e164e998971eb706554ecfcf37a0c4c51d026 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 13:11:03 +0800 Subject: [PATCH 560/951] final version? --- src/komodo_notary.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index ff7bc5cc3..1d43e2770 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -205,17 +205,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; - - if ( timestamp == 0 ) - timestamp = komodo_heightstamp(height); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - // Here we run the staked notaries function to populate the Notary Address's global var on KMD. - if ( IS_STAKED_NOTARY != -1 ) { - uint8_t tmp_pubkeys[64][33]; - numStakedNotaries(tmp_pubkeys,STAKED_era(timestamp)); - } - timestamp = 0; - } + + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = komodo_heightstamp(height); + else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + timestamp = 0; // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) From 0920b59572b35cc55b82e7d324c4c07286da37b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:27:57 +0800 Subject: [PATCH 561/951] add min recv size and whitelist address --- src/komodo.h | 6 +++-- src/komodo_globals.h | 4 ++-- src/komodo_notary.h | 2 +- src/komodo_utils.h | 2 ++ src/notaries_staked.cpp | 6 ++--- src/notaries_staked.h | 6 ++--- src/notarisationdb.cpp | 2 +- src/wallet/wallet.cpp | 50 +++++++++++++++++++++++++---------------- 8 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e8dab9c77..48d25d776 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -797,7 +797,7 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; - int8_t staked_era; static int8_t lastStakedEra; + int32_t staked_era; static int32_t lastStakedEra; uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; @@ -823,7 +823,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 ) { IS_KOMODO_NOTARY = 0; - fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era); + if ( MIN_RECV_SATS == -1 ) + MIN_RECV_SATS = 100000000; + fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d MIN_TX_VALUE.%lu \n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era,MIN_RECV_SATS); } } } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 05af4edd8..d415cc847 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; +std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; @@ -54,7 +54,7 @@ uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; +uint64_t ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1d43e2770..96497b755 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -252,7 +252,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam { // here we can activate our pubkeys for STAKED chains everythig is in notaries_staked.cpp if (timestamp != 0) { - int staked_era; int32_t numSN; + int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); numSN = numStakedNotaries(staked_pubkeys,staked_era); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 546fa8a13..eeacf90d0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1511,6 +1511,8 @@ void komodo_args(char *argv0) fprintf(stderr, "Cannot be STAKED and KMD notary at the same time!\n"); exit(0); } + MIN_RECV_SATS = GetArg("-mintxvalue",-1); + WHITELIST_ADDRESS = GetArg("-whitelist",""); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index f061810ab..e4e1c8ddb 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -106,7 +106,7 @@ const char *notaries_STAKED4[][2] = int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); -int is_STAKED(const char *chain_name) { +int8_t is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) STAKED = 1; @@ -118,7 +118,7 @@ int is_STAKED(const char *chain_name) { return(STAKED); }; -int STAKED_era(int timestamp) +int32_t STAKED_era(int timestamp) { int8_t era = 0; if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) @@ -289,7 +289,7 @@ int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *R return(-1); } -CrosschainAuthority Choose_auth_STAKED(int chosen_era) { +CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era) { CrosschainAuthority auth; switch (chosen_era) { case 1: diff --git a/src/notaries_staked.h b/src/notaries_staked.h index caee446e7..ae16e316d 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -24,15 +24,15 @@ extern int num_notaries_STAKED3; extern const char *notaries_STAKED4[][2]; extern int num_notaries_STAKED4; -int is_STAKED(const char *chain_name); -int STAKED_era(int timestamp); +int8_t is_STAKED(const char *chain_name); +int32_t STAKED_era(int timestamp); int8_t updateStakedNotary(); int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era); int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries); int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname); -CrosschainAuthority Choose_auth_STAKED(int chosen_era); +CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries); #endif diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index 68c00546b..f551edf3f 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -40,7 +40,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) //printf("Authorised notarisation data for %s \n",data.symbol); } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp - int staked_era = STAKED_era(timestamp); + int32_t staked_era = STAKED_era(timestamp); printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0133d6895..30d2ad461 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1201,8 +1201,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * If fUpdate is true, existing transactions will be updated. */ extern uint8_t NOTARY_PUBKEY33[33]; -extern std::string NOTARY_ADDRESS; +extern std::string NOTARY_ADDRESS,WHITELIST_ADDRESS; extern int32_t IS_STAKED_NOTARY; +extern uint64_t MIN_RECV_SATS; bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { @@ -1216,34 +1217,49 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; - for (size_t i = 0; i < tx.vin.size(); i++) { + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted = false; + for (size_t i = 0; i < tx.vin.size(); i++) + { uint256 hash; CTransaction txin; CTxDestination address; if (GetTransaction(tx.vin[i].prevout.hash,txin,hash,false)) { - if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) { - // This means we sent the tx.. - if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) { + if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) + { + if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) numvinIsOurs++; + if ( !WHITELIST_ADDRESS.empty() ) + { + if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) + whitelisted == true; } - } + } } } - // Now we know if it was a tx sent to us, that wasnt from ourself. + // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); + if ( whitelisted == true ) + fprintf(stderr, "We received from whitelisted address: %s\n",WHITELIST_ADDRESS.c_str()); // Count vouts, check if OUR notary address is the receiver. - if ( numvinIsOurs == 0 ) { - for (size_t i = 0; i < tx.vout.size() ; i++) { + if ( numvinIsOurs == 0 && whitelisted == false ) + { + for (size_t i = 0; i < tx.vout.size() ; i++) + { CTxDestination address2; - if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) { - if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { - // this should be a received tx.. + if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) + { + if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) + { numvoutIsOurs++; totalvoutvalue += tx.vout[i].nValue; } } } + // if MIN_RECV_SATS is 0, we are on full lock down mode, accept NO transactions. + if ( MIN_RECV_SATS == 0 ) { + fprintf(stderr, "This node is on full lock down all txs are ignored! \n"); + return false; + } // If no vouts are to the notary address we will ignore them. if ( numvoutIsOurs == 0 ) { fprintf(stderr, "Received transaction to address other than notary address, ignored! \n"); @@ -1252,15 +1268,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs); // here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not. int64_t avgVoutSize = totalvoutvalue / numvoutIsOurs; - if ( avgVoutSize < 100000000 ) { - // average vout size is less than 1 coin, we will ignore it + if ( avgVoutSize < MIN_RECV_SATS ) { + // average vout size is less than set minimum, default is 1 coin, we will ignore it fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize); return false; } - } else if ( numvinIsOurs < tx.vin.size() ) { - // this means we were in a multi sig, ideally we would remove the utxo we spent from our wallet, but you cant do that, unless all the tx's vouts are also spent. - // RPC call PurgeWalletSpents will be created to clean all fully spent tx's instead. - fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } } From 8d0278b46db7f216a5d6aabfaddd674e435ac3cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:47:39 +0800 Subject: [PATCH 562/951] whitelist arg already used! --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index eeacf90d0..d5ac096f5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1512,7 +1512,7 @@ void komodo_args(char *argv0) exit(0); } MIN_RECV_SATS = GetArg("-mintxvalue",-1); - WHITELIST_ADDRESS = GetArg("-whitelist",""); + WHITELIST_ADDRESS = GetArg("-whitelistaddress",""); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); else KOMODO_MININGTHREADS = -1; From be7ce20da40268d11c1edd1931ebb4a79db2e3b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:54:59 +0800 Subject: [PATCH 563/951] tets --- src/wallet/wallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 30d2ad461..089f82372 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1229,6 +1229,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() ) { + fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString()); if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) whitelisted == true; } From d92a50e5705a7a8079487a7b3f020d6af442913a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 17:56:17 +0800 Subject: [PATCH 564/951] fix --- 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 089f82372..c64e9940f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1229,7 +1229,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl numvinIsOurs++; if ( !WHITELIST_ADDRESS.empty() ) { - fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString()); + fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) whitelisted == true; } From 6af23bd81d8497da5d27b8c0b45d1c4675aa83be Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 18:01:28 +0800 Subject: [PATCH 565/951] debug more --- src/wallet/wallet.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c64e9940f..fbdac9540 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1217,7 +1217,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted = false; + int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; @@ -1230,8 +1230,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( !WHITELIST_ADDRESS.empty() ) { fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); - if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) + if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) { + fprintf(stderr, "whitlisted is set to true here.\n"); whitelisted == true; + } + } + else { + whitelisted == false; + fprintf(stderr, "whitlisted is set to false here.\n"); } } } From 0be25e9aca6e1b77ccd2a936bf436522acabf031 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 7 Nov 2018 18:06:58 +0800 Subject: [PATCH 566/951] try this instead? --- src/wallet/wallet.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fbdac9540..ea47c39c1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1217,7 +1217,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { - int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; bool whitelisted; + int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { uint256 hash; CTransaction txin; CTxDestination address; @@ -1232,23 +1232,19 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, "white list address: %s recv address: %s\n", WHITELIST_ADDRESS.c_str(),CBitcoinAddress(address).ToString().c_str()); if ( CBitcoinAddress(address).ToString() == WHITELIST_ADDRESS ) { fprintf(stderr, "whitlisted is set to true here.\n"); - whitelisted == true; + numvinIsWhiteList++; } } - else { - whitelisted == false; - fprintf(stderr, "whitlisted is set to false here.\n"); - } } } } // Now we know if it was a tx sent to us, that wasnt from ourself or the whitelist address if set.. if ( numvinIsOurs != 0 ) fprintf(stderr, "We sent from address: %s vins: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs); - if ( whitelisted == true ) + if ( numvinIsWhiteList != 0 ) fprintf(stderr, "We received from whitelisted address: %s\n",WHITELIST_ADDRESS.c_str()); // Count vouts, check if OUR notary address is the receiver. - if ( numvinIsOurs == 0 && whitelisted == false ) + if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) { for (size_t i = 0; i < tx.vout.size() ; i++) { From d07da88136c7a2aab60dd01edcbb4806c938f813 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 9 Nov 2018 14:14:02 +0800 Subject: [PATCH 567/951] add cleanwalletnotarisations RPC call for testing --- src/rpcserver.cpp | 25 ++++---- src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 133 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 145 insertions(+), 14 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 8934ae717..32c3ba5db 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -350,16 +350,16 @@ static const CRPCCommand vRPCCommands[] = #endif /* auction */ { "auction", "auctionaddress", &auctionaddress, true }, - + /* lotto */ { "lotto", "lottoaddress", &lottoaddress, true }, - + /* fsm */ { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + /* rewards */ { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -368,16 +368,16 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + /* faucet */ { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - + /* MofN */ { "MofN", "mofnaddress", &mofnaddress, true }, - + /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, { "channels", "channelsinfo", &channelsinfo, true }, @@ -386,7 +386,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelscollect", &channelscollect, true }, { "channels", "channelsstop", &channelsstop, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + /* Oracles */ { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, @@ -396,7 +396,7 @@ static const CRPCCommand vRPCCommands[] = { "oracles", "oraclessubscribe", &oraclessubscribe, true }, { "oracles", "oraclesdata", &oraclesdata, true }, { "oracles", "oraclessamples", &oraclessamples, true }, - + /* Prices */ { "prices", "pricesaddress", &pricesaddress, true }, { "prices", "priceslist", &priceslist, true }, @@ -406,16 +406,16 @@ static const CRPCCommand vRPCCommands[] = { "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesstatus", &pricesstatus, true }, { "prices", "pricesfinish", &pricesfinish, true }, - + /* Pegs */ { "pegs", "pegsaddress", &pegsaddress, true }, - + /* Triggers */ { "triggers", "triggersaddress", &triggersaddress, true }, - + /* Payments */ { "payments", "paymentsaddress", &paymentsaddress, true }, - + /* Gateways */ { "gateways", "gatewaysaddress", &gatewaysaddress, true }, { "gateways", "gatewayslist", &gatewayslist, true }, @@ -494,6 +494,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, + { "wallet", "cleanwalletnotarisations", &cleanwalletnotarisations, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index f4c502d63..4a1370465 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -301,6 +301,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); +extern UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 055352973..d5ec198e8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -398,7 +398,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Parse Zcash address CScript scriptPubKey = GetScriptForDestination(address); - + // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; @@ -995,6 +995,135 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } +UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 1 ) + throw runtime_error( + "cleanwalletnotarisations \"txid\"\n" + "\nRemove all txs which are totally spent and all notarisations created from them, you can clear all txs bar one, by specifiying a txid.\n" + "\nPlease backup your wallet.dat before running this command.\n" + "\nArguments:\n" + "1. \"txid\" (string, optional) The transaction id to keep.\n" + "\nResult:\n" + "{\n" + " \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n" + " \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n" + " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("cleanoldtxs", "") + + HelpExampleCli("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanoldtxs", "") + + HelpExampleRpc("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + UniValue ret(UniValue::VOBJ); + uint256 exception; int32_t txs = 0; + std::vector TxToRemove; + if (params.size() == 1) + { + exception.SetHex(params[0].get_str()); + uint256 tmp_hash; CTransaction tmp_tx; + if (GetTransaction(exception,tmp_tx,tmp_hash,false)) + { + if ( !pwalletMain->IsMine(tmp_tx) ) + { + throw runtime_error("\nThe transaction is not yours!\n"); + } + else + { + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + txs++; + const CWalletTx& wtx = (*it).second; + if ( wtx.GetHash() != exception ) + { + TxToRemove.push_back(wtx.GetHash()); + } + } + } + } + else + { + throw runtime_error("\nThe transaction could not be found!\n"); + } + } + else + { + std::vector NotarisationTxs; + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 50 ) + continue; + + CCoins coins; + if (!pcoinsTip->GetCoins(wtx.GetHash(), coins)) + { + int spents = 0; int mine = 0; + for (unsigned int n = 0; n < wtx.vout.size() ; n++) + { + if ( pwalletMain->IsMine(wtx.vout[n]) ) + mine++; + if ( ((unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) ) + spents++; + } + if ( spents == mine ) + { + TxToRemove.push_back(wtx.GetHash()); + for (unsigned int n = 0; n < wtx.vin.size() ; n++) + { + if ( pwalletMain->IsMine(wtx.vin[n]) ) + TxToRemove.push_back(wtx.vin[n].prevout.hash); + } + } + } + + CTxDestination address; + // get all notarisations + if ( ExtractDestination(wtx.vout[0].scriptPubKey, address) ) + { + if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) + NotarisationTxs.push_back(wtx); + } + txs++; + } + + // Erase notarisations spending from fully spent splits. + BOOST_FOREACH (CWalletTx& tx, NotarisationTxs) + { + for (int n = 0; n < tx.vin.size(); n++) + { + BOOST_FOREACH (uint256& SpentHash, TxToRemove) + { + if ( SpentHash == tx.vin[n].prevout.hash ) + { + pwalletMain->EraseFromWallet(tx.GetHash()); + //fprintf(stderr, "ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); + } + } + } + } + } + + // erase txs + BOOST_FOREACH (uint256& hash, TxToRemove) + { + pwalletMain->EraseFromWallet(hash); + //fprintf(stderr, "ERASED spent Tx: %s\n",hash.ToString().c_str()); + } + + // build return JSON for stats. + int remaining = pwalletMain->mapWallet.size(); + ret.push_back(Pair("total_transactons", (int)txs)); + ret.push_back(Pair("remaining_transactons", (int)remaining)); + ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); + return (ret); +} UniValue getbalance(const UniValue& params, bool fHelp) { @@ -5669,7 +5798,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) UniValue oraclessamples(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; + UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); if ( ensure_CCrequirements() < 0 ) From b5c356dddfd4e31c4a2a3a5ec7b76a63b84477af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 9 Nov 2018 14:58:10 +0800 Subject: [PATCH 568/951] fix txs counter --- src/wallet/rpcwallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d5ec198e8..8a62b2153 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1022,7 +1022,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); UniValue ret(UniValue::VOBJ); - uint256 exception; int32_t txs = 0; + uint256 exception; int32_t txs = pwalletMain->mapWallet.size(); std::vector TxToRemove; if (params.size() == 1) { @@ -1090,7 +1090,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) NotarisationTxs.push_back(wtx); } - txs++; } // Erase notarisations spending from fully spent splits. From 3ce2f4ec500cf863d8132c6f2a19a8887251cd80 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 18:19:01 +0800 Subject: [PATCH 569/951] try ignore 0 sat coinbase --- src/wallet/wallet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ea47c39c1..e86c54ae2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1209,6 +1209,11 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { { AssertLockHeld(cs_wallet); + if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) + { + fprintf(stderr, "ZERO sat coinbase, ignored!\n"); + return false; + } bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); From bf554eb6cff6042787ead1ef9abdc4e601776cc2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 18:45:39 +0800 Subject: [PATCH 570/951] remove print ... 0 sat coinbase ignore is working --- src/wallet/wallet.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e86c54ae2..96ec88e6e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1210,10 +1210,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) - { - fprintf(stderr, "ZERO sat coinbase, ignored!\n"); return false; - } bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); From 9f4d613cf365801c0389b70945a3b42bb9e58d66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 19:40:34 +0800 Subject: [PATCH 571/951] add Bar_F1sh_Rel .. move PoSPerc to debug.log add longest chain miner back --- src/miner.cpp | 12 ++++++------ src/notaries_staked.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5aef46148..ce5021cde 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -979,20 +979,20 @@ void static BitcoinMiner() HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); if ( ASSETCHAINS_STAKED < 100 ) { - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); - fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + //for (z=31; z>=0; z--) + // fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); + LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } while (true) { - /*if ( KOMODO_INSYNC == 0 && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( KOMODO_INSYNC == 0 && KOMODO_LONGESTCHAIN != 0 ) { fprintf(stderr,"Mining when blockchain might not be in sync longest.%d vs %d\n",KOMODO_LONGESTCHAIN,Mining_height); if ( KOMODO_LONGESTCHAIN != 0 && Mining_height >= KOMODO_LONGESTCHAIN ) KOMODO_INSYNC = 1; sleep(3); - } */ + } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; @@ -1008,7 +1008,7 @@ void static BitcoinMiner() curr_state = state; crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size()); // (x_1, x_2, ...) = A(I, V, n, k) - LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); + LogPrintf("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); arith_uint256 hashTarget; if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e4e1c8ddb..bb2289a17 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -22,7 +22,7 @@ const char *notaries_STAKED1[][2] = {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 + {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca From a573cd9e263c0f6bf4ea07fa837068779d74057d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 20:00:04 +0800 Subject: [PATCH 572/951] remove +1 sat for staked chains, needs ot be tested! --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c4fb3b6e9..590e3569f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3188,7 +3188,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size()); } } - if ( block.vtx[0].GetValueOut() > blockReward+1 ) + + if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From d10c7b83583314a4e8578aea222653835a1ddc91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 10 Nov 2018 21:11:42 +0800 Subject: [PATCH 573/951] fix max money problem, maximum 1 million coins per export, minimum max money on fungible chains 1 milion. --- src/komodo_utils.h | 2 ++ src/rpccrosschain.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d5ac096f5..188e62603 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1636,6 +1636,8 @@ void komodo_args(char *argv0) MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN; else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; + if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) + MAX_MONEY = 1000000LL*COIN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 52df5efaf..26edb575a 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -175,6 +175,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) CAmount burnAmount = AmountFromValue(params[2]); if (burnAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export"); + if (burnAmount > 1000000LL*COIN) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export, cannot export more than 1 million coins per export."); { CAmount needed = 0; for (int i=0; i Date: Sat, 10 Nov 2018 21:19:15 +0800 Subject: [PATCH 574/951] fix --- src/komodo_defs.h | 1 + src/komodo_utils.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 1efd187d9..ca9a05c37 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -9,6 +9,7 @@ #define IGUANA_MAXSCRIPTSIZE 10001 #define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" +#define KOMODO_FIRSTFUNGIBLEID 100 extern uint8_t ASSETCHAINS_TXPOW; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 188e62603..962af99aa 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1637,7 +1637,7 @@ void komodo_args(char *argv0) else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) - MAX_MONEY = 1000000LL*COIN; + MAX_MONEY = 1000000LL*SATOSHIDEN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From 973fa76710f704f5690a2f53e7a1c75f5985c5e4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 00:52:44 +0800 Subject: [PATCH 575/951] fix logprint, extra f ? --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ce5021cde..c2b95178e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1008,7 +1008,7 @@ void static BitcoinMiner() curr_state = state; crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size()); // (x_1, x_2, ...) = A(I, V, n, k) - LogPrintf("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); + LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString()); arith_uint256 hashTarget; if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; From 1fe70b907a40043a5f8cf9f1b3e9927f75f4463f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 05:18:03 +0800 Subject: [PATCH 576/951] make coinbase normal tx --- src/rpcmining.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 0a2b56ca9..48c63aff1 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -673,8 +673,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; - if (tx.IsCoinBase() && !coinbasetxn) - continue; + //if (tx.IsCoinBase() && !coinbasetxn) + // continue; UniValue entry(UniValue::VOBJ); @@ -694,17 +694,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template])); - if (tx.IsCoinBase()) { + //if (tx.IsCoinBase()) { // Show founders' reward if it is required //if (pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); //} - CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); - entry.push_back(Pair("coinbasevalue", nReward)); - entry.push_back(Pair("required", true)); - txCoinbase = entry; - } else + // CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); + // entry.push_back(Pair("coinbasevalue", nReward)); + // entry.push_back(Pair("required", true)); + // txCoinbase = entry; + // } else transactions.push_back(entry); } @@ -726,13 +726,13 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) result.push_back(Pair("version", pblock->nVersion)); result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); - if (coinbasetxn) { - assert(txCoinbase.isObject()); - result.push_back(Pair("coinbasetxn", txCoinbase)); - } else { - result.push_back(Pair("coinbaseaux", aux)); - result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); - } + //if (coinbasetxn) { + // assert(txCoinbase.isObject()); + // result.push_back(Pair("coinbasetxn", txCoinbase)); + //} else { + // result.push_back(Pair("coinbaseaux", aux)); + // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + //} result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); if ( ASSETCHAINS_STAKED != 0 ) { From 921b6a7d52d570a839a706db7b4ba5f7b5179fee Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:04:36 +0800 Subject: [PATCH 577/951] add disablecb option to getblocktemplate --- src/rpcmining.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 48c63aff1..7d5b2ebdc 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -518,7 +518,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) #endif } - std::string strMode = "template"; UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written bool coinbasetxn = true; @@ -530,12 +529,15 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = modeval.get_str(); else if (modeval.isNull()) { - /* Do nothing */ + std::string strMode = "template"; } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); lpval = find_value(oparam, "longpollid"); + if (strMode == "disablecb") + coinbasetxn = false; + if (strMode == "proposal") { const UniValue& dataval = find_value(oparam, "data"); @@ -567,7 +569,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } } - if (strMode != "template") + if (strMode != "template" || strMode != "disablecb") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) @@ -694,17 +696,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template])); - //if (tx.IsCoinBase()) { + if (tx.IsCoinBase() && coinbasetxn == true ) { // Show founders' reward if it is required //if (pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); //} - // CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); - // entry.push_back(Pair("coinbasevalue", nReward)); - // entry.push_back(Pair("required", true)); - // txCoinbase = entry; - // } else + CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus()); + entry.push_back(Pair("coinbasevalue", nReward)); + entry.push_back(Pair("required", true)); + txCoinbase = entry; + } else transactions.push_back(entry); } @@ -726,12 +728,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) result.push_back(Pair("version", pblock->nVersion)); result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); - //if (coinbasetxn) { - // assert(txCoinbase.isObject()); - // result.push_back(Pair("coinbasetxn", txCoinbase)); - //} else { - // result.push_back(Pair("coinbaseaux", aux)); - // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + if (coinbasetxn) { + assert(txCoinbase.isObject()); + result.push_back(Pair("coinbasetxn", txCoinbase)); + } // else { + // result.push_back(Pair("coinbaseaux", aux)); + // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); //} result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); if ( ASSETCHAINS_STAKED != 0 ) From 2205820299eefee6bdedbcb2188cd07e2bc51124 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:11:19 +0800 Subject: [PATCH 578/951] fix --- src/rpcmining.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 7d5b2ebdc..a3d7a5893 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -521,6 +521,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written bool coinbasetxn = true; + std::string strMode; if (params.size() > 0) { const UniValue& oparam = params[0].get_obj(); @@ -529,7 +530,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = modeval.get_str(); else if (modeval.isNull()) { - std::string strMode = "template"; + strMode = "template"; } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); From 4129000ec324cf9bd23678307b4d176d12c52092 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:23:51 +0800 Subject: [PATCH 579/951] print --- src/rpcmining.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index a3d7a5893..944879120 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -528,6 +528,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) const UniValue& modeval = find_value(oparam, "mode"); if (modeval.isStr()) strMode = modeval.get_str(); + fprintf(stderr, "%s\n",strMode); else if (modeval.isNull()) { strMode = "template"; From 3354f67d5d576fafd16453fcc4c1b398d56c298b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:25:19 +0800 Subject: [PATCH 580/951] fix --- src/rpcmining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 944879120..cb421b9e0 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -528,7 +528,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) const UniValue& modeval = find_value(oparam, "mode"); if (modeval.isStr()) strMode = modeval.get_str(); - fprintf(stderr, "%s\n",strMode); + fprintf(stderr, "%s\n",strMode.c_str()); else if (modeval.isNull()) { strMode = "template"; From b6f711b69d3e0a0d702537a50b66c84ed5b03b9b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:26:36 +0800 Subject: [PATCH 581/951] fix --- src/rpcmining.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index cb421b9e0..b317190dd 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -526,9 +526,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) { const UniValue& oparam = params[0].get_obj(); const UniValue& modeval = find_value(oparam, "mode"); - if (modeval.isStr()) + if (modeval.isStr()) { strMode = modeval.get_str(); - fprintf(stderr, "%s\n",strMode.c_str()); + fprintf(stderr, "%s\n",strMode.c_str()); + } else if (modeval.isNull()) { strMode = "template"; From 1d3226eafa4934936fae8fba749835c081750204 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:29:06 +0800 Subject: [PATCH 582/951] fix --- src/rpcmining.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index b317190dd..ad2058fd5 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -526,10 +526,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) { const UniValue& oparam = params[0].get_obj(); const UniValue& modeval = find_value(oparam, "mode"); - if (modeval.isStr()) { + if (modeval.isStr()) strMode = modeval.get_str(); - fprintf(stderr, "%s\n",strMode.c_str()); - } else if (modeval.isNull()) { strMode = "template"; @@ -571,6 +569,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } + fprintf(stderr, "%s\n",strMode.c_str()); if (strMode != "template" || strMode != "disablecb") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); From 47bc56ea6a88664e7d14b69e2fe3095e03824964 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:32:53 +0800 Subject: [PATCH 583/951] fix? --- src/rpcmining.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index ad2058fd5..907d13ada 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -569,10 +569,11 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } - fprintf(stderr, "%s\n",strMode.c_str()); + if (coinbasetxn == false ) + fprintf(stderr, "disable coinbase: %s\n",strMode.c_str()); - if (strMode != "template" || strMode != "disablecb") - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + //if (strMode != "template" || strMode != "disablecb") + // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); From 7e45307718c3f325f550fae104f79da27d991629 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 06:35:30 +0800 Subject: [PATCH 584/951] done --- src/rpcmining.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 907d13ada..d3f0563f8 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -569,11 +569,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } - if (coinbasetxn == false ) - fprintf(stderr, "disable coinbase: %s\n",strMode.c_str()); - - //if (strMode != "template" || strMode != "disablecb") - // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); From 2016042c79ad810dfdd92c06c36da7e8cdfa1241 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 13:16:56 +0800 Subject: [PATCH 585/951] fix! lol --- src/notaries_staked.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ae16e316d..51124be23 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,9 +7,9 @@ static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1541498901; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1541500201; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1541501501; +static const int STAKED_NOTARIES_TIMESTAMP1 = 1604211111; +static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; +static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; extern const char *notaries_STAKED1[][2]; From 677d4f9b5053791a804a86c908948894ff54fe6e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 14:23:46 +0800 Subject: [PATCH 586/951] remove vin,vins --- src/wallet/rpcwallet.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8a62b2153..3d5d41871 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1074,12 +1074,18 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) } if ( spents == mine ) { - TxToRemove.push_back(wtx.GetHash()); for (unsigned int n = 0; n < wtx.vin.size() ; n++) { - if ( pwalletMain->IsMine(wtx.vin[n]) ) - TxToRemove.push_back(wtx.vin[n].prevout.hash); + //if ( pwalletMain->IsMine(wtx.vin[n]) ) + CTransaction vintx; uint256 hashBlock; + if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) + { + for (unsigned int z = 0; z < vintx.vin.size() ; z++) + TxToRemove.push_back(vintx.vin[z].prevout.hash); + } + TxToRemove.push_back(wtx.vin[n].prevout.hash); } + TxToRemove.push_back(wtx.GetHash()); } } From 13a5aa70a7c6e2be3d327820da9ba81dbc901797 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:10:41 +0800 Subject: [PATCH 587/951] print --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3d5d41871..a393a0518 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,7 +1058,8 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 50 ) + fprintf(stderr, "depth in main chain: %d\n", wtx.GetDepthInMainChain()); + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; CCoins coins; From 462acd24ab3a84a2365190a992beb40f13d2aef5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:21:38 +0800 Subject: [PATCH 588/951] fix 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 a393a0518..688675d71 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,7 +1058,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - fprintf(stderr, "depth in main chain: %d\n", wtx.GetDepthInMainChain()); + fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; From 2e4ff8898f7d13bd7363d559eb62ad776b3595f4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:32:28 +0800 Subject: [PATCH 589/951] try --- src/wallet/rpcwallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 688675d71..725cba3a0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1059,7 +1059,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { const CWalletTx& wtx = (*it).second; fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() > 360 ) continue; CCoins coins; @@ -1082,7 +1082,10 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) - TxToRemove.push_back(vintx.vin[z].prevout.hash); + { + fprintf(stderr, "[ %s ] depth : %d\n", vintx.GetHash().ToString().c_str(),vintx.GetDepthInMainChain()); + TxToRemove.push_back(vintx.vin[z].prevout.hash); + } } TxToRemove.push_back(wtx.vin[n].prevout.hash); } From e0383c82b916480011fb55de8e5a696005d3b855 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:35:50 +0800 Subject: [PATCH 590/951] fix --- 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 725cba3a0..d89368ba5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1083,7 +1083,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) { - fprintf(stderr, "[ %s ] depth : %d\n", vintx.GetHash().ToString().c_str(),vintx.GetDepthInMainChain()); + fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str(); TxToRemove.push_back(vintx.vin[z].prevout.hash); } } From 025924e9ffc8a9ce2da2dc89685f364f659537b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:36:54 +0800 Subject: [PATCH 591/951] ) --- 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 d89368ba5..f9ac24016 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1083,7 +1083,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) { - fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str(); + fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str()); TxToRemove.push_back(vintx.vin[z].prevout.hash); } } From 4d6499bd8d737b9bb95818bf13b7aaf0c8463744 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:42:26 +0800 Subject: [PATCH 592/951] fix --- 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 f9ac24016..e7a7a2953 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1059,7 +1059,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { const CWalletTx& wtx = (*it).second; fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() > 360 ) + if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; CCoins coins; From 2e91034c1ec168edecec4d6b5c7c65a659f4af91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 15:57:40 +0800 Subject: [PATCH 593/951] LogPrintf the removed txs --- src/wallet/rpcwallet.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e7a7a2953..238744805 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1058,7 +1058,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - fprintf(stderr, "[%s] depth : %d\n", wtx.GetHash().ToString().c_str(),wtx.GetDepthInMainChain()); if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) continue; @@ -1077,13 +1076,11 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (unsigned int n = 0; n < wtx.vin.size() ; n++) { - //if ( pwalletMain->IsMine(wtx.vin[n]) ) CTransaction vintx; uint256 hashBlock; if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) { for (unsigned int z = 0; z < vintx.vin.size() ; z++) { - fprintf(stderr, "TX: %s in block : %s\n", vintx.GetHash().ToString().c_str(),hashBlock.ToString().c_str()); TxToRemove.push_back(vintx.vin[z].prevout.hash); } } @@ -1112,7 +1109,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) if ( SpentHash == tx.vin[n].prevout.hash ) { pwalletMain->EraseFromWallet(tx.GetHash()); - //fprintf(stderr, "ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); + LogPrintf("ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); } } } @@ -1123,7 +1120,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); - //fprintf(stderr, "ERASED spent Tx: %s\n",hash.ToString().c_str()); + LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); } // build return JSON for stats. From 55b48771eabd6e77d86795132aaed122f52fceb3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 17:50:01 +0800 Subject: [PATCH 594/951] fix --- src/cc/dice.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 847fc5bee..a321d7149 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1425,11 +1425,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { -<<<<<<< HEAD - CCerror = "Diceinit error in bet, is your transaction confirmed?"; -======= + CCerror = "error in Diceinit"; ->>>>>>> 880fda004f9487b7ca227f54d2f733f3139d935e return(""); } if ( bet < minbet || bet > maxbet || odds > maxodds ) @@ -1437,10 +1434,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CCerror = strprintf("Dice plan %s illegal bet %.8f: minbet %.8f maxbet %.8f or odds %d vs max.%d\n",planstr,(double)bet/COIN,(double)minbet/COIN,(double)maxbet/COIN,(int32_t)odds,(int32_t)maxodds); return(""); } -<<<<<<< HEAD - int32_t entropytxs; - if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs)) >= 2*bet*odds+txfee && entropyval != 0 ) -======= int32_t entropytxs=0,emptyvar=0; funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); DicePlanFunds(entropyval2,entropytxid2,sbits,cp,dicepk,fundingtxid,emptyvar,true); @@ -1450,7 +1443,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet entropytxid = entropytxid2; } if ( ( funding >= 2*bet*odds+txfee && entropyval != 0 ) ) ->>>>>>> 880fda004f9487b7ca227f54d2f733f3139d935e { if ( entropytxs < 100 ) { CCerror = "Your dealer is broke, find a new casino."; From c7fec5f7b694c122af0c25c5ce53a899b362d6af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 17:51:00 +0800 Subject: [PATCH 595/951] fix --- src/cc/dice.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a321d7149..5a206727b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1643,12 +1643,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { -<<<<<<< HEAD - CCerror = "Diceinit error in status, is your transaction confirmed?"; - fprintf(stderr,"%s\n", CCerror.c_str() ); -======= CCerror = "Diceinit error in status"; ->>>>>>> 880fda004f9487b7ca227f54d2f733f3139d935e return(0.); } win = loss = 0; From 0d318f6411454abebed095070618a0411b55fd10 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:03:52 +0800 Subject: [PATCH 596/951] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index f471b0013..c6ac90196 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -458,7 +458,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block),(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From 13a13cd164590cbeb9b8509bf1d3d911c924b69f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:05:55 +0800 Subject: [PATCH 597/951] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c6ac90196..43ebf8607 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -458,7 +458,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block),(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From ecd40761e8b85770f701e035a4329214d55add13 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:31:51 +0800 Subject: [PATCH 598/951] fix stream option? --- src/komodo_utils.h | 12 ++++++------ src/pow.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index be39b4d46..9b54dace7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1600,6 +1600,11 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 && ASSETCHAINS_STREAM != 0 ) + { + printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); + exit(0); + } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) @@ -1607,11 +1612,6 @@ void komodo_args(char *argv0) decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); } - else if ( ASSETCHAINS_STREAM != 0) - { - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); - exit(0); - } if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_COMMISSION = 53846154; // maps to 35% @@ -1661,7 +1661,7 @@ void komodo_args(char *argv0) MAX_MONEY = 1000000LL*SATOSHIDEN; if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) MAX_MONEY = 1000000000LL*SATOSHIDEN; - //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) diff --git a/src/pow.cpp b/src/pow.cpp index 9c8f68586..0e7e6678c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -24,7 +24,7 @@ extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if ( ASSETCHAINS_STREAM == 0) + if ( ASSETCHAINS_STREAM != 2 ) { unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block From eb7f16be6a8c5e0f9033f7900a79aeb47c53fdb3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 11 Nov 2018 18:45:20 +0800 Subject: [PATCH 599/951] h --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9b54dace7..0add63fbb 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1623,12 +1623,12 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_COMMISSION != 0 ) { ASSETCHAINS_COMMISSION = 0; - printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); + printf("ASSETCHAINS_COMMISSION needs an ASSETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); } if ( ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_FOUNDERS = 0; - printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n"); + printf("ASSETCHAINS_FOUNDERS needs an ASSETCHAINS_OVERRIDE_PUBKEY or ASSETCHAINS_SCRIPTPUB\n"); } } if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) @@ -1661,7 +1661,7 @@ void komodo_args(char *argv0) MAX_MONEY = 1000000LL*SATOSHIDEN; if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) MAX_MONEY = 1000000000LL*SATOSHIDEN; - fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From 7c50dd216c722eea4e3f1903d1d168d6ac7a3a4f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 01:33:57 +0800 Subject: [PATCH 600/951] try --- src/cc/CCinclude.h | 1 - src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index f9924e173..0f3603d41 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -155,7 +155,6 @@ bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t n bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); std::vector Mypubkey(); bool Myprivkey(uint8_t myprivkey[]); -bool pubkey2addr(char *destaddr,uint8_t *pubkey33); int64_t CCduration(int32_t &numblocks,uint256 txid); bool isCCTxNotarizedConfirmed(uint256 txid); // CCtx diff --git a/src/miner.cpp b/src/miner.cpp index 43ebf8607..a657e773e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -674,7 +674,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - //fprintf(stderr,"use notary pubkey\n"); + fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 05cbb5dee..0641b446c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5085,7 +5085,7 @@ extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - if ( fHelp || params.size() != 1 ) + if ( fHelp || params.size() > 1 ) throw runtime_error( "setpubkey\n" "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" @@ -5128,10 +5128,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { result.push_back(Pair("IsNotary", notaryname)); IS_KOMODO_NOTARY = 0; - USE_EXTERNAL_PUBKEY = 1; } NOTARY_PUBKEY = params[0].get_str(); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; } } else result.push_back(Pair("error", "pubkey entered is invalid.")); From 025d680a9e209a7813fbd5cbd969ada66372a755 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 10:40:49 +0800 Subject: [PATCH 601/951] remove print again --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a657e773e..43ebf8607 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -674,7 +674,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - fprintf(stderr,"use notary pubkey\n"); + //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { From e5028657278760d5536ada58319a576b05c15518 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 12 Nov 2018 15:20:20 +0800 Subject: [PATCH 602/951] fix setpubkey for pool --- src/wallet/rpcwallet.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0641b446c..17d28aced 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5120,26 +5120,31 @@ UniValue setpubkey(const UniValue& params, bool fHelp) CTxDestination dest = address.Get(); isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; if ( mine == ISMINE_NO ) { - result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!")); + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); } else { result.push_back(Pair("ismine", "true")); - NOTARY_ADDRESS = address.ToString(); std::string notaryname; if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { result.push_back(Pair("IsNotary", notaryname)); IS_KOMODO_NOTARY = 0; } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - USE_EXTERNAL_PUBKEY = 1; } - } else + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; + NOTARY_ADDRESS = address.ToString(); + } else { result.push_back(Pair("error", "pubkey entered is invalid.")); + } } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); } } else { + if ( NOTARY_ADDRESS.empty() ) { + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + NOTARY_ADDRESS.assign(Raddress); + } result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { From 0724759fc48231f550a3f4614e47b61159f45cbd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 13:57:06 +0800 Subject: [PATCH 603/951] fix KMD sync issue? --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 92634de0f..2072aadb5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3192,7 +3192,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) ) + if ( ( block.vtx[0].GetValueOut() > blockReward && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward+1 ) ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From 2120ab4fd111d67d655eb434dd9ce6b54bb4f90b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 18:09:23 +0800 Subject: [PATCH 604/951] fix --- src/cc/dice.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7ef00ad6c..81a141d3b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1425,12 +1425,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { -<<<<<<< HEAD CCerror = "error in Diceinit"; -======= - CCerror = "Diceinit error in bet, is your transaction confirmed?"; ->>>>>>> 08b2f80458cd1f0313af8089c9fda3b9a82ea68c return(""); } if ( bet < minbet || bet > maxbet || odds > maxodds ) From cad34b503d51f9076adef1e65435854f54fdba68 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 18:25:07 +0800 Subject: [PATCH 605/951] fix streamer with ac_pubey requiring ac_perc --- src/cryptoconditions/compile | 13 +++++----- src/komodo_utils.h | 4 +-- src/pow.cpp | 50 +++++++++++++++++------------------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/cryptoconditions/compile b/src/cryptoconditions/compile index a85b723c7..99e50524b 100755 --- a/src/cryptoconditions/compile +++ b/src/cryptoconditions/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -255,7 +255,8 @@ EOF echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -339,9 +340,9 @@ exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a1705c20a..80581a1f8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1620,10 +1620,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else + else if ( ASSETCHAINS_STREAM == 0 ) { ASSETCHAINS_OVERRIDE_PUBKEY.clear(); - printf("-ac_perc must be set with -ac_pubkey\n"); + printf("-ac_perc or -ac_stream must be set with -ac_pubkey\n"); } } } diff --git a/src/pow.cpp b/src/pow.cpp index 0e7e6678c..07776e273 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -24,35 +24,31 @@ extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if ( ASSETCHAINS_STREAM != 2 ) - { - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); - // Genesis block - if (pindexLast == NULL ) - return nProofOfWorkLimit; - - // Find the first block in the averaging interval - const CBlockIndex* pindexFirst = pindexLast; - arith_uint256 bnTot {0}; - for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { - arith_uint256 bnTmp; - bnTmp.SetCompact(pindexFirst->nBits); - bnTot += bnTmp; - pindexFirst = pindexFirst->pprev; - } - - // Check we have enough blocks - if (pindexFirst == NULL) - return nProofOfWorkLimit; - - arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; - - return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); - } - else - { + if ( ASSETCHAINS_STREAM == 2 ) return 537857807; + + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + // Genesis block + if (pindexLast == NULL ) + return nProofOfWorkLimit; + + // Find the first block in the averaging interval + const CBlockIndex* pindexFirst = pindexLast; + arith_uint256 bnTot {0}; + for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) { + arith_uint256 bnTmp; + bnTmp.SetCompact(pindexFirst->nBits); + bnTot += bnTmp; + pindexFirst = pindexFirst->pprev; } + + // Check we have enough blocks + if (pindexFirst == NULL) + return nProofOfWorkLimit; + + arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow}; + + return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params); } unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, From 02c49755a585fab54e469206da5c7dbc97a7fcf4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 18 Nov 2018 22:55:36 +0800 Subject: [PATCH 606/951] fix wallet cleaner --- src/rpcserver.cpp | 2 +- src/rpcserver.h | 2 +- src/wallet/rpcwallet.cpp | 88 +++++++++++----------------------------- 3 files changed, 25 insertions(+), 67 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 7267461b3..65f12a346 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -495,7 +495,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "cleanwalletnotarisations", &cleanwalletnotarisations, false }, + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 873e2dc05..f7fa65942 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -300,7 +300,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -extern UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp); +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 69c310bcf..a5c8bdaff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1003,15 +1003,15 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } -UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; if (fHelp || params.size() > 1 ) throw runtime_error( - "cleanwalletnotarisations \"txid\"\n" - "\nRemove all txs which are totally spent and all notarisations created from them, you can clear all txs bar one, by specifiying a txid.\n" + "cleanwallettransactions \"txid\"\n" + "\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n" "\nPlease backup your wallet.dat before running this command.\n" "\nArguments:\n" "1. \"txid\" (string, optional) The transaction id to keep.\n" @@ -1022,10 +1022,10 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) " \"removed_transactons\" : n, (numeric) The number of transactions removed.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("cleanoldtxs", "") - + HelpExampleCli("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") - + HelpExampleRpc("cleanoldtxs", "") - + HelpExampleRpc("cleanoldtxs","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleCli("cleanwallettransactions", "") + + HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("cleanwallettransactions", "") + + HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1046,7 +1046,6 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) { for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - txs++; const CWalletTx& wtx = (*it).second; if ( wtx.GetHash() != exception ) { @@ -1062,65 +1061,24 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) } else { - std::vector NotarisationTxs; + // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + int32_t oldestTxDepth = 0; + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( out.nDepth > oldestTxDepth ) + oldestTxDepth = out.nDepth; + } + oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + + // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 360 ) - continue; - - CCoins coins; - if (!pcoinsTip->GetCoins(wtx.GetHash(), coins)) - { - int spents = 0; int mine = 0; - for (unsigned int n = 0; n < wtx.vout.size() ; n++) - { - if ( pwalletMain->IsMine(wtx.vout[n]) ) - mine++; - if ( ((unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) ) - spents++; - } - if ( spents == mine ) - { - for (unsigned int n = 0; n < wtx.vin.size() ; n++) - { - CTransaction vintx; uint256 hashBlock; - if ( GetTransaction(wtx.vin[n].prevout.hash,vintx,hashBlock,false) != 0 ) - { - for (unsigned int z = 0; z < vintx.vin.size() ; z++) - { - TxToRemove.push_back(vintx.vin[z].prevout.hash); - } - } - TxToRemove.push_back(wtx.vin[n].prevout.hash); - } - TxToRemove.push_back(wtx.GetHash()); - } - } - - CTxDestination address; - // get all notarisations - if ( ExtractDestination(wtx.vout[0].scriptPubKey, address) ) - { - if ( strcmp(CBitcoinAddress(address).ToString().c_str(),CRYPTO777_KMDADDR) == 0 ) - NotarisationTxs.push_back(wtx); - } - } - - // Erase notarisations spending from fully spent splits. - BOOST_FOREACH (CWalletTx& tx, NotarisationTxs) - { - for (int n = 0; n < tx.vin.size(); n++) - { - BOOST_FOREACH (uint256& SpentHash, TxToRemove) - { - if ( SpentHash == tx.vin[n].prevout.hash ) - { - pwalletMain->EraseFromWallet(tx.GetHash()); - LogPrintf("ERASED Notarisation: %s\n",tx.GetHash().ToString().c_str()); - } - } - } + if (wtx.GetDepthInMainChain() > oldestTxDepth) + TxToRemove.push_back(wtx.GetHash()); } } @@ -1128,7 +1086,7 @@ UniValue cleanwalletnotarisations(const UniValue& params, bool fHelp) BOOST_FOREACH (uint256& hash, TxToRemove) { pwalletMain->EraseFromWallet(hash); - LogPrintf("ERASED spent Tx: %s\n",hash.ToString().c_str()); + LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str()); } // build return JSON for stats. From f72c3ba1d27e3e8d4dc7e0f19ed0138c4965ba5c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 16:51:34 +0800 Subject: [PATCH 607/951] fix --- src/komodo.h | 6 ++++-- src/rpcmisc.cpp | 8 ++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 9 +++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e6c9a8c54..5b1bfe1ac 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -811,9 +811,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY != -1 ) { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { staked_era = STAKED_era(pindex->GetBlockTime()); - if ( staked_era != lastStakedEra ) { + if ( staked_era != lastStakedEra ) + { uint8_t tmp_pubkeys[64][33]; int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); UpdateNotaryAddrs(tmp_pubkeys,numSN); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e51a50a97..f85705a90 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,14 @@ extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; +UniValue getiguanajson(const UniValue& params, bool fHelp) +{ + if ( params.size() != 1 ) + throw runtime_error("please supply old staked.json!\n"); + UniValue json = params[0].get_obj(); + return json; +} + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 65f12a346..dc0ebd465 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -263,6 +263,7 @@ static const CRPCCommand vRPCCommands[] = /* Overall control/query calls */ { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, + { "control", "getiguanajson", &getiguanajson, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpcserver.h b/src/rpcserver.h index f7fa65942..2ae1e8de1 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -324,6 +324,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue getiguanajson(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a5c8bdaff..d6a06525d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1061,6 +1061,11 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) } else { + // get all locked utxos to relock them later. + vector vLockedUTXO; + pwalletMain->ListLockedCoins(vLockedUTXO); + // unlock all coins so that the following call containes all utxos. + pwalletMain->UnlockAllCoins(); // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, vector vecOutputs; assert(pwalletMain != NULL); @@ -1072,6 +1077,10 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) oldestTxDepth = out.nDepth; } oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + // lock all the previouly locked coins. + BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { + pwalletMain->LockCoin(outpt); + } // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) From 06659e51f2ba27e7a022ea0cd29d7b1f7723f7bb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 16:55:14 +0800 Subject: [PATCH 608/951] remove wrong +1 fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 590e3569f..840705d2d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3189,7 +3189,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - if ( ( block.vtx[0].GetValueOut() > blockReward+1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) || ( block.vtx[0].GetValueOut() > blockReward ) ) + if ( ( block.vtx[0].GetValueOut() > blockReward+1 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From ec8f86f89db78e29f1898fc5d36dd9e93fef82b7 Mon Sep 17 00:00:00 2001 From: Alrighttt Date: Thu, 22 Nov 2018 11:05:39 +0100 Subject: [PATCH 609/951] update ERA2 --- src/notaries_staked.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index bb2289a17..ae2646e9e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -40,20 +40,25 @@ const char *notaries_STAKED2[][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, //RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 + {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN + {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p + {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s + {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t + {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 + {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q + {"dukeleto", "03e4322510ee46d417b8382fe124f5a381a3cef6aef08f8a4e90c66a42a04b4015" }, // RB8vS1fkGuttoNYkA2B1ivNn8vhqbCEqbe + {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP + {"ca333", "03a18a33313ccdbf3c9778776e33c423e073ff5833fa1de092ce9e921de52f22f6" }, // RX333A56jWdeW15MwZsaW3mHxGaDu2Yutp + {"computergenie", "03448ce28fb21748e8b05bbe32d6b1e758b589ac1eb359e5d552f8868f2b75dc92" }, // RGeniexxkjnR34hg7ZnCf36kmfuJusf6rE }; int num_notaries_STAKED2 = (sizeof(notaries_STAKED2)/sizeof(*notaries_STAKED2)); From 7d13c2e5a0b4eadb56d87433ebb5254daea2a6aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 19:49:49 +0800 Subject: [PATCH 610/951] add getiguanajson RPC, for ERA2 only at this stage. --- src/notaries_staked.cpp | 24 ++++++++++++++++------ src/notaries_staked.h | 11 ++++++---- src/rpcmisc.cpp | 45 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ae2646e9e..65e71f0c6 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -10,6 +10,18 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; +const char *iguanaSeeds[8][1] = +{ + {"80.240.17.222"}, + {"103.6.12.112"}, + {"18.224.176.46"}, + {"45.76.120.247"}, + {"103.6.12.112"}, + {"103.6.12.112"}, + {"103.6.12.112"}, + {"103.6.12.112"}, +}; + // Era 1 set of pubkeys const char *notaries_STAKED1[][2] = { @@ -113,9 +125,9 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); int8_t is_STAKED(const char *chain_name) { int STAKED = 0; - if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; - else if ( (strcmp(chain_name, "STKD") == 0) || (strncmp(chain_name, "STKD", 4) == 0) ) + else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; @@ -126,13 +138,13 @@ int8_t is_STAKED(const char *chain_name) { int32_t STAKED_era(int timestamp) { int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) + if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) era = 1; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[1] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[0] + STAKED_ERA_GAP)) era = 2; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[2] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[1] + STAKED_ERA_GAP)) era = 3; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP)) + else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[3] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[2] + STAKED_ERA_GAP)) era = 4; else era = 0; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 51124be23..f71f75264 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -5,12 +5,15 @@ #include "crosschain.h" #include "cc/CCinclude.h" +static const int32_t iguanaPort = 9997; +static const int8_t BTCminsigs = 13; +static const int8_t overrideMinSigs = 0; +extern const char *iguanaSeeds[8][1]; + static const int STAKED_ERA_GAP = 777; -static const int STAKED_NOTARIES_TIMESTAMP1 = 1604211111; -static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; -static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; -static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; +static const int NUM_STAKED_ERAS = 4; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542885514, 1604222222, 1604233333, 1604244444}; extern const char *notaries_STAKED1[][2]; extern int num_notaries_STAKED1; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f85705a90..965286d6b 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -66,9 +66,48 @@ extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[ UniValue getiguanajson(const UniValue& params, bool fHelp) { - if ( params.size() != 1 ) - throw runtime_error("please supply old staked.json!\n"); - UniValue json = params[0].get_obj(); + if (fHelp || params.size() != 0) + throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); + + UniValue json(UniValue::VOBJ); + UniValue seeds(UniValue::VARR); + UniValue notaries(UniValue::VARR); + // get the current era, use local time for now. + // should ideally take blocktime of last known block. + int now = time(NULL); int32_t era; + for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { + if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + era = i + 1; + break; + } + } + if ( era != 2 ) + throw runtime_error("its not era2 yet!"); + + // loop over seeds array and push back to json array for seeds + for (int8_t i = 0; i < 8; i++) { + seeds.push_back(iguanaSeeds[i][0]); + } + + // loop over era's notaries and push back each pair to the notary array + for (int8_t i = 0; i < num_notaries_STAKED2; i++) { + UniValue notary(UniValue::VOBJ); + notary.push_back(Pair(notaries_STAKED2[i][0],notaries_STAKED2[i][1])); + notaries.push_back(notary); + } + + // get the min sigs + int minsigs; + if ( num_notaries_STAKED2/5 > overrideMinSigs ) + minsigs = (num_notaries_STAKED2 + 4) / 5; + else + minsigs = overrideMinSigs; + + json.push_back(Pair("port",iguanaPort)); + json.push_back(Pair("BTCminsigs",BTCminsigs)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("notaries",notaries)); return json; } From 03c35656685cff2ff1db602fc2d025a47ba8c2c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 19:51:13 +0800 Subject: [PATCH 611/951] fix ( --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 840705d2d..903b07a65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3189,7 +3189,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - if ( ( block.vtx[0].GetValueOut() > blockReward+1 ) + if ( block.vtx[0].GetValueOut() > blockReward+1 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From 5bbc803ee844b8d977b62609b0e9fab293aabbed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 23:05:15 +0800 Subject: [PATCH 612/951] refactor to use 3d array of pubkeys --- src/notaries_staked.cpp | 236 +++++++--------------------------------- src/notaries_staked.h | 113 ++++++++++++++++--- src/rpcmisc.cpp | 12 +- 3 files changed, 146 insertions(+), 215 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 65e71f0c6..19fe06b81 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -10,119 +10,6 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; -const char *iguanaSeeds[8][1] = -{ - {"80.240.17.222"}, - {"103.6.12.112"}, - {"18.224.176.46"}, - {"45.76.120.247"}, - {"103.6.12.112"}, - {"103.6.12.112"}, - {"103.6.12.112"}, - {"103.6.12.112"}, -}; - -// Era 1 set of pubkeys -const char *notaries_STAKED1[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED1 = (sizeof(notaries_STAKED1)/sizeof(*notaries_STAKED1)); - -// Era 2 set of pubkeys -const char *notaries_STAKED2[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, //RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu - {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 - {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p - {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t - {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 - {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q - {"dukeleto", "03e4322510ee46d417b8382fe124f5a381a3cef6aef08f8a4e90c66a42a04b4015" }, // RB8vS1fkGuttoNYkA2B1ivNn8vhqbCEqbe - {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP - {"ca333", "03a18a33313ccdbf3c9778776e33c423e073ff5833fa1de092ce9e921de52f22f6" }, // RX333A56jWdeW15MwZsaW3mHxGaDu2Yutp - {"computergenie", "03448ce28fb21748e8b05bbe32d6b1e758b589ac1eb359e5d552f8868f2b75dc92" }, // RGeniexxkjnR34hg7ZnCf36kmfuJusf6rE -}; - -int num_notaries_STAKED2 = (sizeof(notaries_STAKED2)/sizeof(*notaries_STAKED2)); - -// Era 3 set of pubkeys -const char *notaries_STAKED3[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED3 = (sizeof(notaries_STAKED3)/sizeof(*notaries_STAKED3)); - -// Era 4 set of pubkeys -const char *notaries_STAKED4[][2] = -{ - {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x - {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg - {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 - {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 - {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL - {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s -}; - -int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); - int8_t is_STAKED(const char *chain_name) { int STAKED = 0; if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) @@ -137,19 +24,16 @@ int8_t is_STAKED(const char *chain_name) { int32_t STAKED_era(int timestamp) { - int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) - era = 1; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[1] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[0] + STAKED_ERA_GAP)) - era = 2; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[2] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[1] + STAKED_ERA_GAP)) - era = 3; - else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[3] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[2] + STAKED_ERA_GAP)) - era = 4; - else - era = 0; + int8_t era = 0; + if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) + return(1); + for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) + { + if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) + return(i); + } // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. - return(era); + return(0); }; #ifdef SERVER @@ -169,24 +53,16 @@ int8_t updateStakedNotary() { #endif int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - int8_t notaryID = -1; - if ( STAKED_ERA != 0 ) { - switch (STAKED_ERA) { - case 1: - notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname); - break; - case 2: - notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname); - break; - case 3: - notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname); - break; - case 4: - notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname); - break; - } + if ( STAKED_ERA != 0 ) + { + for (int8_t i = 0; i < num_notaries_STAKED[STAKED_ERA-1]; i++) { + if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { + notaryname.assign(notaries_STAKED[STAKED_ERA-1][i][0]); + return(i); + } + } } - return(notaryID); + return(-1); } int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { @@ -208,50 +84,50 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { case 1: if ( didstaked1 == 0 ) { - for (i=0; i overrideMinSigs ) - minsigs = (num_notaries_STAKED2 + 4) / 5; + if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) + minsigs = (num_notaries_STAKED[era] + 4) / 5; else minsigs = overrideMinSigs; From e232fd00498c4e3c844f0200540a71f5abdf5cd1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 00:02:46 +0800 Subject: [PATCH 613/951] fix new era function --- src/notaries_staked.cpp | 4 ++-- src/rpcmisc.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 19fe06b81..d29d5dfb2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -18,7 +18,7 @@ int8_t is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - //fprintf(stderr, "This chains is: %s which is: %d\n", chain_name,STAKED); + //fprintf(stderr, "This chain is: %s which is: %d\n", chain_name,STAKED); return(STAKED); }; @@ -30,7 +30,7 @@ int32_t STAKED_era(int timestamp) for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) { if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) - return(i); + return(i+1); } // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(0); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1a5095823..a8f1830ff 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -109,6 +109,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) return json; } + + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; From 1dfb6457a1b533335e84689dee9dd99c6ffb22ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 00:17:57 +0800 Subject: [PATCH 614/951] fix --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5b1bfe1ac..e58fe9be6 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -811,7 +811,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); if ( staked_era != lastStakedEra ) From f24352c4a21f58d96f7c4b08ee038fdcda1662b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 01:28:05 +0800 Subject: [PATCH 615/951] revert era to 1 --- src/notaries_staked.h | 2 +- src/rpcmisc.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index a931abdf7..0c2a7eb22 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542885514, 1604222222, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1604111111, 1604222222, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a8f1830ff..4160da730 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -109,7 +109,28 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) return json; } - +UniValue getnotarysendmany(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error("getnotarysendmany\n "); + // era + int32_t era = params[0].get_int() - 1; + if ( era < 0 || era > NUM_STAKED_ERAS ) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); + // Amount + CAmount nAmount = AmountFromValue(params[1]); + if (nAmount <= 0) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); + UniValue ret(UniValue::VOBJ) + for (int i = 0; i Date: Fri, 23 Nov 2018 01:29:52 +0800 Subject: [PATCH 616/951] fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 4160da730..a9ce7ffd8 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -121,7 +121,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) CAmount nAmount = AmountFromValue(params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); - UniValue ret(UniValue::VOBJ) + UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 02:32:25 +0800 Subject: [PATCH 617/951] try this --- src/notarisationdb.cpp | 1 + src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index f551edf3f..a4efa8b24 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -50,6 +50,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) // pass era slection off to notaries_staked.cpp file auth_STAKED = Choose_auth_STAKED(staked_era); } + printf("minsigs.%i era.%i authsize.%i\n",auth_STAKED.requiredSigs,staked_era,auth_STAKED.size); if (!CheckTxAuthority(tx, auth_STAKED)) continue; printf("Authorised notarisation data for %s \n",data.symbol); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index dc0ebd465..d4143fcfb 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -264,6 +264,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, { "control", "getiguanajson", &getiguanajson, true }, + { "control", "getnotarysendmany", &getnotarysendmany, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpcserver.h b/src/rpcserver.h index 2ae1e8de1..9ab033d12 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -325,6 +325,7 @@ extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); extern UniValue getiguanajson(const UniValue& params, bool fHelp); +extern UniValue getnotarysendmany(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); From eb533cf7d7975fea498d3dc6fc8c7d1fd653c67e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 02:42:57 +0800 Subject: [PATCH 618/951] fix? --- src/crosschain.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain.h b/src/crosschain.h index c186d5161..b59037cc8 100644 --- a/src/crosschain.h +++ b/src/crosschain.h @@ -9,8 +9,8 @@ const int CROSSCHAIN_STAKED = 3; typedef struct CrosschainAuthority { uint8_t notaries[64][33]; - size_t size; - size_t requiredSigs; + int8_t size; + int8_t requiredSigs; } CrosschainAuthority; int GetSymbolAuthority(const char* symbol); From 46f857e7300d349df264a3567557958d0f868c6e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:04:30 +0800 Subject: [PATCH 619/951] try --- src/crosschain_authority.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 8116b2887..c43639836 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -42,10 +42,14 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (!seen[i]) { if (memcmp(pk, auth.notaries[i], 33) == 0) { seen[i] = 1; + printf("seennotary..%i\n",i); goto found; + } else { + printf("notary.%i is not valid!\n",i); } } } + return false; found:; } From f6c1f9803821d0f911c95ae49bf0b05cf971b8c2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:09:15 +0800 Subject: [PATCH 620/951] fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a9ce7ffd8..d3dd9a569 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -111,7 +111,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany\n "); // era int32_t era = params[0].get_int() - 1; From 141cca7fa7de59c0298a3f40a6cfb8e95992021e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:33:04 +0800 Subject: [PATCH 621/951] try --- src/crosschain_authority.cpp | 2 +- src/rpcmisc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index c43639836..262a70c40 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -42,7 +42,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (!seen[i]) { if (memcmp(pk, auth.notaries[i], 33) == 0) { seen[i] = 1; - printf("seennotary..%i\n",i); + printf("seennotary.%i\n",i); goto found; } else { printf("notary.%i is not valid!\n",i); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index d3dd9a569..5deaf15c1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany\n "); // era - int32_t era = params[0].get_int() - 1; + int32_t era = (int)params[0] - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From d7d0047b8f4a4b1d0b777c1458eff885d1f6a1cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 03:58:04 +0800 Subject: [PATCH 622/951] try --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5deaf15c1..89c66355f 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany\n "); // era - int32_t era = (int)params[0] - 1; + int32_t era = params[0] - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From 84c5374aaa307feeb252829676cd372e51ef8019 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:03:27 +0800 Subject: [PATCH 623/951] try --- src/rpcmisc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 89c66355f..64537d401 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -112,13 +112,13 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 2) - throw runtime_error("getnotarysendmany\n "); + throw runtime_error("getnotarysendmany "); // era - int32_t era = params[0] - 1; + int32_t era = params[1].get_int() - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount - CAmount nAmount = AmountFromValue(params[1]); + CAmount nAmount = AmountFromValue(params[0]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); UniValue ret(UniValue::VOBJ); From 504d318eac432298d03ece964c9689271c9e67b8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:08:49 +0800 Subject: [PATCH 624/951] try --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 64537d401..0ffe4ecf6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era - int32_t era = params[1].get_int() - 1; + era = params[1].get_int() - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From a632f010dd202868d2f21eb89b7776848e28510f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:10:18 +0800 Subject: [PATCH 625/951] try --- src/rpcmisc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 0ffe4ecf6..f323a73ce 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,6 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era + int era = 1; era = params[1].get_int() - 1; if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); From 918ba2b923a812cd93a7a4b3caf630da6b5afc29 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:15:53 +0800 Subject: [PATCH 626/951] try --- src/rpcmisc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f323a73ce..003c39bde 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,8 +114,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era - int era = 1; - era = params[1].get_int() - 1; + int era = ValueFromAmount(AmountFromValue(params[1])); if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From 9168011a9a74ff5e174a57d9a786c8e5c64d5eed Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:18:14 +0800 Subject: [PATCH 627/951] fix --- src/rpcmisc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 003c39bde..91faf6221 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,7 +114,8 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("getnotarysendmany "); // era - int era = ValueFromAmount(AmountFromValue(params[1])); + int era = AmountFromValue(params[1]); + printf("%i\n",era ); if ( era < 0 || era > NUM_STAKED_ERAS ) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); // Amount From 85a7b3b92a327c4589b588ae7c3a6be12357af6e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:26:07 +0800 Subject: [PATCH 628/951] try --- src/rpcmisc.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 91faf6221..6413f4ee0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,16 @@ extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; +int32_t getera(int now) +{ + for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { + if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + era = i; + break; + } + } +} + UniValue getiguanajson(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -74,13 +84,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue notaries(UniValue::VARR); // get the current era, use local time for now. // should ideally take blocktime of last known block. - int now = time(NULL); int32_t era; - for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { - if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { - era = i; - break; - } - } + int now = time(NULL); + int32_t era = getera(now); // loop over seeds array and push back to json array for seeds for (int8_t i = 0; i < 8; i++) { @@ -111,13 +116,10 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 2) - throw runtime_error("getnotarysendmany "); + if (fHelp || params.size() != 1) + throw runtime_error("getnotarysendmany "); // era - int era = AmountFromValue(params[1]); - printf("%i\n",era ); - if ( era < 0 || era > NUM_STAKED_ERAS ) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid era"); + int32_t era = getera(time(NULL)); // Amount CAmount nAmount = AmountFromValue(params[0]); if (nAmount <= 0) From 8c8c1a5aeae33303146f630a49420acf45089409 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:27:18 +0800 Subject: [PATCH 629/951] fix --- src/rpcmisc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 6413f4ee0..bd05635f6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -68,8 +68,7 @@ int32_t getera(int now) { for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { - era = i; - break; + return(i); } } } From a89c137047fc4417c0331b74db6ce062d24067a8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 04:37:39 +0800 Subject: [PATCH 630/951] fix? --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index bd05635f6..063a71bed 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -126,7 +126,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 12:10:09 +0800 Subject: [PATCH 631/951] fix --- src/rpcmisc.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 063a71bed..5f1db9636 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,21 +115,32 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) - throw runtime_error("getnotarysendmany "); - // era - int32_t era = getera(time(NULL)); + if (fHelp || params.size() > 2) + throw runtime_error( + "getnotarysendmany ( era amount_to_send )\n" + "\nReturn a sendmany array for all notary address in defined era.\n" + ); + int era = 0; + if (params.size() > 0) { + era = params[0].get_int(); + } + if (era < 0 || era > NUM_STAKED_ERAS) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); + } // Amount - CAmount nAmount = AmountFromValue(params[0]); + if (params.size() > 1) + CAmount nAmount = AmountFromValue(params[1]); + if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 12:22:21 +0800 Subject: [PATCH 632/951] fix --- src/rpcmisc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5f1db9636..864b23aac 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -120,6 +120,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) "getnotarysendmany ( era amount_to_send )\n" "\nReturn a sendmany array for all notary address in defined era.\n" ); + // era int era = 0; if (params.size() > 0) { era = params[0].get_int(); @@ -128,8 +129,9 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); } // Amount + CAmount nAmount; if (params.size() > 1) - CAmount nAmount = AmountFromValue(params[1]); + nAmount = AmountFromValue(params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); From deab4769eec95eda79e826e89d9b8a8f94d89f42 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 12:35:11 +0800 Subject: [PATCH 633/951] try --- src/rpcmisc.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 864b23aac..bd1c4ade8 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,23 +115,15 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() > 2) + if (fHelp || params.size() != 1) throw runtime_error( - "getnotarysendmany ( era amount_to_send )\n" - "\nReturn a sendmany array for all notary address in defined era.\n" + "getnotarysendmany ( amount_to_send )\n" + "\nReturn a sendmany array for all notary address in current era.\n" ); // era - int era = 0; - if (params.size() > 0) { - era = params[0].get_int(); - } - if (era < 0 || era > NUM_STAKED_ERAS) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); - } + int era = getera(time(NULL)); // Amount - CAmount nAmount; - if (params.size() > 1) - nAmount = AmountFromValue(params[1]); + CAmount nAmount = AmountFromValue(params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); From 537d2f88216d3951b6f000750a9c45f71033d569 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 12:39:53 +0800 Subject: [PATCH 634/951] fix --- src/rpcmisc.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index bd1c4ade8..3583fe590 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,15 +115,23 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() > 3) throw runtime_error( - "getnotarysendmany ( amount_to_send )\n" - "\nReturn a sendmany array for all notary address in current era.\n" + "getnotarysendmany ( all era amount_to_send )\n" + "\nReturn a sendmany array for all notary address in defined era.\n" ); - // era - int era = getera(time(NULL)); + // era: + int era = 0; + if (params.size() > 0) { + era = params[1].get_int(); + } + if (era < 0 || era > NUM_STAKED_ERAS) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); + } // Amount - CAmount nAmount = AmountFromValue(params[1]); + CAmount nAmount; + if (params.size() > 1) + nAmount = AmountFromValue(params[2]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); From a959c865b824ecf46fbdd8364eb87444b499c5c4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 12:43:25 +0800 Subject: [PATCH 635/951] wtf?!?! --- src/rpcmisc.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 3583fe590..499eafea0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,26 +115,12 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - if (fHelp || params.size() > 3) - throw runtime_error( - "getnotarysendmany ( all era amount_to_send )\n" - "\nReturn a sendmany array for all notary address in defined era.\n" - ); - // era: - int era = 0; - if (params.size() > 0) { - era = params[1].get_int(); - } - if (era < 0 || era > NUM_STAKED_ERAS) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "era is not valid"); - } - // Amount - CAmount nAmount; - if (params.size() > 1) - nAmount = AmountFromValue(params[2]); - if (nAmount <= 0) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); + // era: + int era = getera(time(NULL)); + // Amount + CAmount nAmount = AmountFromValue(10); + UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 13:02:21 +0800 Subject: [PATCH 636/951] fix --- src/crosschain_authority.cpp | 2 +- src/rpcmisc.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 262a70c40..f7f51c8df 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -45,7 +45,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) printf("seennotary.%i\n",i); goto found; } else { - printf("notary.%i is not valid!\n",i); + //printf("notary.%i is not valid!\n",i); } } } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 499eafea0..98bcf70d1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -115,11 +115,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { - - // era: int era = getera(time(NULL)); - // Amount - CAmount nAmount = AmountFromValue(10); UniValue ret(UniValue::VOBJ); for (int i = 0; i Date: Fri, 23 Nov 2018 13:14:04 +0800 Subject: [PATCH 637/951] fix --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 98bcf70d1..9be0af7c0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -123,7 +123,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)notaries_STAKED[era][i][1]); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - ret.push_back(Pair(Raddress,(int)10); + ret.push_back(Pair(Raddress,(int)10)); } return ret; } From a8e89788c5869d0c61ec26a1dac31983a9294c71 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 15:17:02 +0800 Subject: [PATCH 638/951] change protocol version and ERA --- src/notaries_staked.h | 2 +- src/version.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 0c2a7eb22..9d0a3aae0 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1604111111, 1604222222, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1604222222, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = diff --git a/src/version.h b/src/version.h index aaa172403..633f2ec18 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170005; +static const int PROTOCOL_VERSION = 170006; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -19,7 +19,7 @@ static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION = 170002; -static const int STAKEDMIN_PEER_PROTO_VERSION = 170005; +static const int STAKEDMIN_PEER_PROTO_VERSION = 170006; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 4ef4377c8b3e8085381b7629ecd92592d88c7736 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 15:25:55 +0800 Subject: [PATCH 639/951] change CrisF pubkey --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 9d0a3aae0..82b226ee6 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -51,7 +51,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, //RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev From aeaab7fb86d53cafec8640ca74fb6f329e873ba4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 23 Nov 2018 22:39:57 +0800 Subject: [PATCH 640/951] fix dwy_merge for only 10ksat size p2pk --- 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 d6a06525d..a05eede52 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4473,7 +4473,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (nValue > maximum_utxo_size) { continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() == 35) { + if (out.tx->vout[out.i].scriptPubKey.size() == 35 && nValue == 10000) { continue; } } From cbc4bd2bacef68ffc19f1ae68633819707f454e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 24 Nov 2018 12:32:52 +0800 Subject: [PATCH 641/951] add smk again, wrong key somehow --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 82b226ee6..8b1a1e945 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -52,7 +52,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu - {"smk762", "0330e8fbdb6d560095d33da86a139c755b7896eb5b85239966fa7b235db16d4037" }, // RFB8zewwMNcLMPuQ84B6PofxJBBsuYxiN8 + {"smk762", "029f6c1f38c4d6825acb3b4b5147f7992e943b617cdaa0f4f5f36187e239d52d5a" }, // RPy6Xj2LWrxNoEW9YyREDgBZDZZ5qURXBU {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 From e341d1c1efc486d3350339409f4fad747563d741 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 24 Nov 2018 15:59:47 +0800 Subject: [PATCH 642/951] add kmdcrazy corret key --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 8b1a1e945..b407e6412 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -62,7 +62,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca + {"kmdkrazy", "02da444a2627d420f1f622fcdfb9bddb67d6d4241ad6b4d5054716ddbde8a25dfb" }, // RJPJBbHcm5mkAxhkkERHRfEE9Cvkr4Euoi {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q From bde984aee2fdfc09820a2cb0ebfb8dc6e2796f87 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 25 Nov 2018 00:16:00 +0800 Subject: [PATCH 643/951] jl77s peferct fix --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index cd415040a..c24ca2bde 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2017,6 +2017,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) bool IsInitialBlockDownload() { + return false; const CChainParams& chainParams = Params(); LOCK(cs_main); if (fImporting || fReindex) From 1c4dda372adf492da2988b846d5f91f2c7153162 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 25 Nov 2018 00:23:17 +0800 Subject: [PATCH 644/951] no boueno --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c24ca2bde..cd415040a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2017,7 +2017,6 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) bool IsInitialBlockDownload() { - return false; const CChainParams& chainParams = Params(); LOCK(cs_main); if (fImporting || fReindex) From 7b7271aa452943abe27fc21c2e1f99affa5c0e2d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 15:26:00 +0800 Subject: [PATCH 645/951] remove isinitialblockdl from tmpmempool and revert false as default --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cd415040a..36624e624 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4313,7 +4313,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C const uint256 &hash = tx.GetHash(); if ( tx.vjoinsplit.size() == 0 ) { transactionsToRemove.push_back(tx); - tmpmempool.addUnchecked(hash,e,!IsInitialBlockDownload()); + tmpmempool.addUnchecked(hash,e,false); } } BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { From f4ff5f49b53d0ce3b1d9eeb47a9deed2c5105fc1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 15:31:54 +0800 Subject: [PATCH 646/951] fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 36624e624..33bd98928 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4313,7 +4313,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C const uint256 &hash = tx.GetHash(); if ( tx.vjoinsplit.size() == 0 ) { transactionsToRemove.push_back(tx); - tmpmempool.addUnchecked(hash,e,false); + tmpmempool.addUnchecked(hash,e,true); } } BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { From 7399a87134480f12a04ff7ba33017ce5e9a53dac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 16:15:27 +0800 Subject: [PATCH 647/951] fix --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 33bd98928..2b6966659 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4374,6 +4374,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // here we add back all txs from the temp mempool to the main mempool. // which removes any tx locally that were invalid after the block arrives. int invalidtxs = 0; + LOCK(mempool.cs); BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { CTransaction tx = e.GetTx(); CValidationState state; bool fMissingInputs,fOverrideFees = false; From 7a25c614cf50353776e295be8a1583c0401f2734 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 20:52:50 +0800 Subject: [PATCH 648/951] speed up miner modifications? --- src/miner.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index aad8d0c44..fc0280868 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -105,6 +105,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #include "komodo_defs.h" +#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; @@ -214,7 +215,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { - int numNotaryVins = 0; + // TODO: It will be much faster here to just compare scriptpubkey! + CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; + if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { + if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) + fToCryptoAddress = true; + } BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -253,7 +259,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) int nConf = nHeight - coins->nHeight; - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) { uint256 hash; CTransaction tx1; CTxDestination address; if (GetTransaction(txin.prevout.hash,tx1,hash,false)) From f5746c6416a52e74f65ecfe93b61d8747774d50a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 20:55:46 +0800 Subject: [PATCH 649/951] debug print --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index fc0280868..0b38afa88 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -290,8 +290,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if (fNotarisation) + if (fNotarisation) { dPriority = 1e16; + fprintf(stderr, "Notarisation.%s set to maximum priority.\n",tx.hash.ToString().c_str()); + } if (porphan) { From c3e81dab26d099f080cea0286c288f8a437481c3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 20:58:12 +0800 Subject: [PATCH 650/951] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0b38afa88..012e89c95 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -292,7 +292,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if (fNotarisation) { dPriority = 1e16; - fprintf(stderr, "Notarisation.%s set to maximum priority.\n",tx.hash.ToString().c_str()); + fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); } if (porphan) From d1fa5c68b426ce4cee0fb2c353e71e6ca98cd4ad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 21:36:41 +0800 Subject: [PATCH 651/951] more debug --- src/miner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 012e89c95..3bbf928f4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -218,6 +218,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // TODO: It will be much faster here to just compare scriptpubkey! CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { + fprintf(stderr, "%s %s\n",CRYPTO777_KMDADDR, CBitcoinAddress(ToAddress).ToString().c_str()); if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) fToCryptoAddress = true; } @@ -262,6 +263,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) { uint256 hash; CTransaction tx1; CTxDestination address; + fprintf(stderr, "Checking vins for notarisation.\n"); if (GetTransaction(txin.prevout.hash,tx1,hash,false)) { if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { From ea8cf3fc1cb7d80ec5807b442a8d9fe27353df5b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 21:46:41 +0800 Subject: [PATCH 652/951] try again --- src/miner.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3bbf928f4..ef826d05d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -218,7 +218,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) // TODO: It will be much faster here to just compare scriptpubkey! CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { - fprintf(stderr, "%s %s\n",CRYPTO777_KMDADDR, CBitcoinAddress(ToAddress).ToString().c_str()); if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) fToCryptoAddress = true; } @@ -263,7 +262,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) { uint256 hash; CTransaction tx1; CTxDestination address; - fprintf(stderr, "Checking vins for notarisation.\n"); if (GetTransaction(txin.prevout.hash,tx1,hash,false)) { if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { @@ -276,6 +274,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } dPriority += (double)nValueIn * nConf; } + fprintf(stderr, "minsigs.%i vs numsigs.%i\n",(NUM_NOTARIES/5),numNotaryVins); if ( numNotaryVins > NUM_NOTARIES / 5 ) fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); From 9a72f91980227622cf7c508391d73ac25d469e56 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 28 Nov 2018 21:50:30 +0800 Subject: [PATCH 653/951] fix! --- src/miner.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ef826d05d..7d15c3003 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -274,8 +274,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) } dPriority += (double)nValueIn * nConf; } - fprintf(stderr, "minsigs.%i vs numsigs.%i\n",(NUM_NOTARIES/5),numNotaryVins); - if ( numNotaryVins > NUM_NOTARIES / 5 ) + if ( numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); } From 0b6970c798ac63e02dbf380f1f2f201cb4caec02 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 09:35:50 +0800 Subject: [PATCH 654/951] change min sigs to +1 --- src/komodo.h | 4 ++++ src/miner.cpp | 2 +- src/rpcmisc.cpp | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e58fe9be6..d5f5817a1 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -708,6 +708,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr 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); + //if ( is_STAKED != 0 ) + //{ + // HERE we should add the notarisation to libscotts DB. + //} if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 7d15c3003..7370beb64 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -215,7 +215,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { - // TODO: It will be much faster here to just compare scriptpubkey! + // TODO: It will be much faster here to just compare scriptpubkey to the crypto pubkey! CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 9be0af7c0..4f436f41a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -82,7 +82,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue seeds(UniValue::VARR); UniValue notaries(UniValue::VARR); // get the current era, use local time for now. - // should ideally take blocktime of last known block. + // should ideally take blocktime of last known block? int now = time(NULL); int32_t era = getera(now); @@ -98,10 +98,10 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) notaries.push_back(notary); } - // get the min sigs + // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. int minsigs; if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) - minsigs = (num_notaries_STAKED[era] + 4) / 5; + minsigs = (num_notaries_STAKED[era] / 5) + 1; else minsigs = overrideMinSigs; From d54d5424585c2b91ebf166f9a302eb89d37a7f73 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 22:33:01 +0800 Subject: [PATCH 655/951] remove streamer --- src/komodo_bitcoind.h | 52 ++++------ src/komodo_gateway.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 14 +-- src/main.cpp | 22 +--- src/miner.cpp | 40 +------- src/pow.cpp | 4 - src/rpcblockchain.cpp | 212 --------------------------------------- src/rpcserver.cpp | 1 - src/rpcserver.h | 1 - src/wallet/rpcwallet.cpp | 1 - 11 files changed, 27 insertions(+), 324 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d0d6a7632..c00d33216 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1105,7 +1105,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ 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] */ -extern int32_t ASSETCHAINS_STREAM; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1113,29 +1112,26 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); - if ( ASSETCHAINS_STREAM == 0 ) + if ( ASSETCHAINS_FOUNDERS != 0 ) { - if ( ASSETCHAINS_FOUNDERS != 0 ) + nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); + //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); + n = pblock->vtx[0].vout.size(); + for (j=0; jvtx[0].vout[j].nValue; + } + else + { + for (i=0; ivtx[0].vout.size(); + n = pblock->vtx[i].vout.size(); for (j=0; jvtx[0].vout[j].nValue; - } - else - { - for (i=0; ivtx[i].vout.size(); - for (j=0; jvtx[i].vout[j].nValue; - } + //fprintf(stderr,"(%d %.8f).%d ",i,dstr(block.vtx[i].vout[j].nValue),j); + if ( i != 0 || j != 1 ) + total += pblock->vtx[i].vout[j].nValue; } } } @@ -1483,7 +1479,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; - if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock,height); //fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); @@ -1632,20 +1628,6 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); } - if ( ASSETCHAINS_STREAM != 0 && height > 128 ) - { - int lasttx = ( pblock->vtx.size() -1 ); - if ( lasttx == 0 ) - return(-1); - uint256 hash; CTransaction tx; - if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false)) - { - script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) { - 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 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ed05897d..3845030ca 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -744,7 +744,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { checktoshis = 0; - if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && height > 1 ) + if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0953713b0..dda78a6e1 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES,ASSETCHAINS_FOUNDERS; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 80581a1f8..1a6757b49 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1573,12 +1573,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_STREAM = GetArg("-ac_stream",0); - if ( ASSETCHAINS_STREAM != 0 && ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_PRIVATE != 0 )) { - printf("ASSETCHAINS_STREAM cannot be used with:\n ASSETCHAINS_COMMISSION \n ASSETCHAINS_ENDSUBSIDY\n ASSETCHAINS_REWARD\n ASSETCHAINS_HALVING\n ASSETCHAINS_DECAY\n ASSETCHAINS_PRIVATE\n"); - exit(0); - } if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) @@ -1601,11 +1596,6 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } - if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 && ASSETCHAINS_STREAM != 0 ) - { - printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! \n"); - exit(0); - } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) @@ -1620,10 +1610,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else if ( ASSETCHAINS_STREAM == 0 ) + else { ASSETCHAINS_OVERRIDE_PUBKEY.clear(); - printf("-ac_perc or -ac_stream must be set with -ac_pubkey\n"); + printf("-ac_perc must be set with -ac_pubkey\n"); } } } diff --git a/src/main.cpp b/src/main.cpp index 2b6966659..26b5e8f5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1918,7 +1918,6 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) //uint64_t komodo_moneysupply(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint32_t ASSETCHAINS_MAGIC; -extern int32_t ASSETCHAINS_STREAM; extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; @@ -1947,12 +1946,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) else if ( ASSETCHAINS_ENDSUBSIDY == 0 || nHeight < ASSETCHAINS_ENDSUBSIDY ) { if ( ASSETCHAINS_REWARD == 0 ) - { - if ( ASSETCHAINS_STREAM != 0 && nHeight > 128 ) - return(0); - else - return(10000); - } + return(10000); else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY ) return(0); else @@ -3020,18 +3014,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( ASSETCHAINS_STREAM != 0 ) - { - if ( block.vtx.size() == 1 && block.vtx[0].vout.size() == 2 && pindex->nHeight > ASSETCHAINS_MINHEIGHT) - { - return state.DoS(100, error("ConnectBlock(): There are no TX in this block, it is invalid!"), - REJECT_INVALID, "bad-block-no-transactions"); - } - } - } - if (fAddressIndex || fSpentIndex) { for (size_t j = 0; j < tx.vin.size(); j++) { @@ -3181,7 +3163,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && + if ( ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->nHeight)) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 7370beb64..709ba6a65 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -107,7 +107,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" #define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; @@ -467,7 +467,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -544,26 +544,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) return(0); } } - else if ( ASSETCHAINS_STREAM != 0 && ASSETCHAINS_SYMBOL[0] != 0 && nHeight > 128 ) - { - CMutableTransaction txStream = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1); - if ( komodo_notaryvin(txStream,ASSETCHAINS_OVERRIDE_PUBKEY33) > 0 ) - { - CAmount txfees = 10000; - pblock->vtx.push_back(txStream); - pblocktemplate->vTxFees.push_back(txfees); - pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStream)); - nFees += txfees; - pblocktemplate->vTxFees[0] = -nFees; - //*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; - //fprintf(stderr,"added notaryvin\n"); - } - else - { - fprintf(stderr,"error adding streamer vin, the chain broke! \n"); - return(0); - } - } else if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (ASSETCHAINS_SYMBOL[0] != 0 || IS_KOMODO_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; @@ -690,13 +670,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); } } - else if ( ASSETCHAINS_STREAM != 0 ) - { - if ( nHeight < 128 ) - scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; - else - scriptPubKey = CScript() << ParseHex(CRYPTO777_PUBSECPSTR) << OP_CHECKSIG; - } else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); @@ -926,19 +899,14 @@ void static BitcoinMiner() { if ( ASSETCHAINS_REWARD == 0 ) { - int minvoutsize = 1; - int minvtxsize = 1; - if ( ASSETCHAINS_STREAM != 0 ) - minvoutsize = 2; - minvtxsize = 2; - if ( pblock->vtx.size() == minvtxsize && pblock->vtx[0].vout.size() == minvoutsize && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else fprintf(stderr,"%s tx.%d vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx.size(),(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); diff --git a/src/pow.cpp b/src/pow.cpp index 07776e273..1291e445e 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -20,13 +20,9 @@ #include "librustzcash.h" #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); -extern int32_t ASSETCHAINS_STREAM; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if ( ASSETCHAINS_STREAM == 2 ) - return 537857807; - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block if (pindexLast == NULL ) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index abc8864bc..f078094ff 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -261,218 +261,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) return result; } -unsigned char hexval(unsigned char c) -{ - if ('0' <= c && c <= '9') - return c - '0'; - else if ('a' <= c && c <= 'f') - return c - 'a' + 10; - else if ('A' <= c && c <= 'F') - return c - 'A' + 10; - else abort(); -} - -void hex2ascii(const string& in, string& out) -{ - out.clear(); - out.reserve(in.length() / 2); - for (string::const_iterator p = in.begin(); p != in.end(); p++) - { - unsigned char c = hexval(*p); - p++; - if (p == in.end()) break; // incomplete last digit - should report error - c = (c << 4) + hexval(*p); // + takes precedence over << - out.push_back(c); - } -} - -UniValue getdatafromblock(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 1 || params.size() > 2) - throw runtime_error( - "getdatafromblock \"hash|height\" true/false\n" - "\nReturns all the data sent via streamer in block if there was any data in it.\n" - "\nArguments:\n" - "1. \"hash|height\" (string, required) The block hash or height\n" - "2. \"true/false\" (bool, optional) if false do not return the actual data. Default true.\n" - "\nResult (for verbose = true):\n" - "{\n" - " \"streamid\" : \"string\", (string) the name of the stream.\n" - " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" - " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" - " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" - " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" - " \"data\" : \"xxxx\", (string) A hex string containing all the data chunks in this block.\n" - "}\n" - "\nResult (for verbose=false):\n" - " \"streamid\" : \"string\", (string) the name of the stream.\n" - " \"firsttxid\" : \"hash\", (string) the first transaction of the stream.\n" - " \"firstblockheight\" : \"n\", (numeric) the block the stream starts in.\n" - " \"firstdeqid\" : n, (numeric) The sequence id of the first data chunk in this block\n" - " \"lastseqid\" : n, (numeric) The sequence id of the last data chunk in this block\n" - + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09 false\"") - + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") - + HelpExampleCli("getblock", "12800") - + HelpExampleRpc("getblock", "12800 false") - ); - - LOCK(cs_main); - - std::string strHash = params[0].get_str(); - bool fVerbose = true; - if (params.size() > 1) { - std::string verboseflag = params[1].get_str(); - if ( verboseflag == "false" ) - fVerbose = false; - } - - // If height is supplied, find the hash - if (strHash.size() < (2 * sizeof(uint256))) { - // std::stoi allows characters, whereas we want to be strict - regex r("[[:digit:]]+"); - if (!regex_match(strHash, r)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); - } - - int nHeight = -1; - try { - nHeight = std::stoi(strHash); - } - catch (const std::exception &e) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); - } - - if (nHeight < 0 || nHeight > chainActive.Height()) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - } - strHash = chainActive[nHeight]->GetBlockHash().GetHex(); - } - - uint256 hash(uint256S(strHash)); - - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlock block; - CBlockIndex* pblockindex = mapBlockIndex[hash]; - - if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - - if(!ReadBlockFromDisk(block, pblockindex,1)) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - - UniValue result(UniValue::VOBJ); - int firstseqid = 0; - int lastseqid = 0; - int i = 0; - int did1 = 0; - int skippedtxs = 0; - int failed = 0; - int getfirstblock = 0; - static std::string streamid,firsttxid; - static int firsttxnHeight; - std::string blockdata; - fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size()); - // Iif block tx size is > 2 then we can do this - if ( block.vtx.size() > 2 ) - { - BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - // ignore first and last TX and any TX that does not have 3 vouts. - if ( (i == 0) || (i == (block.vtx.size() -1)) || (tx.vout.size() != 3) ) - { - fprintf(stderr, "skipped tx number: %d\n",i); - skippedtxs = skippedtxs + 1; - } else { - std::string opretstr = HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end()); - // scriptPubKey is longer than 81, should mean its an OP_RETURN, maybe also check vout == 0 ? - if ( opretstr.size() > 81 ) { - std::string idstr = opretstr.substr (8,64); // stream ID or txid - std::string seqidstr = opretstr.substr (72,8); // sequence ID - std::string data = opretstr.substr (80); // data chunk - unsigned int seqid; - std::stringstream ss; - ss << std::hex << seqidstr; - ss >> seqid; - if ( seqid == 1 ) { - streamid = idstr; - getfirstblock = 1; - } else if ( seqid == 2 ) { - firsttxid = idstr; - } else if (firsttxid.empty()) { - firsttxid.append(idstr); - } else if ( firsttxid != idstr ) { - printf("firsttxid.%s idstr.%s change firsttxid and wipe streamid?\n",firsttxid.c_str(),idstr.c_str()); - firsttxid.clear(); - firsttxid.append(idstr); - streamid.clear(); - firsttxnHeight = 0; - } - if ( seqid == (lastseqid + 1) || did1 == 0 ) { - blockdata.append(data); - } else { - result.push_back(Pair("error","chunck out of order or missing in this block!")); - result.push_back(Pair("lastvalidseqid", (int)lastseqid)); - break; - } - if ( did1 == 0 ) { - firstseqid = seqid; - did1 = 1; - } - lastseqid = seqid; - } else { - skippedtxs = skippedtxs + 1; - fprintf(stderr, "skipped tx number: %d\n",i); - } - // function here to extract seqid from first and last TX - // we an push the data or not depending on input from RPC. - } - i = i + 1; - } - if (streamid.empty() || getfirstblock == 1) { - if ( lastseqid == 1) { - firsttxid = block.vtx[1].GetHash().GetHex(); - } - uint256 hash; CTransaction firsttx; - uint256 firsttxid_256(uint256S(firsttxid)); - if (GetTransaction(firsttxid_256,firsttx,hash,false)) { - if ( streamid.empty() ) { - std::string firststreamid = HexStr(firsttx.vout[2].scriptPubKey.begin(), firsttx.vout[2].scriptPubKey.end()); - streamid.append(firststreamid.substr (8,64)); - } - printf("first stream id changed to: %s\n", streamid.c_str()); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - printf("found block height: %d\n",pindex->nHeight); - if (chainActive.Contains(pindex)) { - firsttxnHeight = pindex->nHeight; - } - } - } - } - } else { - failed = 1; - } - - if ( failed == 1 || skippedtxs == i ) { - result.push_back(Pair("error","there is no data in this block.")); - } else { - std::string decodedstreamid; - hex2ascii(streamid, decodedstreamid); - result.push_back(Pair("streamid", decodedstreamid.c_str())); - result.push_back(Pair("firsttxid", firsttxid)); - result.push_back(Pair("firstblockheight", (int)firsttxnHeight)); - result.push_back(Pair("firstseqid", (int)firstseqid)); - result.push_back(Pair("lastseqid", (int)lastseqid)); - if (fVerbose == true) { - result.push_back(Pair("data", blockdata)); - } - } - return result; -} - UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index d4143fcfb..98417e201 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -287,7 +287,6 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "getbestblockhash", &getbestblockhash, true }, { "blockchain", "getblockcount", &getblockcount, true }, { "blockchain", "getblock", &getblock, true }, - { "blockchain", "getdatafromblock", &getdatafromblock, true }, { "blockchain", "getblockdeltas", &getblockdeltas, false }, { "blockchain", "getblockhashes", &getblockhashes, true }, { "blockchain", "getblockhash", &getblockhash, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 9ab033d12..851c39d42 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -368,7 +368,6 @@ extern UniValue getblockdeltas(const UniValue& params, bool fHelp); extern UniValue getblockhash(const UniValue& params, bool fHelp); extern UniValue getblockheader(const UniValue& params, bool fHelp); extern UniValue getblock(const UniValue& params, bool fHelp); -extern UniValue getdatafromblock(const UniValue& params, bool fHelp); extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp); extern UniValue gettxout(const UniValue& params, bool fHelp); extern UniValue verifychain(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a05eede52..5e24f1530 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -46,7 +46,6 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; -extern int32_t ASSETCHAINS_STREAM; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern uint8_t ASSETCHAINS_PRIVATE; extern int32_t USE_EXTERNAL_PUBKEY; From 5dead9f36b8ea0cd8b79d5a31d929feab225caaa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 22:37:23 +0800 Subject: [PATCH 656/951] fix --- src/komodo_bitcoind.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c00d33216..124c8f2b2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1135,10 +1135,6 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } } } - else - { - commission = 10000; - } return(commission); } From aba30935272dc1215f52ba14808cbcd42ac98721 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:36:51 +0800 Subject: [PATCH 657/951] try fix --- src/crosschain.cpp | 2 +- src/crosschain_authority.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index ff143da2c..fbd6b8f1a 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -284,7 +284,7 @@ bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom) return nota.second.MoMoM == momom; }; - return (bool) ScanNotarisationsFromHeight(block.nHeight-100, checkMoMoM, nota); + return (bool) ScanNotarisationsFromHeight(block.GetHeight()-100, checkMoMoM, nota); } diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index f7f51c8df..7aeb27f01 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = spk.data(); + const unsigned char *pk = spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From 598ccdb0900514850bc71a3f7b79beaac30b2f72 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:39:57 +0800 Subject: [PATCH 658/951] fix --- src/crosschain_authority.cpp | 2 +- src/komodo_globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 7aeb27f01..3fbc39b42 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = spk[0]; + const unsigned char *pk = (char *)spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a09d81e4e..c0de313ab 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; bool VERUS_MINTBLOCKS; From d2b899687e374bd25ce2ca9df8fed4016ef734a1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:41:15 +0800 Subject: [PATCH 659/951] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 3fbc39b42..af462731f 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = (char *)spk[0]; + const unsigned char *pk = (char *)&spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From ab2a8e53ca0ddf0c0f4ff427e32b4b60e2e6e47f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:43:59 +0800 Subject: [PATCH 660/951] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index af462731f..928f6ed64 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - const unsigned char *pk = (char *)&spk[0]; + char *pk = *spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From 88da77886c0c231af8d36965a6902db43553395b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:45:42 +0800 Subject: [PATCH 661/951] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 928f6ed64..551c322fe 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - char *pk = *spk[0]; + unsigned char *pk = *spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From be1b9071a1c1eae51058dddebc051a8a75afc78e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:46:34 +0800 Subject: [PATCH 662/951] try --- src/crosschain_authority.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index 551c322fe..b4379c010 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -33,7 +33,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (tx.vout.size() < txIn.prevout.n) return false; CScript spk = tx.vout[txIn.prevout.n].scriptPubKey; if (spk.size() != 35) return false; - unsigned char *pk = *spk[0]; + const unsigned char *pk = &spk[0]; if (pk++[0] != 33) return false; if (pk[33] != OP_CHECKSIG) return false; From c8e652c452504de65333246368caebe5d190ab3e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:50:38 +0800 Subject: [PATCH 663/951] fix --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 35b9b0120..edc0ba40c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -277,7 +277,7 @@ libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: zcashd libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER -libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSEVER +libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSERVER libbitcoin_server_a_SOURCES = \ sendalert.cpp \ addrman.cpp \ From 43a6b39140840314678ac07720f6a1c400d3f890 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:55:14 +0800 Subject: [PATCH 664/951] try --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 31cfd9a3d..e49ffadcc 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -75,7 +75,7 @@ public: #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" -#include "notaries_staked.cpp" +//#include "notaries_staked.cpp" From 104f60f0949fbe5132330910bc013f6890b68139 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:56:28 +0800 Subject: [PATCH 665/951] uh --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e49ffadcc..31cfd9a3d 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -75,7 +75,7 @@ public: #include "komodo_utils.h" #include "komodo_cJSON.c" #include "komodo_notary.h" -//#include "notaries_staked.cpp" +#include "notaries_staked.cpp" From 95fbd857070b9a3688d28915f35b0362df6e98b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 29 Nov 2018 23:59:48 +0800 Subject: [PATCH 666/951] try --- src/bitcoin-cli.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 31cfd9a3d..488516abb 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -74,8 +74,8 @@ public: #include "komodo_globals.h" #include "komodo_utils.h" #include "komodo_cJSON.c" -#include "komodo_notary.h" -#include "notaries_staked.cpp" +//#include "komodo_notary.h" +//#include "notaries_staked.cpp" From 3a55d61fb6f1b7dbdbd34e37ebbbc54b3b794b1f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:01:24 +0800 Subject: [PATCH 667/951] try --- src/bitcoin-cli.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 488516abb..e6e7819f5 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -72,8 +72,8 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" +//#include "komodo_utils.h" +//#include "komodo_cJSON.c" //#include "komodo_notary.h" //#include "notaries_staked.cpp" From d56e1595668aca0ff17031b821208d7fafa8b5d6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:14:53 +0800 Subject: [PATCH 668/951] y --- src/bitcoin-cli.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e6e7819f5..c06b24693 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -72,10 +72,10 @@ public: #include "komodo_structs.h" #include "komodo_globals.h" -//#include "komodo_utils.h" -//#include "komodo_cJSON.c" -//#include "komodo_notary.h" -//#include "notaries_staked.cpp" +#include "komodo_utils.h" +#include "komodo_cJSON.c" +#include "komodo_notary.h" +#include "notaries_staked.h" From 6f16da8472e827faad938b312a1c65e7ec3af4bb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:15:59 +0800 Subject: [PATCH 669/951] y --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index c06b24693..4731fd9a2 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -76,6 +76,7 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.h" +#include "notaries_staked.cpp" From 5552614eeac670242511ce1447d7a6024abd7e22 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:25:25 +0800 Subject: [PATCH 670/951] try --- src/coins.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coins.h b/src/coins.h index f35af02f0..62943eb83 100644 --- a/src/coins.h +++ b/src/coins.h @@ -26,7 +26,7 @@ #include "zcash/IncrementalMerkleTree.hpp" #include "veruslaunch.h" -/** +/** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs * * Serialized format: @@ -428,10 +428,10 @@ public: class CCoinsViewCache; -/** +/** * A reference to a mutable cache entry. Encapsulating it allows us to run * cleanup code after the modification is finished, and keeping track of - * concurrent modifications. + * concurrent modifications. */ class CCoinsModifier { @@ -456,6 +456,7 @@ class CTransactionExceptionData CTransactionExceptionData() : scriptPubKey(), voutMask() {} }; +#ifdef SERVER class CLaunchMap { public: @@ -478,6 +479,7 @@ class CLaunchMap } }; static CLaunchMap launchMap = CLaunchMap(); +#endif /** CCoinsView that adds a memory cache for transactions to another CCoinsView */ class CCoinsViewCache : public CCoinsViewBacked @@ -488,7 +490,7 @@ protected: /** * Make mutable so that we can "fill the cache" even from Get-methods - * declared as "const". + * declared as "const". */ mutable uint256 hashBlock; mutable CCoinsMap cacheCoins; @@ -564,7 +566,7 @@ public: //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** + /** * Amount of bitcoins coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. From caad5eaee1856469ae75fa019b2a2821b5b07da0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:32:20 +0800 Subject: [PATCH 671/951] fix --- src/coins.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coins.h b/src/coins.h index 62943eb83..4ef6ad29f 100644 --- a/src/coins.h +++ b/src/coins.h @@ -456,7 +456,6 @@ class CTransactionExceptionData CTransactionExceptionData() : scriptPubKey(), voutMask() {} }; -#ifdef SERVER class CLaunchMap { public: @@ -479,7 +478,6 @@ class CLaunchMap } }; static CLaunchMap launchMap = CLaunchMap(); -#endif /** CCoinsView that adds a memory cache for transactions to another CCoinsView */ class CCoinsViewCache : public CCoinsViewBacked From a4e70bd4644bbad5e31692408a3f8d83e383fbbe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 00:48:04 +0800 Subject: [PATCH 672/951] try reverse --- src/Makefile.am | 10 +++++----- src/notaries_staked.cpp | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index edc0ba40c..daced98c8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -276,8 +276,8 @@ obj/build.h: FORCE libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: zcashd -libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER -libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSERVER +libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) +libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_server_a_SOURCES = \ sendalert.cpp \ addrman.cpp \ @@ -581,9 +581,9 @@ endif # bitcoin-cli binary # komodo_cli_SOURCES = bitcoin-cli.cpp -komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -DCLI +komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DCLI +komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -DCLI # wallet-utility binary # if ENABLE_WALLET diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index d29d5dfb2..e69a43397 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -36,7 +36,11 @@ int32_t STAKED_era(int timestamp) return(0); }; -#ifdef SERVER +#ifdef CLI +int8_t updateStakedNotary() { + return(-1); +} +#else int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; @@ -46,10 +50,6 @@ int8_t updateStakedNotary() { NOTARY_ADDRESS.assign(Raddress); return(StakedNotaryID(notaryname,Raddress)); } -#else -int8_t updateStakedNotary() { - return(-1); -} #endif int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { @@ -150,24 +150,24 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { if ( pubkeys[0][0] == 0 ) { // null pubkeys, era 0. -#ifdef SERVER pthread_mutex_lock(&staked_mutex); memset(NOTARYADDRS,0,sizeof(NOTARYADDRS)); NUM_NOTARIES = 0; pthread_mutex_unlock(&staked_mutex); -#endif } else { // staked era is set. -#ifdef SERVER pthread_mutex_lock(&staked_mutex); for (int i = 0; i Date: Fri, 30 Nov 2018 00:55:05 +0800 Subject: [PATCH 673/951] wtrf --- src/bitcoin-cli.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 4731fd9a2..e123e536b 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -69,14 +69,14 @@ public: #include "uint256.h" #include "arith_uint256.h" -#include "komodo_structs.h" +//#include "komodo_structs.h" -#include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" -#include "komodo_notary.h" -#include "notaries_staked.h" -#include "notaries_staked.cpp" +//#include "komodo_globals.h" +//#include "komodo_utils.h" +//#include "komodo_cJSON.c" +//#include "komodo_notary.h" +//#include "notaries_staked.h" +//#include "notaries_staked.cpp" @@ -104,7 +104,7 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - komodo_args(argv[0]); + //komodo_args(argv[0]); if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { From 2afd221d79dbcc7308cc0b531a9e1429fb23e351 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:05:05 +0800 Subject: [PATCH 674/951] really --- src/bitcoin-cli.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e123e536b..d30d75d38 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -65,19 +65,19 @@ public: }; +#ifdef FROM_CLI #define FROM_CLI #include "uint256.h" #include "arith_uint256.h" -//#include "komodo_structs.h" - -//#include "komodo_globals.h" -//#include "komodo_utils.h" -//#include "komodo_cJSON.c" -//#include "komodo_notary.h" -//#include "notaries_staked.h" -//#include "notaries_staked.cpp" +#include "komodo_structs.h" +#include "komodo_globals.h" +#include "komodo_utils.h" +#include "komodo_cJSON.c" +#include "komodo_notary.h" +#include "notaries_staked.cpp" +#endif void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) @@ -104,7 +104,7 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - //komodo_args(argv[0]); + komodo_args(argv[0]); if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { From 7ca059a0fbdd453d80913c809c2ba5d2cbe59a75 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:31:00 +0800 Subject: [PATCH 675/951] last attempt --- src/bitcoin-cli.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index d30d75d38..e4357dbfa 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -17,6 +17,8 @@ #include #include #include "support/events.h" +uint16_t BITCOIND_RPCPORT = 7771; +char ASSETCHAINS_SYMBOL[65]; #include @@ -65,7 +67,7 @@ public: }; -#ifdef FROM_CLI +/* #define FROM_CLI #include "uint256.h" #include "arith_uint256.h" @@ -77,7 +79,6 @@ public: #include "komodo_cJSON.c" #include "komodo_notary.h" #include "notaries_staked.cpp" -#endif void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) @@ -89,6 +90,7 @@ uint32_t komodo_heightstamp(int32_t height) { return(0); } +*/ // // This function returns either one of EXIT_ codes when it's expected to stop the process or @@ -104,7 +106,12 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - komodo_args(argv[0]); + //komodo_args(argv[0]); + std:string name; + name = GetArg("-ac_name",""); + if ( !name.empty() ) + strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); + if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { @@ -218,7 +225,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) { std::string host = GetArg("-rpcconnect", "127.0.0.1"); int port = GetArg("-rpcport", BaseParams().RPCPort()); - BITCOIND_RPCPORT = port; + //BITCOIND_RPCPORT = port; // Obtain event base raii_event_base base = obtain_event_base(); From a4313d45366b97838d9fbc7f6e0649e61a9601ad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:53:45 +0800 Subject: [PATCH 676/951] clean up --- src/Makefile.am | 6 +++--- src/bitcoin-cli.cpp | 28 +--------------------------- src/notaries_staked.cpp | 10 ---------- 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index daced98c8..1eada2c1d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -581,9 +581,9 @@ endif # bitcoin-cli binary # komodo_cli_SOURCES = bitcoin-cli.cpp -komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -DCLI -komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DCLI -komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -DCLI +komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) +komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) # wallet-utility binary # if ENABLE_WALLET diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e4357dbfa..f8f0fe002 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -67,31 +67,6 @@ public: }; -/* -#define FROM_CLI -#include "uint256.h" -#include "arith_uint256.h" - -#include "komodo_structs.h" - -#include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" -#include "komodo_notary.h" -#include "notaries_staked.cpp" - - -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) -{ - -} - -uint32_t komodo_heightstamp(int32_t height) -{ - return(0); -} -*/ - // // This function returns either one of EXIT_ codes when it's expected to stop the process or // CONTINUE_EXECUTION when it's expected to continue further. @@ -106,7 +81,6 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - //komodo_args(argv[0]); std:string name; name = GetArg("-ac_name",""); if ( !name.empty() ) @@ -225,7 +199,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) { std::string host = GetArg("-rpcconnect", "127.0.0.1"); int port = GetArg("-rpcport", BaseParams().RPCPort()); - //BITCOIND_RPCPORT = port; + BITCOIND_RPCPORT = port; // Obtain event base raii_event_base base = obtain_event_base(); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e69a43397..ba9a88343 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -36,11 +36,6 @@ int32_t STAKED_era(int timestamp) return(0); }; -#ifdef CLI -int8_t updateStakedNotary() { - return(-1); -} -#else int8_t updateStakedNotary() { std::string notaryname; char Raddress[18]; uint8_t pubkey33[33]; @@ -50,7 +45,6 @@ int8_t updateStakedNotary() { NOTARY_ADDRESS.assign(Raddress); return(StakedNotaryID(notaryname,Raddress)); } -#endif int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { if ( STAKED_ERA != 0 ) @@ -160,12 +154,8 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { // staked era is set. pthread_mutex_lock(&staked_mutex); for (int i = 0; i Date: Fri, 30 Nov 2018 19:19:58 +0800 Subject: [PATCH 677/951] try --- src/bitcoin-cli.cpp | 2 +- src/main.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f8f0fe002..f632c8827 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -80,7 +80,7 @@ static int AppInitRPC(int argc, char* argv[]) // // Parameters // - ParseParameters(argc, argv); + ParseParameters(argc, lolargv); std:string name; name = GetArg("-ac_name",""); if ( !name.empty() ) diff --git a/src/main.cpp b/src/main.cpp index 0404df255..06c564f7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6556,7 +6556,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } -//fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); + fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); if (strCommand == "version") { @@ -6572,12 +6572,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; + fprintf(stderr, "version.%i\n",pfrom->nVersion); int nVersion; // use temporary for version, don't set version number until validated as connected vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) nVersion = 300; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { + fprintf(stderr, "Is Staked!\n"); if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version @@ -6587,8 +6589,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - } else + } + else { + fprintf(stderr, "Is not staked!\n"); if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version From f74593d621328048ff2e0b7f614e669584997bad Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 19:22:49 +0800 Subject: [PATCH 678/951] go --- src/bitcoin-cli.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index f632c8827..f8f0fe002 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -80,7 +80,7 @@ static int AppInitRPC(int argc, char* argv[]) // // Parameters // - ParseParameters(argc, lolargv); + ParseParameters(argc, argv); std:string name; name = GetArg("-ac_name",""); if ( !name.empty() ) From fd988f01f14eb3c625b906d3484b600360655a85 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 19:30:09 +0800 Subject: [PATCH 679/951] try fix --- src/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 06c564f7f..53265e7e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6579,8 +6579,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, nVersion = 300; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { - fprintf(stderr, "Is Staked!\n"); - if (pfrom->nVersion < STAKEDMIN_PEER_PROTO_VERSION) + if (nVersion < STAKEDMIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); @@ -6592,8 +6591,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } else { - fprintf(stderr, "Is not staked!\n"); - if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + if (nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); From 7644808ff16e50f954914d95ca333a375dbf7732 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 21:21:08 +0800 Subject: [PATCH 680/951] try --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 53265e7e3..7a81501e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6556,7 +6556,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } - fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); + //fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); if (strCommand == "version") { @@ -6572,7 +6572,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; - fprintf(stderr, "version.%i\n",pfrom->nVersion); int nVersion; // use temporary for version, don't set version number until validated as connected vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) From a089187c442bc897ae1f672fc2d1de5cc0b6a72f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 12:02:09 +0800 Subject: [PATCH 681/951] attempt wallet fix for empty vin issue --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 96ec88e6e..91d3e6d56 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1211,6 +1211,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) return false; + if ( tx.vin.empty() ) + return false; bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); From 0fc3fd3de9876e1280b97a4fc0dfe14176eafaba Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 12:18:44 +0800 Subject: [PATCH 682/951] fix getblocktemplate --- src/rpc/mining.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index aed10944c..e4a1dcd4a 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -606,9 +606,13 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } + else + { + strMode = "template"; + } - if (strMode != "template") - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + //if (strMode != "template") + // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); bool fvNodesEmpty; { From 905a829964f30925399dc0604668fbe3f23f3389 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 14:08:51 +0800 Subject: [PATCH 683/951] p --- src/rpc/mining.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index e4a1dcd4a..25b75c301 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -611,9 +611,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = "template"; } - //if (strMode != "template") - // throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); - bool fvNodesEmpty; { LOCK(cs_vNodes); From 52b1898322c16f2a008767264f7e7ff99e17dacd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 4 Dec 2018 11:19:44 +0800 Subject: [PATCH 684/951] p --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6d50bdef5..2e1b1cef4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -331,7 +331,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } dPriority += (double)nValueIn * nConf; } - if ( numNotaryVins >= NUM_NOTARIES / 5 ) + if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; nTotalIn += tx.GetShieldedValueIn(); } From 6595ab0201e6dc448cee218c323b13241f3fd1f3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:21:12 +0800 Subject: [PATCH 685/951] try fix wallet get corrupt, add prints --- src/main.cpp | 7 +++++-- src/miner.cpp | 6 ++++-- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0f694c5b6..e76299a25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1757,7 +1757,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { if (pfMissingInputs) *pfMissingInputs = true; - //fprintf(stderr,"missing inputs\n"); + fprintf(stderr,"missing inputs in %s\n",tx.GetHash().ToString().c_str()); return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); } } @@ -3839,7 +3839,10 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { //if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { - EraseFromWallets(tx.GetHash()); + //EraseFromWallets(tx.GetHash()); +#ifdef ENABLE_WALLET + pwalletMain->EraseFromWallet(tx.GetHash()); +#endif } else { diff --git a/src/miner.cpp b/src/miner.cpp index 272ca98be..bb38e1c02 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1569,7 +1569,7 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; - if ( ASSETCHAINS_STAKED != 0 ) + if ( ASSETCHAINS_STAKED > 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); @@ -1858,8 +1858,10 @@ void static BitcoinMiner() } //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); - if ( nThreads == 0 && ASSETCHAINS_STAKED ) + if ( ASSETCHAINS_STAKED > 0 && pwallet != NULL && nThreads == 0 ) nThreads = 1; + else + return; if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL)) return; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 06f87a79b..73293c669 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5365,7 +5365,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } //else fprintf(stderr,"utxo not eligible\n"); } - if ( numkp < 10000 && array != 0 ) + if ( numkp < 1000000 && array != 0 ) { free(array); array = 0; @@ -7283,7 +7283,7 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); asktxid = Parseuint256((char *)params[1].get_str().c_str()); - //fillunits = atol(params[2].get_str().c_str()); + //fillunits = atol(params[2].get_str().c_str()); fillunits = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance if ( fillunits <= 0 ) { From 0545cb9ba6e72c6799c553dd27dd2e57716153de Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:28:29 +0800 Subject: [PATCH 686/951] prints --- src/main.cpp | 4 +++- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e76299a25..17cd42f2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1316,9 +1316,11 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // Transactions containing empty `vin` must have either non-empty // `vjoinsplit` or non-empty `vShieldedSpend`. - if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) + if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); + printf("vim empty for tx: %s\n",tx.GetHash().ToString().c_str()); + } // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. if (tx.vout.empty() && tx.vjoinsplit.empty() && tx.vShieldedOutput.empty()) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 73293c669..c4204f8a0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5365,7 +5365,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } //else fprintf(stderr,"utxo not eligible\n"); } - if ( numkp < 1000000 && array != 0 ) + if ( numkp < 10000 && array != 0 ) { free(array); array = 0; From f27f8c2821c2f82d08236f2ef4e93457e1f7158b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:38:19 +0800 Subject: [PATCH 687/951] fix --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 17cd42f2b..cca92b681 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1319,7 +1319,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); - printf("vim empty for tx: %s\n",tx.GetHash().ToString().c_str()); + fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); } // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. @@ -1759,7 +1759,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { if (pfMissingInputs) *pfMissingInputs = true; - fprintf(stderr,"missing inputs in %s\n",tx.GetHash().ToString().c_str()); + //fprintf(stderr,"missing inputs in %s\n",tx.GetHash().ToString().c_str()); return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); } } From 3a705a843e6632c7221c657abb96adf3e3ada344 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 01:39:27 +0800 Subject: [PATCH 688/951] fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cca92b681..7668f7f87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1317,9 +1317,9 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // Transactions containing empty `vin` must have either non-empty // `vjoinsplit` or non-empty `vShieldedSpend`. if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { + fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); - fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); } // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. From 1602f04ac8c07a167a08d38e7f0c2ffc2e3ed4df Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 16:59:28 +0800 Subject: [PATCH 689/951] fix miner try to stop staker pegging a core --- src/init.cpp | 2 +- src/miner.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index f3d728933..6015106aa 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1501,7 +1501,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fReindex = true; } } - + bool clearWitnessCaches = false; bool fLoaded = false; diff --git a/src/miner.cpp b/src/miner.cpp index bb38e1c02..da9824fd4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1638,8 +1638,8 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( h > hashTarget ) { - //if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) - // sleep(1); + if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) + MilliSleep(30); return false; } if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetAdjustedTime() ) @@ -1858,10 +1858,14 @@ void static BitcoinMiner() } //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); - if ( ASSETCHAINS_STAKED > 0 && pwallet != NULL && nThreads == 0 ) - nThreads = 1; - else - return; + + if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 ) + { + if ( pwallet != NULL ) + nThreads = 1; + else + return; + } if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL)) return; From d84aad965157fdb91ed4b67d83fe9f21cd99b40c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 18:41:28 +0800 Subject: [PATCH 690/951] remove sleep does nothign --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index da9824fd4..fe9fff5bc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1638,8 +1638,8 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( h > hashTarget ) { - if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) - MilliSleep(30); + //if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) + // MilliSleep(30); return false; } if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetAdjustedTime() ) From e9719a96b00fdf5ef74ed382c0ea3b527dbcb620 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 20:08:01 +0800 Subject: [PATCH 691/951] disavle DNS seeds --- src/net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net.cpp b/src/net.cpp index 47aaf921c..c33f82627 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1263,6 +1263,7 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { + return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From 3dd1038988c7aecdc6042561b63612af318aea0d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 20:09:57 +0800 Subject: [PATCH 692/951] what --- src/rpcmisc.cpp | 1300 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1300 insertions(+) create mode 100644 src/rpcmisc.cpp diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp new file mode 100644 index 000000000..4f436f41a --- /dev/null +++ b/src/rpcmisc.cpp @@ -0,0 +1,1300 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "base58.h" +#include "clientversion.h" +#include "init.h" +#include "main.h" +#include "net.h" +#include "netbase.h" +#include "rpcserver.h" +#include "timedata.h" +#include "txmempool.h" +#include "util.h" +#include "notaries_staked.h" +#ifdef ENABLE_WALLET +#include "wallet/wallet.h" +#include "wallet/walletdb.h" +#endif + +#include + +#include + +#include + +#include "zcash/Address.hpp" + +using namespace std; + +/** + * @note Do not add or change anything in the information returned by this + * method. `getinfo` exists for backwards-compatibility only. It combines + * information from wildly different sources in the program, which is a mess, + * and is thus planned to be deprecated eventually. + * + * Based on the source of the information, new information should be added to: + * - `getblockchaininfo`, + * - `getnetworkinfo` or + * - `getwalletinfo` + * + * Or alternatively, create a specific query method for the information. + **/ + +int32_t Jumblr_depositaddradd(char *depositaddr); +int32_t Jumblr_secretaddradd(char *secretaddr); +uint64_t komodo_interestsum(); +int32_t komodo_longestchain(); +int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); +uint32_t komodo_chainactive_timestamp(); +int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); +extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +uint32_t komodo_segid32(char *coinaddr); +int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); +int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); +int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); +#define KOMODO_VERSION "0.2.1" +extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; +extern uint32_t ASSETCHAINS_CC; +extern uint32_t ASSETCHAINS_MAGIC; +extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; +extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; + +int32_t getera(int now) +{ + for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { + if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + return(i); + } + } +} + +UniValue getiguanajson(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); + + UniValue json(UniValue::VOBJ); + UniValue seeds(UniValue::VARR); + UniValue notaries(UniValue::VARR); + // get the current era, use local time for now. + // should ideally take blocktime of last known block? + int now = time(NULL); + int32_t era = getera(now); + + // loop over seeds array and push back to json array for seeds + for (int8_t i = 0; i < 8; i++) { + seeds.push_back(iguanaSeeds[i][0]); + } + + // loop over era's notaries and push back each pair to the notary array + for (int8_t i = 0; i < num_notaries_STAKED[era]; i++) { + UniValue notary(UniValue::VOBJ); + notary.push_back(Pair(notaries_STAKED[era][i][0],notaries_STAKED[era][i][1])); + notaries.push_back(notary); + } + + // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. + int minsigs; + if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) + minsigs = (num_notaries_STAKED[era] / 5) + 1; + else + minsigs = overrideMinSigs; + + json.push_back(Pair("port",iguanaPort)); + json.push_back(Pair("BTCminsigs",BTCminsigs)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("notaries",notaries)); + return json; +} + +UniValue getnotarysendmany(const UniValue& params, bool fHelp) +{ + int era = getera(time(NULL)); + + UniValue ret(UniValue::VOBJ); + for (int i = 0; ics_wallet : NULL); +//#else + LOCK(cs_main); +//#endif + + proxyType proxy; + GetProxy(NET_IPV4, proxy); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); + + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("version", CLIENT_VERSION)); + obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); + obj.push_back(Pair("KMDversion", KOMODO_VERSION)); + obj.push_back(Pair("notarized", notarized_height)); + obj.push_back(Pair("prevMoMheight", prevMoMheight)); + obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); + obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); + txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + if ( txid_height > 0 ) + obj.push_back(Pair("notarizedtxid_height", txid_height)); + else obj.push_back(Pair("notarizedtxid_height", "mempool")); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); + //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); + obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() + } + else + { + obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); // + } + } +#endif + //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); + obj.push_back(Pair("blocks", (int)chainActive.Height())); + if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) + longestchain = chainActive.Height(); + //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); + obj.push_back(Pair("longestchain", longestchain)); + obj.push_back(Pair("timeoffset", GetTimeOffset())); + if ( chainActive.LastTip() != 0 ) + obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime)); + obj.push_back(Pair("connections", (int)vNodes.size())); + obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); + obj.push_back(Pair("difficulty", (double)GetDifficulty())); + obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + } + if (pwalletMain && pwalletMain->IsCrypted()) + obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); + obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); +#endif + obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + if ( NOTARY_PUBKEY33[0] != 0 ) { + char pubkeystr[65]; int32_t notaryid; std::string notaryname; + if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str())) != -1 ) { + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("notaryname", notaryname)); + } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { + obj.push_back(Pair("notaryid", notaryid)); + if ( KOMODO_LASTMINED != 0 ) + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } + obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } + if ( ASSETCHAINS_CC != 0 ) + obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); + obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); + obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); + obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + obj.push_back(Pair("StakedEra", STAKED_ERA)); + //obj.push_back(Pair("name", ASSETCHAINS_SYMBOL)); + obj.push_back(Pair("magic", (int)ASSETCHAINS_MAGIC)); + if ( ASSETCHAINS_SUPPLY != 0 ) + obj.push_back(Pair("premine", ASSETCHAINS_SUPPLY)); + if ( ASSETCHAINS_REWARD != 0 ) + obj.push_back(Pair("reward", ASSETCHAINS_REWARD)); + if ( ASSETCHAINS_HALVING != 0 ) + obj.push_back(Pair("halving", ASSETCHAINS_HALVING)); + if ( ASSETCHAINS_DECAY != 0 ) + obj.push_back(Pair("decay", ASSETCHAINS_DECAY)); + if ( ASSETCHAINS_ENDSUBSIDY != 0 ) + obj.push_back(Pair("endsubsidy", ASSETCHAINS_ENDSUBSIDY)); + if ( ASSETCHAINS_COMMISSION != 0 ) + obj.push_back(Pair("commission", ASSETCHAINS_COMMISSION)); + if ( ASSETCHAINS_STAKED != 0 ) + obj.push_back(Pair("staked", ASSETCHAINS_STAKED)); + } + return obj; +} + +#ifdef ENABLE_WALLET +class DescribeAddressVisitor : public boost::static_visitor +{ +public: + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } + + UniValue operator()(const CKeyID &keyID) const { + UniValue obj(UniValue::VOBJ); + CPubKey vchPubKey; + obj.push_back(Pair("isscript", false)); + if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) { + obj.push_back(Pair("pubkey", HexStr(vchPubKey))); + obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); + } + return obj; + } + + UniValue operator()(const CScriptID &scriptID) const { + UniValue obj(UniValue::VOBJ); + CScript subscript; + obj.push_back(Pair("isscript", true)); + if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { + std::vector addresses; + txnouttype whichType; + int nRequired; + ExtractDestinations(subscript, whichType, addresses, nRequired); + obj.push_back(Pair("script", GetTxnOutputType(whichType))); + obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); + UniValue a(UniValue::VARR); + BOOST_FOREACH(const CTxDestination& addr, addresses) + a.push_back(CBitcoinAddress(addr).ToString()); + obj.push_back(Pair("addresses", a)); + if (whichType == TX_MULTISIG) + obj.push_back(Pair("sigsrequired", nRequired)); + } + return obj; + } +}; +#endif + +UniValue coinsupply(const UniValue& params, bool fHelp) +{ + int32_t height = 0; int32_t currentHeight; int64_t zfunds,supply = 0; UniValue result(UniValue::VOBJ); + if (fHelp || params.size() > 1) + throw runtime_error("coinsupply \n" + "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" + "\nArguments:\n" + "1. \"height\" (integer, optional) Block height\n" + "\nResult:\n" + "{\n" + " \"result\" : \"success\", (string) If the request was successful.\n" + " \"coin\" : \"KMD\", (string) The currency symbol of the coin for asset chains, otherwise KMD.\n" + " \"height\" : 420, (integer) The height of this coin supply data\n" + " \"supply\" : \"777.0\", (float) The transparent coin supply\n" + " \"zfunds\" : \"0.777\", (float) The shielded coin supply (in zaddrs)\n" + " \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("coinsupply", "420") + + HelpExampleRpc("coinsupply", "420") + ); + if ( params.size() == 0 ) + height = chainActive.Height(); + else height = atoi(params[0].get_str()); + currentHeight = chainActive.Height(); + + if (height >= 0 && height <= currentHeight) { + if ( (supply= komodo_coinsupply(&zfunds,height)) > 0 ) + { + result.push_back(Pair("result", "success")); + result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); + result.push_back(Pair("height", (int)height)); + result.push_back(Pair("supply", ValueFromAmount(supply))); + result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); + result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); + } else result.push_back(Pair("error", "couldnt calculate supply")); + } else { + result.push_back(Pair("error", "invalid height")); + } + return(result); +} + +UniValue jumblr_deposit(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp || params.size() != 1) + throw runtime_error("jumblr_deposit \"depositaddress\"\n"); + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + if ( isValid != 0 ) + { + string addr = params[0].get_str(); + if ( (retval= Jumblr_depositaddradd((char *)addr.c_str())) >= 0 ) + { + result.push_back(Pair("result", retval)); + JUMBLR_PAUSE = 0; + } + else result.push_back(Pair("error", retval)); + } else result.push_back(Pair("error", "invalid address")); + return(result); +} + +UniValue jumblr_secret(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp || params.size() != 1) + throw runtime_error("jumblr_secret \"secretaddress\"\n"); + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + if ( isValid != 0 ) + { + string addr = params[0].get_str(); + retval = Jumblr_secretaddradd((char *)addr.c_str()); + result.push_back(Pair("result", "success")); + result.push_back(Pair("num", retval)); + JUMBLR_PAUSE = 0; + } else result.push_back(Pair("error", "invalid address")); + return(result); +} + +UniValue jumblr_pause(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp ) + throw runtime_error("jumblr_pause\n"); + JUMBLR_PAUSE = 1; + result.push_back(Pair("result", "paused")); + return(result); +} + +UniValue jumblr_resume(const UniValue& params, bool fHelp) +{ + int32_t retval; UniValue result(UniValue::VOBJ); + if (fHelp ) + throw runtime_error("jumblr_resume\n"); + JUMBLR_PAUSE = 0; + result.push_back(Pair("result", "resumed")); + return(result); +} + +UniValue validateaddress(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "validateaddress \"komodoaddress\"\n" + "\nReturn information about the given Komodo address.\n" + "\nArguments:\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\" : \"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" + " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" + " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" + " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") + + HelpExampleRpc("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") + ); + +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif + + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + + UniValue ret(UniValue::VOBJ); + ret.push_back(Pair("isvalid", isValid)); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + ret.push_back(Pair("address", currentAddress)); + + CScript scriptPubKey = GetScriptForDestination(dest); + ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); + ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f)); +#ifdef ENABLE_WALLET + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); + ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); + UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest); + ret.pushKVs(detail); + if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) + ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); +#endif + } + return ret; +} + + +UniValue z_validateaddress(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "z_validateaddress \"zaddr\"\n" + "\nReturn information about the given z address.\n" + "\nArguments:\n" + "1. \"zaddr\" (string, required) The z 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\" : \"zaddr\", (string) The z address validated\n" + " \"ismine\" : true|false, (boolean) If the address is yours or not\n" + " \"payingkey\" : \"hex\", (string) The hex value of the paying key, a_pk\n" + " \"transmissionkey\" : \"hex\", (string) The hex value of the transmission key, pk_enc\n" + + "}\n" + "\nExamples:\n" + + HelpExampleCli("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") + + HelpExampleRpc("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") + ); + + +#ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain->cs_wallet); +#else + LOCK(cs_main); +#endif + + bool isValid = false; + bool isMine = false; + std::string payingKey, transmissionKey; + + string strAddress = params[0].get_str(); + try { + CZCPaymentAddress address(strAddress); + libzcash::PaymentAddress addr = address.Get(); + +#ifdef ENABLE_WALLET + isMine = pwalletMain->HaveSpendingKey(addr); +#endif + payingKey = addr.a_pk.GetHex(); + transmissionKey = addr.pk_enc.GetHex(); + isValid = true; + } catch (std::runtime_error e) { + // address is invalid, nop here as isValid is false. + } + + UniValue ret(UniValue::VOBJ); + ret.push_back(Pair("isvalid", isValid)); + if (isValid) + { + ret.push_back(Pair("address", strAddress)); + ret.push_back(Pair("payingkey", payingKey)); + ret.push_back(Pair("transmissionkey", transmissionKey)); +#ifdef ENABLE_WALLET + ret.push_back(Pair("ismine", isMine)); +#endif + } + return ret; +} + + +/** + * Used by addmultisigaddress / createmultisig: + */ +CScript _createmultisig_redeemScript(const UniValue& params) +{ + int nRequired = params[0].get_int(); + const UniValue& keys = params[1].get_array(); + + // Gather public keys + if (nRequired < 1) + throw runtime_error("a multisignature address must require at least one key to redeem"); + if ((int)keys.size() < nRequired) + throw runtime_error( + strprintf("not enough keys supplied " + "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired)); + if (keys.size() > 16) + throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number"); + std::vector pubkeys; + pubkeys.resize(keys.size()); + for (unsigned int i = 0; i < keys.size(); i++) + { + const std::string& ks = keys[i].get_str(); +#ifdef ENABLE_WALLET + // Case 1: Bitcoin address and we have full public key: + CBitcoinAddress address(ks); + if (pwalletMain && address.IsValid()) + { + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw runtime_error( + strprintf("%s does not refer to a key",ks)); + CPubKey vchPubKey; + if (!pwalletMain->GetPubKey(keyID, vchPubKey)) + throw runtime_error( + strprintf("no full public key for address %s",ks)); + if (!vchPubKey.IsFullyValid()) + throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; + } + + // Case 2: hex public key + else +#endif + if (IsHex(ks)) + { + CPubKey vchPubKey(ParseHex(ks)); + if (!vchPubKey.IsFullyValid()) + throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; + } + else + { + throw runtime_error(" Invalid public key: "+ks); + } + } + CScript result = GetScriptForMultisig(nRequired, pubkeys); + + if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) + throw runtime_error( + strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE)); + + return result; +} + +UniValue createmultisig(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() < 2 || params.size() > 2) + { + string msg = "createmultisig nrequired [\"key\",...]\n" + "\nCreates a multi-signature address with n signature of m keys required.\n" + "It returns a json object with the address and redeemScript.\n" + + "\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 Komodo addresses or hex-encoded public keys\n" + " [\n" + " \"key\" (string) Komodo address or hex-encoded public key\n" + " ,...\n" + " ]\n" + + "\nResult:\n" + "{\n" + " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" + " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" + "}\n" + + "\nExamples:\n" + "\nCreate a multisig address from 2 addresses\n" + + HelpExampleCli("createmultisig", "2 \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + + "\nAs a json rpc call\n" + + HelpExampleRpc("createmultisig", "2, \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + ; + throw runtime_error(msg); + } + + // Construct using pay-to-script-hash: + CScript inner = _createmultisig_redeemScript(params); + CScriptID innerID(inner); + CBitcoinAddress address(innerID); + + UniValue result(UniValue::VOBJ); + result.push_back(Pair("address", address.ToString())); + result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); + + return result; +} + +UniValue verifymessage(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 3) + throw runtime_error( + "verifymessage \"komodoaddress\" \"signature\" \"message\"\n" + "\nVerify a signed message\n" + "\nArguments:\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" + "true|false (boolean) If the signature is verified or not.\n" + "\nExamples:\n" + "\nUnlock the wallet for 30 seconds\n" + + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + + "\nCreate the signature\n" + + HelpExampleCli("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"my message\"") + + "\nVerify the signature\n" + + HelpExampleCli("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"signature\" \"my message\"") + + "\nAs json rpc\n" + + HelpExampleRpc("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"signature\", \"my message\"") + ); + + LOCK(cs_main); + + string strAddress = params[0].get_str(); + string strSign = params[1].get_str(); + string strMessage = params[2].get_str(); + + CBitcoinAddress addr(strAddress); + if (!addr.IsValid()) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); + + CKeyID keyID; + if (!addr.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); + + bool fInvalid = false; + vector vchSig = DecodeBase64(strSign.c_str(), &fInvalid); + + if (fInvalid) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); + + CHashWriter ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << strMessage; + + CPubKey pubkey; + if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) + return false; + + return (pubkey.GetID() == keyID); +} + +UniValue setmocktime(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "setmocktime timestamp\n" + "\nSet the local time to given timestamp (-regtest only)\n" + "\nArguments:\n" + "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" + " Pass 0 to go back to using the system time." + ); + + if (!Params().MineBlocksOnDemand()) + throw runtime_error("setmocktime for regression testing (-regtest mode) only"); + + // cs_vNodes is locked and node send/receive times are updated + // atomically with the time change to prevent peers from being + // disconnected because we think we haven't communicated with them + // in a long time. + LOCK2(cs_main, cs_vNodes); + + RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); + SetMockTime(params[0].get_int64()); + + uint64_t t = GetTime(); + BOOST_FOREACH(CNode* pnode, vNodes) { + pnode->nLastSend = pnode->nLastRecv = t; + } + + return NullUniValue; +} + +bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address) +{ + if (type == 2) { + address = CBitcoinAddress(CScriptID(hash)).ToString(); + } else if (type == 1) { + address = CBitcoinAddress(CKeyID(hash)).ToString(); + } + else { + return false; + } + return true; +} + +bool getAddressesFromParams(const UniValue& params, std::vector > &addresses) +{ + if (params[0].isStr()) { + CBitcoinAddress address(params[0].get_str()); + uint160 hashBytes; + int type = 0; + if (!address.GetIndexKey(hashBytes, type)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + addresses.push_back(std::make_pair(hashBytes, type)); + } else if (params[0].isObject()) { + + UniValue addressValues = find_value(params[0].get_obj(), "addresses"); + if (!addressValues.isArray()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Addresses is expected to be an array"); + } + + std::vector values = addressValues.getValues(); + + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + + CBitcoinAddress address(it->get_str()); + uint160 hashBytes; + int type = 0; + if (!address.GetIndexKey(hashBytes, type)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses"); + } + addresses.push_back(std::make_pair(hashBytes, type)); + } + } else { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresse"); + } + + return true; +} + +bool heightSort(std::pair a, + std::pair b) { + return a.second.blockHeight < b.second.blockHeight; +} + +bool timestampSort(std::pair a, + std::pair b) { + return a.second.time < b.second.time; +} + +UniValue getaddressmempool(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressmempool\n" + "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + "}\n" + "\nResult:\n" + "[\n" + " {\n" + " \"address\" (string) The base58check encoded address\n" + " \"txid\" (string) The related txid\n" + " \"index\" (number) The related input or output index\n" + " \"satoshis\" (number) The difference of satoshis\n" + " \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n" + " \"prevtxid\" (string) The previous txid (if spending)\n" + " \"prevout\" (string) The previous transaction output index (if spending)\n" + " }\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > indexes; + + if (!mempool.getAddressIndex(addresses, indexes)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + + std::sort(indexes.begin(), indexes.end(), timestampSort); + + UniValue result(UniValue::VARR); + + for (std::vector >::iterator it = indexes.begin(); + it != indexes.end(); it++) { + + std::string address; + if (!getAddressFromIndex(it->first.type, it->first.addressBytes, address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); + } + + UniValue delta(UniValue::VOBJ); + delta.push_back(Pair("address", address)); + delta.push_back(Pair("txid", it->first.txhash.GetHex())); + delta.push_back(Pair("index", (int)it->first.index)); + delta.push_back(Pair("satoshis", it->second.amount)); + delta.push_back(Pair("timestamp", it->second.time)); + if (it->second.amount < 0) { + delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex())); + delta.push_back(Pair("prevout", (int)it->second.prevout)); + } + result.push_back(delta); + } + + return result; +} + +UniValue getaddressutxos(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressutxos\n" + "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ],\n" + " \"chainInfo\" (boolean) Include chain info with results\n" + "}\n" + "\nResult\n" + "[\n" + " {\n" + " \"address\" (string) The address base58check encoded\n" + " \"txid\" (string) The output txid\n" + " \"height\" (number) The block height\n" + " \"outputIndex\" (number) The output index\n" + " \"script\" (strin) The script hex encoded\n" + " \"satoshis\" (number) The number of satoshis of the output\n" + " }\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + bool includeChainInfo = false; + if (params[0].isObject()) { + UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); + if (chainInfo.isBool()) { + includeChainInfo = chainInfo.get_bool(); + } + } + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > unspentOutputs; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (!GetAddressUnspent((*it).first, (*it).second, unspentOutputs)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + + std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort); + + UniValue utxos(UniValue::VARR); + + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { + UniValue output(UniValue::VOBJ); + std::string address; + if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); + } + + output.push_back(Pair("address", address)); + output.push_back(Pair("txid", it->first.txhash.GetHex())); + output.push_back(Pair("outputIndex", (int)it->first.index)); + output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end()))); + output.push_back(Pair("satoshis", it->second.satoshis)); + output.push_back(Pair("height", it->second.blockHeight)); + utxos.push_back(output); + } + + if (includeChainInfo) { + UniValue result(UniValue::VOBJ); + result.push_back(Pair("utxos", utxos)); + + LOCK(cs_main); + result.push_back(Pair("hash", chainActive.LastTip()->GetBlockHash().GetHex())); + result.push_back(Pair("height", (int)chainActive.Height())); + return result; + } else { + return utxos; + } +} + +UniValue getaddressdeltas(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1 || !params[0].isObject()) + throw runtime_error( + "getaddressdeltas\n" + "\nReturns all changes for an address (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + " \"start\" (number) The start block height\n" + " \"end\" (number) The end block height\n" + " \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n" + "}\n" + "\nResult:\n" + "[\n" + " {\n" + " \"satoshis\" (number) The difference of satoshis\n" + " \"txid\" (string) The related txid\n" + " \"index\" (number) The related input or output index\n" + " \"height\" (number) The block height\n" + " \"address\" (string) The base58check encoded address\n" + " }\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + + UniValue startValue = find_value(params[0].get_obj(), "start"); + UniValue endValue = find_value(params[0].get_obj(), "end"); + + UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); + bool includeChainInfo = false; + if (chainInfo.isBool()) { + includeChainInfo = chainInfo.get_bool(); + } + + int start = 0; + int end = 0; + + if (startValue.isNum() && endValue.isNum()) { + start = startValue.get_int(); + end = endValue.get_int(); + if (start <= 0 || end <= 0) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start and end is expected to be greater than zero"); + } + if (end < start) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "End value is expected to be greater than start"); + } + } + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > addressIndex; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (start > 0 && end > 0) { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } else { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + } + + UniValue deltas(UniValue::VARR); + + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { + std::string address; + if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); + } + + UniValue delta(UniValue::VOBJ); + delta.push_back(Pair("satoshis", it->second)); + delta.push_back(Pair("txid", it->first.txhash.GetHex())); + delta.push_back(Pair("index", (int)it->first.index)); + delta.push_back(Pair("blockindex", (int)it->first.txindex)); + delta.push_back(Pair("height", it->first.blockHeight)); + delta.push_back(Pair("address", address)); + deltas.push_back(delta); + } + + UniValue result(UniValue::VOBJ); + + if (includeChainInfo && start > 0 && end > 0) { + LOCK(cs_main); + + if (start > chainActive.Height() || end > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start or end is outside chain range"); + } + + CBlockIndex* startIndex = chainActive[start]; + CBlockIndex* endIndex = chainActive[end]; + + UniValue startInfo(UniValue::VOBJ); + UniValue endInfo(UniValue::VOBJ); + + startInfo.push_back(Pair("hash", startIndex->GetBlockHash().GetHex())); + startInfo.push_back(Pair("height", start)); + + endInfo.push_back(Pair("hash", endIndex->GetBlockHash().GetHex())); + endInfo.push_back(Pair("height", end)); + + result.push_back(Pair("deltas", deltas)); + result.push_back(Pair("start", startInfo)); + result.push_back(Pair("end", endInfo)); + + return result; + } else { + return deltas; + } +} + +UniValue getaddressbalance(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressbalance\n" + "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + "}\n" + "\nResult:\n" + "{\n" + " \"balance\" (string) The current balance in satoshis\n" + " \"received\" (string) The total number of satoshis received (including change)\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + std::vector > addressIndex; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + + CAmount balance = 0; + CAmount received = 0; + + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { + if (it->second > 0) { + received += it->second; + } + balance += it->second; + } + + UniValue result(UniValue::VOBJ); + result.push_back(Pair("balance", balance)); + result.push_back(Pair("received", received)); + + return result; + +} + +UniValue komodo_snapshot(int top); + +UniValue getsnapshot(const UniValue& params, bool fHelp) +{ + UniValue result(UniValue::VOBJ); int64_t total; int32_t top = 0; + + if (params.size() > 0 && !params[0].isNull()) { + top = atoi(params[0].get_str().c_str()); + if (top <= 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); + } + + if ( fHelp || params.size() > 1) + { + throw runtime_error( + "getsnapshot\n" + "\nReturns a snapshot of (address,amount) pairs at current height (requires addressindex to be enabled).\n" + "\nArguments:\n" + " \"top\" (number, optional) Only return this many addresses, i.e. top N richlist\n" + "\nResult:\n" + "{\n" + " \"addresses\": [\n" + " {\n" + " \"addr\": \"RMEBhzvATA8mrfVK82E5TgPzzjtaggRGN3\",\n" + " \"amount\": \"100.0\"\n" + " },\n" + " {\n" + " \"addr\": \"RqEBhzvATAJmrfVL82E57gPzzjtaggR777\",\n" + " \"amount\": \"23.45\"\n" + " }\n" + " ],\n" + " \"total\": 123.45 (numeric) Total amount in snapshot\n" + " \"average\": 61.7, (numeric) Average amount in each address \n" + " \"utxos\": 14, (number) Total number of UTXOs in snapshot\n" + " \"total_addresses\": 2, (number) Total number of addresses in snapshot,\n" + " \"start_height\": 91, (number) Block height snapshot began\n" + " \"ending_height\": 91 (number) Block height snapsho finished,\n" + " \"start_time\": 1531982752, (number) Unix epoch time snapshot started\n" + " \"end_time\": 1531982752 (number) Unix epoch time snapshot finished\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getsnapshot","") + + HelpExampleRpc("getsnapshot", "1000") + ); + } + result = komodo_snapshot(top); + if ( result.size() > 0 ) { + result.push_back(Pair("end_time", (int) time(NULL))); + } else { + result.push_back(Pair("error", "no addressindex")); + } + return(result); +} + +UniValue getaddresstxids(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddresstxids\n" + "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n" + "\nArguments:\n" + "{\n" + " \"addresses\"\n" + " [\n" + " \"address\" (string) The base58check encoded address\n" + " ,...\n" + " ]\n" + " \"start\" (number) The start block height\n" + " \"end\" (number) The end block height\n" + "}\n" + "\nResult:\n" + "[\n" + " \"transactionid\" (string) The transaction id\n" + " ,...\n" + "]\n" + "\nExamples:\n" + + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") + + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") + ); + + std::vector > addresses; + + if (!getAddressesFromParams(params, addresses)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); + } + + int start = 0; + int end = 0; + if (params[0].isObject()) { + UniValue startValue = find_value(params[0].get_obj(), "start"); + UniValue endValue = find_value(params[0].get_obj(), "end"); + if (startValue.isNum() && endValue.isNum()) { + start = startValue.get_int(); + end = endValue.get_int(); + } + } + + std::vector > addressIndex; + + for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { + if (start > 0 && end > 0) { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } else { + if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); + } + } + } + + std::set > txids; + UniValue result(UniValue::VARR); + + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { + int height = it->first.blockHeight; + std::string txid = it->first.txhash.GetHex(); + + if (addresses.size() > 1) { + txids.insert(std::make_pair(height, txid)); + } else { + if (txids.insert(std::make_pair(height, txid)).second) { + result.push_back(txid); + } + } + } + + if (addresses.size() > 1) { + for (std::set >::const_iterator it=txids.begin(); it!=txids.end(); it++) { + result.push_back(it->second); + } + } + + return result; + +} + +UniValue getspentinfo(const UniValue& params, bool fHelp) +{ + + if (fHelp || params.size() != 1 || !params[0].isObject()) + throw runtime_error( + "getspentinfo\n" + "\nReturns the txid and index where an output is spent.\n" + "\nArguments:\n" + "{\n" + " \"txid\" (string) The hex string of the txid\n" + " \"index\" (number) The start block height\n" + "}\n" + "\nResult:\n" + "{\n" + " \"txid\" (string) The transaction id\n" + " \"index\" (number) The spending input index\n" + " ,...\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") + + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}") + ); + + UniValue txidValue = find_value(params[0].get_obj(), "txid"); + UniValue indexValue = find_value(params[0].get_obj(), "index"); + + if (!txidValue.isStr() || !indexValue.isNum()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid txid or index"); + } + + uint256 txid = ParseHashV(txidValue, "txid"); + int outputIndex = indexValue.get_int(); + + CSpentIndexKey key(txid, outputIndex); + CSpentIndexValue value; + + if (!GetSpentIndex(key, value)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info"); + } + + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("txid", value.txid.GetHex())); + obj.push_back(Pair("index", (int)value.inputIndex)); + obj.push_back(Pair("height", value.blockHeight)); + + return obj; +} From 6b8d3d392ad0dac9b71f0d229448eb0020f9d01a Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Wed, 5 Dec 2018 20:13:30 +0800 Subject: [PATCH 693/951] Delete rpcmisc.cpp --- src/rpcmisc.cpp | 1300 ----------------------------------------------- 1 file changed, 1300 deletions(-) delete mode 100644 src/rpcmisc.cpp diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp deleted file mode 100644 index 4f436f41a..000000000 --- a/src/rpcmisc.cpp +++ /dev/null @@ -1,1300 +0,0 @@ -// Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "base58.h" -#include "clientversion.h" -#include "init.h" -#include "main.h" -#include "net.h" -#include "netbase.h" -#include "rpcserver.h" -#include "timedata.h" -#include "txmempool.h" -#include "util.h" -#include "notaries_staked.h" -#ifdef ENABLE_WALLET -#include "wallet/wallet.h" -#include "wallet/walletdb.h" -#endif - -#include - -#include - -#include - -#include "zcash/Address.hpp" - -using namespace std; - -/** - * @note Do not add or change anything in the information returned by this - * method. `getinfo` exists for backwards-compatibility only. It combines - * information from wildly different sources in the program, which is a mess, - * and is thus planned to be deprecated eventually. - * - * Based on the source of the information, new information should be added to: - * - `getblockchaininfo`, - * - `getnetworkinfo` or - * - `getwalletinfo` - * - * Or alternatively, create a specific query method for the information. - **/ - -int32_t Jumblr_depositaddradd(char *depositaddr); -int32_t Jumblr_secretaddradd(char *secretaddr); -uint64_t komodo_interestsum(); -int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); -uint32_t komodo_chainactive_timestamp(); -int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); -extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -uint32_t komodo_segid32(char *coinaddr); -int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); -int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); -#define KOMODO_VERSION "0.2.1" -extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAINS_CC; -extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; -extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; - -int32_t getera(int now) -{ - for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { - if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { - return(i); - } - } -} - -UniValue getiguanajson(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); - - UniValue json(UniValue::VOBJ); - UniValue seeds(UniValue::VARR); - UniValue notaries(UniValue::VARR); - // get the current era, use local time for now. - // should ideally take blocktime of last known block? - int now = time(NULL); - int32_t era = getera(now); - - // loop over seeds array and push back to json array for seeds - for (int8_t i = 0; i < 8; i++) { - seeds.push_back(iguanaSeeds[i][0]); - } - - // loop over era's notaries and push back each pair to the notary array - for (int8_t i = 0; i < num_notaries_STAKED[era]; i++) { - UniValue notary(UniValue::VOBJ); - notary.push_back(Pair(notaries_STAKED[era][i][0],notaries_STAKED[era][i][1])); - notaries.push_back(notary); - } - - // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. - int minsigs; - if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) - minsigs = (num_notaries_STAKED[era] / 5) + 1; - else - minsigs = overrideMinSigs; - - json.push_back(Pair("port",iguanaPort)); - json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",minsigs)); - json.push_back(Pair("seeds", seeds)); - json.push_back(Pair("notaries",notaries)); - return json; -} - -UniValue getnotarysendmany(const UniValue& params, bool fHelp) -{ - int era = getera(time(NULL)); - - UniValue ret(UniValue::VOBJ); - for (int i = 0; ics_wallet : NULL); -//#else - LOCK(cs_main); -//#endif - - proxyType proxy; - GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); - //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("version", CLIENT_VERSION)); - obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); - obj.push_back(Pair("KMDversion", KOMODO_VERSION)); - obj.push_back(Pair("notarized", notarized_height)); - obj.push_back(Pair("prevMoMheight", prevMoMheight)); - obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); - obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); - txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); - if ( txid_height > 0 ) - obj.push_back(Pair("notarizedtxid_height", txid_height)); - else obj.push_back(Pair("notarizedtxid_height", "mempool")); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); - //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); -#ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); - obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() - } - else - { - obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); // - } - } -#endif - //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); - obj.push_back(Pair("blocks", (int)chainActive.Height())); - if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) - longestchain = chainActive.Height(); - //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); - obj.push_back(Pair("longestchain", longestchain)); - obj.push_back(Pair("timeoffset", GetTimeOffset())); - if ( chainActive.LastTip() != 0 ) - obj.push_back(Pair("tiptime", (int)chainActive.LastTip()->nTime)); - obj.push_back(Pair("connections", (int)vNodes.size())); - obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); - obj.push_back(Pair("difficulty", (double)GetDifficulty())); - obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); -#ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); - } - if (pwalletMain && pwalletMain->IsCrypted()) - obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); - obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); -#endif - obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); - if ( NOTARY_PUBKEY33[0] != 0 ) { - char pubkeystr[65]; int32_t notaryid; std::string notaryname; - if ( (notaryid= StakedNotaryID(notaryname, (char *)NOTARY_ADDRESS.c_str())) != -1 ) { - obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("notaryname", notaryname)); - } else if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) { - obj.push_back(Pair("notaryid", notaryid)); - if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); - } - obj.push_back(Pair("pubkey", NOTARY_PUBKEY)); - } - if ( ASSETCHAINS_CC != 0 ) - obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); - obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); - obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); - obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - obj.push_back(Pair("StakedEra", STAKED_ERA)); - //obj.push_back(Pair("name", ASSETCHAINS_SYMBOL)); - obj.push_back(Pair("magic", (int)ASSETCHAINS_MAGIC)); - if ( ASSETCHAINS_SUPPLY != 0 ) - obj.push_back(Pair("premine", ASSETCHAINS_SUPPLY)); - if ( ASSETCHAINS_REWARD != 0 ) - obj.push_back(Pair("reward", ASSETCHAINS_REWARD)); - if ( ASSETCHAINS_HALVING != 0 ) - obj.push_back(Pair("halving", ASSETCHAINS_HALVING)); - if ( ASSETCHAINS_DECAY != 0 ) - obj.push_back(Pair("decay", ASSETCHAINS_DECAY)); - if ( ASSETCHAINS_ENDSUBSIDY != 0 ) - obj.push_back(Pair("endsubsidy", ASSETCHAINS_ENDSUBSIDY)); - if ( ASSETCHAINS_COMMISSION != 0 ) - obj.push_back(Pair("commission", ASSETCHAINS_COMMISSION)); - if ( ASSETCHAINS_STAKED != 0 ) - obj.push_back(Pair("staked", ASSETCHAINS_STAKED)); - } - return obj; -} - -#ifdef ENABLE_WALLET -class DescribeAddressVisitor : public boost::static_visitor -{ -public: - UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } - - UniValue operator()(const CKeyID &keyID) const { - UniValue obj(UniValue::VOBJ); - CPubKey vchPubKey; - obj.push_back(Pair("isscript", false)); - if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) { - obj.push_back(Pair("pubkey", HexStr(vchPubKey))); - obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); - } - return obj; - } - - UniValue operator()(const CScriptID &scriptID) const { - UniValue obj(UniValue::VOBJ); - CScript subscript; - obj.push_back(Pair("isscript", true)); - if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { - std::vector addresses; - txnouttype whichType; - int nRequired; - ExtractDestinations(subscript, whichType, addresses, nRequired); - obj.push_back(Pair("script", GetTxnOutputType(whichType))); - obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); - UniValue a(UniValue::VARR); - BOOST_FOREACH(const CTxDestination& addr, addresses) - a.push_back(CBitcoinAddress(addr).ToString()); - obj.push_back(Pair("addresses", a)); - if (whichType == TX_MULTISIG) - obj.push_back(Pair("sigsrequired", nRequired)); - } - return obj; - } -}; -#endif - -UniValue coinsupply(const UniValue& params, bool fHelp) -{ - int32_t height = 0; int32_t currentHeight; int64_t zfunds,supply = 0; UniValue result(UniValue::VOBJ); - if (fHelp || params.size() > 1) - throw runtime_error("coinsupply \n" - "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" - "\nArguments:\n" - "1. \"height\" (integer, optional) Block height\n" - "\nResult:\n" - "{\n" - " \"result\" : \"success\", (string) If the request was successful.\n" - " \"coin\" : \"KMD\", (string) The currency symbol of the coin for asset chains, otherwise KMD.\n" - " \"height\" : 420, (integer) The height of this coin supply data\n" - " \"supply\" : \"777.0\", (float) The transparent coin supply\n" - " \"zfunds\" : \"0.777\", (float) The shielded coin supply (in zaddrs)\n" - " \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("coinsupply", "420") - + HelpExampleRpc("coinsupply", "420") - ); - if ( params.size() == 0 ) - height = chainActive.Height(); - else height = atoi(params[0].get_str()); - currentHeight = chainActive.Height(); - - if (height >= 0 && height <= currentHeight) { - if ( (supply= komodo_coinsupply(&zfunds,height)) > 0 ) - { - result.push_back(Pair("result", "success")); - result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); - result.push_back(Pair("height", (int)height)); - result.push_back(Pair("supply", ValueFromAmount(supply))); - result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); - result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); - } else result.push_back(Pair("error", "couldnt calculate supply")); - } else { - result.push_back(Pair("error", "invalid height")); - } - return(result); -} - -UniValue jumblr_deposit(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp || params.size() != 1) - throw runtime_error("jumblr_deposit \"depositaddress\"\n"); - CBitcoinAddress address(params[0].get_str()); - bool isValid = address.IsValid(); - if ( isValid != 0 ) - { - string addr = params[0].get_str(); - if ( (retval= Jumblr_depositaddradd((char *)addr.c_str())) >= 0 ) - { - result.push_back(Pair("result", retval)); - JUMBLR_PAUSE = 0; - } - else result.push_back(Pair("error", retval)); - } else result.push_back(Pair("error", "invalid address")); - return(result); -} - -UniValue jumblr_secret(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp || params.size() != 1) - throw runtime_error("jumblr_secret \"secretaddress\"\n"); - CBitcoinAddress address(params[0].get_str()); - bool isValid = address.IsValid(); - if ( isValid != 0 ) - { - string addr = params[0].get_str(); - retval = Jumblr_secretaddradd((char *)addr.c_str()); - result.push_back(Pair("result", "success")); - result.push_back(Pair("num", retval)); - JUMBLR_PAUSE = 0; - } else result.push_back(Pair("error", "invalid address")); - return(result); -} - -UniValue jumblr_pause(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp ) - throw runtime_error("jumblr_pause\n"); - JUMBLR_PAUSE = 1; - result.push_back(Pair("result", "paused")); - return(result); -} - -UniValue jumblr_resume(const UniValue& params, bool fHelp) -{ - int32_t retval; UniValue result(UniValue::VOBJ); - if (fHelp ) - throw runtime_error("jumblr_resume\n"); - JUMBLR_PAUSE = 0; - result.push_back(Pair("result", "resumed")); - return(result); -} - -UniValue validateaddress(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "validateaddress \"komodoaddress\"\n" - "\nReturn information about the given Komodo address.\n" - "\nArguments:\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\" : \"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" - " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" - " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" - " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") - + HelpExampleRpc("validateaddress", "\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\"") - ); - -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK(cs_main); -#endif - - CBitcoinAddress address(params[0].get_str()); - bool isValid = address.IsValid(); - - UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("isvalid", isValid)); - if (isValid) - { - CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - ret.push_back(Pair("address", currentAddress)); - - CScript scriptPubKey = GetScriptForDestination(dest); - ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f)); -#ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); - ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); - UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest); - ret.pushKVs(detail); - if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) - ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); -#endif - } - return ret; -} - - -UniValue z_validateaddress(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "z_validateaddress \"zaddr\"\n" - "\nReturn information about the given z address.\n" - "\nArguments:\n" - "1. \"zaddr\" (string, required) The z 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\" : \"zaddr\", (string) The z address validated\n" - " \"ismine\" : true|false, (boolean) If the address is yours or not\n" - " \"payingkey\" : \"hex\", (string) The hex value of the paying key, a_pk\n" - " \"transmissionkey\" : \"hex\", (string) The hex value of the transmission key, pk_enc\n" - - "}\n" - "\nExamples:\n" - + HelpExampleCli("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") - + HelpExampleRpc("z_validateaddress", "\"zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL\"") - ); - - -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain->cs_wallet); -#else - LOCK(cs_main); -#endif - - bool isValid = false; - bool isMine = false; - std::string payingKey, transmissionKey; - - string strAddress = params[0].get_str(); - try { - CZCPaymentAddress address(strAddress); - libzcash::PaymentAddress addr = address.Get(); - -#ifdef ENABLE_WALLET - isMine = pwalletMain->HaveSpendingKey(addr); -#endif - payingKey = addr.a_pk.GetHex(); - transmissionKey = addr.pk_enc.GetHex(); - isValid = true; - } catch (std::runtime_error e) { - // address is invalid, nop here as isValid is false. - } - - UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("isvalid", isValid)); - if (isValid) - { - ret.push_back(Pair("address", strAddress)); - ret.push_back(Pair("payingkey", payingKey)); - ret.push_back(Pair("transmissionkey", transmissionKey)); -#ifdef ENABLE_WALLET - ret.push_back(Pair("ismine", isMine)); -#endif - } - return ret; -} - - -/** - * Used by addmultisigaddress / createmultisig: - */ -CScript _createmultisig_redeemScript(const UniValue& params) -{ - int nRequired = params[0].get_int(); - const UniValue& keys = params[1].get_array(); - - // Gather public keys - if (nRequired < 1) - throw runtime_error("a multisignature address must require at least one key to redeem"); - if ((int)keys.size() < nRequired) - throw runtime_error( - strprintf("not enough keys supplied " - "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired)); - if (keys.size() > 16) - throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number"); - std::vector pubkeys; - pubkeys.resize(keys.size()); - for (unsigned int i = 0; i < keys.size(); i++) - { - const std::string& ks = keys[i].get_str(); -#ifdef ENABLE_WALLET - // Case 1: Bitcoin address and we have full public key: - CBitcoinAddress address(ks); - if (pwalletMain && address.IsValid()) - { - CKeyID keyID; - if (!address.GetKeyID(keyID)) - throw runtime_error( - strprintf("%s does not refer to a key",ks)); - CPubKey vchPubKey; - if (!pwalletMain->GetPubKey(keyID, vchPubKey)) - throw runtime_error( - strprintf("no full public key for address %s",ks)); - if (!vchPubKey.IsFullyValid()) - throw runtime_error(" Invalid public key: "+ks); - pubkeys[i] = vchPubKey; - } - - // Case 2: hex public key - else -#endif - if (IsHex(ks)) - { - CPubKey vchPubKey(ParseHex(ks)); - if (!vchPubKey.IsFullyValid()) - throw runtime_error(" Invalid public key: "+ks); - pubkeys[i] = vchPubKey; - } - else - { - throw runtime_error(" Invalid public key: "+ks); - } - } - CScript result = GetScriptForMultisig(nRequired, pubkeys); - - if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) - throw runtime_error( - strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE)); - - return result; -} - -UniValue createmultisig(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 2 || params.size() > 2) - { - string msg = "createmultisig nrequired [\"key\",...]\n" - "\nCreates a multi-signature address with n signature of m keys required.\n" - "It returns a json object with the address and redeemScript.\n" - - "\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 Komodo addresses or hex-encoded public keys\n" - " [\n" - " \"key\" (string) Komodo address or hex-encoded public key\n" - " ,...\n" - " ]\n" - - "\nResult:\n" - "{\n" - " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" - " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" - "}\n" - - "\nExamples:\n" - "\nCreate a multisig address from 2 addresses\n" - + HelpExampleCli("createmultisig", "2 \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") + - "\nAs a json rpc call\n" - + HelpExampleRpc("createmultisig", "2, \"[\\\"RTZMZHDFSTFQst8XmX2dR4DaH87cEUs3gC\\\",\\\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\\\"]\"") - ; - throw runtime_error(msg); - } - - // Construct using pay-to-script-hash: - CScript inner = _createmultisig_redeemScript(params); - CScriptID innerID(inner); - CBitcoinAddress address(innerID); - - UniValue result(UniValue::VOBJ); - result.push_back(Pair("address", address.ToString())); - result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); - - return result; -} - -UniValue verifymessage(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 3) - throw runtime_error( - "verifymessage \"komodoaddress\" \"signature\" \"message\"\n" - "\nVerify a signed message\n" - "\nArguments:\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" - "true|false (boolean) If the signature is verified or not.\n" - "\nExamples:\n" - "\nUnlock the wallet for 30 seconds\n" - + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + - "\nCreate the signature\n" - + HelpExampleCli("signmessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"my message\"") + - "\nVerify the signature\n" - + HelpExampleCli("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\" \"signature\" \"my message\"") + - "\nAs json rpc\n" - + HelpExampleRpc("verifymessage", "\"RNKiEBduBru6Siv1cZRVhp4fkZNyPska6z\", \"signature\", \"my message\"") - ); - - LOCK(cs_main); - - string strAddress = params[0].get_str(); - string strSign = params[1].get_str(); - string strMessage = params[2].get_str(); - - CBitcoinAddress addr(strAddress); - if (!addr.IsValid()) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); - - CKeyID keyID; - if (!addr.GetKeyID(keyID)) - throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); - - bool fInvalid = false; - vector vchSig = DecodeBase64(strSign.c_str(), &fInvalid); - - if (fInvalid) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); - - CHashWriter ss(SER_GETHASH, 0); - ss << strMessageMagic; - ss << strMessage; - - CPubKey pubkey; - if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) - return false; - - return (pubkey.GetID() == keyID); -} - -UniValue setmocktime(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "setmocktime timestamp\n" - "\nSet the local time to given timestamp (-regtest only)\n" - "\nArguments:\n" - "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" - " Pass 0 to go back to using the system time." - ); - - if (!Params().MineBlocksOnDemand()) - throw runtime_error("setmocktime for regression testing (-regtest mode) only"); - - // cs_vNodes is locked and node send/receive times are updated - // atomically with the time change to prevent peers from being - // disconnected because we think we haven't communicated with them - // in a long time. - LOCK2(cs_main, cs_vNodes); - - RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); - SetMockTime(params[0].get_int64()); - - uint64_t t = GetTime(); - BOOST_FOREACH(CNode* pnode, vNodes) { - pnode->nLastSend = pnode->nLastRecv = t; - } - - return NullUniValue; -} - -bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address) -{ - if (type == 2) { - address = CBitcoinAddress(CScriptID(hash)).ToString(); - } else if (type == 1) { - address = CBitcoinAddress(CKeyID(hash)).ToString(); - } - else { - return false; - } - return true; -} - -bool getAddressesFromParams(const UniValue& params, std::vector > &addresses) -{ - if (params[0].isStr()) { - CBitcoinAddress address(params[0].get_str()); - uint160 hashBytes; - int type = 0; - if (!address.GetIndexKey(hashBytes, type)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - addresses.push_back(std::make_pair(hashBytes, type)); - } else if (params[0].isObject()) { - - UniValue addressValues = find_value(params[0].get_obj(), "addresses"); - if (!addressValues.isArray()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Addresses is expected to be an array"); - } - - std::vector values = addressValues.getValues(); - - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - - CBitcoinAddress address(it->get_str()); - uint160 hashBytes; - int type = 0; - if (!address.GetIndexKey(hashBytes, type)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses"); - } - addresses.push_back(std::make_pair(hashBytes, type)); - } - } else { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresse"); - } - - return true; -} - -bool heightSort(std::pair a, - std::pair b) { - return a.second.blockHeight < b.second.blockHeight; -} - -bool timestampSort(std::pair a, - std::pair b) { - return a.second.time < b.second.time; -} - -UniValue getaddressmempool(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddressmempool\n" - "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - "}\n" - "\nResult:\n" - "[\n" - " {\n" - " \"address\" (string) The base58check encoded address\n" - " \"txid\" (string) The related txid\n" - " \"index\" (number) The related input or output index\n" - " \"satoshis\" (number) The difference of satoshis\n" - " \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n" - " \"prevtxid\" (string) The previous txid (if spending)\n" - " \"prevout\" (string) The previous transaction output index (if spending)\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > indexes; - - if (!mempool.getAddressIndex(addresses, indexes)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - - std::sort(indexes.begin(), indexes.end(), timestampSort); - - UniValue result(UniValue::VARR); - - for (std::vector >::iterator it = indexes.begin(); - it != indexes.end(); it++) { - - std::string address; - if (!getAddressFromIndex(it->first.type, it->first.addressBytes, address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); - } - - UniValue delta(UniValue::VOBJ); - delta.push_back(Pair("address", address)); - delta.push_back(Pair("txid", it->first.txhash.GetHex())); - delta.push_back(Pair("index", (int)it->first.index)); - delta.push_back(Pair("satoshis", it->second.amount)); - delta.push_back(Pair("timestamp", it->second.time)); - if (it->second.amount < 0) { - delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex())); - delta.push_back(Pair("prevout", (int)it->second.prevout)); - } - result.push_back(delta); - } - - return result; -} - -UniValue getaddressutxos(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddressutxos\n" - "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ],\n" - " \"chainInfo\" (boolean) Include chain info with results\n" - "}\n" - "\nResult\n" - "[\n" - " {\n" - " \"address\" (string) The address base58check encoded\n" - " \"txid\" (string) The output txid\n" - " \"height\" (number) The block height\n" - " \"outputIndex\" (number) The output index\n" - " \"script\" (strin) The script hex encoded\n" - " \"satoshis\" (number) The number of satoshis of the output\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - bool includeChainInfo = false; - if (params[0].isObject()) { - UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); - if (chainInfo.isBool()) { - includeChainInfo = chainInfo.get_bool(); - } - } - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > unspentOutputs; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (!GetAddressUnspent((*it).first, (*it).second, unspentOutputs)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - - std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort); - - UniValue utxos(UniValue::VARR); - - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - UniValue output(UniValue::VOBJ); - std::string address; - if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); - } - - output.push_back(Pair("address", address)); - output.push_back(Pair("txid", it->first.txhash.GetHex())); - output.push_back(Pair("outputIndex", (int)it->first.index)); - output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end()))); - output.push_back(Pair("satoshis", it->second.satoshis)); - output.push_back(Pair("height", it->second.blockHeight)); - utxos.push_back(output); - } - - if (includeChainInfo) { - UniValue result(UniValue::VOBJ); - result.push_back(Pair("utxos", utxos)); - - LOCK(cs_main); - result.push_back(Pair("hash", chainActive.LastTip()->GetBlockHash().GetHex())); - result.push_back(Pair("height", (int)chainActive.Height())); - return result; - } else { - return utxos; - } -} - -UniValue getaddressdeltas(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1 || !params[0].isObject()) - throw runtime_error( - "getaddressdeltas\n" - "\nReturns all changes for an address (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - " \"start\" (number) The start block height\n" - " \"end\" (number) The end block height\n" - " \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n" - "}\n" - "\nResult:\n" - "[\n" - " {\n" - " \"satoshis\" (number) The difference of satoshis\n" - " \"txid\" (string) The related txid\n" - " \"index\" (number) The related input or output index\n" - " \"height\" (number) The block height\n" - " \"address\" (string) The base58check encoded address\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - - UniValue startValue = find_value(params[0].get_obj(), "start"); - UniValue endValue = find_value(params[0].get_obj(), "end"); - - UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo"); - bool includeChainInfo = false; - if (chainInfo.isBool()) { - includeChainInfo = chainInfo.get_bool(); - } - - int start = 0; - int end = 0; - - if (startValue.isNum() && endValue.isNum()) { - start = startValue.get_int(); - end = endValue.get_int(); - if (start <= 0 || end <= 0) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start and end is expected to be greater than zero"); - } - if (end < start) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "End value is expected to be greater than start"); - } - } - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > addressIndex; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (start > 0 && end > 0) { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } else { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - } - - UniValue deltas(UniValue::VARR); - - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - std::string address; - if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); - } - - UniValue delta(UniValue::VOBJ); - delta.push_back(Pair("satoshis", it->second)); - delta.push_back(Pair("txid", it->first.txhash.GetHex())); - delta.push_back(Pair("index", (int)it->first.index)); - delta.push_back(Pair("blockindex", (int)it->first.txindex)); - delta.push_back(Pair("height", it->first.blockHeight)); - delta.push_back(Pair("address", address)); - deltas.push_back(delta); - } - - UniValue result(UniValue::VOBJ); - - if (includeChainInfo && start > 0 && end > 0) { - LOCK(cs_main); - - if (start > chainActive.Height() || end > chainActive.Height()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start or end is outside chain range"); - } - - CBlockIndex* startIndex = chainActive[start]; - CBlockIndex* endIndex = chainActive[end]; - - UniValue startInfo(UniValue::VOBJ); - UniValue endInfo(UniValue::VOBJ); - - startInfo.push_back(Pair("hash", startIndex->GetBlockHash().GetHex())); - startInfo.push_back(Pair("height", start)); - - endInfo.push_back(Pair("hash", endIndex->GetBlockHash().GetHex())); - endInfo.push_back(Pair("height", end)); - - result.push_back(Pair("deltas", deltas)); - result.push_back(Pair("start", startInfo)); - result.push_back(Pair("end", endInfo)); - - return result; - } else { - return deltas; - } -} - -UniValue getaddressbalance(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddressbalance\n" - "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - "}\n" - "\nResult:\n" - "{\n" - " \"balance\" (string) The current balance in satoshis\n" - " \"received\" (string) The total number of satoshis received (including change)\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - std::vector > addressIndex; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - - CAmount balance = 0; - CAmount received = 0; - - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - if (it->second > 0) { - received += it->second; - } - balance += it->second; - } - - UniValue result(UniValue::VOBJ); - result.push_back(Pair("balance", balance)); - result.push_back(Pair("received", received)); - - return result; - -} - -UniValue komodo_snapshot(int top); - -UniValue getsnapshot(const UniValue& params, bool fHelp) -{ - UniValue result(UniValue::VOBJ); int64_t total; int32_t top = 0; - - if (params.size() > 0 && !params[0].isNull()) { - top = atoi(params[0].get_str().c_str()); - if (top <= 0) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); - } - - if ( fHelp || params.size() > 1) - { - throw runtime_error( - "getsnapshot\n" - "\nReturns a snapshot of (address,amount) pairs at current height (requires addressindex to be enabled).\n" - "\nArguments:\n" - " \"top\" (number, optional) Only return this many addresses, i.e. top N richlist\n" - "\nResult:\n" - "{\n" - " \"addresses\": [\n" - " {\n" - " \"addr\": \"RMEBhzvATA8mrfVK82E5TgPzzjtaggRGN3\",\n" - " \"amount\": \"100.0\"\n" - " },\n" - " {\n" - " \"addr\": \"RqEBhzvATAJmrfVL82E57gPzzjtaggR777\",\n" - " \"amount\": \"23.45\"\n" - " }\n" - " ],\n" - " \"total\": 123.45 (numeric) Total amount in snapshot\n" - " \"average\": 61.7, (numeric) Average amount in each address \n" - " \"utxos\": 14, (number) Total number of UTXOs in snapshot\n" - " \"total_addresses\": 2, (number) Total number of addresses in snapshot,\n" - " \"start_height\": 91, (number) Block height snapshot began\n" - " \"ending_height\": 91 (number) Block height snapsho finished,\n" - " \"start_time\": 1531982752, (number) Unix epoch time snapshot started\n" - " \"end_time\": 1531982752 (number) Unix epoch time snapshot finished\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getsnapshot","") - + HelpExampleRpc("getsnapshot", "1000") - ); - } - result = komodo_snapshot(top); - if ( result.size() > 0 ) { - result.push_back(Pair("end_time", (int) time(NULL))); - } else { - result.push_back(Pair("error", "no addressindex")); - } - return(result); -} - -UniValue getaddresstxids(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getaddresstxids\n" - "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n" - "\nArguments:\n" - "{\n" - " \"addresses\"\n" - " [\n" - " \"address\" (string) The base58check encoded address\n" - " ,...\n" - " ]\n" - " \"start\" (number) The start block height\n" - " \"end\" (number) The end block height\n" - "}\n" - "\nResult:\n" - "[\n" - " \"transactionid\" (string) The transaction id\n" - " ,...\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'") - + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}") - ); - - std::vector > addresses; - - if (!getAddressesFromParams(params, addresses)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); - } - - int start = 0; - int end = 0; - if (params[0].isObject()) { - UniValue startValue = find_value(params[0].get_obj(), "start"); - UniValue endValue = find_value(params[0].get_obj(), "end"); - if (startValue.isNum() && endValue.isNum()) { - start = startValue.get_int(); - end = endValue.get_int(); - } - } - - std::vector > addressIndex; - - for (std::vector >::iterator it = addresses.begin(); it != addresses.end(); it++) { - if (start > 0 && end > 0) { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } else { - if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address"); - } - } - } - - std::set > txids; - UniValue result(UniValue::VARR); - - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { - int height = it->first.blockHeight; - std::string txid = it->first.txhash.GetHex(); - - if (addresses.size() > 1) { - txids.insert(std::make_pair(height, txid)); - } else { - if (txids.insert(std::make_pair(height, txid)).second) { - result.push_back(txid); - } - } - } - - if (addresses.size() > 1) { - for (std::set >::const_iterator it=txids.begin(); it!=txids.end(); it++) { - result.push_back(it->second); - } - } - - return result; - -} - -UniValue getspentinfo(const UniValue& params, bool fHelp) -{ - - if (fHelp || params.size() != 1 || !params[0].isObject()) - throw runtime_error( - "getspentinfo\n" - "\nReturns the txid and index where an output is spent.\n" - "\nArguments:\n" - "{\n" - " \"txid\" (string) The hex string of the txid\n" - " \"index\" (number) The start block height\n" - "}\n" - "\nResult:\n" - "{\n" - " \"txid\" (string) The transaction id\n" - " \"index\" (number) The spending input index\n" - " ,...\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") - + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}") - ); - - UniValue txidValue = find_value(params[0].get_obj(), "txid"); - UniValue indexValue = find_value(params[0].get_obj(), "index"); - - if (!txidValue.isStr() || !indexValue.isNum()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid txid or index"); - } - - uint256 txid = ParseHashV(txidValue, "txid"); - int outputIndex = indexValue.get_int(); - - CSpentIndexKey key(txid, outputIndex); - CSpentIndexValue value; - - if (!GetSpentIndex(key, value)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info"); - } - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("txid", value.txid.GetHex())); - obj.push_back(Pair("index", (int)value.inputIndex)); - obj.push_back(Pair("height", value.blockHeight)); - - return obj; -} From 0ae2e97a1dc62464b4c240d0ab14fe475343b734 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 20:57:21 +0800 Subject: [PATCH 694/951] FIX COMMENTED OUT COIN IMPORT --- src/cc/eval.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/eval.cpp b/src/cc/eval.cpp index 03a0cd142..96b85a6dc 100644 --- a/src/cc/eval.cpp +++ b/src/cc/eval.cpp @@ -74,11 +74,11 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn) switch ( ecode ) { case EVAL_IMPORTPAYOUT: - //return ImportPayout(vparams, txTo, nIn); + return ImportPayout(vparams, txTo, nIn); break; case EVAL_IMPORTCOIN: - //return ImportCoin(vparams, txTo, nIn); + return ImportCoin(vparams, txTo, nIn); break; default: From d29eed22d5c374a38d123109afdfa7183ceaa959 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:14:50 +0800 Subject: [PATCH 695/951] try periodic founders payment first time --- src/komodo_bitcoind.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 582509e57..a0560287f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,6 +1112,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ 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] */ +int32_t ASSETCHAINS_FOUNDERS_PERIOD = 5; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1123,11 +1124,14 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - n = pblock->vtx[0].vout.size(); - for (j=0; jvtx[0].vout[j].nValue; + comission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + { + if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + comission = comission * ASSETCHAINS_FOUNDERS_PERIOD; + else + comission = 0; + } } else { @@ -1141,7 +1145,10 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) total += pblock->vtx[i].vout[j].nValue; } } + commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } + if ( commission < 10000 ) + commission = 0; return(commission); } @@ -1541,7 +1548,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) { fprintf(stderr,"ERROR: chain not fully loaded or invalid PoS block %s - no past block found\n",blkHash.ToString().c_str()); } - else + else #ifndef KOMODO_ZCASH if (!GetTransaction(txid, tx, Params().GetConsensus(), blkHash, true)) #else @@ -1574,7 +1581,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) { BlockMap::const_iterator it = mapBlockIndex.find(blkHash); if ((it == mapBlockIndex.end()) || - !(pastBlockIndex = it->second) || + !(pastBlockIndex = it->second) || (height - pastBlockIndex->GetHeight()) < VERUS_MIN_STAKEAGE) { fprintf(stderr,"ERROR: invalid PoS block %s - stake source too new or not found\n",blkHash.ToString().c_str()); @@ -1665,9 +1672,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { checktoshis = komodo_commission(pblock,height); //fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); - /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here - return(-1); - else*/ if ( checktoshis != 0 ) + if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); From d7a2e9ff2ca8db6b1c8f1cd38fa20f77f76e886e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:26:31 +0800 Subject: [PATCH 696/951] fix splling --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a0560287f..0d74a72e2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1124,13 +1124,13 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - comission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) + commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) - comission = comission * ASSETCHAINS_FOUNDERS_PERIOD; + commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else - comission = 0; + commission = 0; } } else From d361307ffadf26a0ea7afb94ab2b969869b0846d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:28:24 +0800 Subject: [PATCH 697/951] ;# --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0d74a72e2..d50032073 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1124,7 +1124,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN) + commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) From 11a9543ba3b1a493fcb9a4a8483a8f2cbfb48419 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:29:44 +0800 Subject: [PATCH 698/951] fix --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d50032073..f7d209639 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,7 +1127,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { - if ( pblock->nHeight % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + if ( pblock.GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else commission = 0; From 5fa97bf2082bafd407bf43b1f983171073a69a7c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:31:02 +0800 Subject: [PATCH 699/951] fix asgin --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f7d209639..8ceb28f26 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,7 +1127,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { - if ( pblock.GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + if ( pblock->GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else commission = 0; From d5e2a1f96bc5502b63881e813a3be1b7ebf89e22 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 5 Dec 2018 23:32:49 +0800 Subject: [PATCH 700/951] oops --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8ceb28f26..b74c958e1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1127,7 +1127,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) { - if ( pblock->GetHeight() % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; else commission = 0; From 311aa931cc143422b68a7cd5a2dfa0466585b9b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:19:31 +0800 Subject: [PATCH 701/951] add ac_period and try to fix sendmany --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 1 + src/rpc/client.cpp | 2 ++ src/rpc/misc.cpp | 13 +++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c0de313ab..5c17e8dce 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 31cc577e6..2533f4860 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1772,6 +1772,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); + ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 91b158f45..6553a348a 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -36,6 +36,8 @@ static const CRPCConvertParam vRPCConvertParams[] = { "sendtoaddress", 1 }, { "sendtoaddress", 4 }, { "settxfee", 0 }, + { "getnotarysendmany", 0 }, + { "getnotarysendmany", 1 }, { "getreceivedbyaddress", 1 }, { "getreceivedbyaccount", 1 }, { "listreceivedbyaddress", 0 }, diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index abd293b28..4ded906c6 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -119,6 +119,19 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) UniValue getnotarysendmany(const UniValue& params, bool fHelp) { + if (fHelp || params.size() > 1) + throw runtime_error( + "getnotarysendmany\n" + "Returns a sendmany JSON array with all current notaries Raddress's.\n" + "\nExamples:\n" + + HelpExampleCli("getnotarysendmany", "10") + + HelpExampleRpc("getnotarysendmany", "10") + ); + int amount = 0; + if ( params.size() = 1 ) { + amount = params[0].get_int(); + } + int era = getera(time(NULL)); UniValue ret(UniValue::VOBJ); From 51b4c9a346492881c9a42708885f1b02e9d5bf04 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:21:36 +0800 Subject: [PATCH 702/951] missed save --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b74c958e1..d9afece44 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ 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] */ -int32_t ASSETCHAINS_FOUNDERS_PERIOD = 5; +extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); From 6731ee159f2f6dc2f3627ce0ce9718dc5e138fe9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:22:23 +0800 Subject: [PATCH 703/951] fix --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 4ded906c6..878eb3755 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,7 +128,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) + HelpExampleRpc("getnotarysendmany", "10") ); int amount = 0; - if ( params.size() = 1 ) { + if ( params.size() == 1 ) { amount = params[0].get_int(); } From 1e8e9c621b6651aac2fdd6eb2dc1764f878ad65f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 00:26:33 +0800 Subject: [PATCH 704/951] fix --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 878eb3755..e9efaecd5 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -140,7 +140,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) char Raddress[18]; uint8_t pubkey33[33]; decode_hex(pubkey33,33,(char *)notaries_STAKED[era][i][1]); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - ret.push_back(Pair(Raddress,(int)10)); + ret.push_back(Pair(Raddress,amount)); } return ret; } From 6a7df872138c299c1b2369f5e30f8a5b207edaab Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 12:19:21 +0800 Subject: [PATCH 705/951] add 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 c4204f8a0..aa308faee 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7365,7 +7365,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; - //fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); + fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); } else fprintf(stderr,"no destination\n"); } ret.push_back(Pair("mature",(double)total/COIN)); From 665d5446d122f5a0cfba61d251d4fb87b69f9c33 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 12:54:01 +0800 Subject: [PATCH 706/951] debug prints --- src/miner.cpp | 10 +++++++--- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fe9fff5bc..e8b1c211d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -760,23 +760,27 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - //fprintf(stderr,"use notary pubkey\n"); + fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { + fprintf(stderr,"do not use notary pubkey\n"); if (!isStake) { + fprintf(stderr,"is not stake.. whatever that means...\n"); if (!reservekey.GetReservedKey(pubkey)) { + fprintf(stderr,"returning null here\n"); return NULL; } scriptPubKey.resize(35); ptr = (uint8_t *)pubkey.begin(); scriptPubKey[0] = 33; - for (i=0; i<33; i++) + for (i=0; i<33; i++) { scriptPubKey[i+1] = ptr[i]; + fprintf(stderr,"%02x",scriptPubKey[i+1]); + } scriptPubKey[34] = OP_CHECKSIG; - //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } } return CreateNewBlock(scriptPubKey, gpucount, isStake); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index aa308faee..c4204f8a0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7365,7 +7365,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp) if ( out.nDepth < 100 ) nValues2[segid] += nValue, total2 += nValue; else nValues[segid] += nValue, total += nValue; - fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); + //fprintf(stderr,"%s %.8f depth.%d segid.%d\n",(char *)CBitcoinAddress(address).ToString().c_str(),(double)nValue/COIN,(int32_t)out.nDepth,segid); } else fprintf(stderr,"no destination\n"); } ret.push_back(Pair("mature",(double)total/COIN)); From 52f7a22072f892d819478ca1782b7cc5064c01a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:13:21 +0800 Subject: [PATCH 707/951] a --- src/miner.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e8b1c211d..f996841a2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -760,17 +760,14 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - fprintf(stderr,"use notary pubkey\n"); + //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { - fprintf(stderr,"do not use notary pubkey\n"); if (!isStake) { - fprintf(stderr,"is not stake.. whatever that means...\n"); if (!reservekey.GetReservedKey(pubkey)) { - fprintf(stderr,"returning null here\n"); return NULL; } scriptPubKey.resize(35); @@ -778,11 +775,15 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey[0] = 33; for (i=0; i<33; i++) { scriptPubKey[i+1] = ptr[i]; - fprintf(stderr,"%02x",scriptPubKey[i+1]); } scriptPubKey[34] = OP_CHECKSIG; } } + fprintf(stderr,"selected pubkey for new block: "); + for (i=0; i<33; i++) { + fprintf(stderr,"%02x",scriptPubKey[i+1]); + } + fprintf(stderr,"/n"); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From 18c8e33c42de502d8a4e487f01ee936f5db62054 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:20:59 +0800 Subject: [PATCH 708/951] more prints --- src/miner.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index f996841a2..523546f46 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,6 +154,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); } + fprintf(stderr,"selected pubkey inside CreateBlock: "); + for (i=0; i<33; i++) { + fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); + } + fprintf(stderr,"/n"); uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); From bc874c93c57248c4036c22929722a6617dd4b9fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:25:27 +0800 Subject: [PATCH 709/951] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 523546f46..96c1ba894 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,7 +155,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, pk = CPubKey(vAddrs[0]); } fprintf(stderr,"selected pubkey inside CreateBlock: "); - for (i=0; i<33; i++) { + for (int i=0; i<33; i++) { fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); } fprintf(stderr,"/n"); From 94b968f032b659ea57a71a66c73428c40527d1ca Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:35:02 +0800 Subject: [PATCH 710/951] check --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 96c1ba894..70bc59868 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -158,7 +158,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, for (int i=0; i<33; i++) { fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); } - fprintf(stderr,"/n"); + fprintf(stderr,"\n"); uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); @@ -773,6 +773,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, { if (!reservekey.GetReservedKey(pubkey)) { + fprintf(stderr,"selected NULL pubkey."); return NULL; } scriptPubKey.resize(35); @@ -788,7 +789,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, for (i=0; i<33; i++) { fprintf(stderr,"%02x",scriptPubKey[i+1]); } - fprintf(stderr,"/n"); + fprintf(stderr,"\n"); return CreateNewBlock(scriptPubKey, gpucount, isStake); } From b0988d092a6797fd85f7f36e4f945274828831d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:42:35 +0800 Subject: [PATCH 711/951] p --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 70bc59868..5af2af034 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -773,7 +773,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, { if (!reservekey.GetReservedKey(pubkey)) { - fprintf(stderr,"selected NULL pubkey."); return NULL; } scriptPubKey.resize(35); @@ -784,6 +783,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } scriptPubKey[34] = OP_CHECKSIG; } + else fprintf(stderr,"IsStake\n"); } fprintf(stderr,"selected pubkey for new block: "); for (i=0; i<33; i++) { From 69a96d010c5a6517619eba2c76dc11283f00d3a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 13:54:23 +0800 Subject: [PATCH 712/951] FIX easter EGG! --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5af2af034..d2f37fbef 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1479,7 +1479,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0; #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From b5a2aa83c53e2f33de71aa02a5c7a2fdc6a2a223 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:00:15 +0800 Subject: [PATCH 713/951] ) --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index d2f37fbef..6dd32564c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1479,7 +1479,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0; + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From f63a5470fb9a74a8d891af6321d39c9e311c6e31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:24:57 +0800 Subject: [PATCH 714/951] try --- src/rpc/mining.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 25b75c301..d680e3867 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -332,7 +332,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) if (params.size() > 0) fGenerate = params[0].get_bool(); - int nGenProcLimit = GetArg("-genproclimit", -1);; + int nGenProcLimit = GetArg("-genproclimit", 0);; if (params.size() > 1) { nGenProcLimit = params[1].get_int(); @@ -356,6 +356,8 @@ UniValue setgenerate(const UniValue& params, bool fHelp) mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); + fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0); + #ifdef ENABLE_WALLET GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); #else From 5acd49d9e60fb3c786b4a5d2f06353e497ff8a5f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:26:08 +0800 Subject: [PATCH 715/951] _= --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index d680e3867..b61ee0f6e 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -356,7 +356,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0); + fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); #ifdef ENABLE_WALLET GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); From a78c87124a1b523b9448f4e80c91c50413588e3b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:34:46 +0800 Subject: [PATCH 716/951] fix --- src/miner.cpp | 10 ++-------- src/rpc/mining.cpp | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6dd32564c..388de0ba7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -769,7 +769,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { - if (!isStake) + if (!isStake && ASSETCHAINS_STAKED != 0) { if (!reservekey.GetReservedKey(pubkey)) { @@ -783,13 +783,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } scriptPubKey[34] = OP_CHECKSIG; } - else fprintf(stderr,"IsStake\n"); } - fprintf(stderr,"selected pubkey for new block: "); - for (i=0; i<33; i++) { - fprintf(stderr,"%02x",scriptPubKey[i+1]); - } - fprintf(stderr,"\n"); return CreateNewBlock(scriptPubKey, gpucount, isStake); } @@ -1479,7 +1473,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index b61ee0f6e..368f68921 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -353,6 +353,8 @@ UniValue setgenerate(const UniValue& params, bool fHelp) } else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; + fprintf(stderr, "BEFORE MAP miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); + mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); From 128a02eb9b07b49a19148c4becfd0d00d65708d2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:44:34 +0800 Subject: [PATCH 717/951] fix --- src/miner.cpp | 2 +- src/rpc/mining.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 388de0ba7..9e60753a9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -769,7 +769,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } else { - if (!isStake && ASSETCHAINS_STAKED != 0) + if (!isStake || ASSETCHAINS_STAKED != 0) { if (!reservekey.GetReservedKey(pubkey)) { diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 368f68921..9285a1258 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -344,7 +344,10 @@ UniValue setgenerate(const UniValue& params, bool fHelp) { VERUS_MINTBLOCKS = 1; fGenerate = GetBoolArg("-gen", false); - nGenProcLimit = KOMODO_MININGTHREADS; + if ( ASSETCHAINS_STAKED != 0 ) + nGenProcLimit = KOMODO_MININGTHREADS; + else + KOMODO_MININGTHREADS = nGenProcLimit; } else if (!fGenerate) { @@ -353,8 +356,6 @@ UniValue setgenerate(const UniValue& params, bool fHelp) } else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; - fprintf(stderr, "BEFORE MAP miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); - mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); From 4b45ea8d969f739787e0c13bfaa0dcc7ebae1c45 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 14:49:25 +0800 Subject: [PATCH 718/951] fix --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 9285a1258..8e6b1dfa2 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -344,7 +344,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) { VERUS_MINTBLOCKS = 1; fGenerate = GetBoolArg("-gen", false); - if ( ASSETCHAINS_STAKED != 0 ) + if ( ASSETCHAINS_STAKED == 0 ) nGenProcLimit = KOMODO_MININGTHREADS; else KOMODO_MININGTHREADS = nGenProcLimit; From f8bbd607ea2b5c632311677c0533d07751fa8e0f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 15:46:14 +0800 Subject: [PATCH 719/951] fix debug prints --- src/miner.cpp | 5 ----- src/rpc/mining.cpp | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9e60753a9..772980fba 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,11 +154,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); } - fprintf(stderr,"selected pubkey inside CreateBlock: "); - for (int i=0; i<33; i++) { - fprintf(stderr,"%02x",scriptPubKeyIn[i+1]); - } - fprintf(stderr,"\n"); uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); //fprintf(stderr,"create new block\n"); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 8e6b1dfa2..52f4afd10 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -359,8 +359,6 @@ UniValue setgenerate(const UniValue& params, bool fHelp) mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - fprintf(stderr, "miningthreads.%i generate.%i\n",KOMODO_MININGTHREADS,(fGenerate ? 1 : 0)); - #ifdef ENABLE_WALLET GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); #else From d33edb4ff3dbecc1235d5d2079695cc9a171a601 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:05:36 +0800 Subject: [PATCH 720/951] change DNS seeds to exit only if staked chain --- src/net.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index c33f82627..34aebfc1a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1259,11 +1259,14 @@ void ThreadSocketHandler() } } } - +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN] +extern int8_t is_STAKED(const char *chain_name) void ThreadDNSAddressSeed() { - return; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From 38d065a44236526ae42b7e7704a915bb5a336614 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:09:28 +0800 Subject: [PATCH 721/951] fix --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 34aebfc1a..3e7c71242 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,7 +1260,7 @@ void ThreadSocketHandler() } } extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN] -extern int8_t is_STAKED(const char *chain_name) +int8_t is_STAKED(const char *chain_name) void ThreadDNSAddressSeed() { From 1c6795117148754adde41acf6f5cc2024b19268f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:10:15 +0800 Subject: [PATCH 722/951] real fix --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 3e7c71242..f305bd733 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1259,8 +1259,8 @@ void ThreadSocketHandler() } } } -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN] -int8_t is_STAKED(const char *chain_name) +extern char ASSETCHAINS_SYMBOL; +extern int8_t is_STAKED(const char *chain_name) void ThreadDNSAddressSeed() { From 04e51c373ca27f990c5b9f9121081ebe15ff6e2a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:11:01 +0800 Subject: [PATCH 723/951] now its fixed --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index f305bd733..8655e05cb 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,7 +1260,7 @@ void ThreadSocketHandler() } } extern char ASSETCHAINS_SYMBOL; -extern int8_t is_STAKED(const char *chain_name) +extern int8_t is_STAKED(const char *chain_name); void ThreadDNSAddressSeed() { From 98b374cdd6136e402dea45d41997e9465f941f4d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:15:00 +0800 Subject: [PATCH 724/951] try this --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 8655e05cb..d7d81558a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -17,6 +17,7 @@ #include "scheduler.h" #include "ui_interface.h" #include "crypto/common.h" +#include "notaries_staked.h" #ifdef _WIN32 #include @@ -1260,7 +1261,6 @@ void ThreadSocketHandler() } } extern char ASSETCHAINS_SYMBOL; -extern int8_t is_STAKED(const char *chain_name); void ThreadDNSAddressSeed() { From 01861c777f84449ec50080ce769e10a8f11a3393 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:16:20 +0800 Subject: [PATCH 725/951] wtf --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index d7d81558a..25e2fed9f 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1265,7 +1265,7 @@ extern char ASSETCHAINS_SYMBOL; void ThreadDNSAddressSeed() { // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED((const char*)ASSETCHAINS_SYMBOL) != 0 ) return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && From d5ce03972a25da4ae831e8708514ab5479123ae5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:17:16 +0800 Subject: [PATCH 726/951] y --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 25e2fed9f..2d9daf380 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,12 +1260,12 @@ void ThreadSocketHandler() } } } -extern char ASSETCHAINS_SYMBOL; +//extern char ASSETCHAINS_SYMBOL[]; void ThreadDNSAddressSeed() { // skip DNS seeds for staked chains. - if ( is_STAKED((const char*)ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && From 0ccd6d40be1e22f8e2dfd959fcb8381672f12f39 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:22:31 +0800 Subject: [PATCH 727/951] try --- src/net.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 2d9daf380..f7e86bd34 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1260,7 +1260,6 @@ void ThreadSocketHandler() } } } -//extern char ASSETCHAINS_SYMBOL[]; void ThreadDNSAddressSeed() { From 7e85c39a79738fbca409fd1c7caaba222833ad08 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:54:07 +0800 Subject: [PATCH 728/951] the is better, should be able to add own seeds if this works --- src/chainparams.cpp | 13 +++++++++++-- src/net.cpp | 4 ---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a04e4131a..1885088ac 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -6,6 +6,7 @@ #include "key_io.h" #include "main.h" #include "crypto/equihash.h" +#include "notaries_staked.h" #include "util.h" #include "utilstrencodings.h" @@ -201,6 +202,14 @@ public: fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = false; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n", ); + vFixedSeeds.clear(); + vSeeds.clear(); + } + if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,chainparams_commandline,(void *)&consensus) != 0 ) { @@ -257,7 +266,7 @@ void *chainparams_commandline(void *ptr) if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: - // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing + // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing mainParams.consensus.nLwmaAjustedWeight = 1350; mainParams.consensus.nPowAveragingWindow = 45; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); @@ -632,7 +641,7 @@ public: BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; nEquihashK = K; - + genesis = CreateGenesisBlock( 1296688602, uint256S("0x0000000000000000000000000000000000000000000000000000000000000009"), diff --git a/src/net.cpp b/src/net.cpp index f7e86bd34..b36723b28 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -17,7 +17,6 @@ #include "scheduler.h" #include "ui_interface.h" #include "crypto/common.h" -#include "notaries_staked.h" #ifdef _WIN32 #include @@ -1263,9 +1262,6 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - return; // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From c09d9ceefdb89212e83e42a2c3515006e9298279 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:55:15 +0800 Subject: [PATCH 729/951] fix --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1885088ac..1bc848c6d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -205,7 +205,7 @@ public: // skip DNS seeds for staked chains. if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n", ); + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); vFixedSeeds.clear(); vSeeds.clear(); } From 96ea4486a76f1c9a5aca4a36894edb388c990660 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:56:47 +0800 Subject: [PATCH 730/951] try --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1bc848c6d..b4a383456 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -6,7 +6,6 @@ #include "key_io.h" #include "main.h" #include "crypto/equihash.h" -#include "notaries_staked.h" #include "util.h" #include "utilstrencodings.h" @@ -77,6 +76,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st */ void *chainparams_commandline(void *ptr); #include "komodo_defs.h" +#include "notaries_staked.h" extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; From ade96c9e6520682d4fbe94a567b885bd099578f2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 17:58:50 +0800 Subject: [PATCH 731/951] try --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b4a383456..ff2cbc48e 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -76,7 +76,6 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st */ void *chainparams_commandline(void *ptr); #include "komodo_defs.h" -#include "notaries_staked.h" extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; @@ -84,6 +83,7 @@ extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; +int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { From e6515a9f87ca02b511670e6e1b1cfc4a696b0c4c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:03:00 +0800 Subject: [PATCH 732/951] sloppy --- src/chainparams.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index ff2cbc48e..7f7eb8820 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -83,7 +83,6 @@ extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; -int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { @@ -203,7 +202,14 @@ public: fTestnetToBeDeprecatedFieldRPC = false; // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + int8_t STAKED = 0; + if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) + STAKED = 1; + else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) + STAKED = 2; + else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + STAKED = 3; + if ( STAKED != 0 ) { fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); vFixedSeeds.clear(); From 2a0cb852a55fa8633cafc32edab1315fffb4a40a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:07:00 +0800 Subject: [PATCH 733/951] fix --- src/chainparams.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7f7eb8820..eb3b5f514 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -203,11 +203,11 @@ public: // skip DNS seeds for staked chains. int8_t STAKED = 0; - if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) + if ( (strcmp(ASSETCHAINS_SYMBOL, "LABS") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LABS", 4) == 0) ) STAKED = 1; - else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) + else if ( (strcmp(ASSETCHAINS_SYMBOL, "LAB") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LAB", 3) == 0) ) STAKED = 2; - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + else if ( (strcmp(ASSETCHAINS_SYMBOL, "CFEK") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "CFEK", 4) == 0) ) STAKED = 3; if ( STAKED != 0 ) { From e108119312c4dc771477fadac8c6c266d0a7a64f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:15:06 +0800 Subject: [PATCH 734/951] better again? --- src/chainparams.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index eb3b5f514..cd6635552 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -83,6 +83,7 @@ extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; +extern int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { @@ -201,21 +202,6 @@ public: fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = false; - // skip DNS seeds for staked chains. - int8_t STAKED = 0; - if ( (strcmp(ASSETCHAINS_SYMBOL, "LABS") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LABS", 4) == 0) ) - STAKED = 1; - else if ( (strcmp(ASSETCHAINS_SYMBOL, "LAB") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "LAB", 3) == 0) ) - STAKED = 2; - else if ( (strcmp(ASSETCHAINS_SYMBOL, "CFEK") == 0) || (strncmp(ASSETCHAINS_SYMBOL, "CFEK", 4) == 0) ) - STAKED = 3; - if ( STAKED != 0 ) - { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - vFixedSeeds.clear(); - vSeeds.clear(); - } - if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,chainparams_commandline,(void *)&consensus) != 0 ) { @@ -267,6 +253,13 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); + mainParams.vFixedSeeds.clear(); + mainParams.vSeeds.clear(); + } fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) From d4c29970c53dbb3810966ce51606c7383c52207e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:26:25 +0800 Subject: [PATCH 735/951] fix? --- src/chainparams.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chainparams.h b/src/chainparams.h index 566f07f36..fb0af946a 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -111,6 +111,8 @@ public: //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); }; CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved Consensus::Params consensus; + std::vector vFixedSeeds; + std::vector vSeeds; protected: CChainParams() {} @@ -123,14 +125,12 @@ protected: uint64_t nPruneAfterHeight = 0; unsigned int nEquihashN = 0; unsigned int nEquihashK = 0; - std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; std::string bech32HRPs[MAX_BECH32_TYPES]; std::string strNetworkID; std::string strCurrencyUnits; uint32_t bip44CoinType; CBlock genesis; - std::vector vFixedSeeds; bool fMiningRequiresPeers = false; bool fDefaultConsistencyChecks = false; bool fRequireStandard = false; From 1e487493a6ac9b839deb95000f9ea879046d73a7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:37:54 +0800 Subject: [PATCH 736/951] try --- src/chainparams.cpp | 6 ++++++ src/chainparams.h | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index cd6635552..9cf7fcf97 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -216,6 +216,12 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } +void ClearSeeds() +{ + vSeeds.clear(); + vFixedSeeds.clear(); +} + int32_t MAX_BLOCK_SIZE(int32_t height) { //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); diff --git a/src/chainparams.h b/src/chainparams.h index fb0af946a..6637f9ac1 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -104,6 +104,7 @@ public: void SetDefaultPort(uint16_t port) { nDefaultPort = port; } void SetCheckpointData(CCheckpointData checkpointData); + void ClearSeeds(); //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); } //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; } @@ -111,8 +112,6 @@ public: //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); }; CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved Consensus::Params consensus; - std::vector vFixedSeeds; - std::vector vSeeds; protected: CChainParams() {} @@ -125,12 +124,14 @@ protected: uint64_t nPruneAfterHeight = 0; unsigned int nEquihashN = 0; unsigned int nEquihashK = 0; + std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; std::string bech32HRPs[MAX_BECH32_TYPES]; std::string strNetworkID; std::string strCurrencyUnits; uint32_t bip44CoinType; CBlock genesis; + std::vector vFixedSeeds; bool fMiningRequiresPeers = false; bool fDefaultConsistencyChecks = false; bool fRequireStandard = false; From 73afad81775d112c00f12fa4db3d3a50fbf8de1a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:42:37 +0800 Subject: [PATCH 737/951] fool errand --- src/chainparams.cpp | 13 ------------- src/chainparams.h | 1 - src/net.cpp | 9 +++++++++ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9cf7fcf97..452e232a6 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -216,12 +216,6 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat CChainParams::checkpointData = checkpointData; } -void ClearSeeds() -{ - vSeeds.clear(); - vFixedSeeds.clear(); -} - int32_t MAX_BLOCK_SIZE(int32_t height) { //fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight); @@ -259,13 +253,6 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - mainParams.vFixedSeeds.clear(); - mainParams.vSeeds.clear(); - } fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) diff --git a/src/chainparams.h b/src/chainparams.h index 6637f9ac1..566f07f36 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -104,7 +104,6 @@ public: void SetDefaultPort(uint16_t port) { nDefaultPort = port; } void SetCheckpointData(CCheckpointData checkpointData); - void ClearSeeds(); //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); } //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; } diff --git a/src/net.cpp b/src/net.cpp index b36723b28..a456830a4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1262,6 +1262,15 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { + extern int8_t is_STAKED(const char *chain_name); + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); + mainParams.vFixedSeeds.clear(); + mainParams.vSeeds.clear(); + } + // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { From 7f19010a7be811968ec44acaba09057e57d51736 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:44:27 +0800 Subject: [PATCH 738/951] try --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index a456830a4..db1794699 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1263,12 +1263,12 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { extern int8_t is_STAKED(const char *chain_name); + extern char ASSETCHAINS_SYMBOL[65]; // skip DNS seeds for staked chains. if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - mainParams.vFixedSeeds.clear(); - mainParams.vSeeds.clear(); + return; } // goal: only query DNS seeds if address need is acute From 29cefb7ef161aa9b4d8c42f790156e34150047cd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 18:53:05 +0800 Subject: [PATCH 739/951] FIXED? --- src/net.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index db1794699..e78f1846c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1380,13 +1380,19 @@ void ThreadOpenConnections() // Add seed nodes if DNS seeds are all down (an infrastructure attack?). // if (addrman.size() == 0 && (GetTime() - nStart > 60)) { - if (GetTime() - nStart > 60) { - static bool done = false; - if (!done) { - //LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); - LogPrintf("Adding fixed seed nodes.\n"); - addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1")); - done = true; + extern int8_t is_STAKED(const char *chain_name); + extern char ASSETCHAINS_SYMBOL[65]; + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) + { + if (GetTime() - nStart > 60) { + static bool done = false; + if (!done) { + //LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); + LogPrintf("Adding fixed seed nodes.\n"); + addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1")); + done = true; + } } } From ce88a314868dd1f341a354a80605449c61c19798 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:16:11 +0800 Subject: [PATCH 740/951] ipv6 unreachable no print --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 7369b0167..84e84f6ca 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -498,7 +498,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe CloseSocket(hSocket); return false; } - if (nRet != 0) + if (nRet != 0 && nRet != 101) { LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); From 04c758ba8bbbe4ed55235e337edd42a044dd8e5c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:23:48 +0800 Subject: [PATCH 741/951] fix --- src/netbase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 84e84f6ca..cb443e5ea 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -498,9 +498,10 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe CloseSocket(hSocket); return false; } - if (nRet != 0 && nRet != 101) + if (nRet != 0) { - LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); + if ( nRet != 101) + LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); return false; } From a02f7be2539eeb6624abf369e8a1a72e54e17402 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:29:06 +0800 Subject: [PATCH 742/951] fix --- src/netbase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index cb443e5ea..e9aea7965 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -500,8 +500,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe } if (nRet != 0) { - if ( nRet != 101) - LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); + LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); return false; } @@ -512,7 +511,8 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); + if ( nRet != 101) + LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } From 135ad0456cb4cccc87f3b7a9dac1e08343dc0443 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:30:47 +0800 Subject: [PATCH 743/951] try --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index e9aea7965..a8d279ad7 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,7 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - if ( nRet != 101) + if ( NetworkErrorString(WSAGetLastError() != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; From c9b2ab288a31ac294b97076b6cd400475c9706cd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:31:29 +0800 Subject: [PATCH 744/951] fix --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index a8d279ad7..28adce0e2 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,7 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - if ( NetworkErrorString(WSAGetLastError() != "101") + if ( NetworkErrorString(WSAGetLastError()) != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; From c144c7d68bfc1ddc3c38d526f4a865ba3b207646 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:50:54 +0800 Subject: [PATCH 745/951] wtf --- src/netbase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/netbase.cpp b/src/netbase.cpp index 28adce0e2..9838c4528 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,6 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { + fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError())); if ( NetworkErrorString(WSAGetLastError()) != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); From b1d5f3efc7a7f05767aa40bbe149c540f7afb986 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:52:23 +0800 Subject: [PATCH 746/951] fix --- src/netbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 9838c4528..167cd8f95 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,7 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError())); + fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError()).c_str()); if ( NetworkErrorString(WSAGetLastError()) != "101") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); From 04285b4b257648f89e81829426aca4e706702e24 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 6 Dec 2018 19:54:08 +0800 Subject: [PATCH 747/951] finally works? --- src/netbase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index 167cd8f95..baae83e4a 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -511,8 +511,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - fprintf(stderr, "%s\n", NetworkErrorString(WSAGetLastError()).c_str()); - if ( NetworkErrorString(WSAGetLastError()) != "101") + if ( NetworkErrorString(WSAGetLastError()) != "Network is unreachable (101)") LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; From b76ca3dc43dce40ca09b462803cb558f2c2e7249 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 7 Dec 2018 00:38:13 +0800 Subject: [PATCH 748/951] Try wallet fix here --- src/main.cpp | 24 ++++++++++++++++++++++-- src/wallet/walletdb.cpp | 9 ++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7668f7f87..912ab7cf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3835,15 +3835,16 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), newSaplingTree)); // Let wallets know transactions went from 1-confirmed to // 0-confirmed or conflicted: + std::vector TxToRemove; for (int i = 0; i < block.vtx.size(); i++) { CTransaction &tx = block.vtx[i]; //if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { - //EraseFromWallets(tx.GetHash()); #ifdef ENABLE_WALLET - pwalletMain->EraseFromWallet(tx.GetHash()); + TxToRemove.push_back(tx.GetHash()); + //pwalletMain->EraseFromWallet(tx.GetHash()); #endif } else @@ -3851,6 +3852,25 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { SyncWithWallets(tx, NULL); } } + if ( ASSETCHAINS_STAKED != 0 ) // If Staked chain, scan wallet for orphaned txs and delete them. + { + LOCK2(cs_main, pwalletMain->cs_wallet); + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction((*it).first,tx,hashBlock,true)) + { + fprintf(stderr, "TX Does Not Exist: %s\n",(*it).first.ToString().c_str()); + TxToRemove.push_back((*it).first); + } + } + BOOST_FOREACH (uint256& hash, TxToRemove) + { + pwalletMain->EraseFromWallet(hash); + fprintf(stderr, "Erased %s from wallet.\n",hash.ToString().c_str()); + } + } // Update cached incremental witnesses GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false); return true; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 41c0de4b2..52c815ce2 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -867,6 +867,8 @@ static bool IsKeyType(string strType) strType == "mkey" || strType == "ckey"); } +extern uint64_t ASSETCHAINS_STAKED; + DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { pwallet->vchDefaultKey = CPubKey(); @@ -918,8 +920,9 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx") - // Rescan if there is a bad transaction record: + if (strType == "tx" && ASSETCHAINS_STAKED == 0 ) + // Rescan if there is a bad transaction record.. + // But dont on staked chains! SoftSetBoolArg("-rescan", true); } } @@ -967,7 +970,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (wss.fAnyUnordered) result = ReorderTransactions(pwallet); - + return result; } From dd6b254fd46edfe9a73cda32b291179d8292f04a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 7 Dec 2018 00:52:38 +0800 Subject: [PATCH 749/951] fix --- 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 c4204f8a0..fe1ead8ad 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5294,7 +5294,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; From 25406293e54ad4a1ef25890494aedafab40cffc9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 7 Dec 2018 01:34:15 +0800 Subject: [PATCH 750/951] add ac_period to --- src/komodo_utils.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2533f4860..67a080556 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1771,8 +1771,8 @@ void komodo_args(char *argv0) ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); - ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); + ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); + ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1874,7 +1874,11 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } From 6d3a761da6552656aa68693363976271a9f69c01 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 10 Dec 2018 17:57:28 +0800 Subject: [PATCH 751/951] is this fixed? --- src/komodo_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 67a080556..37b411ead 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1874,11 +1874,11 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - } + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } From 0a1874835c2b65e84e2d30b898009d1cba615c67 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 08:31:15 +0800 Subject: [PATCH 752/951] fix silly code --- src/notaries_staked.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ba9a88343..e53553b23 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -153,10 +153,9 @@ void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) { { // staked era is set. pthread_mutex_lock(&staked_mutex); - for (int i = 0; i Date: Tue, 11 Dec 2018 08:57:09 +0800 Subject: [PATCH 753/951] attempt simpler to crypto address function --- src/main.cpp | 3 --- src/miner.cpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 912ab7cf8..7084ddbb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1597,7 +1597,6 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) { - extern int32_t KOMODO_ON_DEMAND; { LOCK(mempool.cs); uint256 hash = tx.GetHash(); @@ -1918,8 +1917,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa KOMODO_CONNECTING = -1; // Store transaction in memory - if ( komodo_is_notarytx(tx) == 0 ) - KOMODO_ON_DEMAND++; pool.addUnchecked(hash, entry, !IsInitialBlockDownload()); if (!tx.IsCoinImport()) diff --git a/src/miner.cpp b/src/miner.cpp index 772980fba..484b03a6d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #include "komodo_defs.h" -#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" +//#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern CCriticalSection cs_metrics; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; @@ -272,12 +272,16 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { - // TODO: It will be much faster here to just compare scriptpubkey to the crypto pubkey! - CTxDestination ToAddress; int numNotaryVins = 0; bool fToCryptoAddress = false; + int numNotaryVins = 0; bool fToCryptoAddress = false; + if ( komodo_is_notarytx(tx) == 1 ) + fToCryptoAddress = true; + + /*CTxDestination ToAddress; if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) fToCryptoAddress = true; - } + } */ + BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction From 319308d956e117ad35a0bc924f58d858101b7983 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 08:59:17 +0800 Subject: [PATCH 754/951] fix --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 484b03a6d..39155dc50 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -141,6 +141,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); +int32_t komodo_is_notarytx(const CTransaction& tx); CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { From 7c60f8032a05544b2b43182cb2a3d875e5d04596 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 09:59:10 +0800 Subject: [PATCH 755/951] clean up. --- src/miner.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 39155dc50..c5cdd6ac2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,6 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #include "komodo_defs.h" -//#define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern CCriticalSection cs_metrics; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; @@ -277,12 +276,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if ( komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; - /*CTxDestination ToAddress; - if (ExtractDestination(tx.vout[0].scriptPubKey, ToAddress)) { - if ( strcmp(CRYPTO777_KMDADDR,CBitcoinAddress(ToAddress).ToString().c_str()) == 0 ) - fToCryptoAddress = true; - } */ - BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction From bf11ecef123d5398d38746abe7b8d9507d10a575 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:15:17 +0800 Subject: [PATCH 756/951] Add segid to getsnapshot --- src/txdb.cpp | 71 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 212eda7a0..0b55f3338 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -45,7 +45,7 @@ static const char DB_LAST_BLOCK = 'l'; CCoinsViewDB::CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / dbName, nCacheSize, fMemory, fWipe) { } -CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe) +CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe) { } @@ -107,7 +107,7 @@ uint256 CCoinsViewDB::GetBestBlock() const { uint256 CCoinsViewDB::GetBestAnchor(ShieldedType type) const { uint256 hashBestAnchor; - + switch (type) { case SPROUT: if (!db.Read(DB_BEST_SPROUT_ANCHOR, hashBestAnchor)) @@ -421,6 +421,7 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, } bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address); +uint32_t komodo_segid32(char *coinaddr); UniValue CBlockTreeDB::Snapshot(int top) { @@ -433,23 +434,23 @@ UniValue CBlockTreeDB::Snapshot(int top) result.push_back(Pair("start_time", (int) time(NULL))); std::map ignoredMap = { - {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, - {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, - {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, - {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, - {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, - {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, - {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, - {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, - {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, - {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, - {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, - {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, - {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, - {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey + {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, + {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, + {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, + {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, + {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, + {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, + {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, + {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, + {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, + {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, + {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, + {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, + {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, + {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, + {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, + {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey }; int64_t startingHeight = chainActive.Height(); @@ -511,29 +512,31 @@ UniValue CBlockTreeDB::Snapshot(int top) //fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses); for (std::pair element : addressAmounts) { - vaddr.push_back( make_pair(element.second, element.first) ); + vaddr.push_back( make_pair(element.second, element.first) ); } std::sort(vaddr.rbegin(), vaddr.rend()); UniValue obj(UniValue::VOBJ); UniValue addressesSorted(UniValue::VARR); int topN = 0; - for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) { - UniValue obj(UniValue::VOBJ); - obj.push_back( make_pair("addr", it->second.c_str() ) ); - char amount[32]; - sprintf(amount, "%.8f", (double) it->first / COIN); - obj.push_back( make_pair("amount", amount) ); - total += it->first; - addressesSorted.push_back(obj); - topN++; - // If requested, only show top N addresses in output JSON - if (top == topN) - break; + for (std::vector>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) + { + UniValue obj(UniValue::VOBJ); + obj.push_back( make_pair("addr", it->second.c_str() ) ); + char amount[32]; + sprintf(amount, "%.8f", (double) it->first / COIN); + obj.push_back( make_pair("amount", amount) ); + obj.push_back( make_pair("segid", komodo_segid32(it->second.c_str()))); + total += it->first; + addressesSorted.push_back(obj); + topN++; + // If requested, only show top N addresses in output JSON + if (top == topN) + break; } if (top) - totalAddresses = top; + totalAddresses = top; if (totalAddresses > 0) { // Array of all addreses with balances @@ -670,7 +673,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nCachedBranchId = diskindex.nCachedBranchId; pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; - + // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From d75387aa35e38e484d7c85987ee30e3203639288 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:16:57 +0800 Subject: [PATCH 757/951] fix? --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 0b55f3338..5183599f9 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", komodo_segid32(it->second.c_str()))); + obj.push_back( make_pair("segid", komodo_segid32((char *)it->second.c_str()))); total += it->first; addressesSorted.push_back(obj); topN++; From 10e4b836a4bb2f38d1ab627b2615f4502c875761 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:18:00 +0800 Subject: [PATCH 758/951] fix --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 5183599f9..f0ebb2deb 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", komodo_segid32((char *)it->second.c_str()))); + obj.push_back( make_pair("segid", (int)komodo_segid32((char *)it->second.c_str()))); total += it->first; addressesSorted.push_back(obj); topN++; From bcf2def09789ac0d91a7a0a36839ac71b74936d9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:34:26 +0800 Subject: [PATCH 759/951] fix --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index f0ebb2deb..15c46fc08 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", (int)komodo_segid32((char *)it->second.c_str()))); + obj.push_back( make_pair("segid", (uint32_t)komodo_segid32((char *)it->second.c_str()))); total += it->first; addressesSorted.push_back(obj); topN++; From 5dcc40c3add9c825803018b9d5e69578f82943e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:41:11 +0800 Subject: [PATCH 760/951] convert unsigned int --- src/txdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 15c46fc08..123917549 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,8 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid", (uint32_t)komodo_segid32((char *)it->second.c_str()))); + int segid = (short) komodo_segid32( (char *)it->second.c_str() ); + obj.push_back( make_pair("segid",(int) segid)) ); total += it->first; addressesSorted.push_back(obj); topN++; From 632d84fd6116c23c877bd7e6dd11fb995536ae0e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:42:24 +0800 Subject: [PATCH 761/951] ) --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 123917549..8d2ae7366 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -527,7 +527,7 @@ UniValue CBlockTreeDB::Snapshot(int top) sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); int segid = (short) komodo_segid32( (char *)it->second.c_str() ); - obj.push_back( make_pair("segid",(int) segid)) ); + obj.push_back( make_pair("segid",(int) segid) ); total += it->first; addressesSorted.push_back(obj); topN++; From 3a35b8345bff0849d48f01db5db221b0b253739b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:47:35 +0800 Subject: [PATCH 762/951] fixed --- src/txdb.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 8d2ae7366..00e43495a 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,8 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - int segid = (short) komodo_segid32( (char *)it->second.c_str() ); - obj.push_back( make_pair("segid",(int) segid) ); + obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f) ); total += it->first; addressesSorted.push_back(obj); topN++; From a0ad1185d8f4b6cb1c30b8136cb473f8d7070d5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:50:11 +0800 Subject: [PATCH 763/951] nope --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 00e43495a..c54c3e28e 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f) ); + obj.push_back( make_pair("segid",((int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f)) ); total += it->first; addressesSorted.push_back(obj); topN++; From ab5447324f16c9496a465ea5b9888b8271dd1cb6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 11:52:39 +0800 Subject: [PATCH 764/951] fix --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index c54c3e28e..11c52f071 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -526,7 +526,7 @@ UniValue CBlockTreeDB::Snapshot(int top) char amount[32]; sprintf(amount, "%.8f", (double) it->first / COIN); obj.push_back( make_pair("amount", amount) ); - obj.push_back( make_pair("segid",((int32_t)komodo_segid32((char *)it->second.c_str() & 0x3f)) ); + obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) ); total += it->first; addressesSorted.push_back(obj); topN++; From 5ced63c9c902d3da02bde1d97dc3e46c0481f129 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 11 Dec 2018 14:18:44 +0800 Subject: [PATCH 765/951] Add getlastsegidstakes RPC --- src/rpc/blockchain.cpp | 64 +++++++++++++++++++++++++++++++++++++++++- src/rpc/client.cpp | 1 + src/rpc/server.cpp | 11 ++++---- src/rpc/server.h | 1 + 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a69a4ebb3..f2bf20e3e 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -606,6 +606,68 @@ UniValue getblockhash(const UniValue& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } +extern uint64_t ASSETCHAINS_STAKED; +int32_t komodo_isPoS(CBlock *pblock); +uint32_t komodo_segid32(char *coinaddr); + +UniValue getlastsegidstakes(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getlastsegidstakes depth\n" + "\nReturns object containing the counts of the last X blocks staked by each segid.\n" + "\nArguments:\n" + "1. depth (numeric, required) The amount of blocks to scan back." + "\nResult:\n" + "{\n" + " \"0\" : n, (numeric) number of stakes from segid 0 in the last X blocks.\n" + " .....\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getlastsegidstakes", "1000") + + HelpExampleRpc("getlastsegidstakes", "1000") + ); + + if ( ASSETCHAINS_STAKED == 0 ) + throw runtime_error("Only applies to ac_staked chains\n"); + + LOCK(cs_main); + + int depth = params[0].get_int(); + int32_t segids[64] = {0}; + + for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) + { + CBlockIndex* pblockindex = chainActive[i]; + CBlock block; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + if ( komodo_isPoS((CBlock *)&block) != 0 ) + { + CTxDestination voutaddress; int32_t segid; + if ( ExtractDestination(block.vtx[block.vtx.size()-1].vout[0].scriptPubKey,voutaddress) ) + { + segid = (int32_t)komodo_segid32((char *)CBitcoinAddress(voutaddress).ToString().c_str()) & 0x3f; + segids[segid] += 1; + } + } + } + + UniValue ret(UniValue::VOBJ); + for (int8_t i = 0; i < 64; i++) + { + char str[4]; + sprintf(str, "%d", i); + ret.push_back(Pair(str,segids[i])); + } + return ret; +} + /*uint256 _komodo_getblockhash(int32_t nHeight) { uint256 hash; @@ -859,7 +921,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp) " \"currentheight\": xxxxx, (numeric) current height of the chain\n" " \"key\": \"xxxxx\", (string) key\n" " \"keylen\": xxxxx, (string) length of the key \n" - " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" + " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" " \"height\": xxxxx, (numeric) height the key was stored at\n" " \"expiration\": xxxxx, (numeric) height the key will expire\n" " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 6553a348a..bf8cb0c38 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -74,6 +74,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 2 }, { "getblock", 1 }, { "getblockheader", 1 }, + { "getlastsegidstakes", 0 }, { "gettransaction", 1 }, { "getrawtransaction", 1 }, { "createrawtransaction", 0 }, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 47f29bbfa..eb3cc80a0 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -304,6 +304,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "getblockhashes", &getblockhashes, true }, { "blockchain", "getblockhash", &getblockhash, true }, { "blockchain", "getblockheader", &getblockheader, true }, + { "blockchain", "getlastsegidstakes", &getlastsegidstakes, true }, { "blockchain", "getchaintips", &getchaintips, true }, { "blockchain", "getdifficulty", &getdifficulty, true }, { "blockchain", "getmempoolinfo", &getmempoolinfo, true }, @@ -366,16 +367,16 @@ static const CRPCCommand vRPCCommands[] = // auction { "auction", "auctionaddress", &auctionaddress, true }, - + // lotto { "lotto", "lottoaddress", &lottoaddress, true }, - + // fsm { "FSM", "FSMaddress", &FSMaddress, true }, { "FSM", "FSMcreate", &FSMcreate, true }, { "FSM", "FSMlist", &FSMlist, true }, { "FSM", "FSMinfo", &FSMinfo, true }, - + // rewards { "rewards", "rewardslist", &rewardslist, true }, { "rewards", "rewardsinfo", &rewardsinfo, true }, @@ -384,7 +385,7 @@ static const CRPCCommand vRPCCommands[] = { "rewards", "rewardslock", &rewardslock, true }, { "rewards", "rewardsunlock", &rewardsunlock, true }, { "rewards", "rewardsaddress", &rewardsaddress, true }, - + // faucet { "faucet", "faucetinfo", &faucetinfo, true }, { "faucet", "faucetfund", &faucetfund, true }, @@ -401,7 +402,7 @@ static const CRPCCommand vRPCCommands[] = { "channels", "channelspayment", &channelspayment, true }, { "channels", "channelsclose", &channelsclose, true }, { "channels", "channelsrefund", &channelsrefund, true }, - + // Oracles { "oracles", "oraclesaddress", &oraclesaddress, true }, { "oracles", "oracleslist", &oracleslist, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 122e818c3..e64216116 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -385,6 +385,7 @@ extern UniValue getblockhashes(const UniValue& params, bool fHelp); extern UniValue getblockdeltas(const UniValue& params, bool fHelp); extern UniValue getblockhash(const UniValue& params, bool fHelp); extern UniValue getblockheader(const UniValue& params, bool fHelp); +extern UniValue getlastsegidstakes(const UniValue& params, bool fHelp); extern UniValue getblock(const UniValue& params, bool fHelp); extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp); extern UniValue gettxout(const UniValue& params, bool fHelp); From 345260d1b5d42dc9eb9ec492726bd90aa99d2c2f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Dec 2018 13:13:57 +0800 Subject: [PATCH 766/951] oops --- src/wallet/rpcwallet.cpp | 53 ---------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 062e2ec24..dab6f19dd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4641,7 +4641,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (!fEnableMergeToAddress) { strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg); } -<<<<<<< HEAD if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( @@ -4694,58 +4693,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); -======= - - if (fHelp || params.size() < 2 || params.size() > 6) - throw runtime_error( - "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" - + strDisabledMsg + - "\nMerge multiple UTXOs and notes into a single UTXO or note. Coinbase UTXOs are ignored; use `z_shieldcoinbase`" - "\nto combine those into a single note." - "\n\nThis is an asynchronous operation, and UTXOs selected for merging will be locked. If there is an error, they" - "\nare unlocked. The RPC call `listlockunspent` can be used to return a list of locked UTXOs." - "\n\nThe number of UTXOs and notes selected for merging can be limited by the caller. If the transparent limit" - "\nparameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit option will determine the" - "\nnumber of UTXOs. Any limit is constrained by the consensus rule defining a maximum transaction size of" - + strprintf("\n%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING) - + HelpRequiringPassphrase() + "\n" - "\nArguments:\n" - "1. fromaddresses (string, required) A JSON array with addresses.\n" - " The following special strings are accepted inside the array:\n" - " - \"ANY_TADDR\": Merge UTXOs from any t-addrs belonging to the wallet.\n" - " - \"ANY_SPROUT\": Merge notes from any Sprout z-addrs belonging to the wallet.\n" - " - \"ANY_SAPLING\": Merge notes from any Sapling z-addrs belonging to the wallet.\n" - " If a special string is given, any given addresses of that type will be ignored.\n" - " [\n" - " \"address\" (string) Can be a t-addr or a z-addr\n" - " ,...\n" - " ]\n" - "2. \"toaddress\" (string, required) The t-addr or z-addr to send the funds to.\n" - "3. fee (numeric, optional, default=" - + strprintf("%s", FormatMoney(MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n" - "4. transparent_limit (numeric, optional, default=" - + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n" - "4. shielded_limit (numeric, optional, default=" - + strprintf("%d Sprout or %d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT, MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" - "\nResult:\n" - "{\n" - " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" - " \"remainingTransparentValue\": xxx (numeric) Value of UTXOs still available for merging.\n" - " \"remainingNotes\": xxx (numeric) Number of notes still available for merging.\n" - " \"remainingShieldedValue\": xxx (numeric) Value of notes still available for merging.\n" - " \"mergingUTXOs\": xxx (numeric) Number of UTXOs being merged.\n" - " \"mergingTransparentValue\": xxx (numeric) Value of UTXOs being merged.\n" - " \"mergingNotes\": xxx (numeric) Number of notes being merged.\n" - " \"mergingShieldedValue\": xxx (numeric) Value of notes being merged.\n" - " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("z_mergetoaddress", "'[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") - + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\"") - ); - ->>>>>>> e719e666307adb77fb4b79c7737256ea959fe188 if (!fEnableMergeToAddress) { throw JSONRPCError(RPC_WALLET_ERROR, "Error: z_mergetoaddress is disabled."); } From 3e7c05f2f0dc79118675bf9f9599956e8fb6576c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 13 Dec 2018 13:18:06 +0800 Subject: [PATCH 767/951] fix --- 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 dab6f19dd..1771e6abb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4672,7 +4672,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) "4. transparent_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n" "4. shielded_limit (numeric, optional, default=" - + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" + + strprintf("%d Sprout or %d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT, MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" From 58076c86ea94a3d9c682695618c4ebf00802afc1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 09:34:03 +0800 Subject: [PATCH 768/951] fix build --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b4214d491..519753090 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -44,7 +44,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; From 95cada6581668e87acb89ca53a51ba1da1d063bf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 09:37:28 +0800 Subject: [PATCH 769/951] fix conflict --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 519753090..8f2fa782c 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,NUM_NOTARIES; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ebeebd712..94a44d123 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1774,13 +1774,7 @@ void komodo_args(char *argv0) ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); -<<<<<<< HEAD - ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); -======= ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - //ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); ->>>>>>> 655ef3c8ae43446c2cd361677699dcbe37f8fea4 if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; From de19acf57f3af47a596ff855902634f812da7798 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 10:51:43 +0800 Subject: [PATCH 770/951] try fix --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 94a44d123..6af8af4cc 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,7 +1538,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"sapling\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1}\""; From c75b409f673557c13d1c63913a21186d1c62c7aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 11:05:37 +0800 Subject: [PATCH 771/951] revert --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6af8af4cc..94a44d123 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,7 +1538,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"sapling\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; From e474c107ed5bc3047b872af7775c41edb6377d4f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 11:40:00 +0800 Subject: [PATCH 772/951] revert agin --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 94a44d123..6af8af4cc 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1538,7 +1538,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"sapling\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1}\""; From 3028d884e531765a4f02b5be21b91cf324690fa2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 16 Dec 2018 23:04:45 +0800 Subject: [PATCH 773/951] Major rebase and fix staking. --- src/komodo_bitcoind.h | 1 - src/komodo_notary.h | 78 +++++++++++++++++++--------------------- src/komodo_utils.h | 2 +- src/main.cpp | 70 ++++++++++++------------------------ src/wallet/rpcwallet.cpp | 4 +-- src/wallet/walletdb.cpp | 5 +-- 6 files changed, 63 insertions(+), 97 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 882292032..a342bb459 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ 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] */ -extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 96497b755..58bc3bffa 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -207,59 +207,55 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - timestamp = komodo_heightstamp(height); + timestamp = komodo_heightstamp(height); else if ( ASSETCHAINS_SYMBOL[0] == 0 ) - timestamp = 0; + timestamp = 0; // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. if (is_STAKED(ASSETCHAINS_SYMBOL) == 0) { - if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) - { - if ( did0 == 0 ) - { - n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); - for (i=0; i= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) + timestamp = 0; + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) + { + if ( did0 == 0 ) + { + n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6af8af4cc..c4c26e0c7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1711,7 +1711,7 @@ void komodo_args(char *argv0) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); } - if ( name.c_str()[0] != 0 ) + if ( name.c_str()[0] != 0 ) { std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0])); diff --git a/src/main.cpp b/src/main.cpp index 17ff3cbb8..1385ab69b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1244,7 +1244,8 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { for (int32_t i=0; i<=NUM_NOTARIES; i++) if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) return(1); @@ -1764,8 +1765,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = true; //fprintf(stderr,"missing inputs\n"); - return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); - return(false); + if (!fSkipExpiry) + return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); + else + return(false); } } @@ -1773,7 +1776,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveInputs(tx)) { //fprintf(stderr,"accept failure.1\n"); - return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); + if (!fSkipExpiry) + return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); + else + return(false); } } // are the joinsplit's requirements met? @@ -3302,7 +3308,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if (!view.HaveInputs(tx)) { - return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), + return state.DoS(100, error("ConnectBlock(): inputs missing/spent %s",tx.GetHash().ToString().c_str()), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } // are the JoinSplit's requirements met? @@ -3846,8 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET - TxToRemove.push_back(tx.GetHash()); - //pwalletMain->EraseFromWallet(tx.GetHash()); + pwalletMain->EraseFromWallet(tx.GetHash()); #endif } else @@ -3855,25 +3860,6 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { SyncWithWallets(tx, NULL); } } - if ( ASSETCHAINS_STAKED != 0 ) // If Staked chain, scan wallet for orphaned txs and delete them. - { - LOCK2(cs_main, pwalletMain->cs_wallet); - for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - CTransaction tx; - uint256 hashBlock; - if (!GetTransaction((*it).first,tx,hashBlock,true)) - { - fprintf(stderr, "TX Does Not Exist: %s\n",(*it).first.ToString().c_str()); - TxToRemove.push_back((*it).first); - } - } - BOOST_FOREACH (uint256& hash, TxToRemove) - { - pwalletMain->EraseFromWallet(hash); - fprintf(stderr, "Erased %s from wallet.\n",hash.ToString().c_str()); - } - } // Update cached incremental witnesses GetMainSignals().ChainTip(pindexDelete, &block, newSproutTree, newSaplingTree, false); return true; @@ -6601,32 +6587,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addrFrom; uint64_t nNonce = 1; int nVersion; // use temporary for version, don't set version number until validated as connected + int minVersion = MIN_PEER_PROTO_VERSION; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + minVersion = STAKEDMIN_PEER_PROTO_VERSION; vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe; if (nVersion == 10300) nVersion = 300; - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if (nVersion < minVersion) { - if (nVersion < STAKEDMIN_PEER_PROTO_VERSION) - { - // disconnect from peers older than this proto version - LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); - pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, - strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); - pfrom->fDisconnect = true; - return false; - } - } - else - { - if (nVersion < MIN_PEER_PROTO_VERSION) - { - // disconnect from peers older than this proto version - LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); - pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, - strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); - pfrom->fDisconnect = true; - return false; - } + // disconnect from peers older than this proto version + LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); + pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, + strprintf("Version must be %d or greater", minVersion)); + pfrom->fDisconnect = true; + return false; } // Reject incoming connections from nodes that don't know about the current epoch diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1771e6abb..2f6455701 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5317,7 +5317,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; @@ -5388,7 +5388,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } //else fprintf(stderr,"utxo not eligible\n"); } - if ( numkp < 10000 && array != 0 ) + if ( numkp < 1000 && array != 0 ) { free(array); array = 0; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 52c815ce2..4dedab834 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -867,8 +867,6 @@ static bool IsKeyType(string strType) strType == "mkey" || strType == "ckey"); } -extern uint64_t ASSETCHAINS_STAKED; - DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { pwallet->vchDefaultKey = CPubKey(); @@ -920,9 +918,8 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx" && ASSETCHAINS_STAKED == 0 ) + if (strType == "tx" ) // Rescan if there is a bad transaction record.. - // But dont on staked chains! SoftSetBoolArg("-rescan", true); } } From 2ebdae67e8fbe0e8decd4f7fded3410c1c826390 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 11:41:26 +0800 Subject: [PATCH 774/951] fix setgenerate better, bug on deamon stop it was starting another staking thread. --- src/miner.cpp | 4 ++-- src/rpc/mining.cpp | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 01ee92234..5c8109f40 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1441,7 +1441,7 @@ void static BitcoinMiner() #ifdef ENABLE_WALLET // notaries always default to staking - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif @@ -1831,7 +1831,7 @@ void static BitcoinMiner() } //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); - if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 ) + if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 && fGenerate ) { if ( pwallet != NULL ) nThreads = 1; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5ed1de14c..042dd9b00 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -339,22 +339,25 @@ UniValue setgenerate(const UniValue& params, bool fHelp) //if (nGenProcLimit == 0) // fGenerate = false; } - - if (fGenerate && !nGenProcLimit) + if ( ASSETCHAINS_LWMAPOS != 0 ) { - VERUS_MINTBLOCKS = 1; - fGenerate = GetBoolArg("-gen", false); - if ( ASSETCHAINS_STAKED == 0 ) - nGenProcLimit = KOMODO_MININGTHREADS; - else + if (fGenerate && !nGenProcLimit) + { + VERUS_MINTBLOCKS = 1; + fGenerate = GetBoolArg("-gen", false); KOMODO_MININGTHREADS = nGenProcLimit; + } + else if (!fGenerate) + { + VERUS_MINTBLOCKS = 0; + KOMODO_MININGTHREADS = 0; + } + else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; } - else if (!fGenerate) + else { - VERUS_MINTBLOCKS = 0; - KOMODO_MININGTHREADS = 0; + KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; } - else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit; mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); From cacd2c7c02ca85bfaf5daa6d05f2181953d52bb1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 16:24:29 +0800 Subject: [PATCH 775/951] fix prints and revert mempool error. --- src/crosschain_authority.cpp | 1 - src/main.cpp | 2 +- src/notarisationdb.cpp | 5 ----- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/crosschain_authority.cpp b/src/crosschain_authority.cpp index b4379c010..7487e4879 100644 --- a/src/crosschain_authority.cpp +++ b/src/crosschain_authority.cpp @@ -42,7 +42,6 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth) if (!seen[i]) { if (memcmp(pk, auth.notaries[i], 33) == 0) { seen[i] = 1; - printf("seennotary.%i\n",i); goto found; } else { //printf("notary.%i is not valid!\n",i); diff --git a/src/main.cpp b/src/main.cpp index c11e58818..cc97b366f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4748,7 +4748,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C CValidationState state; CTransaction Tx; const CTransaction &tx = (CTransaction)block.vtx[i]; - if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) + if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) continue; Tx = tx; if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync diff --git a/src/notarisationdb.cpp b/src/notarisationdb.cpp index c1cee2877..3b0746d80 100644 --- a/src/notarisationdb.cpp +++ b/src/notarisationdb.cpp @@ -41,24 +41,19 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight) } else if (authority == CROSSCHAIN_STAKED) { // We need to create auth_STAKED dynamically here based on timestamp int32_t staked_era = STAKED_era(timestamp); - printf("ERA.(%d) \n",staked_era); if (staked_era == 0) { // this is an ERA GAP, so we will ignore this notarization - printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol); continue; } else { // pass era slection off to notaries_staked.cpp file auth_STAKED = Choose_auth_STAKED(staked_era); } - printf("minsigs.%i era.%i authsize.%i\n",auth_STAKED.requiredSigs,staked_era,auth_STAKED.size); if (!CheckTxAuthority(tx, auth_STAKED)) continue; - printf("Authorised notarisation data for %s \n",data.symbol); } if (parsed) { vNotarisations.push_back(std::make_pair(tx.GetHash(), data)); - printf("Added notarisation data for %s \n",data.symbol); //printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n", // data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth); //if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data()); From 1d1b1290e7d45da563549063fe4467576e8b866e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:23:30 +0800 Subject: [PATCH 776/951] try this --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index bce67d116..3e3791288 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1682,7 +1682,8 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - return(false); + break; + //return(false); } KOMODO_CHOSEN_ONE = 1; // Found a solution From 7a7ae42ab63e7ebe683ae55d7b92c53ce1fdb865 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:36:30 +0800 Subject: [PATCH 777/951] fix? --- src/miner.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3e3791288..4ecf39cb7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1589,6 +1589,7 @@ void static BitcoinMiner() KOMODO_INSYNC = Mining_height; sleep(3); }*/ + bool breakLoop = false; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -1682,8 +1683,9 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - break; - //return(false); + if ( ASSETCHAINS_STAKED != 0 ) + breakLoop = true; + return(false); } KOMODO_CHOSEN_ONE = 1; // Found a solution @@ -1818,6 +1820,8 @@ void static BitcoinMiner() } }*/ } + if (breakLoop) + break; } } catch (const boost::thread_interrupted&) From 867f7853706d8b867198fd6d4837c59cbf3a5869 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:40:35 +0800 Subject: [PATCH 778/951] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4ecf39cb7..dec49ac12 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1614,7 +1614,7 @@ void static BitcoinMiner() else hashTarget = HASHTarget; std::function)> validBlock = #ifdef ENABLE_WALLET - [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams] + [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams, &breakLoop] #else [&pblock, &hashTarget, &m_cs, &cancelSolver, &chainparams] #endif From 90d1fee4812acc76156ea06da2a62e018144c1d1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 17:46:20 +0800 Subject: [PATCH 779/951] try --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index dec49ac12..2de3816f6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1579,6 +1579,7 @@ void static BitcoinMiner() LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } + bool breakLoop; while (true) { /*if ( KOMODO_INSYNC == 0 ) @@ -1589,7 +1590,7 @@ void static BitcoinMiner() KOMODO_INSYNC = Mining_height; sleep(3); }*/ - bool breakLoop = false; + breakLoop = false; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; From 8402a8e954bc6d1d03be5d9bb2ff27621211052c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 18:28:45 +0800 Subject: [PATCH 780/951] fix --- src/miner.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 2de3816f6..9e63da568 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1579,7 +1579,7 @@ void static BitcoinMiner() LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } - bool breakLoop; + //bool breakLoop; while (true) { /*if ( KOMODO_INSYNC == 0 ) @@ -1590,7 +1590,7 @@ void static BitcoinMiner() KOMODO_INSYNC = Mining_height; sleep(3); }*/ - breakLoop = false; + bool breakLoop = false; komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -1716,7 +1716,8 @@ void static BitcoinMiner() std::lock_guard lock{m_cs}; return cancelSolver; }; - + if (breakLoop) + break; // TODO: factor this out into a function with the same API for each solver. if (solver == "tromp" ) { //&& notaryid >= 0 ) { // Create solver and initialize it. @@ -1821,8 +1822,6 @@ void static BitcoinMiner() } }*/ } - if (breakLoop) - break; } } catch (const boost::thread_interrupted&) From e57b2a05fa1eb5f33ed8a93c778443f820b9df2b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 19:14:49 +0800 Subject: [PATCH 781/951] print --- src/main.cpp | 3 ++- src/miner.cpp | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cc97b366f..8b88d44b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3311,7 +3311,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if (!view.HaveInputs(tx)) { - return state.DoS(100, error("ConnectBlock(): inputs missing/spent %s",tx.GetHash().ToString().c_str()), + fprintf(stderr, "Connect Block missing inputs tx_number.%d \nvin txid.%s vout.%ld \n",i,tx.vin[0].prevout.hash.ToString().c_str(),tx.vin[0].prevout.n); + return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } // are the JoinSplit's requirements met? diff --git a/src/miner.cpp b/src/miner.cpp index 9e63da568..dfadf2e33 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1579,7 +1579,6 @@ void static BitcoinMiner() LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } } - //bool breakLoop; while (true) { /*if ( KOMODO_INSYNC == 0 ) From 993444ec3c891e1eea0c4e8c101aa3d0e9230bf7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 19:19:43 +0800 Subject: [PATCH 782/951] fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8b88d44b3..3e6264480 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3311,7 +3311,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if (!view.HaveInputs(tx)) { - fprintf(stderr, "Connect Block missing inputs tx_number.%d \nvin txid.%s vout.%ld \n",i,tx.vin[0].prevout.hash.ToString().c_str(),tx.vin[0].prevout.n); + fprintf(stderr, "Connect Block missing inputs tx_number.%d \nvin txid.%s vout.%d \n",i,tx.vin[0].prevout.hash.ToString().c_str(),tx.vin[0].prevout.n); return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } From 165634876794b60091a99646a44386ac3dc767bf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Dec 2018 00:26:35 +0800 Subject: [PATCH 783/951] Ram staker is fixed! --- src/komodo_bitcoind.h | 277 +++++++++++++++++++++++++++++++++++++++ src/miner.cpp | 7 +- src/wallet/rpcwallet.cpp | 246 +--------------------------------- 3 files changed, 279 insertions(+), 251 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3f524d136..ef915f06c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -25,6 +25,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); +bool EnsureWalletIsAvailable(bool avoidException); //#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr)) @@ -610,6 +611,28 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr) return(txtime); } +int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout) +{ + int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; + if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 ) + { + txid = pblock->vtx[n-1].vin[0].prevout.hash; + vout = pblock->vtx[n-1].vin[0].prevout.n; + txtime = komodo_txtime(&value,txid,vout,destaddr); + if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) ) + { + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[n-1].vout[0].nValue == value ) + { + //fprintf(stderr,"is PoS block!\n"); + addressout = voutaddress; + return(1); + } + } + } + return(0); +} + int32_t komodo_isPoS(CBlock *pblock) { int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; @@ -1935,3 +1958,257 @@ int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) *sproutfundsp = sproutfunds; return(supply); } + +struct komodo_staking +{ + char address[64]; + uint256 txid; + arith_uint256 hashval; + uint64_t nValue; + uint32_t segid32,txtime; + int32_t vout; + CScript scriptPubKey; +}; + +struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numkp,int32_t *maxkp,uint32_t txtime,uint64_t nValue,uint256 txid,int32_t vout,char *address,uint8_t *hashbuf,CScript pk) +{ + uint256 hash; uint32_t segid32; struct komodo_staking *kp; + segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); + if ( *numkp >= *maxkp ) + { + *maxkp += 1000; + array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp)); + //fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); + } + kp = &array[(*numkp)++]; + //fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); + memset(kp,0,sizeof(*kp)); + strcpy(kp->address,address); + kp->txid = txid; + kp->vout = vout; + kp->hashval = UintToArith256(hash); + kp->txtime = txtime; + kp->segid32 = segid32; + kp->nValue = nValue; + kp->scriptPubKey = pk; + return(array); +} + +arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) +{ + int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; + diff = (iter + blocktime - kp->txtime - minage); + if ( diff < 0 ) + diff = 60; + else if ( diff > 3600*24*30 ) + diff = 3600*24*30; + if ( iter > 0 ) + diff += segid*2; + coinage = ((uint64_t)kp->nValue * diff); + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + coinage256 = arith_uint256(coinage+1); + hashval = ratio * (kp->hashval / coinage256); + return(hashval); +} + +uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komodo_staking *kp,int32_t nHeight,uint32_t blocktime,uint32_t prevtime,int32_t minage,uint8_t *hashbuf) +{ + int32_t maxiters = 600; uint256 hash; + int32_t segid,iter,diff; uint64_t coinage; arith_uint256 hashval,coinage256; + komodo_stakehash(&hash,kp->address,hashbuf,kp->txid,kp->vout); + kp->hashval = UintToArith256(hash); + segid = ((nHeight + kp->segid32) & 0x3f); + hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); + //for (int i=32; i>=0; i--) + // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); + if ( hashval <= bnTarget ) + { + for (iter=0; itertxtime+minage ) + continue; + hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); + if ( hashval <= bnTarget ) + { + //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); + blocktime += iter; + blocktime += segid * 2; + return(blocktime); + } + } + } else fprintf(stderr,"maxiters is not good enough\n"); + return(0); +} + +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) +{ + static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; + set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; + if (!EnsureWalletIsAvailable(0)) + return 0; + + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + ratio = (mindiff / bnTarget); + assert(pwalletMain != NULL); + *utxovaluep = 0; + memset(utxotxidp,0,sizeof(*utxotxidp)); + memset(utxovoutp,0,sizeof(*utxovoutp)); + memset(utxosig,0,72); + if ( (tipindex= chainActive.Tip()) == 0 ) + return(0); + nHeight = tipindex->GetHeight() + 1; + if ( (minage= nHeight*3) > 6000 ) // about 100 blocks + minage = 6000; + komodo_segids(hashbuf,nHeight-101,100); + if ( *blocktimep < tipindex->nTime+60 ) + *blocktimep = tipindex->nTime+60; + //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); + + bool resetstaker = false; + if ( array != 0 ) + { + CBlockIndex* pblockindex = chainActive[tipindex->GetHeight()]; + CBlock block; CTxDestination addressout; + if( ReadBlockFromDisk(block, pblockindex, 1) && komodo_WhoStaked(&block, addressout) != 0 && IsMine(*pwalletMain,addressout) != 0 ) + { + resetstaker = true; + fprintf(stderr, "Reset ram staker after mining a block!\n"); + } + } + + if ( time(NULL) > lasttime+600 || array == 0 || resetstaker ) + { + LOCK2(cs_main, pwalletMain->cs_wallet); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); + if ( array != 0 ) + { + free(array); + array = 0; + maxkp = numkp = 0; + lasttime = 0; + } + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if ( (tipindex= chainActive.Tip()) == 0 || tipindex->GetHeight()+1 > nHeight ) + { + fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); + return(0); + } + counter++; + if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) + { + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + continue; + } + CAmount nValue = out.tx->vout[out.i].nValue; + if ( nValue < COIN || !out.fSpendable ) + continue; + const CScript& pk = out.tx->vout[out.i].scriptPubKey; + if ( ExtractDestination(pk,address) != 0 ) + { + if ( IsMine(*pwalletMain,address) == 0 ) + continue; + if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) + { + array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); + //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); + } + } + } + lasttime = (uint32_t)time(NULL); +//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); + } +//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); + block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; + for (i=winners=0; iGetHeight()+1 > nHeight ) + { + fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); + return(0); + } + kp = &array[i]; + if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) + continue; + eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); +//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); + if ( eligible > 0 ) + { + besttime = m = 0; + if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + { + while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + { + besttime = eligible; + eligible--; + if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier + break; + m++; +//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + } + } + else + { + fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + continue; + } + eligible = besttime; + winners++; +//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); + if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) + { + earliest = eligible; + best_scriptPubKey = kp->scriptPubKey; //out.tx->vout[out.i].scriptPubKey; + *utxovaluep = (uint64_t)kp->nValue; + //decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); + decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str()); + *utxovoutp = kp->vout; + *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; + fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); + } + } //else fprintf(stderr,"utxo not eligible\n"); + } + if ( numkp < 1000 && array != 0 ) + { + free(array); + array = 0; + maxkp = numkp = 0; + lasttime = 0; + } + if ( earliest != 0 ) + { + 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 *)utxotxidp)[31 - i]; + txNew.vin[0].prevout.hash = revtxid; + txNew.vin[0].prevout.n = *utxovoutp; + txNew.vout[0].scriptPubKey = best_scriptPubKey;// CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + txNew.vout[0].nValue = *utxovaluep - txfee; + txNew.nLockTime = earliest; + CTransaction txNewConst(txNew); + signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); + if (!signSuccess) + fprintf(stderr,"failed to create signature\n"); + else + { + UpdateTransaction(txNew,0,sigdata); + ptr = (uint8_t *)&sigdata.scriptSig[0]; + siglen = sigdata.scriptSig.size(); + for (i=0; i)> validBlock = #ifdef ENABLE_WALLET - [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams, &breakLoop] + [&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams] #else [&pblock, &hashTarget, &m_cs, &cancelSolver, &chainparams] #endif @@ -1683,8 +1682,6 @@ void static BitcoinMiner() for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&h)[z]); fprintf(stderr," Invalid block mined, try again\n"); - if ( ASSETCHAINS_STAKED != 0 ) - breakLoop = true; return(false); } KOMODO_CHOSEN_ONE = 1; @@ -1715,8 +1712,6 @@ void static BitcoinMiner() std::lock_guard lock{m_cs}; return cancelSolver; }; - if (breakLoop) - break; // TODO: factor this out into a function with the same API for each solver. if (solver == "tromp" ) { //&& notaryid >= 0 ) { // Create solver and initialize it. diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c8b747dc7..710210a80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4218,7 +4218,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) } if ( toSapling && ASSETCHAINS_SYMBOL[0] == 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER,"Sprout usage will expire soon"); - + // If we are sending from a shielded address, all recipient // shielded addresses must be of the same type. if ((fromSprout && toSapling) || (fromSapling && toSprout)) { @@ -5109,9 +5109,6 @@ UniValue z_listoperationids(const UniValue& params, bool fHelp) #include "script/sign.h" 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); -int8_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 txid,int32_t vout); -void komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) { @@ -5192,247 +5189,6 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) return(siglen); } -struct komodo_staking -{ - char address[64]; - uint256 txid; - arith_uint256 hashval; - uint64_t nValue; - uint32_t segid32,txtime; - int32_t vout; - CScript scriptPubKey; -}; - -struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numkp,int32_t *maxkp,uint32_t txtime,uint64_t nValue,uint256 txid,int32_t vout,char *address,uint8_t *hashbuf,CScript pk) -{ - uint256 hash; uint32_t segid32; struct komodo_staking *kp; - segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); - if ( *numkp >= *maxkp ) - { - *maxkp += 1000; - array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp)); - //fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); - } - kp = &array[(*numkp)++]; - //fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); - memset(kp,0,sizeof(*kp)); - strcpy(kp->address,address); - kp->txid = txid; - kp->vout = vout; - kp->hashval = UintToArith256(hash); - kp->txtime = txtime; - kp->segid32 = segid32; - kp->nValue = nValue; - kp->scriptPubKey = pk; - return(array); -} - -arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) -{ - int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; - diff = (iter + blocktime - kp->txtime - minage); - if ( diff < 0 ) - diff = 60; - else if ( diff > 3600*24*30 ) - diff = 3600*24*30; - if ( iter > 0 ) - diff += segid*2; - coinage = ((uint64_t)kp->nValue * diff); - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - coinage256 = arith_uint256(coinage+1); - hashval = ratio * (kp->hashval / coinage256); - return(hashval); -} - -uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komodo_staking *kp,int32_t nHeight,uint32_t blocktime,uint32_t prevtime,int32_t minage,uint8_t *hashbuf) -{ - int32_t maxiters = 600; uint256 hash; - int32_t segid,iter,diff; uint64_t coinage; arith_uint256 hashval,coinage256; - komodo_stakehash(&hash,kp->address,hashbuf,kp->txid,kp->vout); - kp->hashval = UintToArith256(hash); - segid = ((nHeight + kp->segid32) & 0x3f); - hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - //for (int i=32; i>=0; i--) - // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - for (iter=0; itertxtime+minage ) - continue; - hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); - blocktime += iter; - blocktime += segid * 2; - return(blocktime); - } - } - } else fprintf(stderr,"maxiters is not good enough\n"); - return(0); -} - -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) -{ - static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; - set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; - if (!EnsureWalletIsAvailable(0)) - return 0; - - bnTarget.SetCompact(nBits, &fNegative, &fOverflow); - mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - ratio = (mindiff / bnTarget); - assert(pwalletMain != NULL); - LOCK2(cs_main, pwalletMain->cs_wallet); - *utxovaluep = 0; - memset(utxotxidp,0,sizeof(*utxotxidp)); - memset(utxovoutp,0,sizeof(*utxovoutp)); - memset(utxosig,0,72); - pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); - if ( (tipindex= chainActive.Tip()) == 0 ) - return(0); - nHeight = tipindex->GetHeight() + 1; - if ( (minage= nHeight*3) > 6000 ) // about 100 blocks - minage = 6000; - komodo_segids(hashbuf,nHeight-101,100); - if ( *blocktimep < tipindex->nTime+60 ) - *blocktimep = tipindex->nTime+60; - //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); - if ( time(NULL) > lasttime+600 || array == 0 ) - { - if ( array != 0 ) - { - free(array); - array = 0; - maxkp = numkp = 0; - lasttime = 0; - } - BOOST_FOREACH(const COutput& out, vecOutputs) - { - if ( (tipindex= chainActive.Tip()) == 0 || tipindex->GetHeight()+1 > nHeight ) - { - fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); - return(0); - } - counter++; - if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) - { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); - continue; - } - CAmount nValue = out.tx->vout[out.i].nValue; - if ( nValue < COIN || !out.fSpendable ) - continue; - const CScript& pk = out.tx->vout[out.i].scriptPubKey; - if ( ExtractDestination(pk,address) != 0 ) - { - if ( IsMine(*pwalletMain,address) == 0 ) - continue; - if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) - { - array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); - //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); - } - } - } - lasttime = (uint32_t)time(NULL); -//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); - } -//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); - block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; - for (i=winners=0; iGetHeight()+1 > nHeight ) - { - fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); - return(0); - } - kp = &array[i]; - if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) - continue; - eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); - if ( eligible > 0 ) - { - besttime = m = 0; - if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) - { - while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) - { - besttime = eligible; - eligible--; - if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier - break; - m++; -//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); - } - } - else - { - fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); - continue; - } - eligible = besttime; - winners++; -//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); - if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) - { - earliest = eligible; - best_scriptPubKey = kp->scriptPubKey; //out.tx->vout[out.i].scriptPubKey; - *utxovaluep = (uint64_t)kp->nValue; - //decode_hex((uint8_t *)utxotxidp,32,(char *)out.tx->GetHash().GetHex().c_str()); - decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str()); - *utxovoutp = kp->vout; - *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; - fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); - } - } //else fprintf(stderr,"utxo not eligible\n"); - } - if ( numkp < 1000 && array != 0 ) - { - free(array); - array = 0; - maxkp = numkp = 0; - lasttime = 0; - } - if ( earliest != 0 ) - { - 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 *)utxotxidp)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; - txNew.vin[0].prevout.n = *utxovoutp; - txNew.vout[0].scriptPubKey = best_scriptPubKey;// CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; - txNew.vout[0].nValue = *utxovaluep - txfee; - txNew.nLockTime = earliest; - CTransaction txNewConst(txNew); - signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); - if (!signSuccess) - fprintf(stderr,"failed to create signature\n"); - else - { - UpdateTransaction(txNew,0,sigdata); - ptr = (uint8_t *)&sigdata.scriptSig[0]; - siglen = sigdata.scriptSig.size(); - for (i=0; iVerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig, pk); From 6a2e2b414c281633fb371dcc89431946b1f2150d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Dec 2018 23:36:00 +0800 Subject: [PATCH 784/951] Fix lockups with ram staker! --- src/miner.cpp | 527 +++++++++++++++++++++++++------------------------- 1 file changed, 264 insertions(+), 263 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index d68c0d192..ab0630e6f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -200,286 +200,288 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, boost::optional cheatSpend; uint256 cbHash; - CBlockIndex* pindexPrev = 0; + SaplingMerkleTree sapling_tree; uint64_t commission; + int nHeight = 0; + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + + CBlockIndex* pindexPrev = chainActive.LastTip();; { - LOCK2(cs_main, mempool.cs); - pindexPrev = chainActive.LastTip(); - const int nHeight = pindexPrev->GetHeight() + 1; - const Consensus::Params &consensusParams = chainparams.GetConsensus(); - uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); - bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + { // contain lock to block generation and not staking loops. + LOCK2(cs_main, mempool.cs); + nHeight = pindexPrev->GetHeight() + 1; + uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); + bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); - const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - { - // too fast or stuck, this addresses the too fast issue, while moving - // forward as quickly as possible - for (int i; i < 100; i++) + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + uint32_t proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) { - proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - MilliSleep(10); - } - } - pblock->nTime = GetAdjustedTime(); - - CCoinsViewCache view(pcoinsTip); - uint32_t expired; uint64_t commission; - - SaplingMerkleTree sapling_tree; - assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); - - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); - - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size() + 1); - - // now add transactions from the mem pool - for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) - { - const CTransaction& tx = mi->GetTx(); - - int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) - ? nMedianTimePast - : pblock->GetBlockTime(); - - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) - { - //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); - continue; - } - - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) - { - //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); - continue; - } - - COrphan* porphan = NULL; - double dPriority = 0; - CAmount nTotalIn = 0; - bool fMissingInputs = false; - bool fNotarisation = false; - if (tx.IsCoinImport()) - { - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { - int numNotaryVins = 0; bool fToCryptoAddress = false; - if ( komodo_is_notarytx(tx) == 1 ) - fToCryptoAddress = true; - - BOOST_FOREACH(const CTxIn& txin, tx.vin) + // too fast or stuck, this addresses the too fast issue, while moving + // forward as quickly as possible + for (int i; i < 100; i++) { - // Read prev transaction - if (!view.HaveCoins(txin.prevout.hash)) - { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } + proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + MilliSleep(10); + } + } + pblock->nTime = GetAdjustedTime(); - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; - continue; - } - const CCoins* coins = view.AccessCoins(txin.prevout.hash); - assert(coins); + CCoinsViewCache view(pcoinsTip); + uint32_t expired; - CAmount nValueIn = coins->vout[txin.prevout.n].nValue; + assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); + + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + bool fPrintPriority = GetBoolArg("-printpriority", false); + + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size() + 1); + + // now add transactions from the mem pool + for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); + mi != mempool.mapTx.end(); ++mi) + { + const CTransaction& tx = mi->GetTx(); + + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + { + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + continue; + } + + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) + { + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); + continue; + } + + COrphan* porphan = NULL; + double dPriority = 0; + CAmount nTotalIn = 0; + bool fMissingInputs = false; + bool fNotarisation = false; + if (tx.IsCoinImport()) + { + CAmount nValueIn = GetCoinImportValue(tx); nTotalIn += nValueIn; + dPriority += (double)nValueIn * 1000; // flat multiplier + } else { + int numNotaryVins = 0; bool fToCryptoAddress = false; + if ( komodo_is_notarytx(tx) == 1 ) + fToCryptoAddress = true; - int nConf = nHeight - coins->nHeight; - - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress ) + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - uint256 hash; CTransaction tx1; CTxDestination address; - if (GetTransaction(txin.prevout.hash,tx1,hash,false)) + // Read prev transaction + if (!view.HaveCoins(txin.prevout.hash)) { - if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { - for (int i = 0; i < NUM_NOTARIES; i++) { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } + + // Has to wait for dependencies + if (!porphan) + { + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); + } + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; + continue; + } + const CCoins* coins = view.AccessCoins(txin.prevout.hash); + assert(coins); + + CAmount nValueIn = coins->vout[txin.prevout.n].nValue; + nTotalIn += nValueIn; + + int nConf = nHeight - coins->nHeight; + + // This is to test is a tx is a notarisation and assign it max priotity. + if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) + { + for (int i = 0; i < NUM_NOTARIES; i++) if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) numNotaryVins++; - } + } + } + dPriority += (double)nValueIn * nConf; + } + if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) + fNotarisation = true; + nTotalIn += tx.GetShieldedValueIn(); + } + + if (fMissingInputs) continue; + + // Priority is sum(valuein * age) / modified_txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority = tx.ComputePriority(dPriority, nTxSize); + + uint256 hash = tx.GetHash(); + mempool.ApplyDeltas(hash, dPriority, nTotalIn); + + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + + if (fNotarisation) { + dPriority = 1e16; + fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); + } + + if (porphan) + { + porphan->dPriority = dPriority; + porphan->feeRate = feeRate; + } + else + vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } + + // Collect transactions into block + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int64_t interest; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); + + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& tx = *(vecPriority.front().get<2>()); + + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + 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; + } + + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Skip free transactions if we're past the minimum block size: + const uint256& hash = tx.GetHash(); + double dPriorityDelta = 0; + CAmount nFeeDelta = 0; + mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); + if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + //fprintf(stderr,"fee rate skip\n"); + continue; + } + // Prioritise by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } + + if (!view.HaveInputs(tx)) + { + //fprintf(stderr,"dont have inputs\n"); + continue; + } + CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); + + nTxSigOps += GetP2SHSigOpCount(tx, view); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + CValidationState state; + PrecomputedTransactionData txdata(tx); + if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + //fprintf(stderr,"context failure\n"); + continue; + } + UpdateCoins(tx, view, nHeight); + + BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + sapling_tree.append(outDescription.cm); + } + + // Added + pblock->vtx.push_back(tx); + pblocktemplate->vTxFees.push_back(nTxFees); + pblocktemplate->vTxSigOps.push_back(nTxSigOps); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fPrintPriority) + { + LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + { + if (!porphan->setDependsOn.empty()) + { + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) + { + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } - dPriority += (double)nValueIn * nConf; - } - if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) - fNotarisation = true; - nTotalIn += tx.GetShieldedValueIn(); - } - - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / modified_txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority = tx.ComputePriority(dPriority, nTxSize); - - uint256 hash = tx.GetHash(); - mempool.ApplyDeltas(hash, dPriority, nTotalIn); - - CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - - if (fNotarisation) { - dPriority = 1e16; - fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); - } - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; - } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); - } - - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); - - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - - while (!vecPriority.empty()) - { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); - - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - 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; - } - - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); - - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } - - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; - - if (fPrintPriority) - { - LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); - } - - // Add transactions that depend on this one to the priority queue - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) - { - if (!porphan->setDependsOn.empty()) - { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - } } } - } - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - //pblock->nTime = blocktime + 1; - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + //pblock->nTime = blocktime + 1; + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); + + } // contain lock to block generation only! int32_t stakeHeight = chainActive.Height() + 1; @@ -523,7 +525,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } - // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); txNew.vin.resize(1); From ce8f41325a00a9b131977f42e190f051ed5c09fb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 19 Dec 2018 00:53:05 +0800 Subject: [PATCH 785/951] this is fine --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8b8f52935..0a9efe6ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4724,7 +4724,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. - LOCK2(cs_main,mempool.cs); + LOCK(mempool.cs); //fprintf(stderr, "starting... mempoolsize.%ld\n",mempool.size()); list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { From 261dfbcead4d3e0caca2b014feb6a109be00a2e5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 19 Dec 2018 17:22:44 +0800 Subject: [PATCH 786/951] fix staking crash on shutdown. fix segid in block index. --- src/komodo_bitcoind.h | 18 +++++++++++++----- src/rpc/blockchain.cpp | 19 ++++--------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ef915f06c..c427897af 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -26,7 +26,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); bool EnsureWalletIsAvailable(bool avoidException); - +extern bool fRequestShutdown; //#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr)) struct MemoryStruct { char *memory; size_t size; }; @@ -1462,7 +1462,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( slowflag != 0 && pindex != 0 ) { pindex->segid = -1; - fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } } else @@ -1470,11 +1470,17 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ isPoS = 2; // 2 means staking utxo validated if ( slowflag != 0 && height > 100 ) { - segid = -3; - if ( pindex != 0 && pindex->segid == -2 && (segid= komodo_segid(1,height)) >= 0 ) + CTxDestination voutaddress; char voutaddr[64]; + if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) + { + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + segid = komodo_segid32(voutaddr) & 0x3f; + //fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,segid); + } + if ( pindex != 0 && segid >= 0 ) { pindex->segid = segid; - fprintf(stderr,"B set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"B set segid.%d <- %d\n",height,pindex->segid); } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } } @@ -2125,6 +2131,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; iGetHeight()+1 > nHeight ) { fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index f2bf20e3e..849391e18 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -639,23 +639,12 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp) for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) { CBlockIndex* pblockindex = chainActive[i]; - CBlock block; - if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + //if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + // throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - if(!ReadBlockFromDisk(block, pblockindex,1)) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - - if ( komodo_isPoS((CBlock *)&block) != 0 ) - { - CTxDestination voutaddress; int32_t segid; - if ( ExtractDestination(block.vtx[block.vtx.size()-1].vout[0].scriptPubKey,voutaddress) ) - { - segid = (int32_t)komodo_segid32((char *)CBitcoinAddress(voutaddress).ToString().c_str()) & 0x3f; - segids[segid] += 1; - } - } + if ( pblockindex->segid >= 0 ) + segids[pblockindex->segid] += 1; } UniValue ret(UniValue::VOBJ); From f128d49d2fa8ff675bacb5d2da2db56113f76924 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Dec 2018 19:56:00 +0800 Subject: [PATCH 787/951] fix mempool fix, to allow adding transactions out of order. --- src/main.cpp | 47 ++++++++++++++++++++++-------------------- src/rpc/blockchain.cpp | 4 ---- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0a9efe6ea..98ed24c3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1645,6 +1645,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if ( nextBlockHeight <= 1 || chainActive.LastTip() == 0 ) tiptime = (uint32_t)time(NULL); else tiptime = (uint32_t)chainActive.LastTip()->nTime; + + // is it already in the memory pool? + uint256 hash = tx.GetHash(); + if (pool.exists(hash)) + { + //fprintf(stderr,"already in mempool\n"); + return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); + } + // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); @@ -1683,7 +1692,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // Rather not work on nonstandard transactions (unless -testnet/-regtest) string reason; - if (Params().RequireStandard() && !IsStandardTx(tx, reason, nextBlockHeight)) + if (!fSkipExpiry && Params().RequireStandard() && !IsStandardTx(tx, reason, nextBlockHeight)) { // //fprintf(stderr,"AcceptToMemoryPool reject nonstandard transaction: %s\nscriptPubKey: %s\n",reason.c_str(),tx.vout[0].scriptPubKey.ToString().c_str()); @@ -1692,21 +1701,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Only accept nLockTime-using transactions that can be mined in the next // block; we don't want our mempool filled up with transactions that can't // be mined yet. - if (!CheckFinalTx(tx, STANDARD_LOCKTIME_VERIFY_FLAGS)) + if (!fSkipExpiry && !CheckFinalTx(tx, STANDARD_LOCKTIME_VERIFY_FLAGS)) { //fprintf(stderr,"AcceptToMemoryPool reject non-final\n"); return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } - // is it already in the memory pool? - uint256 hash = tx.GetHash(); - if (pool.exists(hash)) - { - //fprintf(stderr,"already in mempool\n"); - return state.Invalid(false, REJECT_DUPLICATE, "already in mempool"); - } - // Check for conflicts with in-memory transactions + if (!fSkipExpiry) { LOCK(pool.cs); // protect pool.mapNextTx for (unsigned int i = 0; i < tx.vin.size(); i++) @@ -1756,7 +1758,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (ExistsImportTombstone(tx, view)) return state.Invalid(false, REJECT_DUPLICATE, "import tombstone exists"); } - else + else if (!fSkipExpiry) { // do all inputs exist? // Note that this does not check for the presence of actual outputs (see the next check for that), @@ -1768,10 +1770,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = true; //fprintf(stderr,"missing inputs\n"); - if (!fSkipExpiry) - return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); - else - return(false); + return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); } } @@ -1779,10 +1778,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveInputs(tx)) { //fprintf(stderr,"accept failure.1\n"); - if (!fSkipExpiry) - return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); - else - return(false); + return state.Invalid(error("AcceptToMemoryPool: inputs already spent"),REJECT_DUPLICATE, "bad-txns-inputs-spent"); } } // are the joinsplit's requirements met? @@ -1826,7 +1822,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; - if (!tx.IsCoinImport()) { + if (!fSkipExpiry && !tx.IsCoinImport()) { BOOST_FOREACH(const CTxIn &txin, tx.vin) { const CCoins *coins = view.AccessCoins(txin.prevout.hash); if (coins->IsCoinBase()) { @@ -1901,7 +1897,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { //fprintf(stderr,"accept failure.9\n"); return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString()); @@ -1922,7 +1918,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa flag = 1; KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1; } - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + if (!fSkipExpiry && !ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { if ( flag != 0 ) KOMODO_CONNECTING = -1; @@ -4719,6 +4715,9 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // Check transactions CTransaction sTx; CTransaction *ptx = NULL; + if ( ASSETCHAINS_CC != 0 && !fCheckPOW ) + return true; + if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { int32_t i,j,rejects=0,lastrejects=0; @@ -4788,6 +4787,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (!CheckTransaction(tiptime,tx, state, verifier)) return error("CheckBlock: CheckTransaction failed"); } + unsigned int nSigOps = 0; BOOST_FOREACH(const CTransaction& tx, block.vtx) { @@ -7018,6 +7018,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (strCommand == "tx") { + if (IsInitialBlockDownload()) + return true; + vector vWorkQueue; vector vEraseQueue; CTransaction tx; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 849391e18..c5da4ed40 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -639,10 +639,6 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp) for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) { CBlockIndex* pblockindex = chainActive[i]; - - //if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - // throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - if ( pblockindex->segid >= 0 ) segids[pblockindex->segid] += 1; } From 5a09ff96c55cb456ce4f1f1cff92360d85078a89 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Dec 2018 23:56:33 +0800 Subject: [PATCH 788/951] fix --- src/wallet/rpcwallet.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d7cef2700..b36ca6ef7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4809,7 +4809,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) saplingNoteLimit = nNoteLimit; } - std::string memo; CAmount maximum_utxo_size; if (params.size() > 5) { maximum_utxo_size = AmountFromValue( params[5] ); @@ -4879,8 +4878,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } - CAmount nValue = out.tx->vout[out.i].nValue; - if (maximum_utxo_size != 0) { if (nValue > maximum_utxo_size) { continue; From 2a606443239ea9b521eaa34b9e30e0e8a3782e70 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 20 Dec 2018 23:58:26 +0800 Subject: [PATCH 789/951] fix --- src/wallet/rpcwallet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b36ca6ef7..5985a63c2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4878,6 +4878,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } + CAmount nValue = out.tx->vout[out.i].nValue; + if (maximum_utxo_size != 0) { if (nValue > maximum_utxo_size) { continue; @@ -4936,7 +4938,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) // Find unspent notes and update estimated size for (const CSproutNotePlaintextEntry& entry : sproutEntries) { noteCounter++; - CAmount nValue = entry.plaintext.value(); + nValue = entry.plaintext.value(); if (!maxedOutNotesFlag) { // If we haven't added any notes yet and the merge is to a @@ -4963,7 +4965,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; - CAmount nValue = entry.note.value(); + nValue = entry.note.value(); if (!maxedOutNotesFlag) { size_t increase = SPENDDESCRIPTION_SIZE; if (estimatedTxSize + increase >= max_tx_size || From 66bac37186273817ca4972562a07ec87249eb055 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 21 Dec 2018 00:00:11 +0800 Subject: [PATCH 790/951] fixed --- src/wallet/rpcwallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5985a63c2..07761f339 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4891,7 +4891,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } utxoCounter++; - CAmount nValue = out.tx->vout[out.i].nValue; if (!maxedOutUTXOsFlag) { size_t increase = (boost::get(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; if (estimatedTxSize + increase >= max_tx_size || @@ -4938,7 +4937,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) // Find unspent notes and update estimated size for (const CSproutNotePlaintextEntry& entry : sproutEntries) { noteCounter++; - nValue = entry.plaintext.value(); + CAmount nValue = entry.plaintext.value(); if (!maxedOutNotesFlag) { // If we haven't added any notes yet and the merge is to a @@ -4965,7 +4964,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; - nValue = entry.note.value(); + CAmount nValue = entry.note.value(); if (!maxedOutNotesFlag) { size_t increase = SPENDDESCRIPTION_SIZE; if (estimatedTxSize + increase >= max_tx_size || From 292962b36d7ef794fd1e6b1452c303940e3e20b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 28 Dec 2018 15:42:23 +0800 Subject: [PATCH 791/951] Fix flood of send block on chain sync. Make net code to ignore KMD peers for LABS faster. --- src/miner.cpp | 2 ++ src/net.cpp | 33 +++++++++++++++------------------ src/rpc/blockchain.cpp | 2 -- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ab0630e6f..ecf411c5e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -783,6 +783,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, void komodo_broadcast(CBlock *pblock,int32_t limit) { + if (IsInitialBlockDownload()) + return; int32_t n = 1; //fprintf(stderr,"broadcast new block t.%u\n",(uint32_t)time(NULL)); { diff --git a/src/net.cpp b/src/net.cpp index 87abe8e85..9c0683c8e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -63,6 +63,8 @@ namespace { // Global state variables // extern uint16_t ASSETCHAINS_P2PPORT; +extern int8_t is_STAKED(const char *chain_name); +extern char ASSETCHAINS_SYMBOL[65]; bool fDiscover = true; bool fListen = true; @@ -1262,15 +1264,6 @@ void ThreadSocketHandler() void ThreadDNSAddressSeed() { - extern int8_t is_STAKED(const char *chain_name); - extern char ASSETCHAINS_SYMBOL[65]; - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - { - fprintf(stderr, "STAKED CHAIN DISABLED ALL SEEDS!\n"); - return; - } - // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { @@ -1380,22 +1373,20 @@ void ThreadOpenConnections() // Add seed nodes if DNS seeds are all down (an infrastructure attack?). // if (addrman.size() == 0 && (GetTime() - nStart > 60)) { - extern int8_t is_STAKED(const char *chain_name); - extern char ASSETCHAINS_SYMBOL[65]; - // skip DNS seeds for staked chains. - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) - { - if (GetTime() - nStart > 60) { - static bool done = false; - if (!done) { + if (GetTime() - nStart > 60) { + static bool done = false; + if (!done) { + // skip DNS seeds for staked chains. + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) { //LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); LogPrintf("Adding fixed seed nodes.\n"); addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1")); - done = true; } + done = true; } } + // // Choose an address to connect to based on most recently seen // @@ -1802,6 +1793,12 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) Discover(threadGroup); + // skip DNS seeds for staked chains. + extern int8_t is_STAKED(const char *chain_name); + extern char ASSETCHAINS_SYMBOL[65]; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + SoftSetBoolArg("-dnsseed", false); + // // Start threads // diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c5da4ed40..f024215b6 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -607,8 +607,6 @@ UniValue getblockhash(const UniValue& params, bool fHelp) } extern uint64_t ASSETCHAINS_STAKED; -int32_t komodo_isPoS(CBlock *pblock); -uint32_t komodo_segid32(char *coinaddr); UniValue getlastsegidstakes(const UniValue& params, bool fHelp) { From 045afa5dd787db3de5753b965102ecabac1eb84e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 20:08:48 +0800 Subject: [PATCH 792/951] fix MoMoM transaction version. --- src/importcoin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index d36943b5d..bc0b6168f 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -10,7 +10,7 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) { std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); mtx.vout = payouts; auto importData = E_MARSHAL(ss << proof; ss << burnTx); @@ -47,7 +47,7 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); - ss >> targetSymbol; + ss >> targetSymbol; ss >> payoutsHash); } @@ -76,7 +76,7 @@ bool VerifyCoinImport(const CScript& scriptSig, TransactionSignatureChecker& che auto pc = scriptSig.begin(); opcodetype opcode; std::vector evalScript; - + auto f = [&] () { if (!scriptSig.GetOp(pc, opcode, evalScript)) return false; From 0de6fd12eed8dea35765e91c98e65fdf2231782c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 20:41:00 +0800 Subject: [PATCH 793/951] fix build... disable komodo-tx for now. --- src/Makefile.am | 3 ++- src/importcoin.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 98cc79adf..06ce32b40 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,8 +122,9 @@ TESTS = bin_PROGRAMS += komodod #endif +# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli komodo-tx + bin_PROGRAMS += komodo-cli endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility diff --git a/src/importcoin.cpp b/src/importcoin.cpp index bc0b6168f..71e469423 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -5,10 +5,15 @@ #include "hash.h" #include "script/cc.h" #include "primitives/transaction.h" +#include "core_io.h" +#include "script/sign.h" +#include "wallet/wallet.h" +int32_t komodo_nextheight(); CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) { + std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); From 8799583cc0f756df48471934e02612792efe7f31 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 21:18:45 +0800 Subject: [PATCH 794/951] remove rescan for corrupt tx and add LOCK2 for deleteion of staking tx. debug prints. --- src/main.cpp | 1 + src/wallet/walletdb.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 98ed24c3d..d7d6037ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3852,6 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET + LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->EraseFromWallet(tx.GetHash()); #endif } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 4dedab834..3bfb40648 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -919,8 +919,13 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. if (strType == "tx" ) + { // Rescan if there is a bad transaction record.. - SoftSetBoolArg("-rescan", true); + //SoftSetBoolArg("-rescan", true); + uint256 hash; + ssKey >> hash; + fprintf(stderr, "TX corrupted hash: %s\n", hash.ToString().c_str()); + } } } if (!strErr.empty()) From abffb831a69c3a17bc9723de58852b6d7307f567 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 21:31:55 +0800 Subject: [PATCH 795/951] try this --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d7d6037ba..302a6162a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3852,7 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK(cs_main); pwalletMain->EraseFromWallet(tx.GetHash()); #endif } From 9237e43052743b15adb7ce994bc3d5f1aeca8c63 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 29 Dec 2018 21:44:48 +0800 Subject: [PATCH 796/951] change tombstone, revert LOCK, problem isnt that. --- src/importcoin.cpp | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 71e469423..3a5ddcc30 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -107,7 +107,7 @@ void AddImportTombstone(const CTransaction &importTx, CCoinsViewCache &inputs, i uint256 burnHash = importTx.vin[0].prevout.hash; CCoinsModifier modifier = inputs.ModifyCoins(burnHash); modifier->nHeight = nHeight; - modifier->nVersion = 1; + modifier->nVersion = 4; modifier->vout.push_back(CTxOut(0, CScript() << OP_0)); } diff --git a/src/main.cpp b/src/main.cpp index 302a6162a..d7d6037ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3852,7 +3852,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))) { #ifdef ENABLE_WALLET - LOCK(cs_main); + LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->EraseFromWallet(tx.GetHash()); #endif } From 0161c77e078fcd3b89739039b987daa86b164193 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Dec 2018 12:31:03 +0800 Subject: [PATCH 797/951] Fix createexport transaction. Leave params != to 3, for backwards compatability, third param is now ignored. --- src/rpc/crosschain.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 7d299fc1a..8853b3fb2 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -145,9 +145,9 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 3) + if (fHelp || params.size() != 3 || params.size() != 2) throw runtime_error( - "migrate_converttoexport rawTx dest_symbol export_amount\n" + "migrate_converttoexport rawTx dest_symbol\n" "\nConvert a raw transaction to a cross-chain export.\n" "If neccesary, the transaction should be funded using fundrawtransaction.\n" "Finally, the transaction should be signed using signrawtransaction\n" @@ -174,17 +174,13 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0) throw runtime_error("cant send a coin to the same chain"); - CAmount burnAmount = AmountFromValue(params[2]); + CAmount burnAmount = 0; + + for (int i=0; i 1000000LL*COIN) - throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for export, cannot export more than 1 million coins per export."); - { - CAmount needed = 0; - for (int i=0; i Date: Sun, 30 Dec 2018 13:02:43 +0800 Subject: [PATCH 798/951] that didnt work. Need to change all scripts! --- src/rpc/crosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 8853b3fb2..98267aae9 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -145,7 +145,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 3 || params.size() != 2) + if (fHelp || params.size() != 2) throw runtime_error( "migrate_converttoexport rawTx dest_symbol\n" "\nConvert a raw transaction to a cross-chain export.\n" From aefee8dada8f76b1243acbf92103c591333c622b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 30 Dec 2018 17:02:37 +0800 Subject: [PATCH 799/951] set expiryHeight to 0 for Import TXs --- src/importcoin.cpp | 4 ++-- src/main.cpp | 18 ------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 3a5ddcc30..487954289 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -13,9 +13,10 @@ int32_t komodo_nextheight(); CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction burnTx, const std::vector payouts) { - std::vector payload = E_MARSHAL(ss << EVAL_IMPORTCOIN); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + if (mtx.fOverwintered) + mtx.nExpiryHeight = 0; mtx.vin.push_back(CTxIn(COutPoint(burnTx.GetHash(), 10e8), CScript() << payload)); mtx.vout = payouts; auto importData = E_MARSHAL(ss << proof; ss << burnTx); @@ -23,7 +24,6 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction b return CTransaction(mtx); } - CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector payouts) { std::vector opret = E_MARSHAL(ss << VARINT(targetCCid); diff --git a/src/main.cpp b/src/main.cpp index d7d6037ba..0b878b245 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1489,24 +1489,6 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio } } - if ( ASSETCHAINS_TXPOW != 0 && tx.vjoinsplit.size() == 0 ) - { - // genesis coinbase 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - uint256 txid = tx.GetHash(); - if ( ((ASSETCHAINS_TXPOW & 2) != 0 && iscoinbase != 0) || ((ASSETCHAINS_TXPOW & 1) != 0 && iscoinbase == 0) ) - { - if ( ((uint8_t *)&txid)[0] != 0 || ((uint8_t *)&txid)[31] != 0 ) - { - uint256 genesistxid = uint256S("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"); - if ( txid != genesistxid ) - { - fprintf(stderr,"private chain iscoinbase.%d invalid txpow.%d txid.%s\n",iscoinbase,ASSETCHAINS_TXPOW,txid.GetHex().c_str()); - return state.DoS(100, error("CheckTransaction(): this is a txpow chain, must have 0x00 ends"),REJECT_INVALID, "bad-txns-actxpow-chain"); - } - } - } - } - // Ensure input values do not exceed MAX_MONEY // We have not resolved the txin values at this stage, // but we do know what the joinsplits claim to add From 9a849703c0c69467c9ac6bd9ca2e69a3243fc0a5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 31 Dec 2018 18:27:10 +0800 Subject: [PATCH 800/951] revert the change here to see if it stops deamons locking up. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0b878b245..9e7cd3b60 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4706,7 +4706,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. - LOCK(mempool.cs); + LOCK2(cs_main,mempool.cs); //fprintf(stderr, "starting... mempoolsize.%ld\n",mempool.size()); list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { From 91b6694c71b4c5ebaa2caef34eaf854552fd6bc5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 2 Jan 2019 23:04:26 +0800 Subject: [PATCH 801/951] Fix some bugs? Add getimports RPC. --- src/notaries_staked.cpp | 7 ++- src/rpc/crosschain.cpp | 105 ++++++++++++++++++++++++++++++++++++++++ src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/walletdb.cpp | 6 +-- 5 files changed, 115 insertions(+), 5 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index e53553b23..8cce14a0b 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -11,14 +11,19 @@ extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { - int STAKED = 0; + static int8_t STAKED,doneinit; + if (doneinit == 1) + return(STAKED); if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; + else + STAKED = 0; //fprintf(stderr, "This chain is: %s which is: %d\n", chain_name,STAKED); + doneinit = 1; return(STAKED); }; diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 98267aae9..3950e48a1 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -307,3 +307,108 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp) out.pushKV("opreturn", HexStr(E_MARSHAL(ss << nota.second))); return out; } + +UniValue getimports(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getmigrates \"hash|height\"\n" + "\n\n" + "\nResult:\n" + "{\n" + " \"imports\" : [ (json array)\n" + " \"transactionid\" : { (json object)\n" + " \"value\" : (numeric)\n" + " \"address\" : (string)\n" + " \"export\" { (json object)\n" + " \"txid\" : (string)\n" + " \"value\" : (numeric)\n" + " \"chain\" : (string)\n" //TODO! + " }\n" + " }" + " ]\n" + " \"TotalImported\" : (numeric)\n" + " \"time\" : (numeric)\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleRpc("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleCli("getmigrates", "12800") + + HelpExampleRpc("getmigrates", "12800") + ); + + LOCK(cs_main); + + std::string strHash = params[0].get_str(); + + // If height is supplied, find the hash + if (strHash.size() < (2 * sizeof(uint256))) { + // std::stoi allows characters, whereas we want to be strict + regex r("[[:digit:]]+"); + if (!regex_match(strHash, r)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + int nHeight = -1; + try { + nHeight = std::stoi(strHash); + } + catch (const std::exception &e) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + if (nHeight < 0 || nHeight > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } + strHash = chainActive[nHeight]->GetBlockHash().GetHex(); + } + + uint256 hash(uint256S(strHash)); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + UniValue result(UniValue::VOBJ); + CAmount TotalImported; + UniValue imports(UniValue::VARR); + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + if(tx.IsCoinImport()) + { + UniValue objTx(UniValue::VOBJ); + objTx.push_back(Pair("txid",tx.GetHash().ToString())); + TxProof proof; + CTransaction burnTx; + std::vector payouts; + TotalImported += tx.vout[1].nValue; + printf("nvalue.%li TotalImported.%li\n",tx.vout[1].nValue,TotalImported); + objTx.push_back(Pair("amount", ValueFromAmount(tx.vout[1].nValue))); + CTxDestination importaddress; + if (ExtractDestination(tx.vout[1].scriptPubKey, importaddress)) + { + objTx.push_back(Pair("address", CBitcoinAddress(importaddress).ToString())); + } + UniValue objBurnTx(UniValue::VOBJ); + if (UnmarshalImportTx(tx, proof, burnTx, payouts)) { + objBurnTx.push_back(Pair("txid", burnTx.GetHash().ToString())); + objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.size() ? burnTx.vout.back().nValue : 0))); + // TODO: add source chain, using new data in burn OP_RETURN from upsteam. + } + objTx.push_back(Pair("export", objBurnTx)); + imports.push_back(objTx); + } + } + result.push_back(Pair("imports", imports)); + result.push_back(Pair("TotalImported", ValueFromAmount(TotalImported))); + result.push_back(Pair("time", block.GetBlockTime())); + return result; +} diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 800c01423..d1c4d56b9 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -333,6 +333,7 @@ static const CRPCCommand vRPCCommands[] = { "crosschain", "crosschainproof", &crosschainproof, true }, { "crosschain", "getNotarisationsForBlock", &getNotarisationsForBlock, true }, { "crosschain", "scanNotarisationsDB", &scanNotarisationsDB, true }, + { "crosschain", "getimports", &getimports, true }, { "crosschain", "migrate_converttoexport", &migrate_converttoexport, true }, { "crosschain", "migrate_createimporttransaction", &migrate_createimporttransaction, true }, { "crosschain", "migrate_completeimporttransaction", &migrate_completeimporttransaction, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index a49355c88..b1f94701e 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -426,6 +426,7 @@ extern UniValue assetchainproof(const UniValue& params, bool fHelp); extern UniValue crosschainproof(const UniValue& params, bool fHelp); extern UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp); extern UniValue scanNotarisationsDB(const UniValue& params, bool fHelp); +extern UniValue getimports(const UniValue& params, bool fHelp); extern UniValue migrate_converttoexport(const UniValue& params, bool fHelp); extern UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp); extern UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 3bfb40648..a230910f3 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -859,7 +859,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, static bool IsKeyType(string strType) { - return (strType== "key" || strType == "wkey" || + return (strType == "key" || strType == "wkey" || strType == "hdseed" || strType == "chdseed" || strType == "zkey" || strType == "czkey" || strType == "sapzkey" || strType == "csapzkey" || @@ -922,9 +922,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Rescan if there is a bad transaction record.. //SoftSetBoolArg("-rescan", true); - uint256 hash; - ssKey >> hash; - fprintf(stderr, "TX corrupted hash: %s\n", hash.ToString().c_str()); + fprintf(stderr, "TX corrupted.. aborted rescan!\n"); } } } From bb95bce9e70d5e51b3f517a223e5adddea1103a0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 3 Jan 2019 01:02:45 +0800 Subject: [PATCH 802/951] Add source chain to burn op return, and extract it in getimports RPC if it exists. --- src/importcoin.cpp | 17 +++++++++++++---- src/komodo_globals.h | 2 +- src/rpc/crosschain.cpp | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 402a1fb36..b47832beb 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -70,10 +70,19 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); - ss >> targetSymbol; - ss >> payoutsHash; - ss >> rawproof); + if ( ccid != 0xffffffff ) + { + return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); + ss >> targetSymbol; + ss >> payoutsHash); + } + else + { + return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); + ss >> targetSymbol; + ss >> payoutsHash; + ss >> rawproof); + } } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index c2d6aa0c4..815dbafe2 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS,,ASSETCHAINS_SELFIMPORT; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,WHITELIST_ADDRESS,ASSETCHAINS_SELFIMPORT; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; bool VERUS_MINTBLOCKS; diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 7b12128e2..49c506e78 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -163,7 +163,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - std::vector rawproof; uint8_t *ptr; int32_t i; uint32_t ccid = ASSETCHAINS_CC; + std::vector rawproof; uint8_t *ptr; uint8_t i; uint32_t ccid = ASSETCHAINS_CC; if (fHelp || params.size() != 2) throw runtime_error( "migrate_converttoexport rawTx dest_symbol\n" @@ -374,7 +374,7 @@ UniValue getimports(const UniValue& params, bool fHelp) " \"export\" { (json object)\n" " \"txid\" : (string)\n" " \"value\" : (numeric)\n" - " \"chain\" : (string)\n" //TODO! + " \"chain\" : (string)\n" " }\n" " }" " ]\n" @@ -437,22 +437,40 @@ UniValue getimports(const UniValue& params, bool fHelp) { UniValue objTx(UniValue::VOBJ); objTx.push_back(Pair("txid",tx.GetHash().ToString())); - TxProof proof; - CTransaction burnTx; - std::vector payouts; + TxProof proof; CTransaction burnTx; std::vector payouts; CTxDestination importaddress; TotalImported += tx.vout[1].nValue; - printf("nvalue.%li TotalImported.%li\n",tx.vout[1].nValue,TotalImported); objTx.push_back(Pair("amount", ValueFromAmount(tx.vout[1].nValue))); - CTxDestination importaddress; if (ExtractDestination(tx.vout[1].scriptPubKey, importaddress)) { objTx.push_back(Pair("address", CBitcoinAddress(importaddress).ToString())); } UniValue objBurnTx(UniValue::VOBJ); - if (UnmarshalImportTx(tx, proof, burnTx, payouts)) { + if (UnmarshalImportTx(tx, proof, burnTx, payouts)) + { + if (burnTx.vout.size() == 0) + continue; objBurnTx.push_back(Pair("txid", burnTx.GetHash().ToString())); - objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.size() ? burnTx.vout.back().nValue : 0))); - // TODO: add source chain, using new data in burn OP_RETURN from upsteam. + objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.back().nValue))); + // extract op_return to get burn source chain. + std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; + GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); + if (E_UNMARSHAL(burnOpret, ss >> VARINT(targetCCid); + ss >> targetSymbol; + ss >> payoutsHash; + ss >> rawproof)); + { + if (rawproof.size() > 0) + { + char *buffer; int32_t n; + buffer = (char*) malloc (65); + if (buffer!=NULL) + { + for (n=0; n<65; n++) + buffer[n]=rawproof[n]; + objBurnTx.push_back(Pair("source", buffer)); + } + } + } } objTx.push_back(Pair("export", objBurnTx)); imports.push_back(objTx); From 3e22247501654a29856fa024754271da556005c5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 3 Jan 2019 09:55:56 +0800 Subject: [PATCH 803/951] try to fix invalid burntx decode error --- src/importcoin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index b47832beb..8d08c2167 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -69,20 +69,20 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint std::vector burnOpret; uint32_t ccid = 0; if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); - E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - if ( ccid != 0xffffffff ) + //E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); + /*if ( ccid != 0xffffffff ) { return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash); } else - { + {*/ return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash; ss >> rawproof); - } + //} } From 542607e4e26ccbfa7738e3d90f2502fe59025005 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 3 Jan 2019 19:52:02 +0800 Subject: [PATCH 804/951] fix my stupidity guys.. sorry --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 8cce14a0b..ebee4868e 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -12,7 +12,7 @@ extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; - if (doneinit == 1) + if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; From 75ae32c0aa866a4c1038b50ec9ce67dcc68cbcef Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 14:35:34 +0800 Subject: [PATCH 805/951] fix source chain display error --- src/importcoin.cpp | 12 +----------- src/rpc/crosschain.cpp | 16 +++------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 8d08c2167..05fd79a95 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -69,20 +69,10 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint std::vector burnOpret; uint32_t ccid = 0; if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); - //E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - /*if ( ccid != 0xffffffff ) - { - return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); - ss >> targetSymbol; - ss >> payoutsHash); - } - else - {*/ - return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); + return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash; ss >> rawproof); - //} } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 49c506e78..5519f0e17 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -453,22 +453,12 @@ UniValue getimports(const UniValue& params, bool fHelp) objBurnTx.push_back(Pair("amount", ValueFromAmount(burnTx.vout.back().nValue))); // extract op_return to get burn source chain. std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; - GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); - if (E_UNMARSHAL(burnOpret, ss >> VARINT(targetCCid); - ss >> targetSymbol; - ss >> payoutsHash; - ss >> rawproof)); + if (UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof)) { if (rawproof.size() > 0) { - char *buffer; int32_t n; - buffer = (char*) malloc (65); - if (buffer!=NULL) - { - for (n=0; n<65; n++) - buffer[n]=rawproof[n]; - objBurnTx.push_back(Pair("source", buffer)); - } + std::string sourceSymbol(rawproof.begin(), rawproof.end()); + objBurnTx.push_back(Pair("source", sourceSymbol)); } } } From 5837b5bc05338966cf4a62d21bed7e153ad5b3f0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 16:11:51 +0800 Subject: [PATCH 806/951] Wallet corruption fix. No longer calls a rescan on daemon load, instead we now delete the non existant txs from the wallet, so next time you load it the error is gone. --- src/main.cpp | 5 ++--- src/wallet/walletdb.cpp | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9537a5c81..c8af01656 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1342,11 +1342,10 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio // Transactions containing empty `vin` must have either non-empty // `vjoinsplit` or non-empty `vShieldedSpend`. - if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { - fprintf(stderr,"vin empty for tx: %s\n",tx.GetHash().ToString().c_str()); + if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) return state.DoS(10, error("CheckTransaction(): vin empty"), REJECT_INVALID, "bad-txns-vin-empty"); - } + // Transactions containing empty `vout` must have either non-empty // `vjoinsplit` or non-empty `vShieldedOutput`. if (tx.vout.empty() && tx.vjoinsplit.empty() && tx.vShieldedOutput.empty()) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index ed37877e7..fc9f4b20f 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -39,6 +39,7 @@ using namespace std; static uint64_t nAccountingEntryNumber = 0; +static list deadTxns; // // CWalletDB @@ -484,8 +485,11 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, CValidationState state; auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) + { + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); return false; - + } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) { @@ -933,12 +937,6 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) { // Leave other errors alone, if we try to fix them we might make things worse. fNoncriticalErrors = true; // ... but do warn the user there is something wrong. - if (strType == "tx" ) - { - // Rescan if there is a bad transaction record.. - //SoftSetBoolArg("-rescan", true); - fprintf(stderr, "TX corrupted.. aborted rescan!\n"); - } } } if (!strErr.empty()) @@ -952,6 +950,16 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) catch (...) { result = DB_CORRUPT; } + + if (!deadTxns.empty()) + { + BOOST_FOREACH (uint256& hash, deadTxns) { + if (!EraseTx(hash)) + fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); + } + fprintf(stderr, "Cleared %i corrupted transactions from wallet.\n",deadTxns.size()); + deadTxns.clear(); + } if (fNoncriticalErrors && result == DB_LOAD_OK) result = DB_NONCRITICAL_ERROR; From ff43475a31a04aaad2b329180dec4f4e5d99150f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 17:26:28 +0800 Subject: [PATCH 807/951] Re-add txs that were removed from wallet, if they are valid. --- src/wallet/wallet.cpp | 2 -- src/wallet/walletdb.cpp | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8ecda92f1..7e77d2d24 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1753,8 +1753,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) return false; - if ( tx.vin.empty() ) - return false; bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto sproutNoteData = FindMySproutNotes(tx); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index fc9f4b20f..21139e0c2 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -489,7 +489,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); deadTxns.push_back(hash); return false; - } + } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) { @@ -953,11 +953,19 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if (!deadTxns.empty()) { + int32_t reAdded = 0; BOOST_FOREACH (uint256& hash, deadTxns) { if (!EraseTx(hash)) fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); + uint256 blockhash; CTransaction tx; + if (GetTransaction(hash,tx,blockhash,true)) + { + CWalletTx wtx(pwallet,tx); + pwallet->AddToWallet(wtx, true, NULL); + reAdded++; + } } - fprintf(stderr, "Cleared %i corrupted transactions from wallet.\n",deadTxns.size()); + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i on chain transactions.\n",deadTxns.size(),reAdded); deadTxns.clear(); } From 1cd888132960ff5f8b220811d9fdbbccf197b784 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 4 Jan 2019 17:51:23 +0800 Subject: [PATCH 808/951] change print --- src/wallet/walletdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 21139e0c2..95ada1448 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -965,7 +965,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) reAdded++; } } - fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i on chain transactions.\n",deadTxns.size(),reAdded); + fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",deadTxns.size(),reAdded); deadTxns.clear(); } From d53a4a9e5b4dcc0bf9e14e1e01b79ad1aa1cee8f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 7 Jan 2019 18:11:51 +0800 Subject: [PATCH 809/951] push changes for getrawtransaction --- src/rpc/rawtransaction.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 117d2ac34..9badcbd30 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -35,6 +35,7 @@ #include "script/sign.h" #include "script/standard.h" #include "uint256.h" +#include "importcoin.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif @@ -202,6 +203,25 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); else if (tx.IsCoinImport()) { in.push_back(Pair("is_import", "1")); + TxProof proof; CTransaction burnTx; std::vector payouts; CTxDestination importaddress; + if (UnmarshalImportTx(tx, proof, burnTx, payouts)) + { + if (burnTx.vout.size() == 0) + continue; + in.push_back(Pair("txid", burnTx.GetHash().ToString())); + in.push_back(Pair("value", ValueFromAmount(burnTx.vout.back().nValue))); + in.push_back(Pair("valueSat", burnTx.vout.back().nValue)); + // extract op_return to get burn source chain. + std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; + if (UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof)) + { + if (rawproof.size() > 0) + { + std::string sourceSymbol(rawproof.begin(), rawproof.end()); + in.push_back(Pair("source", sourceSymbol)); + } + } + } } else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); From 5d34792067130ae4b104e800f3df01f926b643f6 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Mon, 7 Jan 2019 20:41:54 +0800 Subject: [PATCH 810/951] fix --- depends/packages/libsodium.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 67e096fae..76f0d9a28 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -9,7 +9,7 @@ $(package)_config_opts= else package=libsodium $(package)_version=1.0.15 -$(package)_download_path=https://download.libsodium.org/libsodium/releases +$(package)_download_path=https://download.libsodium.org/libsodium/releases/old $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 $(package)_dependencies= From 58cb0e8ea23226b37e6ec1ec53d1cddb51289d47 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 7 Jan 2019 22:36:58 +0800 Subject: [PATCH 811/951] use unused address variable for source, to get source chain to explorer. --- src/rpc/rawtransaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 9badcbd30..d4b5c1b1c 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -218,7 +218,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& if (rawproof.size() > 0) { std::string sourceSymbol(rawproof.begin(), rawproof.end()); - in.push_back(Pair("source", sourceSymbol)); + in.push_back(Pair("address", sourceSymbol)); } } } From 6794cfc0cc4e5932e44934c1fc007cc0489755cb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 7 Jan 2019 23:04:54 +0800 Subject: [PATCH 812/951] add IMP-- to export address for explorer. --- src/rpc/rawtransaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index d4b5c1b1c..94296616f 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -218,7 +218,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& if (rawproof.size() > 0) { std::string sourceSymbol(rawproof.begin(), rawproof.end()); - in.push_back(Pair("address", sourceSymbol)); + in.push_back(Pair("address", "IMP-" + sourceSymbol + "-" + burnTx.GetHash().ToString())); } } } From ddd4b8eab9ae298e1c9217aad4fc8fc222e14f61 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 11:00:26 +0800 Subject: [PATCH 813/951] 4mb blocks --- src/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index 7d3047d80..8901146ca 100644 --- a/src/net.h +++ b/src/net.h @@ -63,7 +63,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024; +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 0b24307e2bd478c5b5bcde8a43bc3608d4e737af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 14:33:27 +0800 Subject: [PATCH 814/951] Add export description to burn TX on explorer. --- src/rpc/rawtransaction.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 94296616f..87e95c14c 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -276,6 +276,14 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& out.push_back(Pair("n", (int64_t)i)); UniValue o(UniValue::VOBJ); ScriptPubKeyToJSON(txout.scriptPubKey, o, true); + if (txout.scriptPubKey.IsOpReturn() && txout.nValue != 0) + { + std::vector burnOpret; std::string targetSymbol; uint32_t targetCCid; uint256 payoutsHash; std::vectorrawproof; + if (UnmarshalBurnTx(tx, targetSymbol, &targetCCid, payoutsHash, rawproof)) + { + out.push_back(Pair("target", "EXPORT->" + targetSymbol)); + } + } out.push_back(Pair("scriptPubKey", o)); // Add spent information if spentindex is enabled From 0dee67a800d0b5257950da5d473aede299352fe4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 8 Jan 2019 23:07:34 +0800 Subject: [PATCH 815/951] set import max priotity, and also 0.001 flat fee. --- src/miner.cpp | 7 ++++--- src/rpc/crosschain.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 66ba92514..3ccacea1c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -285,9 +285,10 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool fNotarisation = false; if (tx.IsCoinImport()) { - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier + CAmount nValueIn = GetCoinImportValue(tx); // burn amount + //tx.vout[1].nValue import amount + //nTotalIn += nValueIn; + dPriority += 1e16; //(double)nValueIn * 1000; // flat multiplier } else { int numNotaryVins = 0; bool fToCryptoAddress = false; if ( komodo_is_notarytx(tx) == 1 ) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 5519f0e17..550efed71 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -205,7 +205,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) ptr = rawproof.data(); for (i=0; i Date: Tue, 8 Jan 2019 23:48:34 +0800 Subject: [PATCH 816/951] oops --- src/rpc/crosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 550efed71..5519f0e17 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -205,7 +205,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) ptr = rawproof.data(); for (i=0; i Date: Wed, 9 Jan 2019 01:39:55 +0800 Subject: [PATCH 817/951] fix minign lock? --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 113fa4c03..a7251057e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,7 +1603,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) { { - LOCK(mempool.cs); + LOCK2(cs_main, mempool.cs); uint256 hash = tx.GetHash(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; From 6ab190c5b44ab00fc6bb00a5bc05b67c04288517 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 9 Jan 2019 04:29:27 +0800 Subject: [PATCH 818/951] try --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a7251057e..dea9ee85f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1872,7 +1872,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa nLastTime = nNow; // -limitfreerelay unit is thousand-bytes-per-minute // At default rate it would take over a month to fill 1GB - if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) + if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*50000) { fprintf(stderr,"accept failure.7\n"); return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); From 7bc81ad0de308e4c97390f4e182740d6e55bc32b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 9 Jan 2019 04:38:54 +0800 Subject: [PATCH 819/951] fix mempool propagation --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index dea9ee85f..0720e2caa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1858,7 +1858,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. - if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize)) + if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize) && !tx.IsCoinImport()) { static CCriticalSection csFreeLimiter; static double dFreeCount; From 9646dd709a04f1b444eb2b472f10a7ebb779580e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 01:35:18 +0800 Subject: [PATCH 820/951] revert changes to import priority. Re-try flat transaction fee. Change miner lock to something safer. Add lock cs_main to import validation when accepting to mempool. --- src/main.cpp | 5 +- src/miner.cpp | 486 +++++++++++++++++++++-------------------- src/rpc/crosschain.cpp | 4 +- 3 files changed, 249 insertions(+), 246 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0720e2caa..fae0998b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1603,7 +1603,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) { { - LOCK2(cs_main, mempool.cs); + LOCK(mempool.cs); uint256 hash = tx.GetHash(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; @@ -1872,7 +1872,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa nLastTime = nNow; // -limitfreerelay unit is thousand-bytes-per-minute // At default rate it would take over a month to fill 1GB - if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*50000) + if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) { fprintf(stderr,"accept failure.7\n"); return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); @@ -2709,6 +2709,7 @@ bool ContextualCheckInputs( if (tx.IsCoinImport()) { + LOCK(cs_main); ServerTransactionSignatureChecker checker(&tx, 0, 0, false, txdata); return VerifyCoinImport(tx.vin[0].scriptSig, checker, state); } diff --git a/src/miner.cpp b/src/miner.cpp index 3ccacea1c..483aef891 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -214,290 +214,286 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CTransaction cheatTx; boost::optional cheatSpend; uint256 cbHash; - - SaplingMerkleTree sapling_tree; uint64_t commission; - int nHeight = 0; - const Consensus::Params &consensusParams = chainparams.GetConsensus(); - - CBlockIndex* pindexPrev = chainActive.LastTip();; + + CBlockIndex* pindexPrev = 0; { - { // contain lock to block generation and not staking loops. - LOCK2(cs_main, mempool.cs); - nHeight = pindexPrev->GetHeight() + 1; - uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); - bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); + pindexPrev = chainActive.LastTip(); + const int nHeight = pindexPrev->GetHeight() + 1; + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); + bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); - const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + uint32_t proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + { + // too fast or stuck, this addresses the too fast issue, while moving + // forward as quickly as possible + for (int i; i < 100; i++) { - // too fast or stuck, this addresses the too fast issue, while moving - // forward as quickly as possible - for (int i; i < 100; i++) - { - proposedTime = GetAdjustedTime(); - if (proposedTime == nMedianTimePast) - MilliSleep(10); - } + proposedTime = GetAdjustedTime(); + if (proposedTime == nMedianTimePast) + MilliSleep(10); } - pblock->nTime = GetAdjustedTime(); + } + pblock->nTime = GetAdjustedTime(); - CCoinsViewCache view(pcoinsTip); - uint32_t expired; + CCoinsViewCache view(pcoinsTip); + uint32_t expired; uint64_t commission; + + SaplingMerkleTree sapling_tree; + assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); - assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + bool fPrintPriority = GetBoolArg("-printpriority", false); - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size() + 1); - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size() + 1); + // now add transactions from the mem pool + for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); + mi != mempool.mapTx.end(); ++mi) + { + const CTransaction& tx = mi->GetTx(); - // now add transactions from the mem pool - for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) + int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { - const CTransaction& tx = mi->GetTx(); + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + continue; + } - int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) - ? nMedianTimePast - : pblock->GetBlockTime(); + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) + { + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); + continue; + } - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + COrphan* porphan = NULL; + double dPriority = 0; + CAmount nTotalIn = 0; + bool fMissingInputs = false; + bool fNotarisation = false; + if (tx.IsCoinImport()) + { + CAmount nValueIn = GetCoinImportValue(tx); // burn amount + nTotalIn += nValueIn; + dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. + } else { + int numNotaryVins = 0; bool fToCryptoAddress = false; + if ( komodo_is_notarytx(tx) == 1 ) + fToCryptoAddress = true; + + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); - continue; - } - - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) - { - //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); - continue; - } - - COrphan* porphan = NULL; - double dPriority = 0; - CAmount nTotalIn = 0; - bool fMissingInputs = false; - bool fNotarisation = false; - if (tx.IsCoinImport()) - { - CAmount nValueIn = GetCoinImportValue(tx); // burn amount - //tx.vout[1].nValue import amount - //nTotalIn += nValueIn; - dPriority += 1e16; //(double)nValueIn * 1000; // flat multiplier - } else { - int numNotaryVins = 0; bool fToCryptoAddress = false; - if ( komodo_is_notarytx(tx) == 1 ) - fToCryptoAddress = true; - - BOOST_FOREACH(const CTxIn& txin, tx.vin) + // Read prev transaction + if (!view.HaveCoins(txin.prevout.hash)) { - // Read prev transaction - if (!view.HaveCoins(txin.prevout.hash)) + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } - - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; - continue; + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; } - const CCoins* coins = view.AccessCoins(txin.prevout.hash); - assert(coins); - CAmount nValueIn = coins->vout[txin.prevout.n].nValue; - nTotalIn += nValueIn; - - int nConf = nHeight - coins->nHeight; - - // This is to test is a tx is a notarisation and assign it max priotity. - if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + // Has to wait for dependencies + if (!porphan) { - uint256 hash; CTransaction tx1; CTxDestination address; - if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) - { - for (int i = 0; i < NUM_NOTARIES; i++) - if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) - numNotaryVins++; - } + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); } - dPriority += (double)nValueIn * nConf; + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue; + continue; } - if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) - fNotarisation = true; - nTotalIn += tx.GetShieldedValueIn(); + const CCoins* coins = view.AccessCoins(txin.prevout.hash); + assert(coins); + + CAmount nValueIn = coins->vout[txin.prevout.n].nValue; + nTotalIn += nValueIn; + + int nConf = nHeight - coins->nHeight; + + // This is to test is a tx is a notarisation and assign it max priotity. + if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) + { + for (int i = 0; i < NUM_NOTARIES; i++) + if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) + numNotaryVins++; + } + } + dPriority += (double)nValueIn * nConf; } - - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / modified_txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority = tx.ComputePriority(dPriority, nTxSize); - - uint256 hash = tx.GetHash(); - mempool.ApplyDeltas(hash, dPriority, nTotalIn); - - CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - - if (fNotarisation) { - dPriority = 1e16; - fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); - } - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; - } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) + fNotarisation = true; + nTotalIn += tx.GetShieldedValueIn(); } - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); + if (fMissingInputs) continue; - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + // Priority is sum(valuein * age) / modified_txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority = tx.ComputePriority(dPriority, nTxSize); - while (!vecPriority.empty()) + uint256 hash = tx.GetHash(); + mempool.ApplyDeltas(hash, dPriority, nTotalIn); + + CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + + if (fNotarisation) { + dPriority = 1e16; + //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); + } + + if (porphan) { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); + porphan->dPriority = dPriority; + porphan->feeRate = feeRate; + } + else + vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); + } - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); + // Collect transactions into block + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int64_t interest; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - 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; - } + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& tx = *(vecPriority.front().get<2>()); - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + 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; + } - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Skip free transactions if we're past the minimum block size: + const uint256& hash = tx.GetHash(); + double dPriorityDelta = 0; + CAmount nFeeDelta = 0; + mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); + if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + //fprintf(stderr,"fee rate skip\n"); + continue; + } + // Prioritise by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; + if (!view.HaveInputs(tx)) + { + //fprintf(stderr,"dont have inputs\n"); + continue; + } + CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - if (fPrintPriority) + nTxSigOps += GetP2SHSigOpCount(tx, view); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + continue; + } + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + CValidationState state; + PrecomputedTransactionData txdata(tx); + if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + //fprintf(stderr,"context failure\n"); + continue; + } + UpdateCoins(tx, view, nHeight); + + BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { + sapling_tree.append(outDescription.cm); + } + + // Added + pblock->vtx.push_back(tx); + pblocktemplate->vTxFees.push_back(nTxFees); + pblocktemplate->vTxSigOps.push_back(nTxSigOps); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fPrintPriority) + { + LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) { - LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); - } - - // Add transactions that depend on this one to the priority queue - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + if (!porphan->setDependsOn.empty()) { - if (!porphan->setDependsOn.empty()) + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); } } } } + } - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - //pblock->nTime = blocktime + 1; - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); - - } // contain lock to block generation only! + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + //pblock->nTime = blocktime + 1; + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); int32_t stakeHeight = chainActive.Height() + 1; @@ -524,7 +520,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = GetAdjustedTime(); //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); + ENTER_CRITICAL_SECTION(cs_main); + ENTER_CRITICAL_SECTION(mempool.cs); } if ( siglen > 0 ) @@ -678,6 +678,8 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 5519f0e17..15e27ead2 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -163,7 +163,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp) UniValue migrate_converttoexport(const UniValue& params, bool fHelp) { - std::vector rawproof; uint8_t *ptr; uint8_t i; uint32_t ccid = ASSETCHAINS_CC; + std::vector rawproof; uint8_t *ptr; uint8_t i; uint32_t ccid = ASSETCHAINS_CC; uint64_t txfee = 10000; if (fHelp || params.size() != 2) throw runtime_error( "migrate_converttoexport rawTx dest_symbol\n" @@ -205,7 +205,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp) ptr = rawproof.data(); for (i=0; i Date: Thu, 10 Jan 2019 02:51:03 +0800 Subject: [PATCH 821/951] fix merge problem --- src/net.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/net.h b/src/net.h index b43422184..3f30175c3 100644 --- a/src/net.h +++ b/src/net.h @@ -63,11 +63,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -<<<<<<< HEAD -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; -======= static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1024 * 1024; // depends on MAX_BLOCK_SIZE ->>>>>>> e755fa0e7bfc079b94c0aa80e80d3b990c9f4b64 /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** -listen default */ From 5cb458b5f20cdeda85d774dd93cac43850007fb5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 16:44:09 +0800 Subject: [PATCH 822/951] fix bug with getimports... Fix miner loop deadlock with staker. Remove annoying pointless prints for staker. --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 16 +++++++++------- src/rpc/crosschain.cpp | 6 +++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fda088631..260f6bc14 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2106,7 +2106,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; @@ -2160,7 +2160,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } else { - fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); + //fprintf(stderr,"ht.%d error validating winning blocktime %u -> %.8f eligible.%u test prior\n",nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); continue; } eligible = besttime; diff --git a/src/miner.cpp b/src/miner.cpp index 957d4cbba..714641bc0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -494,12 +494,14 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); - + int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); @@ -520,11 +522,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = GetAdjustedTime(); //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); - ENTER_CRITICAL_SECTION(cs_main); - ENTER_CRITICAL_SECTION(mempool.cs); } if ( siglen > 0 ) @@ -540,6 +538,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); + } // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -678,8 +677,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, //fprintf(stderr,"valid\n"); } } - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } //fprintf(stderr,"done new block\n"); return pblocktemplate.release(); } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 15e27ead2..e2770b28c 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -363,7 +363,7 @@ UniValue getimports(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( - "getmigrates \"hash|height\"\n" + "getimports \"hash|height\"\n" "\n\n" "\nResult:\n" "{\n" @@ -429,7 +429,7 @@ UniValue getimports(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); UniValue result(UniValue::VOBJ); - CAmount TotalImported; + CAmount TotalImported = 0; UniValue imports(UniValue::VARR); BOOST_FOREACH(const CTransaction&tx, block.vtx) { @@ -467,7 +467,7 @@ UniValue getimports(const UniValue& params, bool fHelp) } } result.push_back(Pair("imports", imports)); - result.push_back(Pair("TotalImported", ValueFromAmount(TotalImported))); + result.push_back(Pair("TotalImported", TotalImported > 0 ? ValueFromAmount(TotalImported) : 0 )); result.push_back(Pair("time", block.GetBlockTime())); return result; } From 2cbde4d787542224e07b662974001d7ea915ec37 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 23:16:28 +0800 Subject: [PATCH 823/951] fix wallet expired on load, fix pindex->segid for PoW. --- src/komodo_bitcoind.h | 17 ++++++++++++++--- src/wallet/walletdb.cpp | 9 ++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 260f6bc14..c8a5d0d19 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1460,7 +1460,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( 0 && ASSETCHAINS_STAKED < 100 ) 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)); - if ( slowflag != 0 && pindex != 0 ) + if ( slowflag != 0 && pindex != 0 && height > 100) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); @@ -1481,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( pindex != 0 && segid >= 0 ) { pindex->segid = segid; - //fprintf(stderr,"B set segid.%d <- %d\n",height,pindex->segid); + fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } } @@ -1817,7 +1817,18 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) 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 failed = 0; + } else + { + // I think this means the block is valid PoW. We need to set the pindex->segid here. + failed = 0; + CBlockIndex *pindex; + BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); + pindex = it != mapBlockIndex.end() ? it->second : NULL; + if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { + pindex->segid = -1; + fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); + } + } } } else if ( is_PoSblock < 0 ) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 95ada1448..daa8881f5 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -486,9 +486,12 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); - deadTxns.push_back(hash); - return false; + if (state.GetRejectReason() != "tx-overwinter-expired") + { + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); + return false; + } } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) From b8ae55bd3ad7ea57ea49515dcbecfaebed3f11d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 10 Jan 2019 23:31:10 +0800 Subject: [PATCH 824/951] remove prints --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c8a5d0d19..0ae824cd6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1481,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( pindex != 0 && segid >= 0 ) { pindex->segid = segid; - fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } } @@ -1826,7 +1826,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { pindex->segid = -1; - fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); + //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } } } From 1e0e89523c062019a529c8125d869f9bb3d3ab59 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 11 Jan 2019 17:06:06 +0800 Subject: [PATCH 825/951] fix segid in pindex, fix help. Remove more pointless prints. --- src/komodo_bitcoind.h | 4 ++-- src/rpc/blockchain.cpp | 34 ++++++++++++++++++++++++++-------- src/rpc/crosschain.cpp | 8 ++++---- src/txdb.cpp | 6 +++++- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0ae824cd6..a13442760 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2055,7 +2055,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod return(blocktime); } } - } else fprintf(stderr,"maxiters is not good enough\n"); + } //else fprintf(stderr,"maxiters is not good enough\n"); return(0); } @@ -2186,7 +2186,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str()); *utxovoutp = kp->vout; *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; - fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); + //fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } } //else fprintf(stderr,"utxo not eligible\n"); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c210e3099..bb46f47fb 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -49,6 +49,7 @@ extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); int32_t komodo_longestchain(); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +extern int8_t komodo_segid(int32_t nocache,int32_t height); extern int32_t KOMODO_LONGESTCHAIN; double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty) @@ -147,7 +148,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits))); result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); + result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight()))); if (blockindex->pprev) result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); @@ -174,7 +175,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) result.push_back(Pair("height", blockindex->GetHeight())); result.push_back(Pair("version", block.nVersion)); result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); + result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight()))); UniValue deltas(UniValue::VARR); @@ -292,7 +293,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.push_back(Pair("height", blockindex->GetHeight())); result.push_back(Pair("version", block.nVersion)); result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); + result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight()))); result.push_back(Pair("finalsaplingroot", block.hashFinalSaplingRoot.GetHex())); UniValue txs(UniValue::VARR); BOOST_FOREACH(const CTransaction&tx, block.vtx) @@ -647,22 +648,39 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp) LOCK(cs_main); int depth = params[0].get_int(); + if ( depth > chainActive.Height() ) + throw runtime_error("Not enough blocks to scan back that far.\n"); + int32_t segids[64] = {0}; + int32_t pow = 0; + int32_t notset = 0; for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--) { - CBlockIndex* pblockindex = chainActive[i]; - if ( pblockindex->segid >= 0 ) - segids[pblockindex->segid] += 1; + int8_t segid = komodo_segid(0,i); + //CBlockIndex* pblockindex = chainActive[i]; + if ( segid >= 0 ) + segids[segid] += 1; + else if ( segid == -1 ) + pow++; + else + notset++; } - + + int8_t posperc = 100*(depth-pow)/depth; + UniValue ret(UniValue::VOBJ); + UniValue objsegids(UniValue::VOBJ); for (int8_t i = 0; i < 64; i++) { char str[4]; sprintf(str, "%d", i); - ret.push_back(Pair(str,segids[i])); + objsegids.push_back(Pair(str,segids[i])); } + ret.push_back(Pair("NotSet",notset)); + ret.push_back(Pair("PoW",pow)); + ret.push_back(Pair("PoSPerc",posperc)); + ret.push_back(Pair("SegIds",objsegids)); return ret; } diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index e2770b28c..d02c1a562 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -382,10 +382,10 @@ UniValue getimports(const UniValue& params, bool fHelp) " \"time\" : (numeric)\n" "}\n" "\nExamples:\n" - + HelpExampleCli("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") - + HelpExampleRpc("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") - + HelpExampleCli("getmigrates", "12800") - + HelpExampleRpc("getmigrates", "12800") + + HelpExampleCli("getimports", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleRpc("getimports", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"") + + HelpExampleCli("getimports", "12800") + + HelpExampleRpc("getimports", "12800") ); LOCK(cs_main); diff --git a/src/txdb.cpp b/src/txdb.cpp index 55f71b28a..fbb94bb65 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -689,7 +689,11 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; pindexNew->nSaplingValue = diskindex.nSaplingValue; - + pindexNew->segid = diskindex.segid; + pindexNew->newcoins = diskindex.newcoins; + pindexNew->zfunds = diskindex.zfunds; + pindexNew->sproutfunds = diskindex.sproutfunds; + // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From dbf6a1f83d736ff99fa39f2b66e8b2be6f216646 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 11 Jan 2019 17:44:10 +0800 Subject: [PATCH 826/951] better fix --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a13442760..4117347b6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1202,7 +1202,8 @@ int8_t komodo_segid(int32_t nocache,int32_t height) if ( strcmp(destaddr,voutaddr) == 0 && block.vtx[txn_count-1].vout[0].nValue == value ) { segid = komodo_segid32(voutaddr) & 0x3f; - //fprintf(stderr,"komodo_segid.(%d) -> %02x\n",height,segid); + pindex->segid = segid; + //fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,pindex->segid); } } else fprintf(stderr,"komodo_segid ht.%d couldnt extract voutaddress\n",height); } @@ -1476,7 +1477,6 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); segid = komodo_segid32(voutaddr) & 0x3f; - //fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,segid); } if ( pindex != 0 && segid >= 0 ) { From 3bf6b75986fe58c37f35828260eb434b6a2dca74 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:02:06 +0800 Subject: [PATCH 827/951] fix miner.cpp --- src/miner.cpp | 130 +------------------------------------------------- 1 file changed, 2 insertions(+), 128 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 56f348f6a..fb61e96ed 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -213,13 +213,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // we will attempt to spend any cheats we see CTransaction cheatTx; boost::optional cheatSpend; -<<<<<<< HEAD - uint256 cbHash; - -======= - uint256 cbHash; ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed + uint256 cbHash; + CBlockIndex* pindexPrev = 0; { ENTER_CRITICAL_SECTION(cs_main); @@ -289,7 +285,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool fNotarisation = false; if (tx.IsCoinImport()) { -<<<<<<< HEAD CAmount nValueIn = GetCoinImportValue(tx); // burn amount nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. @@ -298,12 +293,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if ( komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; -======= - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -342,7 +331,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, int nConf = nHeight - coins->nHeight; -<<<<<<< HEAD // This is to test is a tx is a notarisation and assign it max priotity. if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { @@ -358,10 +346,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; -======= - dPriority += (double)nValueIn * nConf; } ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed nTotalIn += tx.GetShieldedValueIn(); } @@ -376,22 +361,10 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); -<<<<<<< HEAD if (fNotarisation) { dPriority = 1e16; //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); -======= - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); - } - -<<<<<<< HEAD if (porphan) { porphan->dPriority = dPriority; @@ -494,101 +467,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, nBlockSigOps += nTxSigOps; nFees += nTxFees; -======= - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); - - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - - while (!vecPriority.empty()) - { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); - - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - 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; - } - - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); - - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } - - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; - ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); @@ -617,11 +495,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); -<<<<<<< HEAD - -======= ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); From dbf6a552fcedbed6f720bd7f8933177e46984c0b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:04:49 +0800 Subject: [PATCH 828/951] fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index fb61e96ed..06cf809c8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -346,7 +346,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; - } + nTotalIn += tx.GetShieldedValueIn(); } From a963718c7c04d76134cbdbfd3826039ac6f8ee55 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:35:39 +0800 Subject: [PATCH 829/951] tx-overwinter-active skip check on wallet load --- src/wallet/walletdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index daa8881f5..3a3bdf500 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -486,7 +486,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - if (state.GetRejectReason() != "tx-overwinter-expired") + if (state.GetRejectReason() != "tx-overwinter-expired" && state.GetRejectReason() != "tx-overwinter-active") { fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); deadTxns.push_back(hash); From 94593ce8fd486049452f55eaf9d0d798d8c61871 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 01:15:19 +0800 Subject: [PATCH 830/951] CheckTransaction does not call overwinter checks --- src/wallet/walletdb.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 3a3bdf500..95ada1448 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -486,12 +486,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, auto verifier = libzcash::ProofVerifier::Strict(); if (!(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid())) { - if (state.GetRejectReason() != "tx-overwinter-expired" && state.GetRejectReason() != "tx-overwinter-active") - { - fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); - deadTxns.push_back(hash); - return false; - } + fprintf(stderr, "Removing corrupt tx from wallet.%s\n", hash.ToString().c_str()); + deadTxns.push_back(hash); + return false; } // Undo serialize changes in 31600 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) From c2ce7ca9ced8e364a34d98cf814e7bca11bcdae4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 13:23:31 +0800 Subject: [PATCH 831/951] add segid to listunspent --- src/wallet/rpcwallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5a756ad7a..ff1f70eaa 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2775,6 +2775,8 @@ UniValue resendwallettransactions(const UniValue& params, bool fHelp) return result; } +extern uint32_t komodo_segid32(char *coinaddr); + UniValue listunspent(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -2869,6 +2871,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) if (fValidAddress) { entry.push_back(Pair("address", EncodeDestination(address))); + entry.push_back(Pair("segid", (int)komodo_segid32((char*)EncodeDestination(address).c_str()) & 0x3f )); if (pwalletMain->mapAddressBook.count(address)) entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); From 41363b7ea4089cc8720877f7a9eb3f626cb9cda0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 17:09:17 +0800 Subject: [PATCH 832/951] fix prints --- src/miner.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 26d1a1df9..e06a570c7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1303,9 +1303,8 @@ void static BitcoinMiner_noeq() { int32_t percPoS,z; hashTarget = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&hashTarget)[z]); - fprintf(stderr," PoW for staked coin PoS %d%% vs target %d%%\n",percPoS,(int32_t)ASSETCHAINS_STAKED); + if ( ASSETCHAINS_STAKED < 100 ) + LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); } while (true) @@ -1630,18 +1629,16 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; + if ( ASSETCHAINS_STAKED > 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); if ( ASSETCHAINS_STAKED < 100 ) - { - //for (z=31; z>=0; z--) - // fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); - } } + while (true) { /*if ( KOMODO_INSYNC == 0 ) From b0ca0415ef02b2f32753e51befa98c4709a12d16 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 17:27:34 +0800 Subject: [PATCH 833/951] fix build --- 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 9e253b6ea..eae71f987 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5672,7 +5672,7 @@ UniValue marmara_poolpayout(const UniValue& params, bool fHelp) if ( fHelp || params.size() != 3 ) { // marmarapoolpayout 0.5 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000],["02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92",100]]'; - marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' + //marmarapoolpayout 0 2 '[["024131032ed90941e714db8e6dd176fe5a86c9d873d279edecf005c06f773da686",1000]]' throw runtime_error("marmarapoolpayout perc firstheight \"[[\\\"pubkey\\\":shares], ...]\"\n"); } if ( ensure_CCrequirements() < 0 ) From f20420ea80a5147d56502968c6a77b8f2678851d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 14 Jan 2019 18:18:18 +0800 Subject: [PATCH 834/951] fixed staking/generate in getmininginfo --- src/rpc/mining.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index dccbd9cfe..3843529ac 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -438,8 +438,11 @@ UniValue getmininginfo(const UniValue& params, bool fHelp) obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); obj.push_back(Pair("chain", Params().NetworkIDString())); #ifdef ENABLE_MINING - obj.push_back(Pair("staking", VERUS_MINTBLOCKS)); - obj.push_back(Pair("generate", GetBoolArg("-gen", false))); + bool staking = VERUS_MINTBLOCKS; + if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 ) + staking = true; + obj.push_back(Pair("staking", staking)); + obj.push_back(Pair("generate", GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) != 0 )); obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS)); #endif return obj; From 400a0758c1cd785bcedc5864794084045849cf58 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 16 Jan 2019 20:27:35 +0800 Subject: [PATCH 835/951] Many bug fixes. VerusHash now works with PoS64 without special exemptions. Difficulty on new chains still behaves weridly, hoping resolves as chain ages. Also reduced CPU load on all staking. These changes should work better if you are not the only node staking. --- src/komodo_bitcoind.h | 29 ++++++++++++++++------------- src/komodo_globals.h | 4 +++- src/komodo_utils.h | 5 +++-- src/miner.cpp | 41 ++++++++++++++++++++++++++--------------- 4 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bb85ef1d1..662d0703c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1274,7 +1274,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( value < SATOSHIDEN ) return(0); value /= SATOSHIDEN; - mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; @@ -1342,11 +1342,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); + sum = arith_uint256(0); ave = sum; - easydiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + easydiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); for (i=n=m=0; i<100; i++) { ht = height - 100 + i; @@ -1372,8 +1373,10 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } + // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! + // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) - percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + percPoS = (percPoS*100) / (m+n); if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; @@ -1432,7 +1435,8 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); } } - else bnTarget = ave; // recent ave is perfect + else + bnTarget = ave; // recent ave is perfect return(bnTarget); } @@ -1468,7 +1472,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( 0 && ASSETCHAINS_STAKED < 100 ) 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)); - if ( slowflag != 0 && pindex != 0 && height > 100) + if ( slowflag != 0 && pindex != 0 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); @@ -1477,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else { isPoS = 2; // 2 means staking utxo validated - if ( slowflag != 0 && height > 100 ) + if ( slowflag != 0 ) { CTxDestination voutaddress; char voutaddr[64]; if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) @@ -1831,12 +1835,11 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } else { - // I think this means the block is valid PoW. We need to set the pindex->segid here. failed = 0; CBlockIndex *pindex; BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; - if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { + if ( pindex != 0 && pindex->segid == -2 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } @@ -2083,7 +2086,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt return 0; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); - mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); assert(pwalletMain != NULL); *utxovaluep = 0; @@ -2096,7 +2099,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; komodo_segids(hashbuf,nHeight-101,100); - if ( *blocktimep < tipindex->nTime+60 ) + if ( *blocktimep < tipindex->nTime+60) *blocktimep = tipindex->nTime+60; //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); @@ -2155,7 +2158,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } //fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); - block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; + block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; inTime+27,minage,hashbuf)) == 0 ) continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); + //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index ef7af0ba2..f2f6ed6b4 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -53,7 +53,7 @@ bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[64][36]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_BEAMPORT,ASSETCHAINS_CODAPORT; -uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; +uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1,STAKING_MIN_DIFF; uint32_t ASSETCHAINS_MAGIC = 2387029918; int64_t ASSETCHAINS_GENESISTXVAL = 5000000000; @@ -80,6 +80,8 @@ uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff}; uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; +// min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375}; // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0ac40a48b..74e82f1e2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1684,13 +1684,13 @@ void komodo_args(char *argv0) IS_KOMODO_NOTARY = 1; KOMODO_MININGTHREADS = 1; mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - IS_STAKED_NOTARY = -1; + IS_STAKED_NOTARY = -1; fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } } } - name = GetArg("-ac_name",""); + name = GetArg("-ac_name",""); if ( argv0 != 0 ) { len = (int32_t)strlen(argv0); @@ -1726,6 +1726,7 @@ void komodo_args(char *argv0) if (std::string(ASSETCHAINS_ALGORITHMS[i]) == selectedAlgo) { ASSETCHAINS_ALGO = i; + STAKING_MIN_DIFF = ASSETCHAINS_MINDIFF[i]; // only worth mentioning if it's not equihash if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) printf("ASSETCHAINS_ALGO, algorithm set to %s\n", selectedAlgo.c_str()); diff --git a/src/miner.cpp b/src/miner.cpp index e06a570c7..e90b22a5a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -531,6 +531,19 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) // blocktime = pindexPrev->GetMedianTimePast() + 60; siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); + // if you skip this check it will create a block too far into the future and not pass ProcessBlock or AcceptBlock. + // This has been moved from the mining loop to save CPU, and to also make ac_staked work with the verus miner. + while ( blocktime-57 > GetAdjustedTime() ) + { + sleep(1); + if ( (rand() % 100) < 1 ) + fprintf(stderr, "%u seconds until elegible, waiting.\n", blocktime-((uint32_t)GetAdjustedTime()+57)); + if ( chainActive.LastTip()->GetHeight() >= stakeHeight ) + { + fprintf(stderr, "Block Arrived, reset staking loop.\n"); + return(0); + } + } } if ( siglen > 0 ) @@ -546,7 +559,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); - + } // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -838,7 +851,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) isStake = true; - return CreateNewBlock(pubkey,scriptPubKey, gpucount, isStake); + return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } void komodo_broadcast(CBlock *pblock,int32_t limit) @@ -1241,7 +1254,7 @@ void static BitcoinMiner_noeq() if ( ptr == 0 ) { static uint32_t counter; - if ( counter++ < 10 ) + if ( ASSETCHAINS_STAKED == 0 && counter++ < 10 ) fprintf(stderr,"created illegal block, retry\n"); continue; } @@ -1301,10 +1314,12 @@ void static BitcoinMiner_noeq() if ( ASSETCHAINS_STAKED != 0 ) { - int32_t percPoS,z; - hashTarget = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); + int32_t percPoS,z; bool fNegative,fOverflow; + HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); + // We use equihash min diff here to make the verus miner instantly finds a blockhash, this saves CPU when staking. + HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); if ( ASSETCHAINS_STAKED < 100 ) - LogPrintf("Block %d : PoS %d%% vs target %d%% \n",Mining_height,percPoS,(int32_t)ASSETCHAINS_STAKED); + LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } while (true) @@ -1319,6 +1334,9 @@ void static BitcoinMiner_noeq() vh.ClearExtra(); int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; + if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) + hashTarget = HASHTarget_POW; + else hashTarget = HASHTarget; // for speed check NONCEMASK at a time for (i = 0; i < count; i++) @@ -1414,7 +1432,6 @@ void static BitcoinMiner_noeq() printf("%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576); #endif break; - } } } @@ -1724,12 +1741,6 @@ void static BitcoinMiner() } else { - while ( B.nTime-57 > GetAdjustedTime() ) - { - sleep(1); - if ( chainActive.LastTip()->GetHeight() >= Mining_height ) - return(false); - } uint256 tmp = B.GetHash(); int32_t z; for (z=31; z>=0; z--) fprintf(stderr,"%02x",((uint8_t *)&tmp)[z]); @@ -1938,12 +1949,12 @@ void static BitcoinMiner() for (int i = 0; i < nThreads; i++) { #ifdef ENABLE_WALLET - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH || (ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0) ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet)); else minerThreads->create_thread(boost::bind(&BitcoinMiner_noeq, pwallet)); #else - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH || (ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0) ) + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) minerThreads->create_thread(&BitcoinMiner); else minerThreads->create_thread(&BitcoinMiner_noeq); From a4f197794fb89e670714516b130c0ae0acfe0e0a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 16 Jan 2019 21:16:30 +0800 Subject: [PATCH 836/951] Many bug fixes. VerusHash now works with PoS64 without special exemptions. Difficulty on new chains still behaves weridly, hoping resolves as chain ages. Also reduced CPU load on all staking. These changes should work better if you are not the only node staking. --- src/komodo_bitcoind.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 662d0703c..0fea33ee5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1342,6 +1342,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; + static bool new_rules, didinit; + if ( !didinit ) { + new_rules = is_STAKED(ASSETCHAINS_SYMBOL) != 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 3 ? true : false; + didinit = true; + } + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); @@ -1353,6 +1359,9 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he ht = height - 100 + i; if ( ht <= 1 ) continue; + // never count the first 10 blocks, they are always PoW! Cant do this for old chains, so limit to LABS and LAB for now. + if ( new_rules && ht < 10 ) + continue; if ( (pindex= komodo_chainactive(ht)) != 0 ) { if ( komodo_segid(0,ht) >= 0 ) @@ -1376,7 +1385,12 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) - percPoS = (percPoS*100) / (m+n); + { + if ( new_rules) + percPoS = (percPoS*100) / (m+n); + else + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + } if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; From d072863d6f047b99354d05e583cd85f005e54dc3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 17 Jan 2019 00:06:00 +0800 Subject: [PATCH 837/951] fix 100% chains. --- src/komodo_bitcoind.h | 2 +- src/miner.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0fea33ee5..1ffc68c62 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1457,7 +1457,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget,arith_uint256 bhash) { CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; - if ( ASSETCHAINS_STAKED == 100 && height <= 10 ) + if ( ASSETCHAINS_STAKED == 100 && height <= 100 ) return(1); BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; diff --git a/src/miner.cpp b/src/miner.cpp index e90b22a5a..98bfa55a1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -132,7 +132,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" extern CCriticalSection cs_metrics; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; @@ -1316,10 +1316,8 @@ void static BitcoinMiner_noeq() { int32_t percPoS,z; bool fNegative,fOverflow; HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); - // We use equihash min diff here to make the verus miner instantly finds a blockhash, this saves CPU when staking. - HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - if ( ASSETCHAINS_STAKED < 100 ) - LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); + HASHTarget.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); + LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } while (true) @@ -1334,7 +1332,7 @@ void static BitcoinMiner_noeq() vh.ClearExtra(); int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; - if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) + if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; else hashTarget = HASHTarget; From 43be0a0e918c5d83a8be0492499f8c962d9b51d5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 18 Jan 2019 17:54:41 +0800 Subject: [PATCH 838/951] VerusHash fix. 100% PoW wasnt working, min diff is now much higher fixing PoW doing 1s blocks. --- src/komodo_bitcoind.h | 24 ++++++++---------------- src/komodo_globals.h | 4 +++- src/miner.cpp | 16 ++++++++++------ src/notaries_staked.cpp | 4 ++-- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1ffc68c62..2fea50e7b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1296,6 +1296,11 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + { + if ( blocktime+iter+segid*2 > prevtime+200 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+120)); + } if ( blocktime+iter+segid*2 > prevtime+480 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); coinage256 = arith_uint256(coinage+1); @@ -1339,14 +1344,9 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { - int32_t oldflag = 0,dispflag = 0; + int32_t oldflag = 0,dispflag = 1; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - static bool new_rules, didinit; - if ( !didinit ) { - new_rules = is_STAKED(ASSETCHAINS_SYMBOL) != 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 3 ? true : false; - didinit = true; - } if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); @@ -1359,9 +1359,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he ht = height - 100 + i; if ( ht <= 1 ) continue; - // never count the first 10 blocks, they are always PoW! Cant do this for old chains, so limit to LABS and LAB for now. - if ( new_rules && ht < 10 ) - continue; if ( (pindex= komodo_chainactive(ht)) != 0 ) { if ( komodo_segid(0,ht) >= 0 ) @@ -1385,12 +1382,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) - { - if ( new_rules) - percPoS = (percPoS*100) / (m+n); - else - percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; - } + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; @@ -1449,7 +1441,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS); } } - else + else bnTarget = ave; // recent ave is perfect return(bnTarget); } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f2f6ed6b4..70d621756 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -81,7 +81,9 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375}; +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905}; + // nBits.486704888 -- too low? + // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS diff --git a/src/miner.cpp b/src/miner.cpp index 98bfa55a1..aac5164cb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1297,6 +1297,7 @@ void static BitcoinMiner_noeq() pblock->nSolution = solnPlaceholder; savebits = pblock->nBits; arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); + HASHTarget = arith_uint256().SetCompact(savebits); arith_uint256 mask(ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]); Mining_start = 0; @@ -1315,8 +1316,8 @@ void static BitcoinMiner_noeq() if ( ASSETCHAINS_STAKED != 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; - HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED); - HASHTarget.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); + HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED); + HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED); } @@ -1332,10 +1333,12 @@ void static BitcoinMiner_noeq() vh.ClearExtra(); int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; - if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) - hashTarget = HASHTarget_POW; - else hashTarget = HASHTarget; - + if ( ASSETCHAINS_STAKED != 0) + { + if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED < 100 ) + hashTarget = HASHTarget_POW; + else hashTarget = HASHTarget; + } // for speed check NONCEMASK at a time for (i = 0; i < count; i++) { @@ -1429,6 +1432,7 @@ void static BitcoinMiner_noeq() #else printf("%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576); #endif + pblock->nBits = savebits; break; } } diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index ebee4868e..596c78b90 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -14,9 +14,9 @@ int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) + if ( (strcmp(chain_name, "LABMAIN") == 0) || (strncmp(chain_name, "LABT1", 4) == 0) ) STAKED = 1; - else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) ) + else if ( (strcmp(chain_name, "LABT2") == 0) || (strncmp(chain_name, "LABT2", 3) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; From 45dfd3a590a3cab4635f3262d9d8e3b06a3b5138 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 18 Jan 2019 17:55:20 +0800 Subject: [PATCH 839/951] fix back to LABS --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 596c78b90..ad1a2132f 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -14,7 +14,7 @@ int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABMAIN") == 0) || (strncmp(chain_name, "LABT1", 4) == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 1; else if ( (strcmp(chain_name, "LABT2") == 0) || (strncmp(chain_name, "LABT2", 3) == 0) ) STAKED = 2; From f7b6af7b3faac79ba62a8d2bec410c4490de555a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 20 Jan 2019 19:11:31 +0800 Subject: [PATCH 840/951] ac_founders_reward test for Alright --- src/komodo_bitcoind.h | 13 +++++++++---- src/komodo_globals.h | 2 +- src/komodo_utils.h | 11 ++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4117347b6..e38436c71 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1151,7 +1151,12 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( ASSETCHAINS_FOUNDERS > 1 ) { if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) - commission = commission * ASSETCHAINS_FOUNDERS; + { + if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) + commission = commission * ASSETCHAINS_FOUNDERS; + else + commission = ASSETCHAINS_FOUNDERS_REWARD; + } else commission = 0; } } @@ -1820,15 +1825,15 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else { // I think this means the block is valid PoW. We need to set the pindex->segid here. - failed = 0; - CBlockIndex *pindex; + failed = 0; + CBlockIndex *pindex; BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && height > 100 && pindex->segid == -2 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); } - } + } } } else if ( is_PoSblock < 0 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 244655f5f..d5c6ca27e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -92,7 +92,7 @@ int32_t ASSETCHAINS_SAPLING = -1; int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS, ASSETCHAINS_FOUNDERS_REWARD; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 17e849338..a86c993e8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1777,6 +1777,7 @@ void komodo_args(char *argv0) MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); @@ -1809,7 +1810,7 @@ void komodo_args(char *argv0) } // else it can be gateway coin - + if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1835,13 +1836,17 @@ void komodo_args(char *argv0) decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); } - if ( ASSETCHAINS_COMMISSION == 0 ) + if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { - if (ASSETCHAINS_FOUNDERS != 0 ) + if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) { ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } + else + { + printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); + } /*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) { //ASSETCHAINS_OVERRIDE_PUBKEY.clear(); From 2c3247e8f1e8e9e9fe5336fb6b94353d7a98817b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 22 Jan 2019 00:12:05 +0800 Subject: [PATCH 841/951] Enable -ac_algo=verushash11 --- src/chainparams.cpp | 8 +++----- src/init.cpp | 8 +++++++- src/komodo_bitcoind.h | 6 ++---- src/komodo_globals.h | 18 +++++++++--------- src/komodo_utils.h | 5 +++-- src/metrics.cpp | 4 ++-- src/miner.cpp | 32 +++++++++++++++++++++++++------- src/primitives/block.cpp | 12 ++++++++++-- src/primitives/block.h | 1 + src/wallet-utility.cpp | 1 + 10 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6b0627d20..368e0eb50 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -94,11 +94,10 @@ void *chainparams_commandline(void *ptr); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; +extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO; -extern int8_t is_STAKED(const char *chain_name); const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); class CMainParams : public CChainParams { @@ -269,8 +268,7 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); - - if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing diff --git a/src/init.cpp b/src/init.cpp index 3dd09ac50..6aca3ce1b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1177,7 +1177,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) globalVerifyHandle.reset(new ECCVerifyHandle()); // set the hash algorithm to use for this chain - extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH; + // Again likely better solution here, than using long IF ELSE. + extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; CVerusHash::init(); CVerusHashV2::init(); if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) @@ -1185,6 +1186,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // initialize VerusHash CBlockHeader::SetVerusHash(); } + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + { + // initialize VerusHashV2 + CBlockHeader::SetVerusHashV2(); + } // Sanity check if (!InitSanityCheck()) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2fea50e7b..b567c1488 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1296,11 +1296,11 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) { if ( blocktime+iter+segid*2 > prevtime+200 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+120)); - } + } if ( blocktime+iter+segid*2 > prevtime+480 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); coinage256 = arith_uint256(coinage+1); @@ -1379,8 +1379,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } - // We now do actual PoS % at the start. Requires coin distribution in first 10 blocks! - // This is not hard to do and stops the chain having its PoS/PoW in large chunks. if ( m+n < 100 ) percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 70d621756..2c2d4e855 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -68,22 +68,22 @@ int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; -uint32_t ASSETCHAINS_LASTERA = 1; +uint64_t ASSETCHAINS_LASTERA = 1; uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; #define _ASSETCHAINS_EQUIHASH 0 -uint32_t ASSETCHAINS_NUMALGOS = 2; +uint32_t ASSETCHAINS_NUMALGOS = 3; uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH; uint32_t ASSETCHAINS_VERUSHASH = 1; -const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash"}; -uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff}; -uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16}; -uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096}; +uint32_t ASSETCHAINS_VERUSHASHV2 = 2; +const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash", "verushash11"}; +uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff,0xfffffff}; +uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; +uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905}; - // nBits.486704888 -- too low? - +// VerusHash v1 and 1.1 use a custom tuned number or PoW blocks all are 1s. +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905,486648905}; // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 74e82f1e2..1fe4c012a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1742,9 +1742,10 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS ) { ASSETCHAINS_LASTERA = 1; - printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %u\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); + printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; + printf("ASSETCHAINS_LASTERA = %lu\n", ASSETCHAINS_LASTERA); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); @@ -2069,7 +2070,7 @@ void komodo_args(char *argv0) if ( strcmp("PIRATE",ASSETCHAINS_SYMBOL) == 0 && ASSETCHAINS_HALVING[0] == 77777 ) { ASSETCHAINS_HALVING[0] *= 5; - fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%d\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,ASSETCHAINS_LASTERA); + fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%lu\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,ASSETCHAINS_LASTERA); } else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 ) dpowconfs = 0; diff --git a/src/metrics.cpp b/src/metrics.cpp index a01d381a1..879765933 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -40,7 +40,7 @@ #include extern uint64_t ASSETCHAINS_TIMELOCKGTE; -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH; +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; int64_t komodo_block_unlocktime(uint32_t nHeight); void AtomicTimer::start() @@ -137,7 +137,7 @@ int64_t GetUptime() double GetLocalSolPS() { - if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) { return miningTimer.rate(nHashCount); } diff --git a/src/miner.cpp b/src/miner.cpp index aac5164cb..66f1a263f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -137,7 +137,7 @@ extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; -extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; +extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); @@ -1324,26 +1324,44 @@ void static BitcoinMiner_noeq() while (true) { arith_uint256 arNonce = UintToArith256(pblock->nNonce); - + int64_t *extraPtr; + + // This seems to be a really bad way to do this, but its better than copy pasting the entire miner function at this stage. CVerusHashWriter ss = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION); ss << *((CBlockHeader *)pblock); - int64_t *extraPtr = ss.xI64p(); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + extraPtr = ss.xI64p(); CVerusHash &vh = ss.GetState(); uint256 hashResult = uint256(); vh.ClearExtra(); + + CVerusHashV2Writer ss2 = CVerusHashV2Writer(SER_GETHASH, PROTOCOL_VERSION); + ss2 << *((CBlockHeader *)pblock); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + extraPtr = ss2.xI64p(); + CVerusHashV2 &vh2 = ss2.GetState(); + vh2.ClearExtra(); + int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1; int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; - if ( ASSETCHAINS_STAKED != 0) + if ( ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 ) { - if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED < 100 ) + if ( KOMODO_MININGTHREADS > 0 ) hashTarget = HASHTarget_POW; - else hashTarget = HASHTarget; + else + hashTarget = HASHTarget; } + else if ( ASSETCHAINS_STAKED == 100 && Mining_height > 100 ) + hashTarget = HASHTarget; + // for speed check NONCEMASK at a time for (i = 0; i < count; i++) { *extraPtr = i; - vh.ExtraHash((unsigned char *)&hashResult); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) + vh.ExtraHash((unsigned char *)&hashResult); + else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + vh2.ExtraHash((unsigned char *)&hashResult); if ( UintToArith256(hashResult) <= hashTarget ) { diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 00fc8cee9..3c0dfdd37 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -46,8 +46,11 @@ uint256 CBlockHeader::GetVerusHash() const uint256 CBlockHeader::GetVerusV2Hash() const { - // no check for genesis block and use the optimized hash - return SerializeVerusHashV2(*this); + if (hashPrevBlock.IsNull()) + // always use SHA256D for genesis block + return SerializeHash(*this); + else + return SerializeVerusHashV2(*this); } void CBlockHeader::SetSHA256DHash() @@ -60,6 +63,11 @@ void CBlockHeader::SetVerusHash() CBlockHeader::hashFunction = &CBlockHeader::GetVerusHash; } +void CBlockHeader::SetVerusHashV2() +{ + CBlockHeader::hashFunction = &CBlockHeader::GetVerusV2Hash; +} + // returns false if unable to fast calculate the VerusPOSHash from the header. // if it returns false, value is set to 0, but it can still be calculated from the full block // in that case. the only difference between this and the POS hash for the contest is that it is not divided by the value out diff --git a/src/primitives/block.h b/src/primitives/block.h index 5cd0a72fe..6ef8e0633 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -106,6 +106,7 @@ public: uint256 GetVerusEntropyHash(int32_t nHeight) const; uint256 GetVerusV2Hash() const; + static void SetVerusHashV2(); int64_t GetBlockTime() const { diff --git a/src/wallet-utility.cpp b/src/wallet-utility.cpp index 7af2ca5bf..f4041dfbe 100644 --- a/src/wallet-utility.cpp +++ b/src/wallet-utility.cpp @@ -18,6 +18,7 @@ uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint32_t ASSETCHAINS_EQUIHASH = 0; uint32_t ASSETCHAINS_VERUSHASH = 1; +uint32_t ASSETCHAINS_VERUSHASHV2 = 2; uint32_t ASSETCHAINS_ALGO = 0; int32_t ASSETCHAINS_LWMAPOS = 0; int32_t VERUS_BLOCK_POSUNITS = 1000; From 8324e606cd99b240b812013fa3e5f43854d6a6e6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 22 Jan 2019 14:39:29 +0800 Subject: [PATCH 842/951] try to add PoS% to staking loop, to adjust staking difficulty --- src/chainparams.cpp | 14 ++- src/komodo_bitcoind.h | 220 +++++++++++++++++++++++------------------- src/komodo_globals.h | 5 +- src/pow.cpp | 2 + 4 files changed, 135 insertions(+), 106 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 368e0eb50..03a518d4b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -94,9 +94,9 @@ void *chainparams_commandline(void *ptr); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; +extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO; +extern uint64_t ASSETCHAINS_SUPPLY; const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); @@ -268,7 +268,7 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); - if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing @@ -276,6 +276,14 @@ void *chainparams_commandline(void *ptr) mainParams.consensus.nPowAveragingWindow = 45; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); } + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + { + // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: + // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing + mainParams.consensus.nLwmaAjustedWeight = 1350; + mainParams.consensus.nPowAveragingWindow = 45; + mainParams.consensus.powAlternate = uint256S("000000ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); + } if (ASSETCHAINS_LWMAPOS != 0) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b567c1488..d2c3b3b30 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1253,95 +1253,6 @@ uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 return(addrhash.uints[0]); } -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) -{ - bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t diff=0,segid,minage,i,iter=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; - txtime = komodo_txtime2(&value,txid,vout,address); - if ( validateflag == 0 ) - { - //fprintf(stderr,"blocktime.%u -> ",blocktime); - if ( blocktime < prevtime+3 ) - blocktime = prevtime+3; - if ( blocktime < GetAdjustedTime()-60 ) - blocktime = GetAdjustedTime()+30; - //fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime); - } - if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) - { - //fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); - return(0); - } - if ( value < SATOSHIDEN ) - return(0); - value /= SATOSHIDEN; - mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); - ratio = (mindiff / bnTarget); - if ( (minage= nHeight*3) > 6000 ) // about 100 blocks - minage = 6000; - komodo_segids(hashbuf,nHeight-101,100); - segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); - segid = ((nHeight + segid32) & 0x3f); - for (iter=0; iter<600; iter++) - { - if ( blocktime+iter+segid*2 < txtime+minage ) - continue; - diff = (iter + blocktime - txtime - minage); - if ( diff < 0 ) - diff = 60; - else if ( diff > 3600*24*30 ) - { - //printf("diff.%d (iter.%d blocktime.%u txtime.%u minage.%d)\n",(int32_t)diff,iter,blocktime,txtime,(int32_t)minage); - diff = 3600*24*30; - } - if ( iter > 0 ) - diff += segid*2; - coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) - { - if ( blocktime+iter+segid*2 > prevtime+200 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+120)); - } - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - coinage256 = arith_uint256(coinage+1); - hashval = ratio * (UintToArith256(hash) / coinage256); - if ( hashval <= bnTarget ) - { - winner = 1; - if ( validateflag == 0 ) - { - //fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); - 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 "); - 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 v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ - break; - } - } - //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); - if ( 0 && validateflag != 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 v%d diff.%d ht.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff,nHeight); - } - if ( nHeight < 10 ) - return(blocktime); - return(blocktime * winner); -} - arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { int32_t oldflag = 0,dispflag = 1; @@ -1380,7 +1291,17 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he fprintf(stderr," %d, ",percPoS); } if ( m+n < 100 ) - percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + { + // We do actual PoS % at the start. Requires coin distribution in first 10 blocks! + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + percPoS = (percPoS*100) / (m+n); + else + // This seems to be inverse. The actual PoS % is backwards in the first 100 blocks. + // I dont't understand the math here, or why its backwards, so I am just disabling it for VerusHash. + // No doubt this is probably wrong for equihash aswell, we may need to test an equihash chain with the rule above. + // Need to ask james what the deal is here! Seems to be causeing ALL the problems. + percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; + } if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; @@ -1444,9 +1365,104 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he return(bnTarget); } +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,int32_t PoSperc) +{ + bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t diff=0,segid,minage,i,iter=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; + txtime = komodo_txtime2(&value,txid,vout,address); + if ( validateflag == 0 ) + { + //fprintf(stderr,"blocktime.%u -> ",blocktime); + if ( blocktime < prevtime+3 ) + blocktime = prevtime+3; + if ( blocktime < GetAdjustedTime()-60 ) + blocktime = GetAdjustedTime()+30; + //fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime); + } + if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) + { + //fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime); + return(0); + } + if ( value < SATOSHIDEN ) + return(0); + value /= SATOSHIDEN; + mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); + ratio = (mindiff / bnTarget); + if ( (minage= nHeight*3) > 6000 ) // about 100 blocks + minage = 6000; + komodo_segids(hashbuf,nHeight-101,100); + segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout); + segid = ((nHeight + segid32) & 0x3f); + for (iter=0; iter<600; iter++) + { + if ( blocktime+iter+segid*2 < txtime+minage ) + continue; + diff = (iter + blocktime - txtime - minage); + if ( diff < 0 ) + diff = 60; + else if ( diff > 3600*24*30 ) + { + //printf("diff.%d (iter.%d blocktime.%u txtime.%u minage.%d)\n",(int32_t)diff,iter,blocktime,txtime,(int32_t)minage); + diff = 3600*24*30; + } + if ( iter > 0 ) + diff += segid*2; + coinage = (value * diff); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + { + fprintf(stderr, "PoS % is: %i% vs. %i% \n", PoSperc, ASSETCHAINS_STAKED); + if ( PoSperc < ASSETCHAINS_STAKED ) + { + // This means we are under PoS % required and we need some extra help getting an elegible utxo. + // Likley there is some math required here to make it work properly. But getting the data here is no1 priority. + coinage = coinage * 1000; + } + } + // leave this here for now... + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + coinage256 = arith_uint256(coinage+1); + hashval = ratio * (UintToArith256(hash) / coinage256); + if ( hashval <= bnTarget ) + { + winner = 1; + if ( validateflag == 0 ) + { + //fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid); + 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 "); + 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 v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ + break; + } + } + //fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner); + if ( 0 && validateflag != 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 v%d diff.%d ht.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff,nHeight); + } + if ( nHeight < 10 ) + return(blocktime); + return(blocktime * winner); +} + int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget,arith_uint256 bhash) { - CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; + CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; arith_uint256 POWTarget; if ( ASSETCHAINS_STAKED == 100 && height <= 100 ) return(1); BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); @@ -1457,6 +1473,8 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ return(0); else return(1); } + // Get PoSperc and POW Target. for later. + POWTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); txn_count = pblock->vtx.size(); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 ) { @@ -1470,7 +1488,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( komodo_isPoS(pblock) != 0 ) { - eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)""); + eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)"",PoSperc); } if ( eligible == 0 || eligible > pblock->nTime ) { @@ -1515,8 +1533,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ } else { - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); - if ( bhash < bnTarget ) + if ( bhash < POWTarget ) { //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; @@ -2085,10 +2102,11 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod 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) { static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; - set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; + int32_t PoSperc; + set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget,tmpTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; - + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow); ratio = (mindiff / bnTarget); @@ -2100,6 +2118,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (tipindex= chainActive.Tip()) == 0 ) return(0); nHeight = tipindex->GetHeight() + 1; + // Get the PoS% so we can pass it to komodo_stake, this is to adjust PoS dofficulty when it is under the target %! + tmpTarget = komodo_PoWtarget(&PoSperc,bnTarget,nHeight,ASSETCHAINS_STAKED); if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; komodo_segids(hashbuf,nHeight-101,100); @@ -2119,7 +2139,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } - if ( time(NULL) > lasttime+600 || array == 0 || resetstaker ) + if ( resetstaker || array == 0 || time(NULL) > lasttime+600 ) { LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); @@ -2175,14 +2195,14 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt kp = &array[i]; if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) continue; - eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); + eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address,PoSperc); //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; - if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + if ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address,PoSperc) ) { - while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address) ) + while ( eligible == komodo_stake(1,bnTarget,nHeight,kp->txid,kp->vout,eligible,(uint32_t)tipindex->nTime+27,kp->address,PoSperc) ) { besttime = eligible; eligible--; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 2c2d4e855..cb1d9987d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -82,9 +82,8 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -// VerusHash v1 and 1.1 use a custom tuned number or PoW blocks all are 1s. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905,486648905}; - +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,503381775,503381775}; + // ^ wrong! // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS int32_t VERUS_BLOCK_POSUNITS = 1024; // one block is 1000 units diff --git a/src/pow.cpp b/src/pow.cpp index b69c4fce6..0e4b706a8 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -134,6 +134,8 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const bnLimit = UintToArith256(params.powAlternate); unsigned int nProofOfWorkLimit = bnLimit.GetCompact(); + + printf("PoWLimit: %u\n", nProofOfWorkLimit); // Find the first block in the averaging interval as we total the linearly weighted average const CBlockIndex* pindexFirst = pindexLast; From 7167793dbf4b776f6d4d8ae6daf7a6b150747c65 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 02:50:53 +0800 Subject: [PATCH 843/951] new version --- src/chainparams.cpp | 2 +- src/komodo_bitcoind.h | 54 +++++++++++++++++++++++------------------- src/komodo_globals.h | 5 ++-- src/komodo_utils.h | 2 +- src/main.cpp | 3 ++- src/miner.cpp | 8 +++---- src/pow.cpp | 4 ++-- src/rpc/blockchain.cpp | 2 +- src/rpc/mining.cpp | 3 +-- src/rpc/misc.cpp | 4 ++-- 10 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 03a518d4b..45824f22b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -282,7 +282,7 @@ void *chainparams_commandline(void *ptr) // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing mainParams.consensus.nLwmaAjustedWeight = 1350; mainParams.consensus.nPowAveragingWindow = 45; - mainParams.consensus.powAlternate = uint256S("000000ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); + mainParams.consensus.powAlternate = uint256S("0000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); } if (ASSETCHAINS_LWMAPOS != 0) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d2c3b3b30..b2b8011b5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1255,7 +1255,7 @@ uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { - int32_t oldflag = 0,dispflag = 1; + int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; @@ -1367,7 +1367,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he 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,int32_t PoSperc) { - bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t diff=0,segid,minage,i,iter=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; + bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t segid,minage,i,iter=0; int64_t diff=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage; txtime = komodo_txtime2(&value,txid,vout,address); if ( validateflag == 0 ) { @@ -1398,6 +1398,23 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( blocktime+iter+segid*2 < txtime+minage ) continue; diff = (iter + blocktime - txtime - minage); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + { + if ( PoSperc < ASSETCHAINS_STAKED ) + { + // Under PoS % target and we need to increase diff. + //fprintf(stderr, "PoS too low diff.%i changed to.",diff); + diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) ); + //fprintf(stderr, "%i \n",diff); + } + else if ( PoSperc > ASSETCHAINS_STAKED ) + { + // Over PoS target need to lower diff. + //fprintf(stderr, "PoS too high diff.%i changed to.",diff); + diff = diff / ( (PoSperc - ASSETCHAINS_STAKED + 1) * (PoSperc - ASSETCHAINS_STAKED + 1) ); + //fprintf(stderr, "%i \n",diff); + } + } if ( diff < 0 ) diff = 60; else if ( diff > 3600*24*30 ) @@ -1408,19 +1425,8 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) - { - fprintf(stderr, "PoS % is: %i% vs. %i% \n", PoSperc, ASSETCHAINS_STAKED); - if ( PoSperc < ASSETCHAINS_STAKED ) - { - // This means we are under PoS % required and we need some extra help getting an elegible utxo. - // Likley there is some math required here to make it work properly. But getting the data here is no1 priority. - coinage = coinage * 1000; - } - } - // leave this here for now... - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + if ( blocktime+iter+segid*2 > prevtime+128 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( hashval <= bnTarget ) @@ -1441,7 +1447,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh 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 v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff);*/ + fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); */ break; } } @@ -2048,7 +2054,8 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk return(array); } -arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) +// WHY IS THIS HERE! It does this in komodo_stake! WTF! +/*arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) { int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; diff = (iter + blocktime - kp->txtime - minage); @@ -2074,12 +2081,12 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - /*for (int i=31; i>=16; i--) + for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); fprintf(stderr," vs "); for (int i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime);*/ + fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { for (iter=0; iternTime+27,minage,hashbuf)) == 0 ) - continue; + // WTF! was this here for! + //if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) + // continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address,PoSperc); //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index cb1d9987d..dd51d9c93 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -82,7 +82,7 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096}; uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH; // min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked. -uint32_t ASSETCHAINS_MINDIFF[] = {537857807,503381775,503381775}; +uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375,487526159}; // ^ wrong! // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS @@ -95,7 +95,8 @@ int32_t ASSETCHAINS_SAPLING = -1; int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; +int32_t ASSETCHAINS_STAKED; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1fe4c012a..cb7275898 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1916,7 +1916,7 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LWMAPOS),(void *)&ASSETCHAINS_LWMAPOS); } - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; + val = ASSETCHAINS_COMMISSION | (((int64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) { diff --git a/src/main.cpp b/src/main.cpp index c1cdc3935..5aaf69bfb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2216,8 +2216,9 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS]; extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; +extern uint64_t ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; +extern int32_t ASSETCHAINS_STAKED; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { diff --git a/src/miner.cpp b/src/miner.cpp index 66f1a263f..4ce3bc37b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -132,8 +132,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #include "komodo_defs.h" extern CCriticalSection cs_metrics; -extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF; -extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED; +extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF,ASSETCHAINS_STAKED; +extern uint64_t ASSETCHAINS_COMMISSION; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; @@ -558,9 +558,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nFees += txfees; pblock->nTime = blocktime; //printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13))); - } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); - + } else return(0); //fprintf(stderr,"no utxos eligible for staking\n"); } + // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); txNew.vin.resize(1); diff --git a/src/pow.cpp b/src/pow.cpp index 0e4b706a8..3e7afa720 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -37,9 +37,9 @@ #endif // ENABLE_RUST uint32_t komodo_chainactive_timestamp(); -extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED; +extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH; extern char ASSETCHAINS_SYMBOL[65]; -extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD; +extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD,ASSETCHAINS_STAKED; unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params); unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bb46f47fb..147b94b61 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -622,7 +622,7 @@ UniValue getblockhash(const UniValue& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } -extern uint64_t ASSETCHAINS_STAKED; +extern int32_t ASSETCHAINS_STAKED; UniValue getlastsegidstakes(const UniValue& params, bool fHelp) { diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 3843529ac..44b0162ad 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -48,8 +48,7 @@ using namespace std; -extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS; -extern uint64_t ASSETCHAINS_STAKED; +extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS,ASSETCHAINS_STAKED; extern int32_t KOMODO_MININGTHREADS; extern bool VERUS_MINTBLOCKS; arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a174fedf7..4fa5c061c 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -80,8 +80,8 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC; -extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY,ASSETCHAINS_LASTERA; -extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING; +extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY,ASSETCHAINS_LASTERA; +extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; From bbf756704f1bccfdeeae20643a034e53b5e7bfbf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 13:54:09 +0800 Subject: [PATCH 844/951] clean up --- src/komodo_bitcoind.h | 57 +------------------------------------------ 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b2b8011b5..ce7c0259a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2054,63 +2054,11 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk return(array); } -// WHY IS THIS HERE! It does this in komodo_stake! WTF! -/*arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uint32_t blocktime,int32_t iter,int32_t minage,int32_t segid,int32_t nHeight,uint32_t prevtime) -{ - int32_t diff; uint64_t coinage; arith_uint256 coinage256,hashval; - diff = (iter + blocktime - kp->txtime - minage); - if ( diff < 0 ) - diff = 60; - else if ( diff > 3600*24*30 ) - diff = 3600*24*30; - if ( iter > 0 ) - diff += segid*2; - coinage = ((uint64_t)kp->nValue * diff); - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - coinage256 = arith_uint256(coinage+1); - hashval = ratio * (kp->hashval / coinage256); - return(hashval); -} - -uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komodo_staking *kp,int32_t nHeight,uint32_t blocktime,uint32_t prevtime,int32_t minage,uint8_t *hashbuf) -{ - int32_t maxiters = 600; uint256 hash; - int32_t segid,iter,diff; uint64_t coinage; arith_uint256 hashval,coinage256; - komodo_stakehash(&hash,kp->address,hashbuf,kp->txid,kp->vout); - kp->hashval = UintToArith256(hash); - segid = ((nHeight + kp->segid32) & 0x3f); - hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - for (int i=31; i>=16; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," vs "); - for (int i=31; i>=16; i--) - fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); - fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - for (iter=0; itertxtime+minage ) - continue; - hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime); - if ( hashval <= bnTarget ) - { - //fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid); - blocktime += iter; - blocktime += segid * 2; - return(blocktime); - } - } - } //else fprintf(stderr,"maxiters is not good enough\n"); - return(0); -}*/ - 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) { static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; int32_t PoSperc; - set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget,tmpTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; + set setAddress; struct komodo_staking *kp; int32_t winners,segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector vecOutputs; uint32_t block_from_future_rejecttime,besttime,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget,tmpTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock; if (!EnsureWalletIsAvailable(0)) return 0; @@ -2198,9 +2146,6 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt return(0); } kp = &array[i]; - // WTF! was this here for! - //if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 ) - // continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address,PoSperc); //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) From eb164bc03c99e78045391ceb3c7cf75bd13e9a02 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 13:57:04 +0800 Subject: [PATCH 845/951] ok --- src/komodo_bitcoind.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a7afe440b..86deb54be 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1867,14 +1867,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } else { -<<<<<<< HEAD - // I think this means the block is valid PoW. We need to set the pindex->segid here. - failed = 0; - CBlockIndex *pindex; -======= failed = 0; CBlockIndex *pindex; ->>>>>>> new_staker BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; if ( pindex != 0 && pindex->segid == -2 ) { From e460f1aa57d1964965a7b0da629a268e5a4a2df5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 14:15:43 +0800 Subject: [PATCH 846/951] print --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 3e7afa720..5c8baeada 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -135,7 +135,7 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const unsigned int nProofOfWorkLimit = bnLimit.GetCompact(); - printf("PoWLimit: %u\n", nProofOfWorkLimit); + //printf("PoWLimit: %u\n", nProofOfWorkLimit); // Find the first block in the averaging interval as we total the linearly weighted average const CBlockIndex* pindexFirst = pindexLast; From a0427ebf79c35e1821631a3102c9427e5af44c06 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 15:01:08 +0800 Subject: [PATCH 847/951] ac_founders_reward fix --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 10 +++++----- src/main.cpp | 2 +- src/miner.cpp | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 86deb54be..ddbadd527 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1739,7 +1739,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; - if ( ASSETCHAINS_COMMISSION != 0 ) + if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 922179c2d..b66df3833 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1779,7 +1779,7 @@ void komodo_args(char *argv0) MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; - ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); + ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); @@ -1846,10 +1846,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else - { - printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); - } + else + { + printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); + } /*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) { //ASSETCHAINS_OVERRIDE_PUBKEY.clear(); diff --git a/src/main.cpp b/src/main.cpp index 5aaf69bfb..2894b8263 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3474,7 +3474,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && + if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->GetHeight())) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 4ce3bc37b..f18b195da 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -133,7 +133,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern CCriticalSection cs_metrics; extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE,STAKING_MIN_DIFF,ASSETCHAINS_STAKED; -extern uint64_t ASSETCHAINS_COMMISSION; +extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_FOUNDERS_REWARD; extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; @@ -587,7 +587,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret('C',nHeight,pk); } - else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + else if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From de91bdf571a7adada58a5b98e4276883ff3ab4b7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 16:13:54 +0800 Subject: [PATCH 848/951] mutually exclusive founders reward and comission + magic value. --- src/komodo_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b66df3833..b0642b53d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1787,6 +1787,11 @@ void komodo_args(char *argv0) ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0); ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); + if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 ) + { + fprintf(stderr,"cannot use founders reward and commission on the same chain.\n"); + exit(0); + } if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n"); From 0c2aa0a6493203f6a89de5bb4d7388e33c2dea97 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 23 Jan 2019 16:20:31 +0800 Subject: [PATCH 849/951] oops --- src/komodo_utils.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b0642b53d..5d05abd1e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1880,7 +1880,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1928,12 +1928,17 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((int64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); + if ( ASSETCHAINS_FOUNDERS != 0 ) { uint8_t tmp = 1; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp); if ( ASSETCHAINS_FOUNDERS > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + if ( ASSETCHAINS_FOUNDERS_REWARD != 0 ) + { + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD); + } } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { From 1fb9fd6ba7eed852cc5460b4a95df73204673ab9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 24 Jan 2019 00:08:04 +0800 Subject: [PATCH 850/951] fix equihash chain sync. --- src/komodo_bitcoind.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 545e7b241..a8af824d1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1454,8 +1454,16 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( blocktime+iter+segid*2 > prevtime+128 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + { + if ( blocktime+iter+segid*2 > prevtime+128 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); + } + else + { + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + } coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( hashval <= bnTarget ) From b984401e96ff970fb9c82bbf83c13e6da8aaa64c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:18:00 +0800 Subject: [PATCH 851/951] add ca333's Makefile, change depend to hardcoded berkely DB in depnds folder. Add exception for COINABSE_MATURITY =1 for all LABS chains. --- src/cc/Makefile | 13 +++++++------ src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 2 +- src/wallet/db.h | 2 +- zcutil/build.sh | 6 +++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index a3c54d81d..f283f5865 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -1,17 +1,18 @@ SHELL = /bin/sh -CC = gcc +CC = gcc CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib +CFLAGS = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program $(info $(OS)) OS := $(shell uname -s) $(info $(OS)) -TARGET = ../cclib.so -TARGET_WIN = ../cclib.dll +TARGET = ../libcc.so +TARGET_DARWIN = ../libcc.dylib +TARGET_WIN = ../libcc.dll SOURCES = cclib.cpp #HEADERS = $(shell echo ../cryptoconditions/include/*.h) @@ -20,7 +21,7 @@ all: $(TARGET) $(TARGET): $(SOURCES) $(info Building cclib to src/) ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) + $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) $(SOURCES) else ifeq ($(OS),Linux) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a8af824d1..5fa5a3a6b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1288,7 +1288,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height < 100) ) return(target); sum = arith_uint256(0); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6ff7dd96e..4a821a5a6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -2055,7 +2055,7 @@ void komodo_args(char *argv0) if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; else komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT + 1); - if (ASSETCHAINS_LASTERA == 0) + if (ASSETCHAINS_LASTERA == 0 || is_STAKED(ASSETCHAINS_SYMBOL) != 0) COINBASE_MATURITY = 1; //fprintf(stderr,"ASSETCHAINS_RPCPORT (%s) %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_RPCPORT); } diff --git a/src/wallet/db.h b/src/wallet/db.h index 19b9b6079..f7854fe2f 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -33,7 +33,7 @@ #include -#include +#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" extern unsigned int nWalletDBUpdated; diff --git a/zcutil/build.sh b/zcutil/build.sh index 68239e16e..070c669fa 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,6 +101,9 @@ eval "$MAKE" --version as --version ld -v +HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 +./autogen.sh + #BUILD CCLIB WD=$PWD @@ -116,8 +119,5 @@ fi cd $WD -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 -./autogen.sh - CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From 73e71d5e4e2b0b479fe2c27f2e2f57d1e690f4fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:42:50 +0800 Subject: [PATCH 852/951] fix --- zcutil/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zcutil/build.sh b/zcutil/build.sh index 070c669fa..5870f127a 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,6 +101,8 @@ eval "$MAKE" --version as --version ld -v +../src/cc/makecclib + HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh From 63eda9498a8d6f03e57ba0bc5d7fc314aeb0e74f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:50:15 +0800 Subject: [PATCH 853/951] test fix --- src/cc/Makefile | 34 ---------------------------------- zcutil/build.sh | 19 +++---------------- 2 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 src/cc/Makefile diff --git a/src/cc/Makefile b/src/cc/Makefile deleted file mode 100644 index f283f5865..000000000 --- a/src/cc/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -SHELL = /bin/sh -CC = gcc -CC_DARWIN = g++-6 -CC_WIN = x86_64-w64-mingw32-gcc-posix -CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib -CFLAGS = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -DEBUGFLAGS = -O0 -D _DEBUG -RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program -$(info $(OS)) -OS := $(shell uname -s) -$(info $(OS)) -TARGET = ../libcc.so -TARGET_DARWIN = ../libcc.dylib -TARGET_WIN = ../libcc.dll -SOURCES = cclib.cpp -#HEADERS = $(shell echo ../cryptoconditions/include/*.h) - -all: $(TARGET) - -$(TARGET): $(SOURCES) - $(info Building cclib to src/) -ifeq ($(OS),Darwin) - $(CC_DARWIN) $(CFLAGS_DARWIN) $(DEBUGFLAGS) -o $(TARGET_DARWIN) $(SOURCES) -else ifeq ($(OS),Linux) - $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(SOURCES) -#else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host -else - $(info WINDOWS) - $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) $(SOURCES) -endif - -clean: - rm -rf $(TARGET) diff --git a/zcutil/build.sh b/zcutil/build.sh index 5870f127a..131f67d0f 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,25 +101,12 @@ eval "$MAKE" --version as --version ld -v -../src/cc/makecclib +#BUILD CCLIB +cd src/cc/ +./makecclib HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh -#BUILD CCLIB - -WD=$PWD -cd src/cc -echo $PWD - -if make "$@"; then - echo CCLIB BUILD SUCCESSFUL -else - echo CCLIB BUILD FAILED - exit 1 -fi - -cd $WD - CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From fd1de72c60fd6feab14e98ad18c1f9c197511731 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 16:54:27 +0800 Subject: [PATCH 854/951] fixed --- zcutil/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index 131f67d0f..cd96e8890 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,12 +101,12 @@ eval "$MAKE" --version as --version ld -v -#BUILD CCLIB -cd src/cc/ -./makecclib - HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' +#BUILD CCLIB +cd src/cc/ +./makecclib +cd ../../ "$MAKE" "$@" V=1 From 4bda6bcac48d2b720b9687ce1689d11d14fced12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 19:14:22 +0800 Subject: [PATCH 855/951] Change is_STAKED so that chains with a BR are 1 and chains with none are 2. Chains that are 255 are banned, and no notarisations can happen. --- src/komodo.h | 2 +- src/notaries_staked.cpp | 9 ++++----- src/notarisationdb.cpp | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0cf395c51..702de9d67 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -864,7 +864,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txn_count = block.vtx.size(); for (i=0; i Date: Fri, 25 Jan 2019 19:59:42 +0800 Subject: [PATCH 856/951] try fix extralen bug. Add is_STAKED == 2 to have a consensus block reward of 0. --- src/komodo_bitcoind.h | 4 ++++ src/komodo_utils.h | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5fa5a3a6b..cd3ed6bc5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1165,6 +1165,10 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); uint64_t komodo_commission(const CBlock *pblock,int32_t height) { + // LABS fungible chains, cannot have any block reward! + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) + return(0); + int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4a821a5a6..fb236ab24 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1569,6 +1569,9 @@ int64_t komodo_max_money() uint64_t komodo_ac_block_subsidy(int nHeight) { + // LABS fungible chains, cannot have any block reward! + if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) + return(0); // we have to find our era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; @@ -1655,7 +1658,7 @@ extern int64_t MAX_MONEY; void komodo_args(char *argv0) { extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz,baseid,len,n,extralen = 0; uint64_t ccenables[256]; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz = 0,baseid,len,n,extralen = 0; uint64_t ccenables[256]; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_STAKED_NOTARY = GetArg("-stakednotary", -1); if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) { From ef567651e34f3fca52fe1758967a649dfa597b9d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 20:51:57 +0800 Subject: [PATCH 857/951] fix block1 to allow an ac_aupply. --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fb236ab24..d9e1a7982 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1569,9 +1569,6 @@ int64_t komodo_max_money() uint64_t komodo_ac_block_subsidy(int nHeight) { - // LABS fungible chains, cannot have any block reward! - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); // we have to find our era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; @@ -1650,6 +1647,9 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } + else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) + return(0); + // LABS fungible chains, cannot have any block reward! return(subsidy); } From e9bd3e1d679f7124687c6b9b2b56cc568d6dbd91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 25 Jan 2019 23:44:04 +0800 Subject: [PATCH 858/951] try change version --- src/komodo_bitcoind.h | 2 +- src/version.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index cd3ed6bc5..8760ef441 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1292,7 +1292,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; - if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height < 100) ) + if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) return(target); sum = arith_uint256(0); diff --git a/src/version.h b/src/version.h index 09944cdf1..4056f105d 100644 --- a/src/version.h +++ b/src/version.h @@ -24,7 +24,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170007; +static const int PROTOCOL_VERSION = 170008; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -33,8 +33,8 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170002; -static const int STAKEDMIN_PEER_PROTO_VERSION = 170006; +static const int MIN_PEER_PROTO_VERSION = 170007; +static const int STAKEDMIN_PEER_PROTO_VERSION = 170007; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this From 2bff24cffec9fb47f213f3dc6a8aa7ca8424c3fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 00:58:17 +0800 Subject: [PATCH 859/951] fix LABST is not staked = 2. Will stop having any block reward. --- src/notaries_staked.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 5e52a0db1..9dcba0653 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -12,9 +12,11 @@ extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { static int8_t STAKED,doneinit; + if ( chain_name[0] == 0 ) + return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "PAYME") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "PAYME") == 0) || (strcmp(chain_name, "LABST") == 0) ) STAKED = 1; else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; From 0875e0ecf1471384b88b761639c898466e274e0e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 02:52:54 +0800 Subject: [PATCH 860/951] fix setgenerate false --- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8760ef441..8a515507e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2211,8 +2211,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; iGetHeight()+1 > nHeight ) { fprintf(stderr,"chain tip changed during staking loop t.%u counter.%d\n",(uint32_t)time(NULL),counter); diff --git a/src/miner.cpp b/src/miner.cpp index d8b4e7a80..9a70fc113 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -535,6 +535,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Block Arrived, reset staking loop.\n"); return(0); } + if( !GetBoolArg("-gen",false ) + return(0); } } @@ -1563,6 +1565,13 @@ void static BitcoinMiner() #endif if ( ptr == 0 ) { + if ( !GetBoolArg("-gen",false)) + { + miningTimer.stop(); + c.disconnect(); + LogPrintf("KomodoMiner terminated\n"); + return; + } static uint32_t counter; if ( counter++ < 10 && ASSETCHAINS_STAKED == 0 ) fprintf(stderr,"created illegal blockB, retry\n"); From 5131e12bd75bd10a26daf572b25cd866e26ec9b9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 03:00:57 +0800 Subject: [PATCH 861/951] sorrry --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9a70fc113..0aede35bb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -535,7 +535,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Block Arrived, reset staking loop.\n"); return(0); } - if( !GetBoolArg("-gen",false ) + if( !GetBoolArg("-gen",false) ) return(0); } } From 304de9777dff5ef59e34720cec6bc18fdc79085b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 12:57:05 +0800 Subject: [PATCH 862/951] fix getblocktemplate for PoW while staking --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index bccb43878..6bf1397ad 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -717,7 +717,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT); + pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT,false); #else pblocktemplate = CreateNewBlockWithKey(); #endif From 80a8414b8364d9d105d2b4f8d9c9b864392ec819 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 14:37:11 +0800 Subject: [PATCH 863/951] fix lock up with staker when trying to startum mine and stake. --- src/miner.cpp | 2 -- src/rpc/mining.cpp | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0aede35bb..3814abbca 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -843,8 +843,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 ) scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey); - if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 ) - isStake = true; return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 6bf1397ad..71c5aefa4 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -717,10 +717,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT,false); + LEAVE_CRITICAL_SECTION(cs_main); + pblocktemplate = CreateNewBlockWithKey(reservekey,pindexPrevNew->GetHeight()+1,KOMODO_MAXGPUCOUNT,false); #else pblocktemplate = CreateNewBlockWithKey(); #endif + ENTER_CRITICAL_SECTION(cs_main); if (!pblocktemplate) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory or no available utxo for staking"); From 17b2d1ed0627b01970eab33aaa38f76bf607c8fd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 15:00:32 +0800 Subject: [PATCH 864/951] Fix staking output in getgenerate --- src/rpc/mining.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 71c5aefa4..09d7bf673 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -180,7 +180,10 @@ UniValue getgenerate(const UniValue& params, bool fHelp) LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("staking", VERUS_MINTBLOCKS)); + bool staking = VERUS_MINTBLOCKS; + if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 ) + staking = true; + obj.push_back(Pair("staking", staking)); obj.push_back(Pair("generate", GetBoolArg("-gen", false))); obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS)); return obj; From 9bf744ef26182d553c924bb8c6e968167735a0db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 15:08:00 +0800 Subject: [PATCH 865/951] fix getgenerate better --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 09d7bf673..c1d45c6e7 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -184,7 +184,7 @@ UniValue getgenerate(const UniValue& params, bool fHelp) if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 ) staking = true; obj.push_back(Pair("staking", staking)); - obj.push_back(Pair("generate", GetBoolArg("-gen", false))); + obj.push_back(Pair("generate", GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) != 0 )); obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS)); return obj; } From 6d17cb5decebe65e1abb93827f71f7b9bf7b5c5e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 16:00:03 +0800 Subject: [PATCH 866/951] oopps --- src/txdb.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index f36989028..b798599b7 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -689,15 +689,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nTx = diskindex.nTx; pindexNew->nSproutValue = diskindex.nSproutValue; pindexNew->nSaplingValue = diskindex.nSaplingValue; -<<<<<<< HEAD - pindexNew->segid = diskindex.segid; - pindexNew->newcoins = diskindex.newcoins; - pindexNew->zfunds = diskindex.zfunds; - pindexNew->sproutfunds = diskindex.sproutfunds; - -======= //fprintf(stderr,"loadguts ht.%d\n",pindexNew->GetHeight()); ->>>>>>> b778dbef8e85f3f95e36223beb41d4d51eb6072e // Consistency checks auto header = pindexNew->GetBlockHeader(); if (header.GetHash() != pindexNew->GetBlockHash()) From 83387a82d3305aea9f761aef14dd89b3086cf28a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 26 Jan 2019 16:32:56 +0800 Subject: [PATCH 867/951] wtf --- src/cc/Makefile | 2 +- zcutil/build.sh | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cc/Makefile b/src/cc/Makefile index 92fbe0da9..2ba37ccb0 100644 --- a/src/cc/Makefile +++ b/src/cc/Makefile @@ -3,7 +3,7 @@ CC = gcc CC_DARWIN = g++-6 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -std=c++11 -arch x86_64 -I/usr/local/Cellar/gcc\@6/6.4.0_2/include/c++/6.4.0/ -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -c -Wl,-undefined -Wl,dynamic_lookup -dynamiclib -CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c +CFLAGS = -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I../../depends/x86_64-unknown-linux-gnu/include -I.. -I. -fPIC -shared -c CFLAGS_WIN = -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c DEBUGFLAGS = -O0 -D _DEBUG RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program diff --git a/zcutil/build.sh b/zcutil/build.sh index cd96e8890..a70c97f63 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -42,21 +42,16 @@ if [ "x$*" = 'x--help' ] then cat < Date: Sun, 27 Jan 2019 08:54:47 +0800 Subject: [PATCH 868/951] fix verushash staker --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 245a1b2a9..a1af2c7bf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -497,7 +497,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t stakeHeight = chainActive.Height() + 1; - //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); + //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); if ( ASSETCHAINS_SYMBOL[0] != 0 && isStake ) { LEAVE_CRITICAL_SECTION(cs_main); @@ -1239,7 +1239,7 @@ void static BitcoinMiner_noeq() miningTimer.start(); #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif From 7609e7dcd5a70f457c9d87afe3736075718bcf37 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 09:53:23 +0800 Subject: [PATCH 869/951] fix assetchains founders reward --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 02ab67407..08120dc83 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -699,7 +699,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } // we don't want these checks in VRSC, leave it at the Sapling upgrade if ( ASSETCHAINS_SYMBOL[0] == 0 || - (ASSETCHAINS_COMMISSION != 0 && height > 1) || + ((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) || NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) { n = block.vtx[0].vout.size(); @@ -761,7 +761,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim else { checktoshis = 0; - if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) + if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1 ) { if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) { From 1a70313da07dfe825005559b99593fa2ddad768d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 13:59:50 +0800 Subject: [PATCH 870/951] fix cclib fresh clone --- zcutil/build.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zcutil/build.sh b/zcutil/build.sh index a70c97f63..eb7a37157 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -96,6 +96,11 @@ eval "$MAKE" --version as --version ld -v +HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 +./autogen.sh + +CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' + #BUILD CCLIB WD=$PWD @@ -111,8 +116,4 @@ fi cd $WD -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 -./autogen.sh - -CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' "$MAKE" "$@" V=1 From 6756fa3ad732d16be71499efff9c801c3e1dce70 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 27 Jan 2019 23:56:48 +0800 Subject: [PATCH 871/951] disable orphan purge --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 4a0a135a6..af4ea499c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -708,7 +708,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr 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); - if (RemoveOrphanedBlocks(*notarizedheightp)) + if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) { //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); } From 4f212c841d09d258794c4d548288dacbedc302af Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 28 Jan 2019 16:13:25 +0800 Subject: [PATCH 872/951] Fix floating point exception. Problem was POW target trying to calculate when not all blocks avalible. These changes leave us even more open to PoS attack, we need to get temp block file working as soon as we can. --- src/komodo_bitcoind.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2fe42041c..aaf560192 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1319,7 +1319,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he sum += UintToArith256(pindex->GetBlockHash()); m++; } - } + } //else fprintf(stderr, "pindex returned null ht.%i\n",ht); if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } @@ -1521,8 +1521,9 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ return(0); else return(1); } - // Get PoSperc and POW Target. for later. - POWTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + // Get PoSperc and POW Target. slowflag only here, calling it when blocks out of order causes problems. + if ( slowflag != 0 ) + POWTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); txn_count = pblock->vtx.size(); //fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,(int32_t)pblock->vtx[txn_count-1].vin.size(),(int32_t)pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN); if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) ) @@ -1533,7 +1534,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ txid = pblock->vtx[txn_count-1].vin[0].prevout.hash; vout = pblock->vtx[txn_count-1].vin[0].prevout.n; - if ( prevtime != 0 ) + if ( slowflag != 0 && prevtime != 0 ) { if ( komodo_isPoS(pblock,height) != 0 ) { @@ -1543,7 +1544,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { if ( 0 && ASSETCHAINS_STAKED < 100 ) 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)); - if ( slowflag != 0 && pindex != 0 ) + if ( pindex != 0 ) { pindex->segid = -1; //fprintf(stderr,"PoW block detected set segid.%d <- %d\n",height,pindex->segid); @@ -1552,23 +1553,20 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ else { isPoS = 2; // 2 means staking utxo validated - if ( slowflag != 0 ) + CTxDestination voutaddress; char voutaddr[64]; + if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) { - CTxDestination voutaddress; char voutaddr[64]; - if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) - { - strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); - segid = komodo_segid32(voutaddr) & 0x3f; - } - if ( pindex != 0 && segid >= 0 ) - { - pindex->segid = segid; - //fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); - } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); + strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str()); + segid = komodo_segid32(voutaddr) & 0x3f; } + if ( pindex != 0 && segid >= 0 ) + { + pindex->segid = segid; + //fprintf(stderr,"PoS block set segid.%d <- %d\n",height,pindex->segid); + } //else fprintf(stderr,"unexpected null pindex for slowflag set ht.%d segid.%d:%d\n",height,pindex!=0?pindex->segid:-3,segid); } - } - if ( slowflag == 0 && isPoS == 0 ) // maybe previous block is not seen yet, do the best approx + } + else if ( slowflag == 0 ) // previous blocks are not seen yet, do the best approx { if ( komodo_isPoS(pblock,height) != 0 ) isPoS = 1; @@ -1893,8 +1891,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); else { - if ( slowflag != 0 ) - bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); + bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash > bnTarget ) { for (i=31; i>=16; i--) From c14e0909c6459449464853a018943ef0f42bdd0e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 07:06:00 +0800 Subject: [PATCH 873/951] Fix using temp file for receiving blocks. --- src/main.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++--------- src/main.h | 4 +++- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cfa30f44a..86d4504a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3291,7 +3291,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("AcceptBlock(): ReceivedBlockTransactions failed"); setDirtyFileInfo.insert(blockPos.nFile); - fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); + //fprintf(stderr,"added ht.%d copy of tmpfile to %d.%d\n",pindex->GetHeight(),blockPos.nFile,blockPos.nPos); } // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); @@ -3754,7 +3754,8 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) { std::vector > vFiles; vFiles.reserve(setDirtyFileInfo.size()); for (set::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end(); ) { - vFiles.push_back(make_pair(*it, &vinfoBlockFile[*it])); + if ( *it < TMPFILE_START ) + vFiles.push_back(make_pair(*it, &vinfoBlockFile[*it])); setDirtyFileInfo.erase(it++); } std::vector vBlocks; @@ -4601,11 +4602,15 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u LOCK(cs_LastBlockFile); unsigned int nFile; + if ( tmpflag != 0 ) { ptr = &tmpBlockFiles; nFile = nLastTmpFile; lastfilep = &nLastTmpFile; + if (tmpBlockFiles.size() <= nFile) { + tmpBlockFiles.resize(nFile + 1); + } } else { @@ -4617,7 +4622,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u } } if (!fKnown) { - while ((*ptr)[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { + while ( (*ptr)[nFile].nSize + nAddSize >= ((tmpflag != 0) ? MAX_TEMPFILE_SIZE : MAX_BLOCKFILE_SIZE) ) { nFile++; if ((*ptr).size() <= nFile) { (*ptr).resize(nFile + 1); @@ -4628,13 +4633,39 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u if ( 0 && tmpflag != 0 ) fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - + if (nFile != *lastfilep) { if (!fKnown) { LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); + fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); + if ( tmpflag != 0 && tmpBlockFiles.size() >= 4 ) + { + if ( nFile == 1 ) + { + PruneOneBlockFile(true,TMPFILE_START+2); + tmpBlockFiles[2].SetNull(); + LogPrintf("Reset tempfile 2\n"); sleep(15); + } + else if ( nFile == 2 ) + { + PruneOneBlockFile(true,TMPFILE_START+3); + tmpBlockFiles[3].SetNull(); + LogPrintf("Reset tempfile 3\n"); sleep(15); + } + } + if ( tmpflag != 0 && nFile == 3 ) + { + PruneOneBlockFile(true,TMPFILE_START); + tmpBlockFiles[0].SetNull(); + PruneOneBlockFile(true,TMPFILE_START+1); + tmpBlockFiles[1].SetNull(); + nFile = 0; + LogPrintf("Reset tempfile 0\n"); sleep(15); + } *lastfilep = nFile; + fprintf(stderr, "*lastfilep = %i\n",*lastfilep);sleep(15); } (*ptr)[nFile].AddBlock(nHeight, nTime); @@ -5232,7 +5263,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } int nHeight = pindex->GetHeight(); - int32_t usetmp = 0; + int32_t usetmp = 1; + // Write block to history file try { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); @@ -5463,8 +5495,9 @@ uint64_t CalculateCurrentUsage() } /* Prune a block file (modify associated database entries)*/ -void PruneOneBlockFile(const int fileNumber) +void PruneOneBlockFile(bool tempfile, const int fileNumber) { + fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { CBlockIndex* pindex = it->second; if (pindex && pindex->nFile == fileNumber) { @@ -5474,7 +5507,11 @@ void PruneOneBlockFile(const int fileNumber) pindex->nDataPos = 0; pindex->nUndoPos = 0; setDirtyBlockIndex.insert(pindex); - + if (pindex->nStatus & BLOCK_IN_TMPFILE != 0 ) + { + // We should be able to clear these blocks from the index as they are not in the main chains block files. + fprintf(stderr, "Block still in tempfile.%i\n",fileNumber); + } // Prune from mapBlocksUnlinked -- any block we prune would have // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for @@ -5489,8 +5526,8 @@ void PruneOneBlockFile(const int fileNumber) } } } - - vinfoBlockFile[fileNumber].SetNull(); + if (!tempfile) + vinfoBlockFile[fileNumber].SetNull(); setDirtyFileInfo.insert(fileNumber); } @@ -5538,7 +5575,7 @@ void FindFilesToPrune(std::set& setFilesToPrune) if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) continue; - PruneOneBlockFile(fileNumber); + PruneOneBlockFile(false, fileNumber); // Queue up the files for removal setFilesToPrune.insert(fileNumber); nCurrentUsage -= nBytesToPrune; diff --git a/src/main.h b/src/main.h index d19e3aa17..35de3f4de 100644 --- a/src/main.h +++ b/src/main.h @@ -90,7 +90,8 @@ static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100; /** Default for -txexpirydelta, in number of blocks */ static const unsigned int DEFAULT_TX_EXPIRY_DELTA = 20; /** The maximum size of a blk?????.dat file (since 0.8) */ -static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB +static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB +static const unsigned int MAX_TEMPFILE_SIZE = 0x1000000; // 16 MiB 0x8000000 /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ @@ -807,6 +808,7 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,bool checkPOW); bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW); bool RemoveOrphanedBlocks(int32_t notarized_height); +void PruneOneBlockFile(bool tempfile, const int fileNumber); /** Functions for validating blocks and updating the block tree */ From 6b786278c9bbe5fd897ac1ab20d825cca0acc68b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 07:12:20 +0800 Subject: [PATCH 874/951] fix --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 86d4504a0..94b9adf73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4639,20 +4639,20 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); - fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); + //fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); if ( tmpflag != 0 && tmpBlockFiles.size() >= 4 ) { if ( nFile == 1 ) { PruneOneBlockFile(true,TMPFILE_START+2); tmpBlockFiles[2].SetNull(); - LogPrintf("Reset tempfile 2\n"); sleep(15); + LogPrintf("Reset tempfile 2\n"); } else if ( nFile == 2 ) { PruneOneBlockFile(true,TMPFILE_START+3); tmpBlockFiles[3].SetNull(); - LogPrintf("Reset tempfile 3\n"); sleep(15); + LogPrintf("Reset tempfile 3\n"); } } if ( tmpflag != 0 && nFile == 3 ) @@ -4662,10 +4662,10 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u PruneOneBlockFile(true,TMPFILE_START+1); tmpBlockFiles[1].SetNull(); nFile = 0; - LogPrintf("Reset tempfile 0\n"); sleep(15); + LogPrintf("Reset tempfile 0 and 1\n"); } *lastfilep = nFile; - fprintf(stderr, "*lastfilep = %i\n",*lastfilep);sleep(15); + //fprintf(stderr, "*lastfilep = %i\n",*lastfilep); } (*ptr)[nFile].AddBlock(nHeight, nTime); From acf850831ef7e7faee40be71f0df55b2bd25df1b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 07:12:46 +0800 Subject: [PATCH 875/951] k --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 94b9adf73..24044b42f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5497,7 +5497,7 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ void PruneOneBlockFile(bool tempfile, const int fileNumber) { - fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); + //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { CBlockIndex* pindex = it->second; if (pindex && pindex->nFile == fileNumber) { From 041c74c0a6feaf6c9fc78d31bf0e4587c81bfa05 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 29 Jan 2019 10:52:56 +0800 Subject: [PATCH 876/951] Add print and possible rejection of blocks based on valid/invalid notarisation! --- src/komodo.h | 28 ++++++++++++++++++++-------- src/main.cpp | 6 +++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index af4ea499c..2fd89df3c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); -void komodo_connectblock(CBlockIndex *pindex,CBlock& block); +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_structs.h" #include "komodo_globals.h" @@ -695,6 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); + else + { + fprintf(stderr, "NOT VALID NOTARISATION\n"); + return (-2); + } if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -708,10 +713,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr 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); - if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) - { - //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); - } + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -798,7 +800,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys return(-1); } -void komodo_connectblock(CBlockIndex *pindex,CBlock& block) +// int32_t ! +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; int32_t staked_era; static int32_t lastStakedEra; @@ -809,7 +812,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( pindex == 0 ) { fprintf(stderr,"komodo_connectblock null pindex\n"); - return; + return -1; } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); @@ -817,7 +820,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); - return; + return -1; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) @@ -858,6 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); + int transaction = 0; if ( pindex != 0 ) { height = pindex->GetHeight(); @@ -913,6 +917,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } + transaction = i; printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; @@ -938,10 +943,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("%.8f ",dstr(block.vtx[i].vout[j].nValue)); len = block.vtx[i].vout[j].scriptPubKey.size(); + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + if ( notaryid == -2 ) + return(-1); if ( 0 && i > 0 ) { for (k=0; kGetHeight()); + if (notarized = 1) + return(transaction); + else + return(-1); } diff --git a/src/main.cpp b/src/main.cpp index 24044b42f..e4690292e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3684,7 +3684,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); - komodo_connectblock(pindex,*(CBlock *)&block); + int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; + if ( tmp > 0 ) + { + printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),tmp); + } return true; } From 2cf210288737e6c5f047379c9502e4a4f3863d34 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 00:33:08 +0800 Subject: [PATCH 877/951] -ac_notarypay --- src/komodo.h | 28 +++++++--- src/komodo_bitcoind.h | 114 ++++++++++++++++++++++++++++++++++++++++ src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/komodo_utils.h | 7 ++- src/main.cpp | 17 +++++- src/miner.cpp | 71 ++++++++++++++++++++----- src/notaries_staked.cpp | 4 +- 8 files changed, 218 insertions(+), 27 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index af4ea499c..9978e8588 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); -void komodo_connectblock(CBlockIndex *pindex,CBlock& block); +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_structs.h" #include "komodo_globals.h" @@ -695,6 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); + else + { + fprintf(stderr, "NOT matched NOTARISATION\n"); + return (-2); + } if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -708,10 +713,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr 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); - if ( 0 && RemoveOrphanedBlocks(*notarizedheightp)) - { - //fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp); - } + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( signedfp == 0 ) @@ -798,7 +800,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys return(-1); } -void komodo_connectblock(CBlockIndex *pindex,CBlock& block) +// int32_t ! +int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; int32_t staked_era; static int32_t lastStakedEra; @@ -809,7 +812,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( pindex == 0 ) { fprintf(stderr,"komodo_connectblock null pindex\n"); - return; + return -1; } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); @@ -817,7 +820,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); - return; + return -1; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) @@ -858,6 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); + int transaction = 0; if ( pindex != 0 ) { height = pindex->GetHeight(); @@ -913,6 +917,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } + transaction = i; printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; @@ -938,10 +943,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("%.8f ",dstr(block.vtx[i].vout[j].nValue)); len = block.vtx[i].vout[j].scriptPubKey.size(); + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + if ( notaryid == -2 ) + return(-1); if ( 0 && i > 0 ) { for (k=0; kGetHeight()); + if (notarized = 1) + return(transaction); + else + return(-1); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aaf560192..3187099c7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1772,6 +1772,96 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp) +{ + // fetch notary pubkey array. + uint64_t total = 0; + int32_t staked_era; int8_t numSN; + uint8_t staked_pubkeys[64][33]; + staked_era = STAKED_era(timestamp); + numSN = numStakedNotaries(staked_pubkeys,staked_era); + // resize coinbase vouts to number of notary nodes +1 for coinbase itself. + txNew.vout.resize(NotarisationNotaries.size()+1); + // loop over notarisation vins and add transaction to coinbase. + for (int8_t n = 0; n < NotarisationNotaries.size(); n++) + { + uint8_t *ptr; + txNew.vout[n+1].scriptPubKey.resize(35); + ptr = (uint8_t *)&txNew.vout[n+1].scriptPubKey[0]; + ptr[0] = 33; + for (int8_t i=0; i<33; i++) + { + ptr[i+1] = staked_pubkeys[NotarisationNotaries[n]][i]; + //fprintf(stderr,"%02x",ptr[i+1]); + } + ptr[34] = OP_CHECKSIG; + //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); + txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; // ASSETCHAINS_NOTARY_PAY + total += txNew.vout[n+1].nValue; + } + return(total); +} + +uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) +{ + std::vector NotarisationNotaries; + uint32_t timestamp = pblock->nTime; + int32_t staked_era; int8_t numSN; + uint8_t staked_pubkeys[64][33]; + staked_era = STAKED_era(timestamp); + numSN = numStakedNotaries(staked_pubkeys,staked_era); + + uint8_t *script; int32_t scriptlen; + // loop over notaries array and extract index of signers. + + BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) + { + uint256 hash; CTransaction tx1; + if ( GetTransaction(txin.prevout.hash,tx1,hash,false) ) + { + for (int8_t i = 0; i < numSN; i++) + { + //tx1.vout[txin.prevout.n].scriptPubKey + script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; + scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + NotarisationNotaries.push_back(i); + } + } + } + const CChainParams& chainparams = Params(); + const Consensus::Params &consensusParams = chainparams.GetConsensus(); + CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, height); + uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); + int8_t n = 0, i = 0, matches = 0; + uint64_t total = 0; + //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); + BOOST_FOREACH(const CTxOut& txout, txNew.vout) + { + if ( n == 0 ) + { + n++; + continue; + } + script = (uint8_t *)&txout.scriptPubKey[0]; + scriptlen = (int32_t)txout.scriptPubKey.size(); + // ASSETCHAINS_NOTARY_PAY = nValue! + if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) + { + matches++; + total += txout.nValue; + fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + } + n++; + } + if ( matches = n && matches != 0 && total == totalsats ) + { + fprintf(stderr, "VALIDATED.\n" ); + return(totalsats); + } + return(-1); +} + int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; @@ -1952,6 +2042,30 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } + if( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() != 1 ) + { + if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) + { + fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); + return(0); + } + else + { + // Check the notarisation tx is to the crypto address and meets min sigs. + if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) + { + fprintf(stderr, "notarisation is not to crypto address.%i\n",height); + return(0); + } + // Check min sigs. + if ( pblock->vtx[1].vin.size() < num_notaries_STAKED[STAKED_era(pblock->nTime)] ) + { + fprintf(stderr, "block does not meet minsigs .%i\n",height); + return(0); + } + } + } + //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); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index e60e9d3d5..32fb74dab 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -40,7 +40,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD; +extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD, ASSETCHAINS_NOTARY_PAY; extern uint64_t ASSETCHAINS_TIMELOCKGTE; extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a227b642c..13caee41d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -97,7 +97,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t ASSETCHAINS_STAKED; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_NOTARY_PAY; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 51c84a326..4dbf49637 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1895,6 +1895,9 @@ void komodo_args(char *argv0) } else { + ASSETCHAINS_NOTARY_PAY = GetArg("-ac_notarypay",0); + if ( ASSETCHAINS_NOTARY_PAY != 0 ) + printf("Assetchains NOTARY PAY set to %lu sats per notarisation per notary. Cannot work with ac_script or ac_pubkey!\n",ASSETCHAINS_NOTARY_PAY); if ( ASSETCHAINS_COMMISSION != 0 ) { ASSETCHAINS_COMMISSION = 0; @@ -1911,7 +1914,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -2006,6 +2009,8 @@ void komodo_args(char *argv0) } fprintf(stderr," <- CCLIB name\n"); } + if ( ASSETCHAINS_NOTARY_PAY != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY),(void *)&ASSETCHAINS_NOTARY_PAY); } addn = GetArg("-seednode",""); diff --git a/src/main.cpp b/src/main.cpp index 24044b42f..69790a72e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3572,6 +3572,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } + if ( ASSETCHAINS_NOTARY_PAY != 0 && block.vtx[0].vout.size() > 1 ) + { + uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); + if ( notarypaycheque > 0 ) + blockReward += notarypaycheque; + else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 4 && IS_STAKED_NOTARY > 0 ) + blockReward += 999999999999999; // Notaries can validate any block for now. + else + return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds coinbase (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), + REJECT_INVALID, "bad-cb-amount"); + } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) { return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), @@ -3684,7 +3695,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); - komodo_connectblock(pindex,*(CBlock *)&block); + int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; + if ( tmp > 0 ) + { + printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!",pindex->GetHeight(),tmp); + } return true; } diff --git a/src/miner.cpp b/src/miner.cpp index a1af2c7bf..4ad70912c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -55,6 +55,8 @@ #include "sodium.h" +#include "notaries_staked.h" + #include #include #ifdef ENABLE_MINING @@ -151,6 +153,7 @@ int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -170,6 +173,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } else pk = _pk; uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); + bool fNotarisationBlock = false; std::vector NotarisationNotaries; + //fprintf(stderr,"create new block\n"); // Create new block if ( gpucount < 0 ) @@ -239,6 +244,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } pblock->nTime = GetAdjustedTime(); + // Now we have the block time, we can get the active notaries. + int32_t staked_era; int8_t numSN; + uint8_t staked_pubkeys[64][33]; + staked_era = STAKED_era(pblock->nTime); + numSN = numStakedNotaries(staked_pubkeys,staked_era); CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; @@ -249,13 +259,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", false); + bool fPrintPriority = GetBoolArg("-printpriority", true); // This vector will be sorted into a priority queue: vector vecPriority; vecPriority.reserve(mempool.mapTx.size() + 1); // now add transactions from the mem pool + int32_t Notarisations = 0; for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { @@ -329,22 +340,33 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nTotalIn += nValueIn; int nConf = nHeight - coins->nHeight; - - // This is to test is a tx is a notarisation and assign it max priotity. - if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + + uint8_t *script; int32_t scriptlen; uint256 hash; CTransaction tx1; + // loop over notaries array and extract index of signers. + if ( fToCryptoAddress && staked_pubkeys[0][0] != 0 && GetTransaction(txin.prevout.hash,tx1,hash,false) ) { - uint256 hash; CTransaction tx1; CTxDestination address; - if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) ) + for (int8_t i = 0; i < numSN; i++) { - for (int i = 0; i < NUM_NOTARIES; i++) - if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) - numNotaryVins++; + script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; + scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + { + numNotaryVins++; + if ( Notarisations == 0 ) + { + // Until we get a valid notarization this will always be 0. + // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. + NotarisationNotaries.push_back(i); + } + } } } dPriority += (double)nValueIn * nConf; } - if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) + if ( numSN != 0 && numNotaryVins >= numSN / 5 ) fNotarisation = true; + else + NotarisationNotaries.clear(); nTotalIn += tx.GetShieldedValueIn(); } @@ -360,16 +382,27 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if (fNotarisation) { + if (fNotarisation) + { dPriority = 1e16; - //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); + Notarisations++; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation[%i] %s set to maximum priority\n",Notarisations,hash.ToString().c_str()); + } + else if ( dPriority == 1e16 ) + { + dPriority -= 10; + // make sure notarisation is tx[1] in block. + // Need to check this? Tried sapling tx and it was not set to max priotity, maybe missing something. } if (porphan) { porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else + else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0) + continue; // If we have added a notarisation already skip the next one. There can only be one per block. + else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } @@ -637,7 +670,17 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[0].scriptPubKey = CScriptExt().PayToScriptHash(CScriptID(opretScript)); txNew.vout[1].scriptPubKey = CScriptExt().OpReturnScript(opretScript, OPRETTYPE_TIMELOCK); txNew.vout[1].nValue = 0; - } // timelocks and commissions are currently incompatible due to validation complexity of the combination + // timelocks and commissions are currently incompatible due to validation complexity of the combination + } + else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 ) + { + // This block contains a valid notarisation as best as we can know. We cant check this 100% until we try to connect block. + // This assumes notaries are not going to collude to create invalid notarisations. + // If they did this, then the block would be invalid, and all kinds of werid things will happen. + // We can test this, and see what happens, if its unreliable, we will need to create a CC contract. + uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); + fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + } pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 9dcba0653..23bc0f8fd 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -21,7 +21,9 @@ int8_t is_STAKED(const char *chain_name) { else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; + STAKED = 3; + else if ( (strcmp(chain_name, "NOTARYTEST") == 0) ) + STAKED = 4; else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid. doneinit = 1; From abb78c279fc40dfb45266a8607be4082503923d7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 00:39:16 +0800 Subject: [PATCH 878/951] fix min sigs --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3187099c7..e7677b25d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2047,7 +2047,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) { fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); - return(0); + return(0); // skip validation } else { @@ -2055,13 +2055,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) { fprintf(stderr, "notarisation is not to crypto address.%i\n",height); - return(0); + return(0); // skip validatiuon } // Check min sigs. - if ( pblock->vtx[1].vin.size() < num_notaries_STAKED[STAKED_era(pblock->nTime)] ) + if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) { fprintf(stderr, "block does not meet minsigs .%i\n",height); - return(0); + return(0); // skip validation } } } From 84500049345ffe92dbd6affc60e49ce8202b6d21 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 12:14:51 +0800 Subject: [PATCH 879/951] limit some prints to -ac_notarypay --- src/komodo.h | 2 +- src/main.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 9978e8588..f8575ade8 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 } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else + else if ( ASSETCHAINS_NOTARY_PAY != 0 ) { fprintf(stderr, "NOT matched NOTARISATION\n"); return (-2); diff --git a/src/main.cpp b/src/main.cpp index 69790a72e..098b8c388 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3696,9 +3696,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //FlushStateToDisk(); int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; - if ( tmp > 0 ) + if ( ASSETCHAINS_NOTARY_PAY != 0 && tmp > 0 ) { - printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!",pindex->GetHeight(),tmp); + printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!\n",pindex->GetHeight(),tmp); + if ( tmp != 1 ) + printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"; } return true; } From 87a1f9f0003c0b30c0315397e93b2e4c656d751e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 12:27:56 +0800 Subject: [PATCH 880/951] fix ) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 098b8c388..2d5134b4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3700,7 +3700,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!\n",pindex->GetHeight(),tmp); if ( tmp != 1 ) - printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"; + printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"); } return true; } From 8592d0f436527b1fbe6992f8108ca3fafd7c7747 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 14:17:11 +0800 Subject: [PATCH 881/951] fix print --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 2fd89df3c..0816706bc 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 } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else + else if ( ASSETCHAINS_NOTARY_PAY != 0 ) { fprintf(stderr, "NOT VALID NOTARISATION\n"); return (-2); From f9284ad20a53cee2c01f27fa3a88afc3c5772f46 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 14:18:20 +0800 Subject: [PATCH 882/951] oops --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0816706bc..0d4be5d7e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,11 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else if ( ASSETCHAINS_NOTARY_PAY != 0 ) + /*else { fprintf(stderr, "NOT VALID NOTARISATION\n"); return (-2); - } + } */ if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; From 14b64d13fea3e40a6e245d12a1bf3e61e25f72fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 30 Jan 2019 16:55:04 +0800 Subject: [PATCH 883/951] assetchains_algo in getinfo --- src/rpc/misc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 5e919b9bb..180403e00 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -79,7 +79,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; -extern uint32_t ASSETCHAINS_MAGIC; +extern uint32_t ASSETCHAINS_MAGIC,ASSETCHAINS_ALGO; extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; @@ -319,6 +319,8 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("staked", ASSETCHAINS_STAKED)); if ( ASSETCHAINS_LWMAPOS != 0 ) obj.push_back(Pair("veruspos", ASSETCHAINS_LWMAPOS)); + if ( ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH ) + obj.push_back(Pair("algo",ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO])); } return obj; } From cce73b01a767aed3d4cb31757e6c1d0863433940 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 1 Feb 2019 04:01:16 +0800 Subject: [PATCH 884/951] new tempfile rotation. --- src/komodo_utils.h | 1 - src/main.cpp | 150 ++++++++++++++++++++++++++++++++------------- src/main.h | 2 +- 3 files changed, 109 insertions(+), 44 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4dbf49637..fd312e527 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1749,7 +1749,6 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; - printf("ASSETCHAINS_LASTERA = %lu\n", ASSETCHAINS_LASTERA); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); diff --git a/src/main.cpp b/src/main.cpp index 2d5134b4b..074ad81ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -187,6 +187,8 @@ namespace { std::vector vinfoBlockFile,tmpBlockFiles; int nLastBlockFile = 0; int nLastTmpFile = 0; + unsigned int maxTempFileSize0 = MAX_TEMPFILE_SIZE; + unsigned int maxTempFileSize1 = MAX_TEMPFILE_SIZE; /** Global flag to indicate we should check to see if there are * block/undo files that should be deleted. Set on startup * or if we allocate more file space when we're in prune mode @@ -3639,7 +3641,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin setDirtyBlockIndex.insert(pindex); } - ConnectNotarisations(block, pindex->GetHeight()); + ConnectNotarisations(block, pindex->GetHeight()); // MoMoM notarisation DB. + + int notarisationTx = komodo_connectblock(pindex,*(CBlock *)&block); // dPoW state update. + if ( ASSETCHAINS_NOTARY_PAY != 0 && notarisationTx > 0 ) + { + printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),notarisationTx); + if ( notarisationTx != 1 ) + printf("INVALID: notarisation tx is not in vtx[1].\n"); + } if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) @@ -3695,13 +3705,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); - int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000; - if ( ASSETCHAINS_NOTARY_PAY != 0 && tmp > 0 ) - { - printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!\n",pindex->GetHeight(),tmp); - if ( tmp != 1 ) - printf("INVALID NOTARISATION notarisation tx is not in vtx[1].\n"); - } return true; } @@ -4618,7 +4621,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u std::vector *ptr; int *lastfilep; LOCK(cs_LastBlockFile); - unsigned int nFile; + unsigned int nFile,maxTempFileSize; if ( tmpflag != 0 ) { @@ -4628,6 +4631,10 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u if (tmpBlockFiles.size() <= nFile) { tmpBlockFiles.resize(nFile + 1); } + if ( nFile == 0 ) + maxTempFileSize = maxTempFileSize0; + else if ( nFile == 1 ) + maxTempFileSize = maxTempFileSize1; } else { @@ -4638,49 +4645,86 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u vinfoBlockFile.resize(nFile + 1); } } + if (!fKnown) { - while ( (*ptr)[nFile].nSize + nAddSize >= ((tmpflag != 0) ? MAX_TEMPFILE_SIZE : MAX_BLOCKFILE_SIZE) ) { + bool tmpfileflag = false; + while ( (*ptr)[nFile].nSize + nAddSize >= ((tmpflag != 0) ? maxTempFileSize : MAX_BLOCKFILE_SIZE) ) { + if ( tmpflag != 0 && tmpfileflag ) + break; nFile++; if ((*ptr).size() <= nFile) { (*ptr).resize(nFile + 1); } + tmpfileflag = true; } pos.nFile = nFile + tmpflag*TMPFILE_START; pos.nPos = (*ptr)[nFile].nSize; - if ( 0 && tmpflag != 0 ) - fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - if (nFile != *lastfilep) { if (!fKnown) { LogPrintf("Leaving block file %i: %s\n", nFile, (*ptr)[nFile].ToString()); } FlushBlockFile(!fKnown); - //fprintf(stderr, "nFile = %i size.%li\n",nFile,tmpBlockFiles.size()); - if ( tmpflag != 0 && tmpBlockFiles.size() >= 4 ) + //fprintf(stderr, "nFile = %i size.%li maxTempFileSize0.%u maxTempFileSize1.%u\n",nFile,tmpBlockFiles.size(),maxTempFileSize0,maxTempFileSize1); + if ( tmpflag != 0 && tmpBlockFiles.size() >= 3 ) { - if ( nFile == 1 ) + if ( nFile == 1 ) // Trying to get to second temp file. { - PruneOneBlockFile(true,TMPFILE_START+2); - tmpBlockFiles[2].SetNull(); - LogPrintf("Reset tempfile 2\n"); + if (!PruneOneBlockFile(true,TMPFILE_START+1)) + { + // file 1 is not ready to be used yet increase file 0's size. + fprintf(stderr, "Cant clear file 1!\n"); + // We will reset the position to the end of the first file, even if its over max size. + nFile = 0; + pos.nFile = TMPFILE_START; + pos.nPos = (*ptr)[0].nSize; + // Increase temp file one's max size by a chunk, so we wait a reasonable time to recheck the other file. + maxTempFileSize0 += BLOCKFILE_CHUNK_SIZE; + } + else + { + // The file 1 is able to be used now. Reset max size, and set nfile to use file 1. + fprintf(stderr, "CLEARED file 1!\n"); + maxTempFileSize0 = MAX_TEMPFILE_SIZE; + nFile = 1; + tmpBlockFiles[1].SetNull(); + pos.nFile = TMPFILE_START+1; + pos.nPos = (*ptr)[1].nSize; + boost::filesystem::remove(GetBlockPosFilename(pos, "blk")); + LogPrintf("Prune: deleted temp blk (%05u)\n",nFile); + } + if ( 0 && tmpflag != 0 ) + fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } - else if ( nFile == 2 ) + else if ( nFile == 2 ) // Trying to get to third temp file. { - PruneOneBlockFile(true,TMPFILE_START+3); - tmpBlockFiles[3].SetNull(); - LogPrintf("Reset tempfile 3\n"); + if (!PruneOneBlockFile(true,TMPFILE_START)) + { + fprintf(stderr, "Cant clear file 0!\n"); + // We will reset the position to the end of the second block file, even if its over max size. + nFile = 1; + pos.nFile = TMPFILE_START+1; + pos.nPos = (*ptr)[1].nSize; + // Increase temp file one's max size by a chunk, so we wait a reasonable time to recheck the other file. + maxTempFileSize1 += BLOCKFILE_CHUNK_SIZE; + } + else + { + // The file 0 is able to be used now. Reset max size, and set nfile to use file 0. + fprintf(stderr, "CLEARED file 0!\n"); + maxTempFileSize1 = MAX_TEMPFILE_SIZE; + nFile = 0; + tmpBlockFiles[0].SetNull(); + pos.nFile = TMPFILE_START; + pos.nPos = (*ptr)[0].nSize; + boost::filesystem::remove(GetBlockPosFilename(pos, "blk")); + LogPrintf("Prune: deleted temp blk (%05u)\n",nFile); + } + if ( 0 && tmpflag != 0 ) + fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } } - if ( tmpflag != 0 && nFile == 3 ) - { - PruneOneBlockFile(true,TMPFILE_START); - tmpBlockFiles[0].SetNull(); - PruneOneBlockFile(true,TMPFILE_START+1); - tmpBlockFiles[1].SetNull(); - nFile = 0; - LogPrintf("Reset tempfile 0 and 1\n"); - } + //fprintf(stderr, "nFile = %i size.%li maxTempFileSize0.%u maxTempFileSize1.%u\n",nFile,tmpBlockFiles.size(),maxTempFileSize0,maxTempFileSize1); sleep(30); *lastfilep = nFile; //fprintf(stderr, "*lastfilep = %i\n",*lastfilep); } @@ -5512,32 +5556,53 @@ uint64_t CalculateCurrentUsage() } /* Prune a block file (modify associated database entries)*/ -void PruneOneBlockFile(bool tempfile, const int fileNumber) +bool PruneOneBlockFile(bool tempfile, const int fileNumber) { + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); - for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { + for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) + { CBlockIndex* pindex = it->second; - if (pindex && pindex->nFile == fileNumber) { + if (pindex && pindex->nFile == fileNumber) + { + if ( tempfile && (pindex->nStatus & BLOCK_IN_TMPFILE != 0) ) + { + if ( chainActive.Contains(pindex) ) + { + // Block is in main chain so we cant clear this file! + return(false); + } + if ( pindex->GetHeight() > notarized_height ) // Need to check this, does an invalid block have a height? + { + // This blocks height is not older than last notarization so it can be reorged into the main chain. + // We cant clear this file! + return(false); + } + else + { + // Block is not in main chain and is older than last notarised block so its safe for removal. + fprintf(stderr, "Block [%i] in tempfile.%i We can clear this block!\n",pindex->GetHeight(),fileNumber); + // Add index to list and remove after loop? + } + } pindex->nStatus &= ~BLOCK_HAVE_DATA; pindex->nStatus &= ~BLOCK_HAVE_UNDO; pindex->nFile = 0; pindex->nDataPos = 0; pindex->nUndoPos = 0; setDirtyBlockIndex.insert(pindex); - if (pindex->nStatus & BLOCK_IN_TMPFILE != 0 ) - { - // We should be able to clear these blocks from the index as they are not in the main chains block files. - fprintf(stderr, "Block still in tempfile.%i\n",fileNumber); - } // Prune from mapBlocksUnlinked -- any block we prune would have // to be downloaded again in order to consider its chain, at which // point it would be considered as a candidate for // mapBlocksUnlinked or setBlockIndexCandidates. std::pair::iterator, std::multimap::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev); - while (range.first != range.second) { + while (range.first != range.second) + { std::multimap::iterator it = range.first; range.first++; - if (it->second == pindex) { + if (it->second == pindex) + { mapBlocksUnlinked.erase(it); } } @@ -5546,6 +5611,7 @@ void PruneOneBlockFile(bool tempfile, const int fileNumber) if (!tempfile) vinfoBlockFile[fileNumber].SetNull(); setDirtyFileInfo.insert(fileNumber); + return(true); } diff --git a/src/main.h b/src/main.h index 35de3f4de..f12bcb8cd 100644 --- a/src/main.h +++ b/src/main.h @@ -808,7 +808,7 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,bool checkPOW); bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW); bool RemoveOrphanedBlocks(int32_t notarized_height); -void PruneOneBlockFile(bool tempfile, const int fileNumber); +bool PruneOneBlockFile(bool tempfile, const int fileNumber); /** Functions for validating blocks and updating the block tree */ From 1f62670ea2224c942d86a28a972e6b7f96ec2522 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 1 Feb 2019 16:47:43 +0800 Subject: [PATCH 885/951] See comment for test plan. Adds Validation --- src/komodo_bitcoind.h | 21 +++++++++++---------- src/main.cpp | 7 +++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e7677b25d..e679c4084 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1775,6 +1775,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp) { // fetch notary pubkey array. + // Need a better/safer way for notaries era, should really be height based rather than timestamp? uint64_t total = 0; int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; @@ -1783,6 +1784,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); // loop over notarisation vins and add transaction to coinbase. + // Commented prints here can be used to verify manually the pubkeys match. for (int8_t n = 0; n < NotarisationNotaries.size(); n++) { uint8_t *ptr; @@ -1796,7 +1798,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar } ptr[34] = OP_CHECKSIG; //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); - txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; // ASSETCHAINS_NOTARY_PAY + txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; total += txNew.vout[n+1].nValue; } return(total); @@ -1812,8 +1814,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) numSN = numStakedNotaries(staked_pubkeys,staked_era); uint8_t *script; int32_t scriptlen; - // loop over notaries array and extract index of signers. - + // Loop notarisation, and create the coinbase tx, with the same function the miner uses. BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) { uint256 hash; CTransaction tx1; @@ -1836,6 +1837,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) int8_t n = 0, i = 0, matches = 0; uint64_t total = 0; //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); + // Check the created coinbase is equal to the coinbase the miner submitted in the block. BOOST_FOREACH(const CTxOut& txout, txNew.vout) { if ( n == 0 ) @@ -1845,7 +1847,6 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } script = (uint8_t *)&txout.scriptPubKey[0]; scriptlen = (int32_t)txout.scriptPubKey.size(); - // ASSETCHAINS_NOTARY_PAY = nValue! if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) { matches++; @@ -2047,25 +2048,25 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) { fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); - return(0); // skip validation + return(-1); } else { - // Check the notarisation tx is to the crypto address and meets min sigs. + // Check the notarisation tx is to the crypto address. if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) { fprintf(stderr, "notarisation is not to crypto address.%i\n",height); - return(0); // skip validatiuon + return(-1); } // Check min sigs. if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) { - fprintf(stderr, "block does not meet minsigs .%i\n",height); - return(0); // skip validation + fprintf(stderr, "block notarization does not meet minsigs .%i\n",height); + 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); diff --git a/src/main.cpp b/src/main.cpp index 074ad81ac..99fb44147 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3579,10 +3579,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); if ( notarypaycheque > 0 ) blockReward += notarypaycheque; - else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 4 && IS_STAKED_NOTARY > 0 ) - blockReward += 999999999999999; // Notaries can validate any block for now. else - return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds coinbase (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), + return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds the amount allowed! (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) @@ -3648,7 +3646,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),notarisationTx); if ( notarisationTx != 1 ) - printf("INVALID: notarisation tx is not in vtx[1].\n"); + return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + REJECT_INVALID, "bad-notarization-position"); } if (fTxIndex) From f82808e03641d1b6787887a8e1abf2914c1d3ee6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 1 Feb 2019 18:38:55 +0800 Subject: [PATCH 886/951] z_mergetoaddress changes to enable merge of coinbase's, while skipping iguana utxos. --- src/wallet/rpcwallet.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 50aeb2f27..70696d4f5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4777,7 +4777,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d Sprout or %d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT, MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores 10,000 sat p2pk utxo that iguana uses, and merges coinbase utxo.\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4960,7 +4960,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (useAnyUTXO || taddrs.size() > 0) { // Get available utxos vector vecOutputs; - pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, false); + pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, maximum_utxo_size != 0 ? true : false); // Find unspent utxos and update estimated size for (const COutput& out : vecOutputs) { @@ -4981,14 +4981,13 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; - if (maximum_utxo_size != 0) { - if (nValue > maximum_utxo_size) { - continue; - } else { - if (out.tx->vout[out.i].scriptPubKey.size() == 35 && nValue == 10000) { - continue; - } - } + if (maximum_utxo_size != 0) + { + //fprintf(stderr, "utxo txid.%s vout.%i nValue.%li scriptpubkeylength.%i\n",out.tx->GetHash().ToString().c_str(),out.i,nValue,out.tx->vout[out.i].scriptPubKey.size()); + if (nValue > maximum_utxo_size) + continue; + if (nValue == 10000 && out.tx->vout[out.i].scriptPubKey.size() == 35) + continue; } utxoCounter++; @@ -5093,10 +5092,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numUtxos = utxoInputs.size(); size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); + fprintf(stderr, "num utxos.%li\n", numUtxos); if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } - + // Sanity check: Don't do anything if: // - We only have one from address // - It's equal to toaddress From 0ee5e12f0810dd211bb8868fb7f192136b9ed46e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 02:37:04 +0800 Subject: [PATCH 887/951] New method of ac_notarypay --- src/komodo.h | 75 ++++++++++++++----------- src/komodo_bitcoind.h | 128 ++++++++++++++++++++++++++++++++++-------- src/main.cpp | 46 +++++++++------ src/miner.cpp | 18 +++--- 4 files changed, 187 insertions(+), 80 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index f8575ade8..7860863d2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -37,7 +37,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); -int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block); +int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block); #include "komodo_structs.h" #include "komodo_globals.h" @@ -531,7 +531,7 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height) } else return(1); } -int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) +int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) { static uint256 zero; static FILE *signedfp; int32_t opretlen,nid,offset,k,MoMdepth,matched,len = 0; uint256 MoM,srchash,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; @@ -616,7 +616,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( j == 1 && opretlen >= len+offset-opoffset ) { memset(&MoMoMdata,0,sizeof(MoMoMdata)); - if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) + if ( matched == 0 && signedmask != 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) notarized = 1; if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 ) notarized = 1; @@ -685,7 +685,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - if ( matched != 0 ) + if ( !fJustCheck && matched != 0 ) printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) @@ -695,13 +695,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - else if ( ASSETCHAINS_NOTARY_PAY != 0 ) - { - fprintf(stderr, "NOT matched NOTARISATION\n"); - return (-2); - } if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { + if ( fJustCheck ) + return(-2); sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; @@ -744,7 +741,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) { - if ( notaryid >= 0 && notaryid < 64 ) + if ( !fJustCheck && notaryid >= 0 && notaryid < 64 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); } else if ( matched != 0 ) @@ -801,18 +798,18 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys } // int32_t ! -int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) +int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; int32_t staked_era; static int32_t lastStakedEra; - + std::vector notarisations; uint64_t signedmask,voutmask; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; if ( pindex == 0 ) { fprintf(stderr,"komodo_connectblock null pindex\n"); - return -1; + return(0); } memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); @@ -820,13 +817,13 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); - return -1; + return(0); } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); - if ( staked_era != lastStakedEra ) + if ( !fJustCheck && staked_era != lastStakedEra ) { uint8_t tmp_pubkeys[64][33]; int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); @@ -842,8 +839,8 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) fprintf(stderr, "Staked Notary Protection Active! NotaryID.%d RADD.%s ERA.%d MIN_TX_VALUE.%lu \n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),staked_era,MIN_RECV_SATS); } } + lastStakedEra = staked_era; } - lastStakedEra = staked_era; } numnotaries = komodo_notaries(pubkeys,pindex->GetHeight(),pindex->GetBlockTime()); calc_rmd160_sha256(rmd160,pubkeys[0],33); @@ -857,11 +854,13 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_purge_ccdata((int32_t)pindex->GetHeight()); hwmheight = pindex->GetHeight(); } - komodo_event_rewind(sp,symbol,pindex->GetHeight()); - komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); + if (!fJustCheck) + { + komodo_event_rewind(sp,symbol,pindex->GetHeight()); + komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); + } } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); - int transaction = 0; if ( pindex != 0 ) { height = pindex->GetHeight(); @@ -869,9 +868,12 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) for (i=0; i 1) + break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; @@ -900,7 +902,7 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5) ) { - if ( ASSETCHAINS_SYMBOL[0] != 0) + if ( !fJustCheck && ASSETCHAINS_SYMBOL[0] != 0) { static FILE *signedfp; if ( signedfp == 0 ) @@ -917,7 +919,6 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) fwrite(&signedmask,1,sizeof(signedmask),signedfp); fflush(signedfp); } - transaction = i; printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); } notarized = 1; @@ -947,9 +948,13 @@ int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); - notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); - if ( notaryid == -2 ) - return(-1); + notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); + if ( fJustCheck && notaryid == -2 ) + { + // We see a valid notarisation here, save its location. + notarisations.push_back(i); + } + //fprintf(stderr, "notaryid.%i\n",notaryid); if ( 0 && i > 0 ) { for (k=0; kGetHeight() == hwmheight ) + if ( !fJustCheck && pindex->GetHeight() == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); //fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->GetHeight()); - if (notarized = 1) - return(transaction); - else - return(-1); + if (fJustCheck) + { + if (notarisations.size() == 0) + return(0); + if ( notarisations.size() == 1 && notarisations[0] == 1 ) + return(1); + else + return(-1); + } + else return(0); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e679c4084..a139adf90 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1772,17 +1772,67 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); + +uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) +{ + if ( numnotaries == 0 ) + return(0); + // fetch notarised height + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + uint64_t AmountToPay=0,ret=0; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + // dont think this can happen, just sanity check. + if ( height == notarizedht ) + return(0); + // how many block since last notarisation. + int32_t n = height - notarizedht; + fprintf(stderr, "blocks since last notarisation: %i\n",n); + // multiply the amount possible to be used for each block by the amount of blocks passed + // to get the total posible to be paid for this notarisation. + AmountToPay = ASSETCHAINS_NOTARY_PAY*n; + //fprintf(stderr, "AmountToPay.%lu\n",AmountToPay); + ret = AmountToPay / numnotaries; + fprintf(stderr, "payment per notary.%lu\n",ret); + return(ret); +} + +int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); + +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len) { // fetch notary pubkey array. // Need a better/safer way for notaries era, should really be height based rather than timestamp? - uint64_t total = 0; + uint64_t total = 0, AmountToPay = 0; int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); numSN = numStakedNotaries(staked_pubkeys,staked_era); // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); + + // Check the notarisation is valid, and extract notarised height. + uint64_t voutmask; + uint8_t scriptbuf[10001]; + int32_t isratification,specialtx,notarizedheight; + + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) + { + memcpy(scriptbuf,script,len); + if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) + { + fprintf(stderr, "VALID NOTARIZATION ht.%i\n",notarizedheight); + } + else + { + fprintf(stderr, "INVALID NOTARIZATION ht.%i\n",notarizedheight); + return(0); + } + } else return(0); + + // Calcualte the amount to pay. + AmountToPay = komodo_notarypayamount(notarizedheight,NotarisationNotaries.size()); + // loop over notarisation vins and add transaction to coinbase. // Commented prints here can be used to verify manually the pubkeys match. for (int8_t n = 0; n < NotarisationNotaries.size(); n++) @@ -1798,7 +1848,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar } ptr[34] = OP_CHECKSIG; //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); - txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; + txNew.vout[n+1].nValue = AmountToPay; total += txNew.vout[n+1].nValue; } return(total); @@ -1832,35 +1882,69 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } const CChainParams& chainparams = Params(); const Consensus::Params &consensusParams = chainparams.GetConsensus(); + uint64_t totalsats = 0; CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, height); - uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); - int8_t n = 0, i = 0, matches = 0; - uint64_t total = 0; - //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); - // Check the created coinbase is equal to the coinbase the miner submitted in the block. - BOOST_FOREACH(const CTxOut& txout, txNew.vout) + if ( pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { - if ( n == 0 ) + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) + { + totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, height, script, scriptlen); + } + else + { + fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); + return(-1); + } + } + + // if notarypay fails, because the notarisation is not valid, exit now as txNew was not created. + if ( totalsats == 0 ) + { + fprintf(stderr, "notary pay RETURNED 0!\n"); + return(-1); + } + + int8_t n = 0, i = 0, matches = 0; + uint64_t total = 0, AmountToPay = 0; + + // get the pay amount from the created tx. + AmountToPay = txNew.vout[1].nValue; + + //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); + // Check the created coinbase pays the correct notaries. + BOOST_FOREACH(const CTxOut& txout, pblock->vtx[0].vout) + { + // skip the coinbase + if ( n == 0 ) { n++; continue; } + // Check the pubkeys match the pubkeys in the notarisation. script = (uint8_t *)&txout.scriptPubKey[0]; scriptlen = (int32_t)txout.scriptPubKey.size(); - if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) { - matches++; - total += txout.nValue; - fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + // check the value is correct + if ( pblock->vtx[0].vout[n].nValue == AmountToPay ) + { + matches++; + total += txout.nValue; + fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + } + else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]); } - n++; + n++; } - if ( matches = n && matches != 0 && total == totalsats ) + if ( matches != 0 && matches == NotarisationNotaries.size() && totalsats == total ) { fprintf(stderr, "VALIDATED.\n" ); return(totalsats); } - return(-1); + return(0); } int64_t komodo_checkcommission(CBlock *pblock,int32_t height) @@ -2043,14 +2127,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } - if( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() != 1 ) + if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 ) { - if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 ) - { - fprintf(stderr, "Komodo notary pay validation failed.%i\n",height); - return(-1); - } - else + // We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here. + if ( slowflag == 0 ) { // Check the notarisation tx is to the crypto address. if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) diff --git a/src/main.cpp b/src/main.cpp index 99fb44147..ec79fafbc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3574,14 +3574,32 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } - if ( ASSETCHAINS_NOTARY_PAY != 0 && block.vtx[0].vout.size() > 1 ) + bool sleepflag = false; + if ( ASSETCHAINS_NOTARY_PAY != 0 ) { - uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); - if ( notarypaycheque > 0 ) - blockReward += notarypaycheque; - else - return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds the amount allowed! (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), - REJECT_INVALID, "bad-cb-amount"); + // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. + // if notarisation in the block, must be position 1 and the coinbase must pay notaries. + int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); + // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. + if ( notarisationTx == -1 ) + return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + REJECT_INVALID, "bad-notarization-position"); + // 1 means this block contains a valid notarisation + if ( notarisationTx == 1 ) + { + // Check if the notaries have been paid. + if ( block.vtx[0].vout.size() == 1 ) + return state.DoS(100, error("ConnectBlock(): Notary has not been paid!"), + REJECT_INVALID, "bad-cb-amount"); + // calculate the notaries compensation and validate the amounts and pubkeys are correct. + uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); + fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); + if ( notarypaycheque > 0 ) + blockReward += notarypaycheque; + else + return state.DoS(100, error("ConnectBlock(): Notary pay Validation Failed!"), + REJECT_INVALID, "bad-cb-amount"); + } } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) { @@ -3592,6 +3610,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->GetHeight() >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { + //fprintf(stderr, "coinbase pays too much\n"); + //sleepflag = true; return state.DoS(100, error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), @@ -3641,15 +3661,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ConnectNotarisations(block, pindex->GetHeight()); // MoMoM notarisation DB. - int notarisationTx = komodo_connectblock(pindex,*(CBlock *)&block); // dPoW state update. - if ( ASSETCHAINS_NOTARY_PAY != 0 && notarisationTx > 0 ) - { - printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),notarisationTx); - if ( notarisationTx != 1 ) - return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), - REJECT_INVALID, "bad-notarization-position"); - } - if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); @@ -3704,6 +3715,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //FlushStateToDisk(); + komodo_connectblock(false,pindex,*(CBlock *)&block); // dPoW state update. + if (sleepflag) + sleep(30); return true; } diff --git a/src/miner.cpp b/src/miner.cpp index 4ad70912c..6476a7b48 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -153,7 +153,7 @@ int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); -uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp); +uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -672,14 +672,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; // timelocks and commissions are currently incompatible due to validation complexity of the combination } - else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 ) + else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { - // This block contains a valid notarisation as best as we can know. We cant check this 100% until we try to connect block. - // This assumes notaries are not going to collude to create invalid notarisations. - // If they did this, then the block would be invalid, and all kinds of werid things will happen. - // We can test this, and see what happens, if its unreliable, we will need to create a CC contract. - uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime); - fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) + { + uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); + fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + } else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); } pblock->vtx[0] = txNew; From c6e5b70f23db45a5d5458e9577e784669d960119 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 02:44:17 +0800 Subject: [PATCH 888/951] fix --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a139adf90..2bd97fa68 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1904,7 +1904,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) if ( totalsats == 0 ) { fprintf(stderr, "notary pay RETURNED 0!\n"); - return(-1); + return(0); } int8_t n = 0, i = 0, matches = 0; From 52f7cc2caf7d35b6065ec0af09ee2b501fb8a69a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 12:10:26 +0800 Subject: [PATCH 889/951] Add some better prints/comments, move ac_notarypay validation to before temp file fix, to aviod possible attack vector. --- src/komodo_bitcoind.h | 35 ++++++++++++++++--------- src/main.cpp | 60 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2bd97fa68..6fd3b47b3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1807,6 +1807,9 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); + // No point going further, no notaries can be paid. + if ( staked_era == 0 ) + return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); @@ -1821,11 +1824,11 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar memcpy(scriptbuf,script,len); if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) { - fprintf(stderr, "VALID NOTARIZATION ht.%i\n",notarizedheight); + fprintf(stderr, "notarypay found VALID NOTARIZATION ht.%i\n",notarizedheight); } else { - fprintf(stderr, "INVALID NOTARIZATION ht.%i\n",notarizedheight); + fprintf(stderr, "notarypay found INVALID NOTARIZATION ht.%i\n",notarizedheight); return(0); } } else return(0); @@ -1861,10 +1864,13 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; staked_era = STAKED_era(timestamp); + // No point going further, no notaries can be paid. + if ( staked_era == 0 ) + return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); uint8_t *script; int32_t scriptlen; - // Loop notarisation, and create the coinbase tx, with the same function the miner uses. + // Loop over the notarisation and extract the position of the participating notaries in the array of pukeys for this era. BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin) { uint256 hash; CTransaction tx1; @@ -1872,7 +1878,6 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { for (int8_t i = 0; i < numSN; i++) { - //tx1.vout[txin.prevout.n].scriptPubKey script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) @@ -1891,19 +1896,22 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { + // Create the coinbase tx again, using the extracted data, this is the same function the miner uses, with the same data. + // This allows us to know exactly that the coinbase is correct. totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, height, script, scriptlen); } else { fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); - return(-1); + return(0); } } // if notarypay fails, because the notarisation is not valid, exit now as txNew was not created. + // This should never happen, as the notarisation is checked before this function is called. if ( totalsats == 0 ) { - fprintf(stderr, "notary pay RETURNED 0!\n"); + fprintf(stderr, "notary pay returned 0!\n"); return(0); } @@ -1913,11 +1921,10 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) // get the pay amount from the created tx. AmountToPay = txNew.vout[1].nValue; - //fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size()); // Check the created coinbase pays the correct notaries. BOOST_FOREACH(const CTxOut& txout, pblock->vtx[0].vout) { - // skip the coinbase + // skip the coinbase paid to the miner. if ( n == 0 ) { n++; @@ -1933,7 +1940,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { matches++; total += txout.nValue; - fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]); + fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]); } else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]); } @@ -1941,7 +1948,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } if ( matches != 0 && matches == NotarisationNotaries.size() && totalsats == total ) { - fprintf(stderr, "VALIDATED.\n" ); + fprintf(stderr, "Validated coinbase matches notarisation in tx position 1.\n" ); return(totalsats); } return(0); @@ -2127,6 +2134,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } + // Consensus rule to force miners to mine the notary coinbase payment happens in ConnectBlock + // the default daemon miner, checks the actual vins so the only way this will fail, is if someone changes the miner, + // and then creates txs to the crypto address meeting min sigs and puts it in tx position 1. + // If they go through this effort, the block will still fail at connect block, and will be auto purged by the temp file fix. if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 ) { // We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here. @@ -2135,13 +2146,13 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) // Check the notarisation tx is to the crypto address. if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 ) { - fprintf(stderr, "notarisation is not to crypto address.%i\n",height); + fprintf(stderr, "notarisation is not to crypto address ht.%i\n",height); return(-1); } // Check min sigs. if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) { - fprintf(stderr, "block notarization does not meet minsigs .%i\n",height); + fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,(num_notaries_STAKED[STAKED_era(pblock->nTime)]/5),pblock->vtx[1].vin.size()); return(-1); } } diff --git a/src/main.cpp b/src/main.cpp index ec79fafbc..656cc0a96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3267,6 +3267,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin auto verifier = libzcash::ProofVerifier::Strict(); auto disabledVerifier = libzcash::ProofVerifier::Disabled(); int32_t futureblock; + CAmount blockReward = 0; // Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in if (!CheckBlock(&futureblock,pindex->GetHeight(),pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck) || futureblock != 0 ) { @@ -3280,6 +3281,34 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return false; fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } + // Do this here before the block is moved to the main block files. + if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() != 0 ) + { + // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. + // if notarisation in the block, must be position 1 and the coinbase must pay notaries. + int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); + // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. + if ( notarisationTx == -1 ) + return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + REJECT_INVALID, "bad-notarization-position"); + // 1 means this block contains a valid notarisation + if ( notarisationTx == 1 ) + { + // Check if the notaries have been paid. + if ( block.vtx[0].vout.size() == 1 ) + return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), + REJECT_INVALID, "bad-cb-amount"); + // calculate the notaries compensation and validate the amounts and pubkeys are correct. + uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); + fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); + if ( notarypaycheque > 0 ) + blockReward += notarypaycheque; + else + return state.DoS(100, error("ConnectBlock(): Notary pay validation failed!"), + REJECT_INVALID, "bad-cb-amount"); + } + } + // Move the block to the main block file, we need this to create the TxIndex in the following loop. if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 ) { unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); @@ -3562,7 +3591,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); - CAmount blockReward = nFees + GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()) + sum; + blockReward += nFees + GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()) + sum; if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; @@ -3574,33 +3603,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size()); } } - bool sleepflag = false; - if ( ASSETCHAINS_NOTARY_PAY != 0 ) - { - // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. - // if notarisation in the block, must be position 1 and the coinbase must pay notaries. - int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); - // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. - if ( notarisationTx == -1 ) - return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), - REJECT_INVALID, "bad-notarization-position"); - // 1 means this block contains a valid notarisation - if ( notarisationTx == 1 ) - { - // Check if the notaries have been paid. - if ( block.vtx[0].vout.size() == 1 ) - return state.DoS(100, error("ConnectBlock(): Notary has not been paid!"), - REJECT_INVALID, "bad-cb-amount"); - // calculate the notaries compensation and validate the amounts and pubkeys are correct. - uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight()); - fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque); - if ( notarypaycheque > 0 ) - blockReward += notarypaycheque; - else - return state.DoS(100, error("ConnectBlock(): Notary pay Validation Failed!"), - REJECT_INVALID, "bad-cb-amount"); - } - } if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward) { return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward), @@ -3716,8 +3718,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin //FlushStateToDisk(); komodo_connectblock(false,pindex,*(CBlock *)&block); // dPoW state update. - if (sleepflag) - sleep(30); return true; } From 1b504fe06681235f5b28bbd2ff25e7ce48ed963e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 13:42:54 +0800 Subject: [PATCH 890/951] Change ERA to 3 at: (GMT): Sunday, 3 February 2019 9:00:00 AM --- src/notaries_staked.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index b407e6412..2941fd9ac 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1604222222, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549184400, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = @@ -78,20 +78,22 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x {"alright", "0285657c689b903218c97f5f10fe1d10ace2ed6595112d9017f54fb42ea1c1dda8" }, //RXmXeQ8LfJK6Y1aTM97cRz9Gu5f6fmR3sg {"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 - {"CrisF", "03f87f1bccb744d90fdbf7fad1515a98e9fc7feb1800e460d2e7565b88c3971bf3" }, //RMwEpnaVe3cesWbMqqKYPPkaLcDkooTDgZ - {"smk762", "02eacef682d2f86e0103c18f4da46116e17196f3fb8f73ed931acb78e81d8e1aa5" }, // RQVvzJ8gepCDVjhqCAc5Tia1kTmt8KDPL9 - {"jorian", "02150c410a606b898bcab4f083e48e0f98a510e0d48d4db367d37f318d26ae72e3" }, // RFgzxZe2P4RWKx6E9QGPK3rx3TXeWxSqa8 + {"CrisF", "024d19acf0d5de212cdd50326cd143292545d366a71b2b9c6df9f2110de2dfa1f2" }, // RKtAD2kyRRMx4EiG1eeTNprF5h2nmGbzzu + {"smk762", "029f6c1f38c4d6825acb3b4b5147f7992e943b617cdaa0f4f5f36187e239d52d5a" }, // RPy6Xj2LWrxNoEW9YyREDgBZDZZ5qURXBU + {"jorian", "0288e682c1ac449f1b85c4acb2d0bcd216d5df34c15fd18b8a8dd5fa64b8ece8ef" }, // RR1yT5aB19VwFoUCGTW4q4pk4qmhHEEE4t {"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev - {"Emman", "038f642dcdacbdf510b7869d74544dbc6792548d9d1f8d73a999dd9f45f513c935" }, //RN2KsQGW36Ah4NorJDxLJp2xiYJJEzk9Y6 {"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL {"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 - {"jusoaresf", "02dfb7ed72a23f6d07f0ea2f28192ee174733cc8412ec0f97b073007b78fab6346" }, // RBQGfE5Hxsjm1BPraTxbneRuNasPDuoLnu - {"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx - {"blackjok3r2", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"blackjok3r3", "03c3e4c0206551dbf3a4b24d18e5d2737080541184211e3bfd2b1092177410b9c2" }, // RMMav2AVse5XHPvDfTzRpMbFhK3GqFmtSN - {"kmdkrazy", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e" }, // RWHGbrLSP89fTzNVF9U9xiekDYJqcibTca - {"alrighttest", "02e9dfe248f453b499315a90375e58a1c9ad79f5f3932ecb2205399a0f262d65fc" }, // RBevSstS8JtDXMEFNcJws4QTYN4PcE2VL5 - {"alrighttest1", "03527c7ecd6a8c5db6d685a64e6e18c1edb49e2f057a434f56c3f1253a26e9c6a2" }, // RBw2jNU3dnGk86ZLqPMadJwRwg3NU8eC6s + {"greentea", "02054c14ae81838a063d22a75eaa3c961415f6825a57c8b8e4148d19dad64f128e" }, // REF7R76WpL1v7nSXjjiNHtRa2xYtq5qk1p + {"CMaurice", "025830ce81bd1301fb67d5872344efa7a9ff99ae85fe1234f18c085db9072b740f" }, // RX7pXUaV24xFn6DVKV8t3PrRF3gKw6TBjf + {"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t + {"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 + {"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q + {"gcharang", "03336ca9db27cb6e882830e20dc525884e27dc94d557a5e68b972a5cbf9e8c62a8" }, // RJYiWn3FRCSSLf9Pe5RJcbrKQYosaMburP + {"computergenie", "03448ce28fb21748e8b05bbe32d6b1e758b589ac1eb359e5d552f8868f2b75dc92" }, // RGeniexxkjnR34hg7ZnCf36kmfuJusf6rE + {"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, // + {"SHossain", "02791f5c215b8a19c143a98e3371ff03b5613df9ac430c4a331ca55fed5761c800" }, // RKdLoHkyeorXmMtj91B1AAnAGiwsdt9MdF + {"Nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, // RRwCLPZDzpHEFJnLev4phy51e2stHRUAaU }, { {"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x @@ -114,7 +116,7 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = } }; -static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 17, 17 }; +static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; int8_t is_STAKED(const char *chain_name); int32_t STAKED_era(int timestamp); From 2c88bb70b6237ba884ca36ed5bec815d3b669d13 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 3 Feb 2019 16:05:37 +0800 Subject: [PATCH 891/951] disable temp file on initial block sync, extend era2 by 1 hour. --- src/main.cpp | 4 ++++ src/notaries_staked.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 656cc0a96..b904e10e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4736,6 +4736,7 @@ bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, u if ( 0 && tmpflag != 0 ) fprintf(stderr,"pos.nFile %d nPos %u\n",pos.nFile,pos.nPos); } + //sleep(30); } //fprintf(stderr, "nFile = %i size.%li maxTempFileSize0.%u maxTempFileSize1.%u\n",nFile,tmpBlockFiles.size(),maxTempFileSize0,maxTempFileSize1); sleep(30); *lastfilep = nFile; @@ -5338,6 +5339,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C int nHeight = pindex->GetHeight(); int32_t usetmp = 1; + if ( IsInitialBlockDownload() ) + usetmp = 0; // Write block to history file try { @@ -5586,6 +5589,7 @@ bool PruneOneBlockFile(bool tempfile, const int fileNumber) // Block is in main chain so we cant clear this file! return(false); } + fprintf(stderr, "pindex height.%i notarized height.%i \n", pindex->GetHeight(), notarized_height); if ( pindex->GetHeight() > notarized_height ) // Need to check this, does an invalid block have a height? { // This blocks height is not older than last notarization so it can be reorged into the main chain. diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 2941fd9ac..468b7b7ca 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -23,7 +23,7 @@ static const char *iguanaSeeds[8][1] = static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; -static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549184400, 1604233333, 1604244444}; +static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549188000, 1604233333, 1604244444}; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = From 2863dbc6d4e703192efaa04a064ac02dce67145b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 4 Feb 2019 10:06:54 +0800 Subject: [PATCH 892/951] Stop miner trying to mine invalid block. --- src/komodo_bitcoind.h | 5 +++-- src/main.cpp | 17 +++++++++++++++++ src/miner.cpp | 7 ++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6fd3b47b3..0a72903da 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1811,8 +1811,6 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar if ( staked_era == 0 ) return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); - // resize coinbase vouts to number of notary nodes +1 for coinbase itself. - txNew.vout.resize(NotarisationNotaries.size()+1); // Check the notarisation is valid, and extract notarised height. uint64_t voutmask; @@ -1833,6 +1831,9 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar } } else return(0); + // resize coinbase vouts to number of notary nodes +1 for coinbase itself. + txNew.vout.resize(NotarisationNotaries.size()+1); + // Calcualte the amount to pay. AmountToPay = komodo_notarypayamount(notarizedheight,NotarisationNotaries.size()); diff --git a/src/main.cpp b/src/main.cpp index b904e10e2..b9c66c2ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -282,6 +282,9 @@ namespace { bool fCurrentlyConnected; //! Accumulated misbehaviour score for this peer. int nMisbehavior; + // count blocks seen. + //int8_t nBlocksinARow; + //int8_t nBlocksinARow2; //! Whether this peer should be disconnected and banned (unless whitelisted). bool fShouldBan; //! String name of this peer (debugging/logging purposes). @@ -5469,6 +5472,20 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool checked; uint256 hash; int32_t futureblock=0; auto verifier = libzcash::ProofVerifier::Disabled(); hash = pblock->GetHash(); + /*pfrom->nBlocksinARow += 1; + if ( pfrom->nBlocksinARow >= 6 ) + { + pfrom->nBlocksinARow2 += 1; + if ( pfrom->nBlocksinARow2 > 3 ) + { + pfrom->nBlocksinARow = 0; + pfrom->nBlocksinARow2 = 0; + } + else + { + return(false); + } + }*/ //fprintf(stderr,"ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight()); { LOCK(cs_main); diff --git a/src/miner.cpp b/src/miner.cpp index 6476a7b48..da5fcd91f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -680,7 +680,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( script[0] == OP_RETURN ) { uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); - fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); + if ( totalsats == 0 ) + { + fprintf(stderr, "Could not create notary payment, trying again.\n"); + return(0); + } + fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); } else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); } From bd6949b98718fb0228809efc52d372bff18bbd7a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 4 Feb 2019 11:51:02 +0800 Subject: [PATCH 893/951] disable notarisation priority for non staked chains. --- src/miner.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index da5fcd91f..5f1afa874 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -246,9 +246,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->nTime = GetAdjustedTime(); // Now we have the block time, we can get the active notaries. int32_t staked_era; int8_t numSN; - uint8_t staked_pubkeys[64][33]; - staked_era = STAKED_era(pblock->nTime); - numSN = numStakedNotaries(staked_pubkeys,staked_era); + uint8_t staked_pubkeys[64][33] = {0}; + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { + staked_era = STAKED_era(pblock->nTime); + numSN = numStakedNotaries(staked_pubkeys,staked_era); + } CCoinsViewCache view(pcoinsTip); uint32_t expired; uint64_t commission; From 042756499f8b99d3fd590de5ea1ffa043336fe33 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 4 Feb 2019 16:40:47 +0800 Subject: [PATCH 894/951] fix better --- src/miner.cpp | 10 +++++----- src/notaries_staked.cpp | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5f1afa874..10bdb643f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -245,7 +245,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } pblock->nTime = GetAdjustedTime(); // Now we have the block time, we can get the active notaries. - int32_t staked_era; int8_t numSN; + int32_t staked_era = 0; int8_t numSN = 0; uint8_t staked_pubkeys[64][33] = {0}; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) { @@ -303,7 +303,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { int numNotaryVins = 0; bool fToCryptoAddress = false; - if ( komodo_is_notarytx(tx) == 1 ) + if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -346,7 +346,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint8_t *script; int32_t scriptlen; uint256 hash; CTransaction tx1; // loop over notaries array and extract index of signers. - if ( fToCryptoAddress && staked_pubkeys[0][0] != 0 && GetTransaction(txin.prevout.hash,tx1,hash,false) ) + if ( fToCryptoAddress && GetTransaction(txin.prevout.hash,tx1,hash,false) ) { for (int8_t i = 0; i < numSN; i++) { @@ -403,7 +403,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0) + else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) continue; // If we have added a notarisation already skip the next one. There can only be one per block. else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); @@ -1720,7 +1720,7 @@ void static BitcoinMiner() } //else fprintf(stderr,"duplicate at j.%d\n",j); } else Mining_start = 0; } else Mining_start = 0; - + if ( ASSETCHAINS_STAKED > 0 ) { int32_t percPoS,z; bool fNegative,fOverflow; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 23bc0f8fd..cdaffa7a2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -10,7 +10,8 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY; extern pthread_mutex_t staked_mutex; extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; -int8_t is_STAKED(const char *chain_name) { +int8_t is_STAKED(const char *chain_name) +{ static int8_t STAKED,doneinit; if ( chain_name[0] == 0 ) return(0); @@ -22,7 +23,7 @@ int8_t is_STAKED(const char *chain_name) { STAKED = 2; else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; - else if ( (strcmp(chain_name, "NOTARYTEST") == 0) ) + else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) STAKED = 4; else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid. From b9779b671c58466c299bb7df5bb1eb83edbd2a91 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 13:31:02 +0800 Subject: [PATCH 895/951] add LABST2 to block reward chains. Add exeption to verushash staker to increase staking diff in first 50 bocks. --- src/komodo_bitcoind.h | 2 +- src/notaries_staked.cpp | 14 +++++++------- src/notaries_staked.h | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0a72903da..a40a174b1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1437,7 +1437,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh { // Under PoS % target and we need to increase diff. //fprintf(stderr, "PoS too low diff.%i changed to.",diff); - diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) ); + diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) * ( nHeight < 50 ? 1000 : 1)); //fprintf(stderr, "%i \n",diff); } else if ( PoSperc > ASSETCHAINS_STAKED ) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index cdaffa7a2..6e6912256 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,16 +17,16 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "PAYME") == 0) || (strcmp(chain_name, "LABST") == 0) ) - STAKED = 1; - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABST2") == 0) ) + STAKED = 1; // These chains are allowed coin emissions. + else if ( (strncmp(chain_name, "LABS", 4) == 0) ) + STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; + STAKED = 3; // These chains have no speical rules at all. else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; + STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant ot be actually used for anything important. else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid. + STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. doneinit = 1; return(STAKED); }; diff --git a/src/notaries_staked.h b/src/notaries_staked.h index 468b7b7ca..ed195bf48 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -24,6 +24,7 @@ static const int STAKED_ERA_GAP = 777; static const int NUM_STAKED_ERAS = 4; static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542964044, 1549188000, 1604233333, 1604244444}; +static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; // Era array of pubkeys. static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = @@ -116,8 +117,6 @@ static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] = } }; -static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 17, 25, 19, 17 }; - int8_t is_STAKED(const char *chain_name); int32_t STAKED_era(int timestamp); int8_t updateStakedNotary(); From 1728ffabdc43a08cbaf1d4077c4b9a4953de3472 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 15:30:54 +0800 Subject: [PATCH 896/951] minsigs =2 --- src/main.cpp | 2 +- src/notaries_staked.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b9c66c2ca..7ec88830b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3285,7 +3285,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() != 0 ) + if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 ) { // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ed195bf48..af7632b28 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int32_t iguanaPort = 9997; static const int8_t BTCminsigs = 13; -static const int8_t overrideMinSigs = 0; +static const int8_t overrideMinSigs = 2; static const char *iguanaSeeds[8][1] = { {"80.240.17.222"}, From 5f780b0325749d251cf002a0812d001c01c49c08 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 15:35:20 +0800 Subject: [PATCH 897/951] fix --- src/notaries_staked.h | 2 +- src/rpc/misc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index af7632b28..ed195bf48 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int32_t iguanaPort = 9997; static const int8_t BTCminsigs = 13; -static const int8_t overrideMinSigs = 2; +static const int8_t overrideMinSigs = 0; static const char *iguanaSeeds[8][1] = { {"80.240.17.222"}, diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 180403e00..1e0e33c27 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,7 +128,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) json.push_back(Pair("port",iguanaPort)); json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("minsigs",2)); json.push_back(Pair("seeds", seeds)); json.push_back(Pair("notaries",notaries)); return json; From de0ced744452775bd7903e8d19a7c02b60b142c5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 17:00:21 +0800 Subject: [PATCH 898/951] Check for double signs on notarisation checks. revert minsigs to normal value. --- src/komodo_bitcoind.h | 6 ++++++ src/miner.cpp | 9 ++++++++- src/rpc/misc.cpp | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a40a174b1..a476e70e5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1886,6 +1886,12 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } } } + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); + if ( checkdupes.size() != NotarisationNotaries.size() ) { + fprintf(stderr, "Possible notarisation is signed multiple times by same notary. It is invalid.\n"); + return(0); + } const CChainParams& chainparams = Params(); const Consensus::Params &consensusParams = chainparams.GetConsensus(); uint64_t totalsats = 0; diff --git a/src/miner.cpp b/src/miner.cpp index 10bdb643f..e3eb8d262 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -367,7 +367,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * nConf; } if ( numSN != 0 && numNotaryVins >= numSN / 5 ) - fNotarisation = true; + { + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); + if ( checkdupes.size() != NotarisationNotaries.size() ) { + NotarisationNotaries.clear(); + fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); + } else fNotarisation = true; + } else NotarisationNotaries.clear(); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 1e0e33c27..b60809da1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,8 +128,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) json.push_back(Pair("port",iguanaPort)); json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",2)); - json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds",seeds)); json.push_back(Pair("notaries",notaries)); return json; } From c56e206889a5f6187b84a9964fe8d58675ece07c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 19:10:48 +0800 Subject: [PATCH 899/951] jorians ip --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index ed195bf48..c30c8f17e 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -14,7 +14,7 @@ static const char *iguanaSeeds[8][1] = {"103.6.12.112"}, {"18.224.176.46"}, {"45.76.120.247"}, - {"103.6.12.112"}, + {"185.62.57.32"}, {"103.6.12.112"}, {"103.6.12.112"}, {"103.6.12.112"}, From 61aa40edf483a8edfbba6ae8e48aa8dbccf7a21d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 19:41:44 +0800 Subject: [PATCH 900/951] fix miner LOCK UP --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e3eb8d262..c437a19d6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -692,7 +692,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); if ( totalsats == 0 ) { - fprintf(stderr, "Could not create notary payment, trying again.\n"); + fprintf(stderr, "Could not create notary payment, trying again.\n"); + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); return(0); } fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); From cedc9465e64d93abde01719e35cf66c37c3ab0f9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 20:29:27 +0800 Subject: [PATCH 901/951] Make miner not flag invalid notarisation for coinbase createion. --- src/miner.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c437a19d6..87f92559b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -174,6 +174,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarisationBlock = false; std::vector NotarisationNotaries; + static std::string invalidnotarisation; //fprintf(stderr,"create new block\n"); // Create new block @@ -370,10 +371,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); - if ( checkdupes.size() != NotarisationNotaries.size() ) { + if ( tx.GetHash().ToString() == invalidnotarisation ) + { + NotarisationNotaries.clear(); + fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); + } + else if ( checkdupes.size() != NotarisationNotaries.size() ) + { NotarisationNotaries.clear(); fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); - } else fNotarisation = true; + } + else + fNotarisation = true; } else NotarisationNotaries.clear(); @@ -693,6 +702,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); + invalidnotarisation = pblock->vtx[1].GetHash().ToString(); LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); return(0); From e2e7614dffa7e3af0f20996b0eb2b4557627fecb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 21:09:43 +0800 Subject: [PATCH 902/951] try fix --- src/miner.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 87f92559b..94766388f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -371,21 +371,22 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); - if ( tx.GetHash().ToString() == invalidnotarisation ) - { - NotarisationNotaries.clear(); - fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); - } - else if ( checkdupes.size() != NotarisationNotaries.size() ) + if ( checkdupes.size() != NotarisationNotaries.size() ) { NotarisationNotaries.clear(); fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); - } + } + else if ( tx.GetHash().ToString() == invalidnotarisation ) + { + // check if the last notarisation we tried was flagged as invalid. + // then clear it, in case next time it is seen as valid. + NotarisationNotaries.clear(); + invalidnotarisation = ""; + fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); + } else fNotarisation = true; - } - else - NotarisationNotaries.clear(); + } else NotarisationNotaries.clear(); nTotalIn += tx.GetShieldedValueIn(); } From cfef67c59bfb38ff9e16be8739761fde68cfacc2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 7 Feb 2019 00:00:11 +0800 Subject: [PATCH 903/951] fix possible to choose more than 1 notarisation --- src/komodo_bitcoind.h | 8 +++++++- src/miner.cpp | 16 ++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a476e70e5..d22ac895f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1777,14 +1777,20 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) { if ( numnotaries == 0 ) + { + fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); + } // fetch notarised height int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); // dont think this can happen, just sanity check. if ( height == notarizedht ) + { + fprintf(stderr, "komodo_notarypayamount failed notarized height = height\n"); return(0); + } // how many block since last notarisation. int32_t n = height - notarizedht; fprintf(stderr, "blocks since last notarisation: %i\n",n); @@ -1851,7 +1857,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar //fprintf(stderr,"%02x",ptr[i+1]); } ptr[34] = OP_CHECKSIG; - //fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1); + //fprintf(stderr," set notary %i PUBKEY33 into vout[%i] amount.%lu\n",NotarisationNotaries[n],n+1,AmountToPay); txNew.vout[n+1].nValue = AmountToPay; total += txNew.vout[n+1].nValue; } diff --git a/src/miner.cpp b/src/miner.cpp index 94766388f..8f1792f83 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -303,7 +303,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { - int numNotaryVins = 0; bool fToCryptoAddress = false; + //int numNotaryVins = 0; + bool fToCryptoAddress = false; if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; @@ -355,19 +356,19 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) { - numNotaryVins++; + //numNotaryVins++; if ( Notarisations == 0 ) { // Until we get a valid notarization this will always be 0. // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. NotarisationNotaries.push_back(i); - } + } } } } dPriority += (double)nValueIn * nConf; } - if ( numSN != 0 && numNotaryVins >= numSN / 5 ) + if ( numSN != 0 && NotarisationNotaries.size() >= numSN / 5 ) { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); @@ -704,8 +705,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { fprintf(stderr, "Could not create notary payment, trying again.\n"); invalidnotarisation = pblock->vtx[1].GetHash().ToString(); - LEAVE_CRITICAL_SECTION(cs_main); - LEAVE_CRITICAL_SECTION(mempool.cs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) + { + LEAVE_CRITICAL_SECTION(cs_main); + LEAVE_CRITICAL_SECTION(mempool.cs); + } return(0); } fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); From 170ca55e4648ad7d2ac129eada38e414a566083d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 7 Feb 2019 17:07:49 +0800 Subject: [PATCH 904/951] New miner, some prints. YUse equihash difficulty algo for VerusHash and PoS64 --- src/komodo_bitcoind.h | 77 ++++++++++++++++++++++----------------- src/miner.cpp | 84 ++++++++++++++++++++++++++----------------- src/pow.cpp | 17 +++++++-- 3 files changed, 111 insertions(+), 67 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d22ac895f..fc4c66eb5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1433,14 +1433,15 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh diff = (iter + blocktime - txtime - minage); if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) { - if ( PoSperc < ASSETCHAINS_STAKED ) + /*if ( PoSperc < ASSETCHAINS_STAKED ) { // Under PoS % target and we need to increase diff. //fprintf(stderr, "PoS too low diff.%i changed to.",diff); diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) * ( nHeight < 50 ? 1000 : 1)); //fprintf(stderr, "%i \n",diff); } - else if ( PoSperc > ASSETCHAINS_STAKED ) + else */ + if ( PoSperc > ASSETCHAINS_STAKED ) { // Over PoS target need to lower diff. //fprintf(stderr, "PoS too high diff.%i changed to.",diff); @@ -1460,14 +1461,17 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh coinage = (value * diff); if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) { - if ( blocktime+iter+segid*2 > prevtime+128 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); - } - else - { - if ( blocktime+iter+segid*2 > prevtime+480 ) - coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); + if ( PoSperc < ASSETCHAINS_STAKED ) + { + // Under PoS % target and we need to increase diff. + //fprintf(stderr, "PoS too low diff.%i changed to.",diff); + if ( blocktime+iter+segid*2 > prevtime+128 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+102)); + //fprintf(stderr, "%i \n",diff); + } } + if ( blocktime+iter+segid*2 > prevtime+480 ) + coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); coinage256 = arith_uint256(coinage+1); hashval = ratio * (UintToArith256(hash) / coinage256); if ( hashval <= bnTarget ) @@ -1774,9 +1778,9 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); -uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) +uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) { - if ( numnotaries == 0 ) + if ( notarycount == 0 ) { fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); @@ -1793,18 +1797,41 @@ uint64_t komodo_notarypayamount(int32_t height, int64_t numnotaries) } // how many block since last notarisation. int32_t n = height - notarizedht; - fprintf(stderr, "blocks since last notarisation: %i\n",n); + fprintf(stderr, "blocks since last notarization: %i\n",n); // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. AmountToPay = ASSETCHAINS_NOTARY_PAY*n; //fprintf(stderr, "AmountToPay.%lu\n",AmountToPay); - ret = AmountToPay / numnotaries; + ret = AmountToPay / notarycount; fprintf(stderr, "payment per notary.%lu\n",ret); return(ret); } int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); +int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len) +{ + // Check the notarisation is valid, and extract notarised height. + uint64_t voutmask; + uint8_t scriptbuf[10001]; + int32_t isratification,specialtx,notarizedheight; + + if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) + { + memcpy(scriptbuf,script,len); + if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) + { + fprintf(stderr, ">>>>>>VALID NOTARIZATION ht.%i\n",notarizedheight); + } + else + { + fprintf(stderr, "<<<<< &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len) { // fetch notary pubkey array. @@ -1818,25 +1845,11 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); - // Check the notarisation is valid, and extract notarised height. - uint64_t voutmask; - uint8_t scriptbuf[10001]; - int32_t isratification,specialtx,notarizedheight; - - if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) - { - memcpy(scriptbuf,script,len); - if ( komodo_voutupdate(true,&isratification,0,scriptbuf,len,height,uint256(),1,1,&voutmask,&specialtx,¬arizedheight,0,1,0,timestamp) == -2 ) - { - fprintf(stderr, "notarypay found VALID NOTARIZATION ht.%i\n",notarizedheight); - } - else - { - fprintf(stderr, "notarypay found INVALID NOTARIZATION ht.%i\n",notarizedheight); - return(0); - } - } else return(0); - + // Check the notarisation is valid and get the notarized height to calcualte the payment. + int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len); + if ( notarizedheight == 0 ) + return(0); + // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); diff --git a/src/miner.cpp b/src/miner.cpp index 8f1792f83..0b0e12895 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,6 +154,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); +int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -174,7 +175,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarisationBlock = false; std::vector NotarisationNotaries; - static std::string invalidnotarisation; //fprintf(stderr,"create new block\n"); // Create new block @@ -233,6 +233,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetAdjustedTime(); + + int32_t last_notarizedheight = 0; + if (proposedTime == nMedianTimePast) { // too fast or stuck, this addresses the too fast issue, while moving @@ -297,6 +300,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CAmount nTotalIn = 0; bool fMissingInputs = false; bool fNotarisation = false; + std::vector TMP_NotarisationNotaries = {0}; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); // burn amount @@ -304,6 +308,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { //int numNotaryVins = 0; + TMP_NotarisationNotaries.clear(); bool fToCryptoAddress = false; if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; @@ -356,39 +361,22 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) { - //numNotaryVins++; - if ( Notarisations == 0 ) - { - // Until we get a valid notarization this will always be 0. - // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. - NotarisationNotaries.push_back(i); - } + // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. + TMP_NotarisationNotaries.push_back(i); } } } dPriority += (double)nValueIn * nConf; } - if ( numSN != 0 && NotarisationNotaries.size() >= numSN / 5 ) + if ( numSN != 0 && TMP_NotarisationNotaries.size() >= numSN / 5 ) { // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) - std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); - if ( checkdupes.size() != NotarisationNotaries.size() ) + std::set checkdupes( TMP_NotarisationNotaries.begin(), TMP_NotarisationNotaries.end() ); + if ( checkdupes.size() != TMP_NotarisationNotaries.size() ) { - NotarisationNotaries.clear(); fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); - } - else if ( tx.GetHash().ToString() == invalidnotarisation ) - { - // check if the last notarisation we tried was flagged as invalid. - // then clear it, in case next time it is seen as valid. - NotarisationNotaries.clear(); - invalidnotarisation = ""; - fprintf(stderr, "notarisation %s is invalid leave it as a normal tx.\n", invalidnotarisation.c_str()); - } - else - fNotarisation = true; - } else NotarisationNotaries.clear(); - + } else fNotarisation = true; + } nTotalIn += tx.GetShieldedValueIn(); } @@ -405,10 +393,43 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (fNotarisation) { - dPriority = 1e16; - Notarisations++; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation[%i] %s set to maximum priority\n",Notarisations,hash.ToString().c_str()); + // check if the notarization found is actually valid. + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) + { + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) + { + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) + { + if ( last_notarizedheight == 0 ) + { + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + last_notarizedheight = notarizedheight; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + } + else if ( notarizedheight > last_notarizedheight ) + continue; // leave this notarisation for the next block, it will be valid! + else + { + // we need to remove the last seen notarzation from block + double dPriority = vecPriority.front().get<0>(); + CFeeRate feeRate = vecPriority.front().get<1>(); + const CTransaction& Tx = *(vecPriority.front().get<2>()); + // add this one as its valid before the other one. + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); + } + } + } + } } else if ( dPriority == 1e16 ) { @@ -421,8 +442,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - continue; // If we have added a notarisation already skip the next one. There can only be one per block. else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } @@ -700,11 +719,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { + fprintf(stderr, ">>>>>MINER NotarisationNotaries.%li\n",NotarisationNotaries.size()); uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); - invalidnotarisation = pblock->vtx[1].GetHash().ToString(); + // invalidnotarisation = pblock->vtx[1].GetHash().ToString(); if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) { LEAVE_CRITICAL_SECTION(cs_main); diff --git a/src/pow.cpp b/src/pow.cpp index d36357800..1716099ee 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -44,10 +44,15 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) + if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0) return lwmaGetNextWorkRequired(pindexLast, pblock, params); - unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + arith_uint256 bnLimit; + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) + bnLimit = UintToArith256(params.powLimit); + else + bnLimit = UintToArith256(params.powAlternate); + unsigned int nProofOfWorkLimit = bnLimit.GetCompact(); // Genesis block if (pindexLast == NULL ) return nProofOfWorkLimit; @@ -102,7 +107,13 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, nActualTimespan = params.MaxActualTimespan(); // Retarget - const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); + arith_uint256 bnLimit; + if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) + bnLimit = UintToArith256(params.powLimit); + else + bnLimit = UintToArith256(params.powAlternate); + + const arith_uint256 bnPowLimit = bnLimit; //UintToArith256(params.powLimit); arith_uint256 bnNew {bnAvg}; bnNew /= params.AveragingWindowTimespan(); bnNew *= nActualTimespan; From f62017f83e6ec8902305af387235a8bd3fe2e327 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 8 Feb 2019 11:52:43 +0800 Subject: [PATCH 905/951] try fix --- src/miner.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0b0e12895..e8245b710 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -415,12 +415,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } else if ( notarizedheight > last_notarizedheight ) continue; // leave this notarisation for the next block, it will be valid! - else + else if ( notarizedheight == last_notarizedheight ) + continue; // this shouldnt happen :S + else { // we need to remove the last seen notarzation from block - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); const CTransaction& Tx = *(vecPriority.front().get<2>()); + TxPriorityCompare comparer(0); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); // add this one as its valid before the other one. NotarisationNotaries = TMP_NotarisationNotaries; dPriority = 1e16; From 528f39542eb3aee516ef0853903d2ee47ec599cd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 9 Feb 2019 00:08:28 +0800 Subject: [PATCH 906/951] fix reorg problem --- src/komodo.h | 12 +++++++----- src/komodo_bitcoind.h | 13 +++++++------ src/komodo_notary.h | 3 ++- src/komodo_structs.h | 2 +- src/main.cpp | 12 ++++++------ src/miner.cpp | 2 +- src/rpc/misc.cpp | 6 +++--- src/wallet/wallet.cpp | 2 ++ 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3e9d0946f..b97e4d205 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -695,15 +695,17 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - /*else - { - fprintf(stderr, "NOT VALID NOTARISATION\n"); - return (-2); - } */ + + // If we are checking a reorged notarisation tx we need to return true. So the coinbase can be recreated, otherwise notaries are not paid, + // if a notarisation TX is reorged before the next notarization happens! + if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) + return(-2); + if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { if ( fJustCheck ) return(-2); + sp->prevNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fc4c66eb5..caa2c4460 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,7 +1776,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) { @@ -1786,14 +1786,15 @@ uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) return(0); } // fetch notarised height - int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + int32_t notarizedht,prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); - // dont think this can happen, just sanity check. + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); + // if this is the current checkpoint we will use the previous height. + // incase of reorgs, we still need to create the notary payment. if ( height == notarizedht ) { - fprintf(stderr, "komodo_notarypayamount failed notarized height = height\n"); - return(0); + notarizedht = prevnotarizedht; + fprintf(stderr, "using the current checkpoint, calculating based on previous notarized height!\n"); } // how many block since last notarisation. int32_t n = height - notarizedht; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c4984cee2..dcd99bea1 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,13 +452,14 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; + *prevNotarizedHt = sp->prevNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 6b7c316b6..2f8ba0850 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,prevNOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index 7ec88830b..30b569c3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3909,8 +3909,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t prevMoMheight; uint256 notarizedhash,txid; - komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + int32_t prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; + komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4244,8 +4244,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + int32_t notarizedht,prevnotarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5591,8 +5591,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/miner.cpp b/src/miner.cpp index e8245b710..a0934ce96 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -416,7 +416,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 else if ( notarizedheight > last_notarizedheight ) continue; // leave this notarisation for the next block, it will be valid! else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen :S + continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! else { // we need to remove the last seen notarzation from block diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index b60809da1..d0dd65c41 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a8246903c..330fcb9be 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2836,6 +2836,8 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) void CWallet::ReacceptWalletTransactions() { + if ( IsInitialBlockDownload() ) + return; // If transactions aren't being broadcasted, don't let them into local mempool either if (!fBroadcastTransactions) return; From 3dbbf8cafd4352416bf923bba3c321d98e7d00b6 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 9 Feb 2019 03:22:57 +0800 Subject: [PATCH 907/951] try --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index b97e4d205..5c6e84b98 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -701,7 +701,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) return(-2); - if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( matched != 0 && *notarizedheightp >= sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { if ( fJustCheck ) return(-2); From 0ac9828870f4f68f2c788821a6b827935667dbe4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 9 Feb 2019 03:34:52 +0800 Subject: [PATCH 908/951] what --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5c6e84b98..b97e4d205 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -701,7 +701,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) return(-2); - if ( matched != 0 && *notarizedheightp >= sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { if ( fJustCheck ) return(-2); From 8328842ff068c506fe0410a64061c17f45585765 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 10 Feb 2019 21:44:06 +0800 Subject: [PATCH 909/951] Disable getblocktemplate flag --- src/rpc/mining.cpp | 16 +++++++++++++++- src/rpc/misc.cpp | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c1d45c6e7..975154cdf 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -218,7 +218,18 @@ UniValue generate(const UniValue& params, bool fHelp) #endif } if (!Params().MineBlocksOnDemand()) - throw JSONRPCError(RPC_METHOD_NOT_FOUND, "This method can only be used on regtest"); + { + if ( params[0].get_int() == 1 ) + { + mapArgs["disablemining"] = "1"; + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Mining Disabled"); + } + else + { + mapArgs["disablemining"] = "0"; + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Mining Enabled"); + } + } int nHeightStart = 0; int nHeightEnd = 0; @@ -576,6 +587,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "komodod compiled without wallet and -mineraddress not set"); #endif } + + if ( GetArg("disablemining",false) ) + throw JSONRPCError(RPC_TYPE_ERROR, "Mining is Disabled"); UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index d0dd65c41..bda9da062 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -119,7 +119,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) notaries.push_back(notary); } - // get the min sigs .. this always rounds UP so mine sigs in iguana is +1 min sigs in komodod, due to some rounding error. + // get the min sigs .. this always rounds UP so min sigs in iguana is +1 min sigs in komodod, due to some rounding error. int minsigs; if ( num_notaries_STAKED[era]/5 > overrideMinSigs ) minsigs = (num_notaries_STAKED[era] / 5) + 1; From 8d7234bf220b2bb521a4e0445ead6ceab8064b0b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 11 Feb 2019 01:10:27 +0800 Subject: [PATCH 910/951] Test fix to stop nodes forceing an attacking chain onto others. --- src/main.cpp | 36 +++++++++++++++++++----------------- src/net.h | 3 +++ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 30b569c3e..054313a21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -282,9 +282,6 @@ namespace { bool fCurrentlyConnected; //! Accumulated misbehaviour score for this peer. int nMisbehavior; - // count blocks seen. - //int8_t nBlocksinARow; - //int8_t nBlocksinARow2; //! Whether this peer should be disconnected and banned (unless whitelisted). bool fShouldBan; //! String name of this peer (debugging/logging purposes). @@ -5472,20 +5469,6 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool checked; uint256 hash; int32_t futureblock=0; auto verifier = libzcash::ProofVerifier::Disabled(); hash = pblock->GetHash(); - /*pfrom->nBlocksinARow += 1; - if ( pfrom->nBlocksinARow >= 6 ) - { - pfrom->nBlocksinARow2 += 1; - if ( pfrom->nBlocksinARow2 > 3 ) - { - pfrom->nBlocksinARow = 0; - pfrom->nBlocksinARow2 = 0; - } - else - { - return(false); - } - }*/ //fprintf(stderr,"ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight()); { LOCK(cs_main); @@ -5493,6 +5476,25 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo komodo_currentheight_set(chainActive.LastTip()->GetHeight()); checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0); bool fRequested = MarkBlockAsReceived(hash); + if ( pfrom && !fRequested && vNodes.size() > 1 ) + { + pfrom->nBlocksinARow += 1; + if ( pfrom->nBlocksinARow >= 10 ) + { + pfrom->nBlocksinARow2 += 1; + if ( pfrom->nBlocksinARow2 > 5 ) + { + pfrom->nBlocksinARow = 0; + pfrom->nBlocksinARow2 = 0; + //fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId()); + } + else + { + //fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2); + return(false); + } + } + } fRequested |= fForceProcessing; if ( checked != 0 && komodo_checkPOW(0,pblock,height) < 0 ) //from_miner && ASSETCHAINS_STAKED == 0 { diff --git a/src/net.h b/src/net.h index 3e06e9831..b7975bfec 100644 --- a/src/net.h +++ b/src/net.h @@ -293,6 +293,9 @@ public: bool fNetworkNode; bool fSuccessfullyConnected; bool fDisconnect; + // count blocks seen. + int8_t nBlocksinARow; + int8_t nBlocksinARow2; // We use fRelayTxes for two purposes - // a) it allows us to not relay tx invs before receiving the peer's version message // b) the peer may tell us in its version message that we should not relay tx invs From d69be73aece5cbc5021186ead88559e665372cdb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 11 Feb 2019 17:25:51 +0800 Subject: [PATCH 911/951] Change eras activation code. Fix reindex with ac_notarypay! --- src/init.cpp | 2 ++ src/notaries_staked.cpp | 72 +++++++++-------------------------------- 2 files changed, 18 insertions(+), 56 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 6aca3ce1b..ea8286cd0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1554,6 +1554,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (fReindex) { + boost::filesystem::remove(GetDataDir() / "komodostate"); + boost::filesystem::remove(GetDataDir() / "signedmasks"); pblocktree->WriteReindexing(true); //If we're reindexing in prune mode, wipe away unusable block files and all undo data files if (fPruneMode) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 6e6912256..422d0da18 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -70,8 +70,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int i; int8_t retval = 0; - static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2; - static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4; + static uint8_t staked_pubkeys[NUM_STAKED_ERAS][64][33],didinit[NUM_STAKED_ERAS]; static char ChainName[65]; if ( ChainName[0] == 0 ) @@ -82,65 +81,26 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { strcpy(ChainName,ASSETCHAINS_SYMBOL); } - if ( era != 0 ) { - switch (era) { - case 1: - if ( didstaked1 == 0 ) - { - for (i=0; i Date: Mon, 11 Feb 2019 19:52:17 +0800 Subject: [PATCH 912/951] fix error --- 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 70696d4f5..c6bf320a2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5092,8 +5092,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numUtxos = utxoInputs.size(); size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); - fprintf(stderr, "num utxos.%li\n", numUtxos); - if (numUtxos < 2 && numNotes == 0) { + //fprintf(stderr, "num utxos.%li\n", numUtxos); + if (numUtxos < 1 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From f6a51145f59315d8303fdb47709aabdaf4943a06 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 12 Feb 2019 23:28:13 +0800 Subject: [PATCH 913/951] New notary pay mechanisim... --- src/komodo.h | 17 +++++++++++------ src/komodo_bitcoind.h | 42 +++++++++++++++++++++++------------------ src/komodo_notary.h | 5 +++-- src/komodo_structs.h | 2 +- src/main.cpp | 20 +++++++++++--------- src/miner.cpp | 8 ++++++-- src/notaries_staked.cpp | 4 ++-- src/rpc/misc.cpp | 6 +++--- 8 files changed, 61 insertions(+), 43 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b97e4d205..d88b53c2a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -266,7 +266,10 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; } + sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; + sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth); + printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT); } else if ( func == 'U' ) // deprecated { @@ -697,7 +700,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar komodo_rwccdata((char *)"KMD",1,&ccdata,0); // If we are checking a reorged notarisation tx we need to return true. So the coinbase can be recreated, otherwise notaries are not paid, - // if a notarisation TX is reorged before the next notarization happens! + // if a notarisation TX is reorged before the next notarization happens! if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) return(-2); @@ -705,7 +708,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar { if ( fJustCheck ) return(-2); - sp->prevNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; + sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; + sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; @@ -716,7 +720,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } 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); + printf("[%s] ht.%d NUM_NPOINTS.%d NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,sp->NUM_NPOINTS,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,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); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -742,7 +746,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0); } } - } + } else if ( fJustCheck ) + return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one! } else if ( opretlen != 149 && height > 600000 && matched != 0 ) printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } @@ -958,7 +963,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); - if ( fJustCheck && notaryid == -2 ) + if ( fJustCheck && (notaryid == -2 || notaryid == -3) ) { // We see a valid notarisation here, save its location. notarisations.push_back(i); @@ -1025,7 +1030,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { if (notarisations.size() == 0) return(0); - if ( notarisations.size() == 1 && notarisations[0] == 1 ) + if ( notarisations.size() >= 1 && notarisations[0] == 1 ) return(1); else return(-1); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index caa2c4460..e3e99d7c4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,35 +1776,39 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); -uint64_t komodo_notarypayamount(int32_t height, int64_t notarycount) +uint64_t komodo_notarypayamount(int64_t notarycount) { if ( notarycount == 0 ) { fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); } - // fetch notarised height - int32_t notarizedht,prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; + // fetch notarised height, the previous, and the one before that. + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); - // if this is the current checkpoint we will use the previous height. - // incase of reorgs, we still need to create the notary payment. - if ( height == notarizedht ) + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); + //fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d \n",notarizedht,prevnotarizedht,pprevnotarizedht); + + // We cannot pay out if 3 notarisation's have not yet happened! + if ( pprevnotarizedht == 0 ) { - notarizedht = prevnotarizedht; - fprintf(stderr, "using the current checkpoint, calculating based on previous notarized height!\n"); + fprintf(stderr, "need 3 notarizations to happen before notaries can be paid.\n"); + return(0); } - // how many block since last notarisation. - int32_t n = height - notarizedht; + if ( prevnotarizedht == pprevnotarizedht ) + return(0); // cant happen, sanity check. + + // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, + // are them selves actually notarised and cannot be reorged. + int32_t n = prevnotarizedht - pprevnotarizedht; + fprintf(stderr, "blocks since last notarization: %i\n",n); // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. AmountToPay = ASSETCHAINS_NOTARY_PAY*n; - //fprintf(stderr, "AmountToPay.%lu\n",AmountToPay); ret = AmountToPay / notarycount; - fprintf(stderr, "payment per notary.%lu\n",ret); return(ret); } @@ -1846,7 +1850,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar return(0); numSN = numStakedNotaries(staked_pubkeys,staked_era); - // Check the notarisation is valid and get the notarized height to calcualte the payment. + // Check the notarisation is valid. int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len); if ( notarizedheight == 0 ) return(0); @@ -1854,8 +1858,10 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); - // Calcualte the amount to pay. - AmountToPay = komodo_notarypayamount(notarizedheight,NotarisationNotaries.size()); + // Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount. + AmountToPay = komodo_notarypayamount(NotarisationNotaries.size()); + if ( AmountToPay == 0 ) + return(0); // loop over notarisation vins and add transaction to coinbase. // Commented prints here can be used to verify manually the pubkeys match. @@ -1932,7 +1938,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen); return(0); } - } + } else return(0); // if notarypay fails, because the notarisation is not valid, exit now as txNew was not created. // This should never happen, as the notarisation is checked before this function is called. diff --git a/src/komodo_notary.h b/src/komodo_notary.h index dcd99bea1..88a079348 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,14 +452,15 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; - *prevNotarizedHt = sp->prevNOTARIZED_HEIGHT; + *prevNotarizedHt = sp->PNOTARIZED_HEIGHT; + *ppNotarizedHt = sp->PPNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 2f8ba0850..b7a0ddd24 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,prevNOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index 054313a21..283e8ee38 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3284,14 +3284,16 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Do this here before the block is moved to the main block files. if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 ) { - // do a full block scan to get notarisation position and to enforce 1 notarisation is in block only. + // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); - // -1 means that more than 1 notarisation is in a block, or the notarisation is not in order. + // -1 means that the valid notarization isnt in position 1. if ( notarisationTx == -1 ) return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), REJECT_INVALID, "bad-notarization-position"); - // 1 means this block contains a valid notarisation + // 1 means this block contains a valid notarisation and its in position 1. + // its no longer possible for any attempted notarization to be in a block with a valid one! + // if notaries create a notarisation even if its not in this chain it will need to be mined inside its own block! if ( notarisationTx == 1 ) { // Check if the notaries have been paid. @@ -3906,8 +3908,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t prevMoMheight,prevnotarizedht; uint256 notarizedhash,txid; - komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); + int32_t prevMoMheight,prevnotarizedht,prevNotarizedHt; uint256 notarizedhash,txid; + komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4241,8 +4243,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevnotarizedht,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht); + int32_t notarizedht,prevnotarizedht,prevNotarizedHt,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5593,8 +5595,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/miner.cpp b/src/miner.cpp index a0934ce96..36ef947d3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -432,6 +432,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } } + else if ( fNotarisationBlock == true ) + { + // Any attempted notarization needs to be in its own block! + // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. + continue; + } } } } @@ -723,12 +729,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { - fprintf(stderr, ">>>>>MINER NotarisationNotaries.%li\n",NotarisationNotaries.size()); uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen); if ( totalsats == 0 ) { fprintf(stderr, "Could not create notary payment, trying again.\n"); - // invalidnotarisation = pblock->vtx[1].GetHash().ToString(); if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) { LEAVE_CRITICAL_SECTION(cs_main); diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 422d0da18..868956f8a 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,14 +17,14 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABST2") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) STAKED = 3; // These chains have no speical rules at all. else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant ot be actually used for anything important. + STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. doneinit = 1; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index bda9da062..15386d42a 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); From d9ad59f566a33e2d0dba5079704856258a0ec441 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 12 Feb 2019 23:36:31 +0800 Subject: [PATCH 914/951] fix --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d88b53c2a..0ec83579c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1030,7 +1030,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { if (notarisations.size() == 0) return(0); - if ( notarisations.size() >= 1 && notarisations[0] == 1 ) + if ( notarisations.size() == 1 && notarisations[0] == 1 ) return(1); else return(-1); From f993140b2d52a537c8ad45c66f390aa503b19213 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 12:25:01 +0800 Subject: [PATCH 915/951] ORKL --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 868956f8a..c2f902c82 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,7 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "ORKL") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. From abf36fd1e4527a162cd33372ab0810094631f7bd Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 12:25:29 +0800 Subject: [PATCH 916/951] ORKL --- src/notaries_staked.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index 422d0da18..78ab4b11b 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,7 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABST2") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "ORKL") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. From 498e6154a592dd43afecda118bb1a49fc065ba47 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 16:46:15 +0800 Subject: [PATCH 917/951] Add notarypay to eras, for main chain. --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 29 +++++++++++++++++++++-------- src/komodo_defs.h | 4 ++-- src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 24 ++++++++++++++++-------- src/main.cpp | 2 +- src/miner.cpp | 2 +- 7 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0ec83579c..17c98f203 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -885,7 +885,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) break; } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. - if ( !fJustCheck && ASSETCHAINS_NOTARY_PAY != 0 && i > 1) + if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e3e99d7c4..1bf909cf6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1778,8 +1778,21 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); -uint64_t komodo_notarypayamount(int64_t notarycount) +uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) { + int8_t curEra = 0; + // if we have an end block in the first era, find our current era + if ( ASSETCHAINS_ENDSUBSIDY[0] > 1 ) + { + for ( curEra = 0; curEra <= ASSETCHAINS_LASTERA; curEra++ ) + { + if ( ASSETCHAINS_ENDSUBSIDY[curEra] > nHeight || ASSETCHAINS_ENDSUBSIDY[curEra] == 0 ) + break; + } + } + if ( curEra > ASSETCHAINS_LASTERA ) + return(0); + if ( notarycount == 0 ) { fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); @@ -1798,16 +1811,16 @@ uint64_t komodo_notarypayamount(int64_t notarycount) return(0); } if ( prevnotarizedht == pprevnotarizedht ) - return(0); // cant happen, sanity check. + return(0); // cant happen, sanity check. // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, - // are them selves actually notarised and cannot be reorged. + // are them selves actually notarised and cannot be reorged. int32_t n = prevnotarizedht - pprevnotarizedht; - fprintf(stderr, "blocks since last notarization: %i\n",n); // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. - AmountToPay = ASSETCHAINS_NOTARY_PAY*n; + AmountToPay = ASSETCHAINS_NOTARY_PAY[curEra]*n; + fprintf(stderr, "era.%i paying total of %lu for %i blocks\n",curEra,AmountToPay,n); ret = AmountToPay / notarycount; return(ret); } @@ -1859,7 +1872,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar txNew.vout.resize(NotarisationNotaries.size()+1); // Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount. - AmountToPay = komodo_notarypayamount(NotarisationNotaries.size()); + AmountToPay = komodo_notarypayamount(height,NotarisationNotaries.size()); if ( AmountToPay == 0 ) return(0); @@ -1973,7 +1986,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { matches++; total += txout.nValue; - fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]); + //fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]); } else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]); } @@ -2171,7 +2184,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) // the default daemon miner, checks the actual vins so the only way this will fail, is if someone changes the miner, // and then creates txs to the crypto address meeting min sigs and puts it in tx position 1. // If they go through this effort, the block will still fail at connect block, and will be auto purged by the temp file fix. - if ( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() > 1 ) + if ( failed == 0 && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[0].vout.size() > 1 ) { // We check the full validation in ConnectBlock directly to get the amount for coinbase. So just approx here. if ( slowflag == 0 ) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 32fb74dab..09490f3f0 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -40,7 +40,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC; extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER; -extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD, ASSETCHAINS_NOTARY_PAY; +extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD; extern uint64_t ASSETCHAINS_TIMELOCKGTE; extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE; @@ -48,7 +48,7 @@ extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOM extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA; extern bool VERUS_MINTBLOCKS; -extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; +extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 13caee41d..c00247da5 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -69,7 +69,7 @@ uint64_t ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; uint64_t ASSETCHAINS_TIMEUNLOCKFROM = 0, ASSETCHAINS_TIMEUNLOCKTO = 0; uint64_t ASSETCHAINS_LASTERA = 1; -uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS]; +uint64_t ASSETCHAINS_ENDSUBSIDY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_HALVING[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_DECAY[ASSETCHAINS_MAX_ERAS],ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS]; uint8_t ASSETCHAINS_CCDISABLES[256]; #define _ASSETCHAINS_EQUIHASH 0 @@ -97,7 +97,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t ASSETCHAINS_STAKED; -uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_NOTARY_PAY; +uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD; uint32_t KOMODO_INITDONE; char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fd312e527..6e4a09546 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1764,6 +1764,7 @@ void komodo_args(char *argv0) Split(GetArg("-ac_reward",""), ASSETCHAINS_REWARD, 0); Split(GetArg("-ac_halving",""), ASSETCHAINS_HALVING, 0); Split(GetArg("-ac_decay",""), ASSETCHAINS_DECAY, 0); + Split(GetArg("-ac_notarypay",""), ASSETCHAINS_NOTARY_PAY, 0); for ( int i = 0; i < ASSETCHAINS_MAX_ERAS; i++ ) { @@ -1777,6 +1778,11 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY[i] = 0; printf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i); } + if ( ASSETCHAINS_NOTARY_PAY[i] < 64 ) + { + ASSETCHAINS_NOTARY_PAY[i] = 64; + printf("ERA%u: ASSETCHAINS_NOTARY_PAY cant be less than 64. Set to 64.\n", i); + } } MAX_BLOCK_SIGOPS = 60000; @@ -1869,6 +1875,11 @@ void komodo_args(char *argv0) } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) + { + printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n"); + exit(0); + } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); @@ -1894,9 +1905,6 @@ void komodo_args(char *argv0) } else { - ASSETCHAINS_NOTARY_PAY = GetArg("-ac_notarypay",0); - if ( ASSETCHAINS_NOTARY_PAY != 0 ) - printf("Assetchains NOTARY PAY set to %lu sats per notarisation per notary. Cannot work with ac_script or ac_pubkey!\n",ASSETCHAINS_NOTARY_PAY); if ( ASSETCHAINS_COMMISSION != 0 ) { ASSETCHAINS_COMMISSION = 0; @@ -1913,7 +1921,7 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); exit(0); } - if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 ) { fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; @@ -1922,17 +1930,19 @@ void komodo_args(char *argv0) // if we have one era, this should create the same data structure as it used to, same if we increase _MAX_ERAS for ( int i = 0; i <= ASSETCHAINS_LASTERA; i++ ) { - printf("ERA%u: end.%llu reward.%llu halving.%llu decay.%llu\n", i, + printf("ERA%u: end.%llu reward.%llu halving.%llu decay.%llu notarypay.%llu\n", i, (long long)ASSETCHAINS_ENDSUBSIDY[i], (long long)ASSETCHAINS_REWARD[i], (long long)ASSETCHAINS_HALVING[i], - (long long)ASSETCHAINS_DECAY[i]); + (long long)ASSETCHAINS_DECAY[i], + (long long)ASSETCHAINS_NOTARY_PAY[i]); // TODO: Verify that we don't overrun extrabuf here, which is a 256 byte buffer extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY[i]),(void *)&ASSETCHAINS_ENDSUBSIDY[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]); + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); } if (ASSETCHAINS_LASTERA > 0) @@ -2008,8 +2018,6 @@ void komodo_args(char *argv0) } fprintf(stderr," <- CCLIB name\n"); } - if ( ASSETCHAINS_NOTARY_PAY != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY),(void *)&ASSETCHAINS_NOTARY_PAY); } addn = GetArg("-seednode",""); diff --git a/src/main.cpp b/src/main.cpp index 283e8ee38..cd42e109a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3282,7 +3282,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY != 0 && pindex->GetHeight() > 10 ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/miner.cpp b/src/miner.cpp index 36ef947d3..ba946fe58 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -722,7 +722,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout[1].nValue = 0; // timelocks and commissions are currently incompatible due to validation complexity of the combination } - else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) + else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0]; From b9b3afcbe67759298bcacb309dcd3505a7d5cd12 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 17:37:37 +0800 Subject: [PATCH 918/951] notarypay in getinfo --- src/rpc/misc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 15386d42a..2c8d17138 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -82,7 +82,7 @@ extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_MAGIC,ASSETCHAINS_ALGO; extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY; extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; -extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[]; +extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[],ASSETCHAINS_NOTARY_PAY[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; int32_t getera(int now) @@ -287,7 +287,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_LASTERA > 0 ) { - std::string acReward = "", acHalving = "", acDecay = "", acEndSubsidy = ""; + std::string acReward = "", acHalving = "", acDecay = "", acEndSubsidy = "", acNotaryPay = ""; for (int i = 0; i <= ASSETCHAINS_LASTERA; i++) { if (i == 0) @@ -296,6 +296,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) acHalving = std::to_string(ASSETCHAINS_HALVING[i]); acDecay = std::to_string(ASSETCHAINS_DECAY[i]); acEndSubsidy = std::to_string(ASSETCHAINS_ENDSUBSIDY[i]); + acNotaryPay = std::to_string(ASSETCHAINS_NOTARY_PAY[i]); } else { @@ -303,6 +304,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) acHalving += "," + std::to_string(ASSETCHAINS_HALVING[i]); acDecay += "," + std::to_string(ASSETCHAINS_DECAY[i]); acEndSubsidy += "," + std::to_string(ASSETCHAINS_ENDSUBSIDY[i]); + acNotaryPay += "," + std::to_string(ASSETCHAINS_NOTARY_PAY[i]); } } if (ASSETCHAINS_LASTERA > 0) @@ -311,6 +313,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("halving", acHalving)); obj.push_back(Pair("decay", acDecay)); obj.push_back(Pair("endsubsidy", acEndSubsidy)); + obj.push_back(Pair("notarypay", acNotaryPay)); } if ( ASSETCHAINS_COMMISSION != 0 ) From 497302dc75ed5ee52466b928a5fb8d02e3ccd4b1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:04:28 +0800 Subject: [PATCH 919/951] Fix not being able to mine first 3 notarizations. --- src/main.cpp | 20 +++++++++++++++++++- src/miner.cpp | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cd42e109a..eafde8df6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,6 +3248,24 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); +bool check_pprevnotarizedht() +{ + static bool init; + if ( init ) + return(true); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; + uint64_t AmountToPay=0,ret=0; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); + if ( pprevnotarizedht > 0 ) + { + init = true; + return(true); + } + else + return(false); +} + + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3282,7 +3300,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 && check_pprevnotarizedht() ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/miner.cpp b/src/miner.cpp index ba946fe58..a0174a884 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -393,6 +393,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (fNotarisation) { + // Can't make payment until 3 notarizations have happened. + if ( !check_pprevnotarizedht() ) + fNotarisation = false; // check if the notarization found is actually valid. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { From dc343dfd97ea0c4bda74bf7505862f3ac4673eae Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:06:11 +0800 Subject: [PATCH 920/951] fix --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index a0174a884..00270dcd8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,6 +155,7 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); +bool check_pprevnotarizedht(); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { From 2b86a48372ffc41e37200735cdc9422ded6a93bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:19:13 +0800 Subject: [PATCH 921/951] fix --- src/komodo.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 17c98f203..45dc80948 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -38,6 +38,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block); +bool check_pprevnotarizedht(); #include "komodo_structs.h" #include "komodo_globals.h" @@ -885,7 +886,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) break; } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. - if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) + // make sure for first 3 notarizations, that we check all tx in block! + if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 && check_pprevnotarizedht() ) break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); From 695eb871bb8cb0bb7b5bbbabab2f844019cedb8c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 19:52:58 +0800 Subject: [PATCH 922/951] Fix miner --- src/komodo_bitcoind.h | 1 + src/miner.cpp | 82 +++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1bf909cf6..91ffc9043 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1805,6 +1805,7 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) //fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d \n",notarizedht,prevnotarizedht,pprevnotarizedht); // We cannot pay out if 3 notarisation's have not yet happened! + // redundant now... should never happen. if ( pprevnotarizedht == 0 ) { fprintf(stderr, "need 3 notarizations to happen before notaries can be paid.\n"); diff --git a/src/miner.cpp b/src/miner.cpp index 00270dcd8..60c4086dd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -396,52 +396,58 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { // Can't make payment until 3 notarizations have happened. if ( !check_pprevnotarizedht() ) - fNotarisation = false; - // check if the notarization found is actually valid. - if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - // Get the OP_RETURN for the notarisation - uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; - int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); - if ( script[0] == OP_RETURN ) + fNotarisation = false; + fNotarisationBlock = false; + } + else + { + // check if the notarization found is actually valid. + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); - if ( notarizedheight != 0 ) + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) { - if ( last_notarizedheight == 0 ) + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) { - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - last_notarizedheight = notarizedheight; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + if ( last_notarizedheight == 0 ) + { + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + last_notarizedheight = notarizedheight; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + } + else if ( notarizedheight > last_notarizedheight ) + continue; // leave this notarisation for the next block, it will be valid! + else if ( notarizedheight == last_notarizedheight ) + continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! + else + { + // we need to remove the last seen notarzation from block + const CTransaction& Tx = *(vecPriority.front().get<2>()); + TxPriorityCompare comparer(0); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + // add this one as its valid before the other one. + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); + } } - else if ( notarizedheight > last_notarizedheight ) - continue; // leave this notarisation for the next block, it will be valid! - else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else + else if ( fNotarisationBlock == true ) { - // we need to remove the last seen notarzation from block - const CTransaction& Tx = *(vecPriority.front().get<2>()); - TxPriorityCompare comparer(0); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - // add this one as its valid before the other one. - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); + // Any attempted notarization needs to be in its own block! + // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. + continue; } } - else if ( fNotarisationBlock == true ) - { - // Any attempted notarization needs to be in its own block! - // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. - continue; - } } } } From 52450bf20292f572bd7759f944850725d1a36abe Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 14 Feb 2019 21:59:05 +0800 Subject: [PATCH 923/951] fix miner better --- src/komodo.h | 4 +++ src/miner.cpp | 85 +++++++++++++++++++++++---------------------------- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 45dc80948..1e69504d0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -709,6 +709,10 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar { if ( fJustCheck ) return(-2); + // On the first notarization initilise previous previous to 0. + if ( sp->NUM_NPOINTS == 1 ) + sp->PPNOTARIZED_HEIGHT = 0; + sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; diff --git a/src/miner.cpp b/src/miner.cpp index 60c4086dd..e10ba290c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -392,62 +392,53 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if (fNotarisation) + if ( fNotarisation && check_pprevnotarizedht() ) { - // Can't make payment until 3 notarizations have happened. - if ( !check_pprevnotarizedht() ) + // check if the notarization found is actually valid. + if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { - fNotarisation = false; - fNotarisationBlock = false; - } - else - { - // check if the notarization found is actually valid. - if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) + // Get the OP_RETURN for the notarisation + uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; + int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); + if ( script[0] == OP_RETURN ) { - // Get the OP_RETURN for the notarisation - uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0]; - int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); - if ( script[0] == OP_RETURN ) + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) { - int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); - if ( notarizedheight != 0 ) + if ( last_notarizedheight == 0 ) { - if ( last_notarizedheight == 0 ) - { - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - last_notarizedheight = notarizedheight; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); - } - else if ( notarizedheight > last_notarizedheight ) - continue; // leave this notarisation for the next block, it will be valid! - else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else - { - // we need to remove the last seen notarzation from block - const CTransaction& Tx = *(vecPriority.front().get<2>()); - TxPriorityCompare comparer(0); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - // add this one as its valid before the other one. - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); - } + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + last_notarizedheight = notarizedheight; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } - else if ( fNotarisationBlock == true ) + else if ( notarizedheight > last_notarizedheight ) + continue; // leave this notarisation for the next block, it will be valid! + else if ( notarizedheight == last_notarizedheight ) + continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! + else { - // Any attempted notarization needs to be in its own block! - // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. - continue; + // we need to remove the last seen notarzation from block + const CTransaction& Tx = *(vecPriority.front().get<2>()); + TxPriorityCompare comparer(0); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + // add this one as its valid before the other one. + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } } + else if ( fNotarisationBlock == true ) + { + // Any attempted notarization needs to be in its own block! + // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. + continue; + } } } } From d7a122c548c01b9eaa7e4b58694ef332b84c4e94 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 00:13:48 +0800 Subject: [PATCH 924/951] fix reorged notarisation to use the same data points --- src/komodo.h | 8 +++++--- src/komodo_bitcoind.h | 30 +++++++++++++++++++----------- src/komodo_notary.h | 3 ++- src/komodo_structs.h | 2 +- src/main.cpp | 19 +++++++++---------- src/rpc/misc.cpp | 6 +++--- 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 1e69504d0..34051f173 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -267,10 +267,11 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; } + sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth); - printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT); + printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d PPPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,sp->PPPNOTARIZED_HEIGHT); } else if ( func == 'U' ) // deprecated { @@ -711,8 +712,9 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar return(-2); // On the first notarization initilise previous previous to 0. if ( sp->NUM_NPOINTS == 1 ) - sp->PPNOTARIZED_HEIGHT = 0; - + sp->PPPNOTARIZED_HEIGHT = 0; + + sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 91ffc9043..ce6d03076 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,7 +1776,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) { @@ -1799,24 +1799,32 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) return(0); } // fetch notarised height, the previous, and the one before that. - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; + int32_t notarizedht=0,prevMoMheight,prevnotarizedht=0,pprevnotarizedht=0,ppprevnotarizedht=0,n=0; uint256 notarizedhash,txid; uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); - //fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d \n",notarizedht,prevnotarizedht,pprevnotarizedht); + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d ppprevnotarizedht.%d\n",notarizedht,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht); - // We cannot pay out if 3 notarisation's have not yet happened! + // We cannot pay out if 4 notarisation's have not yet happened! // redundant now... should never happen. - if ( pprevnotarizedht == 0 ) + if ( ppprevnotarizedht == 0 ) { - fprintf(stderr, "need 3 notarizations to happen before notaries can be paid.\n"); + fprintf(stderr, "need 4 notarizations to happen before notaries can be paid.\n"); return(0); } if ( prevnotarizedht == pprevnotarizedht ) return(0); // cant happen, sanity check. - - // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, - // are them selves actually notarised and cannot be reorged. - int32_t n = prevnotarizedht - pprevnotarizedht; + + if ( notarizedht == nHeight ) + { + // we need to use the previous previous previous notarized heights, to make sure the payment is the same, if trying to use a reorged nota. + n = ppprevnotarizedht - pprevnotarizedht; + } + else + { + // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, + // are them selves actually notarised and cannot be reorged. + n = prevnotarizedht - pprevnotarizedht; + } // multiply the amount possible to be used for each block by the amount of blocks passed // to get the total posible to be paid for this notarisation. diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 88a079348..5c3372193 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,7 +452,7 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) @@ -461,6 +461,7 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * *txidp = sp->NOTARIZED_DESTTXID; *prevNotarizedHt = sp->PNOTARIZED_HEIGHT; *ppNotarizedHt = sp->PPNOTARIZED_HEIGHT; + *pppNotarizedHt = sp->PPPNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index b7a0ddd24..793957756 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,PPPNOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index eafde8df6..b31a1be80 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3253,10 +3253,9 @@ bool check_pprevnotarizedht() static bool init; if ( init ) return(true); - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; - uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); - if ( pprevnotarizedht > 0 ) + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + if ( ppprevnotarizedht > 0 ) { init = true; return(true); @@ -3926,8 +3925,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t prevMoMheight,prevnotarizedht,prevNotarizedHt; uint256 notarizedhash,txid; - komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4261,8 +4260,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevnotarizedht,prevNotarizedHt,prevMoMheight; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&prevNotarizedHt); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5613,8 +5612,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 2c8d17138..9bc2c0785 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); From 3c605c86a027f5880335211c09cb07b8b999caa0 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 00:19:27 +0800 Subject: [PATCH 925/951] fix mergetoaddress --- 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 c6bf320a2..5996eb870 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5093,7 +5093,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); //fprintf(stderr, "num utxos.%li\n", numUtxos); - if (numUtxos < 1 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From 2172cb6742dcda47fa1c5b6a653c5be0fde1f9ac Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 00:32:44 +0800 Subject: [PATCH 926/951] fix --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e10ba290c..540aee622 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 continue; // leave this notarisation for the next block, it will be valid! else if ( notarizedheight == last_notarizedheight ) continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else + else if ( notarizedheight < last_notarizedheight ) { // we need to remove the last seen notarzation from block const CTransaction& Tx = *(vecPriority.front().get<2>()); @@ -433,12 +433,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } } - else if ( fNotarisationBlock == true ) + else if ( Notarisations > 1 ) { // Any attempted notarization needs to be in its own block! // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } + Notarisations++; } } } From 791d8dc13b4b75800f1f7caf38892ec340e13f2e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 11:01:10 +0800 Subject: [PATCH 927/951] remove dynamic notary pay reward and revert to static amounts, cannot work! --- src/komodo.h | 36 ++++++++++----------------------- src/komodo_bitcoind.h | 46 ++++++++----------------------------------- src/komodo_notary.h | 5 +---- src/komodo_structs.h | 2 +- src/main.cpp | 30 +++++++--------------------- src/miner.cpp | 5 +++-- src/rpc/misc.cpp | 6 +++--- 7 files changed, 33 insertions(+), 97 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 34051f173..82341a369 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -267,11 +267,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; } - sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; - sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; - sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth); - printf("komodo_parsestatefiledata: [%s] NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d PPPNOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,sp->PPPNOTARIZED_HEIGHT); } else if ( func == 'U' ) // deprecated { @@ -701,22 +697,12 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - // If we are checking a reorged notarisation tx we need to return true. So the coinbase can be recreated, otherwise notaries are not paid, - // if a notarisation TX is reorged before the next notarization happens! - if ( fJustCheck && matched != 0 && *notarizedheightp == sp->NOTARIZED_HEIGHT && sp->NOTARIZED_DESTTXID == desttxid && sp->NOTARIZED_HASH == srchash) + // Because of reorgs its not possible to use notarizations that are in order. If its validated pay the notaries! + if ( fJustCheck ) return(-2); if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { - if ( fJustCheck ) - return(-2); - // On the first notarization initilise previous previous to 0. - if ( sp->NUM_NPOINTS == 1 ) - sp->PPPNOTARIZED_HEIGHT = 0; - - sp->PPPNOTARIZED_HEIGHT = sp->PPNOTARIZED_HEIGHT; - sp->PPNOTARIZED_HEIGHT = sp->PNOTARIZED_HEIGHT; - sp->PNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; @@ -727,7 +713,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar } 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 NUM_NPOINTS.%d NOTARIZED.%d PNOTARIZED_HEIGHT.%d PPNOTARIZED_HEIGHT.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,sp->NUM_NPOINTS,sp->NOTARIZED_HEIGHT,sp->PNOTARIZED_HEIGHT,sp->PPNOTARIZED_HEIGHT,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); + printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,sp->NOTARIZED_HEIGHT,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); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -753,8 +739,8 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0); } } - } else if ( fJustCheck ) - return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one! + } //else if ( fJustCheck ) + // return (-3); // if the notarisation is only invalid because its out of order it cannot be mined in a block with a valid one! } else if ( opretlen != 149 && height > 600000 && matched != 0 ) printf("%s validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s len.%d opretlen.%d\n",ccdata.symbol,validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),desttxid.ToString().c_str(),len,opretlen); } @@ -893,7 +879,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. // make sure for first 3 notarizations, that we check all tx in block! - if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 && check_pprevnotarizedht() ) + if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) break; txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); @@ -971,12 +957,11 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); notaryid = komodo_voutupdate(fJustCheck,&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime()); - if ( fJustCheck && (notaryid == -2 || notaryid == -3) ) + if ( fJustCheck && notaryid == -2 ) { - // We see a valid notarisation here, save its location. + // We see a valid notarisation here, save its location. notarisations.push_back(i); } - //fprintf(stderr, "notaryid.%i\n",notaryid); if ( 0 && i > 0 ) { for (k=0; kGetHeight()); if (fJustCheck) { - if (notarisations.size() == 0) + if ( notarisations.size() == 0 ) return(0); if ( notarisations.size() == 1 && notarisations[0] == 1 ) return(1); - else + if ( notarisations.size() > 1 ) return(-1); } else return(0); } - #endif diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ce6d03076..e1ef2c21d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1776,11 +1776,9 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) return(isPOS); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); - uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) { - int8_t curEra = 0; + int8_t curEra = 0; int64_t ret = 0; // if we have an end block in the first era, find our current era if ( ASSETCHAINS_ENDSUBSIDY[0] > 1 ) { @@ -1798,39 +1796,11 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) fprintf(stderr, "komodo_notarypayamount failed num notaries is 0!\n"); return(0); } - // fetch notarised height, the previous, and the one before that. - int32_t notarizedht=0,prevMoMheight,prevnotarizedht=0,pprevnotarizedht=0,ppprevnotarizedht=0,n=0; uint256 notarizedhash,txid; - uint64_t AmountToPay=0,ret=0; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); - fprintf(stderr, "notarizedht.%d prevnotarizedht.%d pprevnotarizedht.%d ppprevnotarizedht.%d\n",notarizedht,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht); - - // We cannot pay out if 4 notarisation's have not yet happened! - // redundant now... should never happen. - if ( ppprevnotarizedht == 0 ) - { - fprintf(stderr, "need 4 notarizations to happen before notaries can be paid.\n"); - return(0); - } - if ( prevnotarizedht == pprevnotarizedht ) - return(0); // cant happen, sanity check. - - if ( notarizedht == nHeight ) - { - // we need to use the previous previous previous notarized heights, to make sure the payment is the same, if trying to use a reorged nota. - n = ppprevnotarizedht - pprevnotarizedht; - } - else - { - // use the previous height and the height before that to guarentee that the notarzations used to calculate these values, - // are them selves actually notarised and cannot be reorged. - n = prevnotarizedht - pprevnotarizedht; - } - - // multiply the amount possible to be used for each block by the amount of blocks passed - // to get the total posible to be paid for this notarisation. - AmountToPay = ASSETCHAINS_NOTARY_PAY[curEra]*n; - fprintf(stderr, "era.%i paying total of %lu for %i blocks\n",curEra,AmountToPay,n); - ret = AmountToPay / notarycount; + // Because of reorgs we cannot use the notarized height value. + // We need to basically guess here and just pay some static amount. + // Has the unwanted effect of varying coin emission, but cannot be helped. + fprintf(stderr, "era.%i paying total of %lu\n",curEra, ASSETCHAINS_NOTARY_PAY[curEra]); + ret = ASSETCHAINS_NOTARY_PAY[curEra] / notarycount; return(ret); } @@ -1852,6 +1822,7 @@ int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *sc } else { + // This should no longer happen. Unless notaries are making actual invalid notarizations. fprintf(stderr, "<<<<< &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len) { // fetch notary pubkey array. - // Need a better/safer way for notaries era, should really be height based rather than timestamp? uint64_t total = 0, AmountToPay = 0; int32_t staked_era; int8_t numSN; uint8_t staked_pubkeys[64][33]; @@ -1880,7 +1850,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar // resize coinbase vouts to number of notary nodes +1 for coinbase itself. txNew.vout.resize(NotarisationNotaries.size()+1); - // Calcualte the amount to pay. If 0, means not enough notarizations to calcuate amount. + // Calcualte the amount to pay according to the current era. AmountToPay = komodo_notarypayamount(height,NotarisationNotaries.size()); if ( AmountToPay == 0 ) return(0); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5c3372193..c4984cee2 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,16 +452,13 @@ int32_t komodo_prevMoMheight() return(0); } -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt) +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) { char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { *hashp = sp->NOTARIZED_HASH; *txidp = sp->NOTARIZED_DESTTXID; - *prevNotarizedHt = sp->PNOTARIZED_HEIGHT; - *ppNotarizedHt = sp->PPNOTARIZED_HEIGHT; - *pppNotarizedHt = sp->PPPNOTARIZED_HEIGHT; *prevMoMheightp = komodo_prevMoMheight(); return(sp->NOTARIZED_HEIGHT); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 793957756..6b7c316b6 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -119,7 +119,7 @@ struct komodo_ccdata struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID,MoM; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,PNOTARIZED_HEIGHT,PPNOTARIZED_HEIGHT,PPPNOTARIZED_HEIGHT,MoMdepth; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,MoMdepth; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; diff --git a/src/main.cpp b/src/main.cpp index b31a1be80..ab95e5b34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,22 +3248,6 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); -bool check_pprevnotarizedht() -{ - static bool init; - if ( init ) - return(true); - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); - if ( ppprevnotarizedht > 0 ) - { - init = true; - return(true); - } - else - return(false); -} - bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { @@ -3299,7 +3283,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 && check_pprevnotarizedht() ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. @@ -3925,8 +3909,8 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { return AbortNode(state, "Failed to read block"); //if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->GetHeight() > 1400000 ) { - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); if ( block.GetHash() == notarizedhash ) { fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight()); @@ -4260,8 +4244,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); if (reorgLength > MAX_REORG_LENGTH) { - int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht,ppprevnotarizedht; uint256 notarizedhash,txid; - notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht,&ppprevnotarizedht); + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); if ( pindexFork->GetHeight() < notarizedht ) { fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht); @@ -5612,8 +5596,8 @@ uint64_t CalculateCurrentUsage() /* Prune a block file (modify associated database entries)*/ bool PruneOneBlockFile(bool tempfile, const int fileNumber) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt; - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr, "pruneblockfile.%i\n",fileNumber); sleep(15); for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) { diff --git a/src/miner.cpp b/src/miner.cpp index 540aee622..539b039c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -392,7 +392,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); - if ( fNotarisation && check_pprevnotarizedht() ) + if ( fNotarisation ) { // check if the notarization found is actually valid. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) @@ -402,6 +402,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size(); if ( script[0] == OP_RETURN ) { + Notarisations++; int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); if ( notarizedheight != 0 ) { @@ -435,11 +436,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } else if ( Notarisations > 1 ) { + fprintf(stderr, "skipping notarizations.%d\n",Notarisations); // Any attempted notarization needs to be in its own block! // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } - Notarisations++; } } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 9bc2c0785..b7f202cb4 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -63,7 +63,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp,int32_t *prevNotarizedHt,int32_t *ppNotarizedHt,int32_t *pppNotarizedHt); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); @@ -164,7 +164,7 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,prevnotarized_height,prevNotarizedHt,pprevNotarizedHt,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -200,7 +200,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid,&prevnotarized_height,&prevNotarizedHt,&pprevNotarizedHt); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); From f577aa00330f4de75bd9899bbe041c26e469f554 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 11:12:17 +0800 Subject: [PATCH 928/951] fix validation --- src/komodo.h | 2 +- src/main.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 82341a369..93e0d9eb2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1025,7 +1025,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) return(0); if ( notarisations.size() == 1 && notarisations[0] == 1 ) return(1); - if ( notarisations.size() > 1 ) + if ( notarisations.size() > 1 || (notarisations.size() == 1 && notarisations[0] != 1) ) return(-1); } else return(0); diff --git a/src/main.cpp b/src/main.cpp index ab95e5b34..66766e795 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,7 +3248,6 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); - bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3288,9 +3287,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. int notarisationTx = komodo_connectblock(true,pindex,*(CBlock *)&block); - // -1 means that the valid notarization isnt in position 1. + // -1 means that the valid notarization isnt in position 1 or there are too many notarizations in this block. if ( notarisationTx == -1 ) - return state.DoS(100, error("ConnectBlock(): Notarisation is not in TX position 1! Invalid Block!"), + return state.DoS(100, error("ConnectBlock(): Notarization is not in TX position 1 or block contains more than 1 notarization! Invalid Block!"), REJECT_INVALID, "bad-notarization-position"); // 1 means this block contains a valid notarisation and its in position 1. // its no longer possible for any attempted notarization to be in a block with a valid one! From 98fe10d12c6cfa925ef60e5425980b3aed0752bf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 14:29:59 +0800 Subject: [PATCH 929/951] enable prints for network hack --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 66766e795..46d259568 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5488,11 +5488,11 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo { pfrom->nBlocksinARow = 0; pfrom->nBlocksinARow2 = 0; - //fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId()); + fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId()); } else { - //fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2); + fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2); return(false); } } From 871b765999694f5943f11bb359cf76fe41867332 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Fri, 15 Feb 2019 17:18:40 +0800 Subject: [PATCH 930/951] fix --- 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 c6bf320a2..5996eb870 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5093,7 +5093,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); //fprintf(stderr, "num utxos.%li\n", numUtxos); - if (numUtxos < 1 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From e6d764b081e3c18d954d3b1538b15a9ee405b789 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 15 Feb 2019 17:20:48 +0800 Subject: [PATCH 931/951] fix miner getting stuck --- src/miner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 539b039c3..aa19c3bd7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -406,13 +406,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); if ( notarizedheight != 0 ) { + //fprintf(stderr, "notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); if ( last_notarizedheight == 0 ) { // this is the first one we see, add it to the block as TX1 NotarisationNotaries = TMP_NotarisationNotaries; dPriority = 1e16; fNotarisationBlock = true; - last_notarizedheight = notarizedheight; fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } else if ( notarizedheight > last_notarizedheight ) @@ -433,6 +433,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fNotarisationBlock = true; fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); } + last_notarizedheight = notarizedheight; } else if ( Notarisations > 1 ) { @@ -441,6 +442,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } + //fprintf(stderr, "BOTTOM: notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); } } } From f6be5ec6480b35deef11c07c7fc1629580c67844 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 16 Feb 2019 16:06:35 +0800 Subject: [PATCH 932/951] LASTH to group1 --- src/miner.cpp | 1 - src/notaries_staked.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index aa19c3bd7..344ef6431 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,7 +155,6 @@ CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); -bool check_pprevnotarizedht(); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c2f902c82..c44d89df2 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -17,7 +17,7 @@ int8_t is_STAKED(const char *chain_name) return(0); if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "ORKL") == 0) ) + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) STAKED = 1; // These chains are allowed coin emissions. else if ( (strncmp(chain_name, "LABS", 4) == 0) ) STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. From 61d7ede6b44b6a3bbf987163e74e4a74dece8f37 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 18 Feb 2019 18:23:47 +0800 Subject: [PATCH 933/951] enable miner only for notary pay, and fix magic values for non notary pay chains. --- src/komodo_utils.h | 8 ++------ src/miner.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6e4a09546..fed8cfcca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1778,11 +1778,6 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY[i] = 0; printf("ERA%u: ASSETCHAINS_DECAY cant be more than 100000000\n", i); } - if ( ASSETCHAINS_NOTARY_PAY[i] < 64 ) - { - ASSETCHAINS_NOTARY_PAY[i] = 64; - printf("ERA%u: ASSETCHAINS_NOTARY_PAY cant be less than 64. Set to 64.\n", i); - } } MAX_BLOCK_SIGOPS = 60000; @@ -1942,7 +1937,8 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); } if (ASSETCHAINS_LASTERA > 0) diff --git a/src/miner.cpp b/src/miner.cpp index 344ef6431..f35fb160c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -251,8 +251,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Now we have the block time, we can get the active notaries. int32_t staked_era = 0; int8_t numSN = 0; uint8_t staked_pubkeys[64][33] = {0}; - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + if ( is_STAKED(ASSETCHAINS_SYMBOL) < 3 ) { + // Only use speical miner for LABS chains in the actual cluster that use notarypay! + // It wouldnt hurt to use it on other chains, but serves little purpose. staked_era = STAKED_era(pblock->nTime); numSN = numStakedNotaries(staked_pubkeys,staked_era); } @@ -393,7 +395,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( fNotarisation ) { - // check if the notarization found is actually valid. + // Special miner for notary pay chains. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation From 986488d139c1eda626c50837a3899e28582bfe3d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 18 Feb 2019 19:55:18 +0800 Subject: [PATCH 934/951] fix format --- src/notaries_staked.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index c44d89df2..5311f8e51 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -12,23 +12,23 @@ extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES; int8_t is_STAKED(const char *chain_name) { - static int8_t STAKED,doneinit; - if ( chain_name[0] == 0 ) - return(0); - if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) + static int8_t STAKED,doneinit; + if ( chain_name[0] == 0 ) + return(0); + if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) + return(STAKED); + if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) + STAKED = 1; // These chains are allowed coin emissions. + else if ( (strncmp(chain_name, "LABS", 4) == 0) ) + STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. + else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) + STAKED = 3; // These chains have no speical rules at all. + else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) + STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. + else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) + STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. + doneinit = 1; return(STAKED); - if ( (strcmp(chain_name, "LABS") == 0) || (strcmp(chain_name, "LABSTH") == 0) ) - STAKED = 1; // These chains are allowed coin emissions. - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; // These chains have no speical rules at all. - else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. - else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. - doneinit = 1; - return(STAKED); }; int32_t STAKED_era(int timestamp) From 8003443417cd7f8f35cb8de12c055aac67ce5099 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 19 Feb 2019 10:16:31 +0800 Subject: [PATCH 935/951] setpubkey fix --- src/komodo.h | 1 - src/wallet/rpcwallet.cpp | 66 +++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 93e0d9eb2..8f4217cc4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -878,7 +878,6 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) break; } // Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check. - // make sure for first 3 notarizations, that we check all tx in block! if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 ) break; txhash = block.vtx[i].GetHash(); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e7b76afc0..4f94ae8a3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5430,50 +5430,54 @@ UniValue setpubkey(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); - char Raddress[18]; + char Raddress[64]; uint8_t pubkey33[33]; - if ( NOTARY_PUBKEY33[0] == 0 ) { - if (strlen(params[0].get_str().c_str()) == 66) { + if ( NOTARY_PUBKEY33[0] == 0 ) + { + if (strlen(params[0].get_str().c_str()) == 66) + { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); pubkey2addr((char *)Raddress,(uint8_t *)pubkey33); - if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) { - result.push_back(Pair("error", "pubkey entered is invalid.")); - } else { - CBitcoinAddress address(Raddress); - bool isValid = address.IsValid(); - if (isValid) + CBitcoinAddress address(Raddress); + bool isValid = address.IsValid(); + if (isValid) + { + CTxDestination dest = address.Get(); + isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; + if ( mine == ISMINE_NO ) + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + else { - CTxDestination dest = address.Get(); - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - if ( mine == ISMINE_NO ) { - result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); - } else { - result.push_back(Pair("ismine", "true")); - std::string notaryname; - if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { - result.push_back(Pair("IsNotary", notaryname)); - IS_KOMODO_NOTARY = 0; - } + result.push_back(Pair("ismine", "true")); + std::string notaryname; + if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) + { + result.push_back(Pair("IsNotary", notaryname)); + IS_KOMODO_NOTARY = 0; } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - USE_EXTERNAL_PUBKEY = 1; - NOTARY_ADDRESS = address.ToString(); - } else { - result.push_back(Pair("error", "pubkey entered is invalid.")); } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; + NOTARY_ADDRESS = address.ToString(); } - } else { - result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + else + result.push_back(Pair("error", "pubkey entered is invalid.")); } - } else { - if ( NOTARY_ADDRESS.empty() ) { + else + result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); + } + else + { + if ( NOTARY_ADDRESS.empty() ) + { pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); NOTARY_ADDRESS.assign(Raddress); } result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { + if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) + { result.push_back(Pair("address", NOTARY_ADDRESS)); result.push_back(Pair("pubkey", NOTARY_PUBKEY)); } From a14c2a2af5ce107988fc0b2fd31a75413746493b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 19 Feb 2019 11:45:14 +0800 Subject: [PATCH 936/951] ? --- 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 4f94ae8a3..1c7114c34 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5466,7 +5466,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); - } + } else { if ( NOTARY_ADDRESS.empty() ) From 70b684eeaacf986ee8438e60426cf65d15de82fa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 19 Feb 2019 12:32:58 +0800 Subject: [PATCH 937/951] add more descriptive print for expired transactions in mempool. --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index de9ad9c9f..6bee5855c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1111,7 +1111,8 @@ bool ContextualCheckTransaction( if (IsExpiredTx(tx, nHeight)) { // Don't increase banscore if the transaction only just expired int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? (dosLevel > 10 ? dosLevel : 10) : 0; - return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired"); + + return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight), REJECT_INVALID, "tx-overwinter-expired"); } } From 536cb5f86d68b8cc9d368986f20ad6c0731fda81 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 21 Feb 2019 20:17:08 +0800 Subject: [PATCH 938/951] geterablockheights RPC --- src/main.cpp | 5 +++-- src/rpc/misc.cpp | 30 ++++++++++++++++++++++++++++-- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6bee5855c..6ad0e613d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1111,8 +1111,9 @@ bool ContextualCheckTransaction( if (IsExpiredTx(tx, nHeight)) { // Don't increase banscore if the transaction only just expired int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? (dosLevel > 10 ? dosLevel : 10) : 0; - - return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight), REJECT_INVALID, "tx-overwinter-expired"); + string strHex = EncodeHexTx(tx); + //fprintf(stderr, "transaction exipred.%s\n",strHex.c_str()); + return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i\n txhex.%s",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight,strHex), REJECT_INVALID, "tx-overwinter-expired"); } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 564d76c9c..a6b0e7923 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -86,10 +86,10 @@ extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING,ASSETCHAINS_STAKED; extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[],ASSETCHAINS_NOTARY_PAY[]; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; -int32_t getera(int now) +int32_t getera(int timestamp) { for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) { - if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) { + if ( timestamp <= STAKED_NOTARIES_TIMESTAMP[i] ) { return(i); } } @@ -163,6 +163,32 @@ UniValue getnotarysendmany(const UniValue& params, bool fHelp) return ret; } +UniValue geterablockheights(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getnotarysendmany\n" + "Returns a JSON object with the first block in each era.\n" + ); + + CBlockIndex *pindex; int8_t lastera,era = 0; UniValue ret(UniValue::VOBJ); + + for (size_t i = 1; i < chainActive.LastTip()->GetHeight(); i++) + { + pindex = chainActive[i]; + era = getera(pindex->nTime)+1; + if ( era > lastera ) + { + char str[16]; + sprintf(str, "%d", era); + ret.push_back(Pair(str,i)); + lastera = era; + } + } + + return(ret); +} + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 89baeddf5..46eb95a25 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -293,6 +293,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "help", &help, true }, { "control", "getiguanajson", &getiguanajson, true }, { "control", "getnotarysendmany", &getnotarysendmany, true }, + { "control", "geterablockheights", &geterablockheights, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpc/server.h b/src/rpc/server.h index 6aedeb254..abd0ea6a8 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -381,6 +381,7 @@ extern UniValue decodeccopret(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); extern UniValue getiguanajson(const UniValue& params, bool fHelp); extern UniValue getnotarysendmany(const UniValue& params, bool fHelp); +extern UniValue geterablockheights(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); From 0f1ceab602d3c3cf48127072a5d39727e1f5b5aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 21 Feb 2019 21:30:39 +0800 Subject: [PATCH 939/951] minsigs = 6. --- src/notaries_staked.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/notaries_staked.h b/src/notaries_staked.h index c30c8f17e..4151e52b6 100644 --- a/src/notaries_staked.h +++ b/src/notaries_staked.h @@ -7,7 +7,7 @@ static const int32_t iguanaPort = 9997; static const int8_t BTCminsigs = 13; -static const int8_t overrideMinSigs = 0; +static const int8_t overrideMinSigs = 6; static const char *iguanaSeeds[8][1] = { {"80.240.17.222"}, From ab4a58ac9c36445d78e990cb7b9369dcf14138b3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 13:43:49 +0800 Subject: [PATCH 940/951] fix getera --- src/rpc/misc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a6b0e7923..43733826d 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -93,6 +93,7 @@ int32_t getera(int timestamp) return(i); } } + return(0) } UniValue getiguanajson(const UniValue& params, bool fHelp) From 9ac98901880a29499aa290be22b1bc2b6d21be4b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 25 Feb 2019 16:08:45 +0800 Subject: [PATCH 941/951] fix --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 43733826d..ef1c8bf5c 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -93,7 +93,7 @@ int32_t getera(int timestamp) return(i); } } - return(0) + return(0); } UniValue getiguanajson(const UniValue& params, bool fHelp) From f76ceced5be31c1483e77a5be26166426a3e9c47 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 11:14:19 +0800 Subject: [PATCH 942/951] make notarypay work with KMD notaries --- src/komodo_bitcoind.h | 33 ++++++++++++++++----------------- src/miner.cpp | 28 ++++++++++++---------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index eafcf16f7..a7dd2027c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -25,6 +25,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); +int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); bool EnsureWalletIsAvailable(bool avoidException); extern bool fRequestShutdown; @@ -1825,8 +1826,6 @@ uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount) return(ret); } -int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); - int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len) { // Check the notarisation is valid, and extract notarised height. @@ -1855,13 +1854,12 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar { // fetch notary pubkey array. uint64_t total = 0, AmountToPay = 0; - int32_t staked_era; int8_t numSN; - uint8_t staked_pubkeys[64][33]; - staked_era = STAKED_era(timestamp); + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, timestamp); + // No point going further, no notaries can be paid. - if ( staked_era == 0 ) + if ( notarypubkeys[0][0] == 0 ) return(0); - numSN = numStakedNotaries(staked_pubkeys,staked_era); // Check the notarisation is valid. int32_t notarizedheight = komodo_getnotarizedheight(timestamp, height, script, len); @@ -1886,7 +1884,7 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &Notar ptr[0] = 33; for (int8_t i=0; i<33; i++) { - ptr[i+1] = staked_pubkeys[NotarisationNotaries[n]][i]; + ptr[i+1] = notarypubkeys[NotarisationNotaries[n]][i]; //fprintf(stderr,"%02x",ptr[i+1]); } ptr[34] = OP_CHECKSIG; @@ -1901,13 +1899,12 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { std::vector NotarisationNotaries; uint32_t timestamp = pblock->nTime; - int32_t staked_era; int8_t numSN; - uint8_t staked_pubkeys[64][33]; - staked_era = STAKED_era(timestamp); + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, timestamp); + // No point going further, no notaries can be paid. - if ( staked_era == 0 ) + if ( notarypubkeys[0][0] == 0 ) return(0); - numSN = numStakedNotaries(staked_pubkeys,staked_era); uint8_t *script; int32_t scriptlen; // Loop over the notarisation and extract the position of the participating notaries in the array of pukeys for this era. @@ -1920,7 +1917,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) { script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 ) NotarisationNotaries.push_back(i); } } @@ -1979,7 +1976,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) // Check the pubkeys match the pubkeys in the notarisation. script = (uint8_t *)&txout.scriptPubKey[0]; scriptlen = (int32_t)txout.scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[NotarisationNotaries[n-1]],33) == 0 ) { // check the value is correct if ( pblock->vtx[0].vout[n].nValue == AmountToPay ) @@ -2196,9 +2193,11 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } // Check min sigs. - if ( pblock->vtx[1].vin.size() < (num_notaries_STAKED[STAKED_era(pblock->nTime)]/5) ) + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + numSN = komodo_notaries(notarypubkeys, height, pblock->nTime) + if ( pblock->vtx[1].vin.size() < numSN/5) ) { - fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,(num_notaries_STAKED[STAKED_era(pblock->nTime)]/5),pblock->vtx[1].vin.size()); + fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5),pblock->vtx[1].vin.size()); return(-1); } } diff --git a/src/miner.cpp b/src/miner.cpp index f35fb160c..0f87a0643 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -152,9 +152,9 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); -int32_t komodo_is_notarytx(const CTransaction& tx); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); +int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -248,15 +248,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } pblock->nTime = GetAdjustedTime(); - // Now we have the block time, we can get the active notaries. - int32_t staked_era = 0; int8_t numSN = 0; - uint8_t staked_pubkeys[64][33] = {0}; - if ( is_STAKED(ASSETCHAINS_SYMBOL) < 3 ) + // Now we have the block time + height, we can get the active notaries. + int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { - // Only use speical miner for LABS chains in the actual cluster that use notarypay! - // It wouldnt hurt to use it on other chains, but serves little purpose. - staked_era = STAKED_era(pblock->nTime); - numSN = numStakedNotaries(staked_pubkeys,staked_era); + // Only use speical miner for notary pay chains. + numSN = komodo_notaries(notarypubkeys, nHeight, pblock->nTime) } CCoinsViewCache view(pcoinsTip); @@ -268,7 +265,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; - bool fPrintPriority = GetBoolArg("-printpriority", true); + bool fPrintPriority = GetBoolArg("-printpriority", false); // This vector will be sorted into a priority queue: vector vecPriority; @@ -302,17 +299,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CAmount nTotalIn = 0; bool fMissingInputs = false; bool fNotarisation = false; - std::vector TMP_NotarisationNotaries = {0}; + std::vector TMP_NotarisationNotaries; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); // burn amount nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. } else { - //int numNotaryVins = 0; TMP_NotarisationNotaries.clear(); bool fToCryptoAddress = false; - if ( numSN != 0 && staked_pubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) + if ( numSN != 0 && notarypubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -361,7 +357,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0]; scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 ) + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 ) { // We can add the index of each notary to vector, and clear it if this notarisation is not valid later on. TMP_NotarisationNotaries.push_back(i); @@ -395,7 +391,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( fNotarisation ) { - // Special miner for notary pay chains. + // Special miner for notary pay chains. Can only enter this if numSN is set higher up. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation @@ -458,7 +454,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 porphan->dPriority = dPriority; porphan->feeRate = feeRate; } - else + else vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } From e3495bf3e9dbd2d226fc4667bffd05e6163d323d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:17:53 +0800 Subject: [PATCH 943/951] remove pointless things --- src/Makefile.am | 21 +++++++-------- src/assetchains.json | 61 ++++++++++++++++++------------------------- src/bitcoin-cli.cpp | 1 - src/cc/dice.cpp | 8 +++--- src/cc/utils.h | 1 - src/coins.h | 8 +++--- src/komodo_bitcoind.h | 8 +++--- src/komodo_utils.h | 12 ++++----- src/main.cpp | 45 ++++++++++++------------------- src/miner.cpp | 2 +- 10 files changed, 70 insertions(+), 97 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c0a2a2e03..a10868135 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,9 +123,8 @@ TESTS = bin_PROGRAMS += komodod #endif -# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli + bin_PROGRAMS += komodo-cli komodo-tx endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility @@ -205,7 +204,7 @@ BITCOIN_CORE_H = \ mruset.h \ net.h \ netbase.h \ - notaries_staked.h \ + notaries_staked.h \ noui.h \ paymentdisclosure.h \ paymentdisclosuredb.h \ @@ -313,7 +312,7 @@ libbitcoin_server_a_SOURCES = \ chain.cpp \ checkpoints.cpp \ crosschain.cpp \ - crosschain_authority.cpp \ + crosschain_authority.cpp \ crypto/haraka.h \ crypto/haraka_portable.h \ crypto/verus_hash.h \ @@ -328,7 +327,7 @@ libbitcoin_server_a_SOURCES = \ metrics.h \ miner.cpp \ net.cpp \ - notaries_staked.cpp \ + notaries_staked.cpp \ noui.cpp \ notarisationdb.cpp \ paymentdisclosure.cpp \ @@ -620,8 +619,8 @@ komodo_cli_LDADD = \ $(EVENT_LIBS) \ $(LIBZCASH) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) if ENABLE_WALLET @@ -629,8 +628,8 @@ wallet_utility_LDADD = \ libbitcoin_wallet.a \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBSECP256K1) \ $(LIBBITCOIN_UTIL) \ $(BOOST_LIBS) \ @@ -639,7 +638,7 @@ wallet_utility_LDADD = \ $(LIBZCASH) \ $(LIBSNARK) \ $(LIBZCASH_LIBS)\ - $(LIBCRYPTOCONDITIONS) + $(LIBCRYPTOCONDITIONS) endif # zcash-tx binary # @@ -679,7 +678,7 @@ libzcash_a_SOURCES = \ zcash/Note.cpp \ zcash/prf.cpp \ zcash/util.cpp \ - zcash/zip32.cpp \ + zcash/zip32.cpp \ zcash/circuit/commitment.tcc \ zcash/circuit/gadget.tcc \ zcash/circuit/merkle.tcc \ diff --git a/src/assetchains.json b/src/assetchains.json index bd07f1fb1..91baf9829 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -136,51 +136,42 @@ "ac_reward": "100000000" }, { - "ac_name": "CFEKED", - "ac_supply": "1000", + "ac_name": "SEC", + "ac_supply": "1000000000", + "ac_cc": "333" + }, + { + "ac_name": "CCL", + "ac_supply": "200000000", "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", "addnode": [ - "195.201.137.5", - "195.201.20.230" + "142.93.136.89", + "195.201.22.89" ] }, { - "ac_name": "CFEKING", - "ac_supply": "1000", - "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", + "ac_name": "PIRATE", + "ac_supply": "0", + "ac_reward": "25600000000", + "ac_halving": "77777", + "ac_private": "1", "addnode": [ - "195.201.137.5", - "195.201.20.230" + "136.243.102.225" ] }, { - "ac_name": "CFEKLF", - "ac_supply": "1000", - "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", + "ac_name": "MGNX", + "ac_supply": "12465003", + "ac_staked": "90", + "ac_reward": "2000000000", + "ac_halving": "525960", + "ac_cc": "2", + "ac_end": "2629800", "addnode": [ - "195.201.137.5", - "195.201.20.230" - ] - }, - { - "ac_name": "CFEKMLT", - "ac_supply": "1000", - "ac_end": "1", - "ac_reward": "1", - "ac_staked": "1", - "ac_cc": "102", - "addnode": [ - "195.201.137.5", - "195.201.20.230" + "142.93.27.180" ] }, { diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 31d3b9e3e..544972586 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -25,7 +25,6 @@ #include "util.h" #include "utilstrencodings.h" - #include #include diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index afd1ff5ac..ab723790f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1213,9 +1213,6 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } else { return(0); } - fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); - entropytxs = n; - return(totalinputs); } bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) @@ -1419,7 +1416,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; if ( bet < 0 ) { - CCerror = "bet must be positive"; + CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); } if ( odds < 2 || odds > 9999 ) @@ -1756,7 +1753,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error in status"; + CCerror = "Diceinit error in status, is your transaction confirmed?"; + fprintf(stderr,"%s\n", CCerror.c_str() ); return(0.); } win = loss = 0; diff --git a/src/cc/utils.h b/src/cc/utils.h index fcbea7f5b..39bce0e95 100644 --- a/src/cc/utils.h +++ b/src/cc/utils.h @@ -20,7 +20,6 @@ #include "version.h" - /* * Serialisation boilerplate */ diff --git a/src/coins.h b/src/coins.h index 6cd5d9933..e0ea7d822 100644 --- a/src/coins.h +++ b/src/coins.h @@ -41,7 +41,7 @@ #include "zcash/IncrementalMerkleTree.hpp" //#include "veruslaunch.h" -/** +/** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs * * Serialized format: @@ -443,7 +443,7 @@ public: class CCoinsViewCache; -/** +/** * A reference to a mutable cache entry. Encapsulating it allows us to run * cleanup code after the modification is finished, and keeping track of * concurrent modifications. @@ -503,7 +503,7 @@ protected: /** * Make mutable so that we can "fill the cache" even from Get-methods - * declared as "const". + * declared as "const". */ mutable uint256 hashBlock; mutable CCoinsMap cacheCoins; @@ -579,7 +579,7 @@ public: //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** + /** * Amount of bitcoins coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a7dd2027c..f23fde7c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1536,7 +1536,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_uint256 bnTarget,arith_uint256 bhash) { CBlockIndex *previndex,*pindex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,PoSperc,txn_count,eligible=0,isPoS = 0,segid; uint64_t value; CTxDestination voutaddress; arith_uint256 POWTarget; - if ( ASSETCHAINS_STAKED == 100 && height <= 100 ) + if ( ASSETCHAINS_STAKED == 100 && height <= 10 ) return(1); BlockMap::const_iterator it = mapBlockIndex.find(pblock->GetHash()); pindex = it != mapBlockIndex.end() ? it->second : NULL; @@ -2194,10 +2194,10 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } // Check min sigs. int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; - numSN = komodo_notaries(notarypubkeys, height, pblock->nTime) - if ( pblock->vtx[1].vin.size() < numSN/5) ) + numSN = komodo_notaries(notarypubkeys, height, pblock->nTime); + if ( pblock->vtx[1].vin.size() < numSN/5 ) { - fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5),pblock->vtx[1].vin.size()); + fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5,pblock->vtx[1].vin.size()); return(-1); } } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 8d6395ac2..2fbb782ce 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1690,7 +1690,7 @@ void komodo_args(char *argv0) IS_KOMODO_NOTARY = 1; KOMODO_MININGTHREADS = 1; mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); - IS_STAKED_NOTARY = -1; + IS_STAKED_NOTARY = -1; fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); break; } @@ -1723,7 +1723,7 @@ void komodo_args(char *argv0) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); } - if ( name.c_str()[0] != 0 ) + if ( name.c_str()[0] != 0 ) { std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0])); @@ -1897,10 +1897,10 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } - else - { - printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); - } + else + { + printf("ASSETCHAINS_FOUNDERS_REWARD set to %ld\n", ASSETCHAINS_FOUNDERS_REWARD); + } /*else if ( ASSETCHAINS_SELFIMPORT.size() == 0 ) { //ASSETCHAINS_OVERRIDE_PUBKEY.clear(); diff --git a/src/main.cpp b/src/main.cpp index 6ad0e613d..ab3a97549 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,6 @@ ******************************************************************************/ #include "main.h" -#include "notaries_staked.h" #include "sodium.h" #include "addrman.h" @@ -1267,35 +1266,23 @@ extern uint8_t NUM_NOTARIES; int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only { - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) - { - if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) - { - for (int32_t i=0; i<=NUM_NOTARIES; i++) - if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 ) - return(1); - } - } - else - { - static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; - int32_t i; - if ( didinit == 0 ) - { - uint8_t pubkey33[33]; - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) - { - if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) - decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); - else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); - pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); - } - didinit = 1; - } - for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) - if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) - return(1); + static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + int32_t i; + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + { + if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) + decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; } + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return(1); return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index 0f87a0643..09ce3fd1a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -253,7 +253,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { // Only use speical miner for notary pay chains. - numSN = komodo_notaries(notarypubkeys, nHeight, pblock->nTime) + numSN = komodo_notaries(notarypubkeys, nHeight, pblock->nTime); } CCoinsViewCache view(pcoinsTip); From 5d8d2753f44d37bb1e077c75218577b2506aef49 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:20:46 +0800 Subject: [PATCH 944/951] fix --- src/Makefile.am | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a10868135..a1d7c8dd3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,8 +123,9 @@ TESTS = bin_PROGRAMS += komodod #endif +# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli komodo-tx + bin_PROGRAMS += komodo-cli endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility @@ -619,8 +620,8 @@ komodo_cli_LDADD = \ $(EVENT_LIBS) \ $(LIBZCASH) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBZCASH_LIBS) if ENABLE_WALLET @@ -628,8 +629,8 @@ wallet_utility_LDADD = \ libbitcoin_wallet.a \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_CRYPTO) \ - $(LIBVERUS_CRYPTO) \ - $(LIBVERUS_PORTABLE_CRYPTO) \ + $(LIBVERUS_CRYPTO) \ + $(LIBVERUS_PORTABLE_CRYPTO) \ $(LIBSECP256K1) \ $(LIBBITCOIN_UTIL) \ $(BOOST_LIBS) \ @@ -638,7 +639,7 @@ wallet_utility_LDADD = \ $(LIBZCASH) \ $(LIBSNARK) \ $(LIBZCASH_LIBS)\ - $(LIBCRYPTOCONDITIONS) + $(LIBCRYPTOCONDITIONS) endif # zcash-tx binary # @@ -678,7 +679,7 @@ libzcash_a_SOURCES = \ zcash/Note.cpp \ zcash/prf.cpp \ zcash/util.cpp \ - zcash/zip32.cpp \ + zcash/zip32.cpp \ zcash/circuit/commitment.tcc \ zcash/circuit/gadget.tcc \ zcash/circuit/merkle.tcc \ From d63ed05d703c804654871ae5e5b349487530709d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:21:39 +0800 Subject: [PATCH 945/951] fix tx --- src/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a1d7c8dd3..d168a328f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,9 +123,8 @@ TESTS = bin_PROGRAMS += komodod #endif -# komodo-tx if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli + bin_PROGRAMS += komodo-cli komodo-tx endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility From c95f1253e337db6adb60dcb8fd1666a935b54eeb Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:22:58 +0800 Subject: [PATCH 946/951] fix dice --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ab723790f..8c17ac184 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1416,7 +1416,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; if ( bet < 0 ) { - CCerror = "Diceinit error in bet, is your transaction confirmed?"; + CCerror = "bet must be positive"; return(""); } if ( odds < 2 || odds > 9999 ) @@ -1426,7 +1426,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "error in Diceinit"; + CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); } if ( bet < minbet || bet > maxbet || odds > maxodds ) From dc30e99e635dab63992be5a3a7a27396483eb282 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:23:31 +0800 Subject: [PATCH 947/951] space --- src/cc/dice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 8c17ac184..1bb44af18 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1425,7 +1425,6 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); } From 096d25df978f1693905c45d5865b403aacf6fce5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 12:49:17 +0800 Subject: [PATCH 948/951] Disable all experminetal/LABS features that are not required. --- src/komodo.h | 3 ++- src/main.cpp | 8 ++++++-- src/rpc/server.cpp | 2 +- src/rpc/server.h | 2 +- src/version.h | 2 +- src/wallet/rpcwallet.cpp | 7 +++++-- src/wallet/wallet.cpp | 3 ++- src/wallet/walletdb.cpp | 18 ------------------ 8 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 8f4217cc4..24a3eb723 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -825,7 +825,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) return(0); } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) + // Wallet Filter. Disabled here. Cant be activated by notaries or pools with some changes. + if ( 0 & is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 ) { staked_era = STAKED_era(pindex->GetBlockTime()); if ( !fJustCheck && staked_era != lastStakedEra ) diff --git a/src/main.cpp b/src/main.cpp index ab3a97549..7658bd4ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5330,7 +5330,9 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C } int nHeight = pindex->GetHeight(); - int32_t usetmp = 1; + // Temp File fix. LABS has been using this for ages with no bad effects. + // Disabled here. Set use tmp to whatever you need to use this for. + int32_t usetmp = 0; if ( IsInitialBlockDownload() ) usetmp = 0; @@ -5468,7 +5470,9 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo komodo_currentheight_set(chainActive.LastTip()->GetHeight()); checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0); bool fRequested = MarkBlockAsReceived(hash); - if ( pfrom && !fRequested && vNodes.size() > 1 ) + // Test thing on LABS to test viability of rejecting a node pushing a chain. + // Supposed to stop malicious forks being pushed. Untested. Disabled incase of problems it may cause. + if ( 0 & pfrom && !fRequested && vNodes.size() > 1 ) { pfrom->nBlocksinARow += 1; if ( pfrom->nBlocksinARow >= 10 ) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 46eb95a25..e8a7d648e 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -561,7 +561,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, +// { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index abd0ea6a8..fcd30d32f 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -353,7 +353,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); +//extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/version.h b/src/version.h index 4056f105d..aab89eea4 100644 --- a/src/version.h +++ b/src/version.h @@ -24,7 +24,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170008; +static const int PROTOCOL_VERSION = 170007; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4ae0b2274..110bbd134 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1030,7 +1030,10 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } -UniValue cleanwallettransactions(const UniValue& params, bool fHelp) + +// for cleaning wallets, many main net notaries are using this to gain a MASSIVE advantage. +// Disabled here. but they can enable it a bit easier now, then using their own forks. +/*UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -1131,7 +1134,7 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) ret.push_back(Pair("remaining_transactons", (int)remaining)); ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); return (ret); -} +} */ UniValue getbalance(const UniValue& params, bool fHelp) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 02467b5d6..d3c1c0f5b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1768,7 +1768,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { - if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + // wallet filter for notary nodes. Disabled! Can be reenabled or customised for any specific use, pools could also use this to prevent wallet dwy attack. + if ( 0 & !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index a1527dcb8..972b2cdf4 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -950,24 +950,6 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) catch (...) { result = DB_CORRUPT; } - - if (!deadTxns.empty()) - { - int32_t reAdded = 0; - BOOST_FOREACH (uint256& hash, deadTxns) { - if (!EraseTx(hash)) - fprintf(stderr, "could not delete tx.%s\n",hash.ToString().c_str()); - uint256 blockhash; CTransaction tx; - if (GetTransaction(hash,tx,blockhash,true)) - { - CWalletTx wtx(pwallet,tx); - pwallet->AddToWallet(wtx, true, NULL); - reAdded++; - } - } - fprintf(stderr, "Cleared %lu corrupted transactions from wallet. Readded %i known transactions.\n",deadTxns.size(),reAdded); - deadTxns.clear(); - } if (!deadTxns.empty()) { From fa0a8e37953c64744f6b4ad5beeaa23241a06147 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 13:19:45 +0800 Subject: [PATCH 949/951] fix build --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 7658bd4ec..01513149c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5472,7 +5472,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo bool fRequested = MarkBlockAsReceived(hash); // Test thing on LABS to test viability of rejecting a node pushing a chain. // Supposed to stop malicious forks being pushed. Untested. Disabled incase of problems it may cause. - if ( 0 & pfrom && !fRequested && vNodes.size() > 1 ) + if ( 0 && pfrom && !fRequested && vNodes.size() > 1 ) { pfrom->nBlocksinARow += 1; if ( pfrom->nBlocksinARow >= 10 ) From 142744f22d18cddaa9378968e501706a7f3be40a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 17:35:07 +0800 Subject: [PATCH 950/951] verushashv1_1, fix walletdb.h, proto version, cleanwallettransactions add --- src/chainparams.cpp | 2 +- src/init.cpp | 4 ++-- src/komodo_bitcoind.h | 6 +++--- src/komodo_defs.h | 2 +- src/komodo_globals.h | 2 +- src/metrics.cpp | 2 +- src/miner.cpp | 4 ++-- src/rpc/server.cpp | 2 +- src/rpc/server.h | 2 +- src/version.h | 2 +- src/wallet-utility.cpp | 2 +- src/wallet/db.h | 2 +- src/wallet/rpcwallet.cpp | 6 ++---- 13 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5fa0007d4..6bfcc0e5c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -297,7 +297,7 @@ void *chainparams_commandline(void *ptr) mainParams.consensus.nPowAveragingWindow = 45; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); } - else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing diff --git a/src/init.cpp b/src/init.cpp index ea8286cd0..6049fb09f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1178,7 +1178,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // set the hash algorithm to use for this chain // Again likely better solution here, than using long IF ELSE. - extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2; + extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1; CVerusHash::init(); CVerusHashV2::init(); if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) @@ -1186,7 +1186,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // initialize VerusHash CBlockHeader::SetVerusHash(); } - else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1) { // initialize VerusHashV2 CBlockHeader::SetVerusHashV2(); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f23fde7c1..dbea7ba12 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1348,7 +1348,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( m+n < 100 ) { // We do actual PoS % at the start. Requires coin distribution in first 10 blocks! - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) percPoS = (percPoS*100) / (m+n); else // This seems to be inverse. The actual PoS % is backwards in the first 100 blocks. @@ -1453,7 +1453,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( blocktime+iter+segid*2 < txtime+minage ) continue; diff = (iter + blocktime - txtime - minage); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) { /*if ( PoSperc < ASSETCHAINS_STAKED ) { @@ -1481,7 +1481,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh if ( iter > 0 ) diff += segid*2; coinage = (value * diff); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) { if ( PoSperc < ASSETCHAINS_STAKED ) { diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 4d89fe416..2c3647b30 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -51,7 +51,7 @@ extern bool VERUS_MINTBLOCKS; extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[]; extern const char *ASSETCHAINS_ALGORITHMS[]; extern int32_t VERUS_MIN_STAKEAGE; -extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV2, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; +extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9c2f1df62..859fada99 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -76,7 +76,7 @@ uint8_t ASSETCHAINS_CCDISABLES[256]; uint32_t ASSETCHAINS_NUMALGOS = 3; uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH; uint32_t ASSETCHAINS_VERUSHASH = 1; -uint32_t ASSETCHAINS_VERUSHASHV2 = 2; +uint32_t ASSETCHAINS_VERUSHASHV1_1 = 2; const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash", "verushash11"}; uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff,0xfffffff}; uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16}; diff --git a/src/metrics.cpp b/src/metrics.cpp index e794ad220..1fa8ebfb5 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -136,7 +136,7 @@ int64_t GetUptime() double GetLocalSolPS() { - if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2) + if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1) { return miningTimer.rate(nHashCount); } diff --git a/src/miner.cpp b/src/miner.cpp index 09ce3fd1a..165adb592 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1436,7 +1436,7 @@ void static BitcoinMiner_noeq() CVerusHashV2Writer ss2 = CVerusHashV2Writer(SER_GETHASH, PROTOCOL_VERSION); ss2 << *((CBlockHeader *)pblock); - if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) extraPtr = ss2.xI64p(); CVerusHashV2 &vh2 = ss2.GetState(); vh2.ClearExtra(); @@ -1459,7 +1459,7 @@ void static BitcoinMiner_noeq() *extraPtr = i; if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH ) vh.ExtraHash((unsigned char *)&hashResult); - else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV2 ) + else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 ) vh2.ExtraHash((unsigned char *)&hashResult); if ( UintToArith256(hashResult) <= hashTarget ) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index e8a7d648e..46eb95a25 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -561,7 +561,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccount", &getaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, -// { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, + { "wallet", "cleanwallettransactions", &cleanwallettransactions, false }, { "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getnewaddress", &getnewaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index fcd30d32f..abd0ea6a8 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -353,7 +353,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp); -//extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); +extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp); extern UniValue getbalance(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); diff --git a/src/version.h b/src/version.h index aab89eea4..64150b740 100644 --- a/src/version.h +++ b/src/version.h @@ -33,7 +33,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 170007; +static const int MIN_PEER_PROTO_VERSION = 170002; static const int STAKEDMIN_PEER_PROTO_VERSION = 170007; //! nTime field added to CAddress, starting with this version; diff --git a/src/wallet-utility.cpp b/src/wallet-utility.cpp index f4041dfbe..655a3cab4 100644 --- a/src/wallet-utility.cpp +++ b/src/wallet-utility.cpp @@ -18,7 +18,7 @@ uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint32_t ASSETCHAINS_EQUIHASH = 0; uint32_t ASSETCHAINS_VERUSHASH = 1; -uint32_t ASSETCHAINS_VERUSHASHV2 = 2; +uint32_t ASSETCHAINS_VERUSHASHV1_1 = 2; uint32_t ASSETCHAINS_ALGO = 0; int32_t ASSETCHAINS_LWMAPOS = 0; int32_t VERUS_BLOCK_POSUNITS = 1000; diff --git a/src/wallet/db.h b/src/wallet/db.h index f7854fe2f..19b9b6079 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -33,7 +33,7 @@ #include -#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" +#include extern unsigned int nWalletDBUpdated; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 110bbd134..f49246995 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1031,9 +1031,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef } -// for cleaning wallets, many main net notaries are using this to gain a MASSIVE advantage. -// Disabled here. but they can enable it a bit easier now, then using their own forks. -/*UniValue cleanwallettransactions(const UniValue& params, bool fHelp) +UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; @@ -1134,7 +1132,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef ret.push_back(Pair("remaining_transactons", (int)remaining)); ret.push_back(Pair("removed_transactions", (int)(txs-remaining))); return (ret); -} */ +} UniValue getbalance(const UniValue& params, bool fHelp) { From e619b775276f94f29bd47d7c6904a7289da252bc Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 26 Feb 2019 19:06:41 +0800 Subject: [PATCH 951/951] fix miner for ac_notarypay. --- src/miner.cpp | 49 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 165adb592..4b5191d06 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -153,7 +153,6 @@ int32_t komodo_is_notarytx(const CTransaction& tx); CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); -int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) @@ -233,8 +232,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetAdjustedTime(); - - int32_t last_notarizedheight = 0; if (proposedTime == nMedianTimePast) { @@ -391,7 +388,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( fNotarisation ) { - // Special miner for notary pay chains. Can only enter this if numSN is set higher up. + // Special miner for notary pay chains. Can only enter this if numSN/notarypubkeys is set higher up. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) { // Get the OP_RETURN for the notarisation @@ -400,46 +397,17 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( script[0] == OP_RETURN ) { Notarisations++; - int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); - if ( notarizedheight != 0 ) + if ( Notarisations > 1 ) { - //fprintf(stderr, "notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); - if ( last_notarizedheight == 0 ) - { - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); - } - else if ( notarizedheight > last_notarizedheight ) - continue; // leave this notarisation for the next block, it will be valid! - else if ( notarizedheight == last_notarizedheight ) - continue; // this shouldnt happen, it would mean there are 2 notarisations for the same block! - else if ( notarizedheight < last_notarizedheight ) - { - // we need to remove the last seen notarzation from block - const CTransaction& Tx = *(vecPriority.front().get<2>()); - TxPriorityCompare comparer(0); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - // add this one as its valid before the other one. - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority replacing notarization %s\n",hash.ToString().c_str(), Tx.GetHash().ToString().c_str()); - } - last_notarizedheight = notarizedheight; - } - else if ( Notarisations > 1 ) - { - fprintf(stderr, "skipping notarizations.%d\n",Notarisations); + fprintf(stderr, "skipping notarization.%d\n",Notarisations); // Any attempted notarization needs to be in its own block! - // If we find a valid one and place it in position 1, an invalid one must wait until the next block to be mined. continue; } - //fprintf(stderr, "BOTTOM: notarizations.%d notarizedheight.%d last_notarizedheight.%d\n",Notarisations,notarizedheight,last_notarizedheight); + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); } } } @@ -447,7 +415,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 { dPriority -= 10; // make sure notarisation is tx[1] in block. - // Need to check this? Tried sapling tx and it was not set to max priotity, maybe missing something. } if (porphan) {