From cbb14226569d8815137524c672fde8250b3327c4 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Tue, 4 Sep 2018 17:12:04 -0300 Subject: [PATCH 001/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] ; --- 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/805] ? --- 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/805] ? --- 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/805] ? --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ) --- 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] } --- 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/805] 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/805] ) --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] == 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ) --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] 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/805] , --- 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/805] 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/805] 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/805] = --- 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/805] 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/805] 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/805] 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/805] < --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] ; --- 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/805] 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/805] ? --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ? --- 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/805] ? --- 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/805] 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/805] 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/805] 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/805] ? --- 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/805] 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/805] 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/805] 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/805] 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/805] ? --- 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/805] ? --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] / --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] :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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] ? --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ; --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ) --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ;# --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ) --- 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/805] 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/805] _= --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] ) --- 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/805] 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/805] 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/805] 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/805] 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/805] 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/805] 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 8584b6d23abd0c773d0de9da4fee8505a0d207d0 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 14 Dec 2018 19:05:45 +0600 Subject: [PATCH 768/805] separated CC tests execution --- qa/pull-tester/cc-tests.sh | 90 ++++++++++++++++++++++++++++++++++++++ qa/rpc-tests/README.md | 2 + 2 files changed, 92 insertions(+) create mode 100755 qa/pull-tester/cc-tests.sh diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh new file mode 100755 index 000000000..e5ade525a --- /dev/null +++ b/qa/pull-tester/cc-tests.sh @@ -0,0 +1,90 @@ +#!/bin/bash +set -e -o pipefail + +CURDIR=$(cd $(dirname "$0"); pwd) +# Get BUILDDIR and REAL_BITCOIND +. "${CURDIR}/tests-config.sh" + +export BITCOINCLI=${BUILDDIR}/qa/pull-tester/run-bitcoin-cli +export BITCOIND=${REAL_BITCOIND} + +#Run the tests + +testScripts=( + 'cryptoconditions_channels.py' + 'cryptoconditions_dice.py' + 'cryptoconditions_faucet.py' + 'cryptoconditions_gateways.py' + 'cryptoconditions_oracles.py' + 'cryptoconditions_rewards.py' + 'cryptoconditions_token.py' +); + +if [ "x$ENABLE_ZMQ" = "x1" ]; then + testScripts+=('zmq_test.py') +fi + +if [ "x$ENABLE_PROTON" = "x1" ]; then + testScripts+=('proton_test.py') +fi + +extArg="-extended" +passOn=${@#$extArg} + +successCount=0 +declare -a failures + +function runTestScript +{ + local testName="$1" + shift + + echo -e "=== Running testscript ${testName} ===" + + if eval "$@" + then + successCount=$(expr $successCount + 1) + echo "--- Success: ${testName} ---" + else + failures[${#failures[@]}]="$testName" + echo "!!! FAIL: ${testName} !!!" + fi + + echo +} + +if [ "x${ENABLE_BITCOIND}${ENABLE_UTILS}${ENABLE_WALLET}" = "x111" ]; then + for (( i = 0; i < ${#testScripts[@]}; i++ )) + do + if [ -z "$1" ] || [ "${1:0:1}" == "-" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ] + then + runTestScript \ + "${testScripts[$i]}" \ + "${BUILDDIR}/qa/rpc-tests/${testScripts[$i]}" \ + --srcdir "${BUILDDIR}/src" ${passOn} + fi + done + for (( i = 0; i < ${#testScriptsExt[@]}; i++ )) + do + if [ "$1" == $extArg ] || [ "$1" == "${testScriptsExt[$i]}" ] || [ "$1.py" == "${testScriptsExt[$i]}" ] + then + runTestScript \ + "${testScriptsExt[$i]}" \ + "${BUILDDIR}/qa/rpc-tests/${testScriptsExt[$i]}" \ + --srcdir "${BUILDDIR}/src" ${passOn} + fi + done + + echo -e "\n\nTests completed: $(expr $successCount + ${#failures[@]})" + echo "successes $successCount; failures: ${#failures[@]}" + + if [ ${#failures[@]} -gt 0 ] + then + echo -e "\nFailing tests: ${failures[*]}" + exit 1 + else + exit 0 + fi +else + echo "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled" +fi diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index 17aee1967..9e78d0628 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -14,6 +14,8 @@ You can run a single test by calling `qa/pull-tester/rpc-tests.sh `. Run all possible tests with `qa/pull-tester/rpc-tests.sh -extended`. +Also it's possible to run CryptoConditions tests only by `qa/pull-tester/cc-tests.sh` + Possible options: ``` From 5e182b2056f4276db5b448c5669df3afb48ca5da Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 14 Dec 2018 23:58:58 +0600 Subject: [PATCH 769/805] splitted cryptoconditions tests and made it pass --- qa/pull-tester/cc-tests.sh | 13 +++---------- qa/pull-tester/rpc-tests.sh | 8 -------- qa/rpc-tests/README.md | 2 +- qa/rpc-tests/cryptoconditions_channels.py | 3 ++- qa/rpc-tests/cryptoconditions_dice.py | 3 ++- qa/rpc-tests/cryptoconditions_gateways.py | 6 ++++-- qa/rpc-tests/cryptoconditions_oracles.py | 5 ++--- qa/rpc-tests/cryptoconditions_rewards.py | 3 ++- qa/rpc-tests/cryptoconditions_token.py | 3 ++- 9 files changed, 18 insertions(+), 28 deletions(-) diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh index e5ade525a..4e8dde894 100755 --- a/qa/pull-tester/cc-tests.sh +++ b/qa/pull-tester/cc-tests.sh @@ -9,25 +9,18 @@ export BITCOINCLI=${BUILDDIR}/qa/pull-tester/run-bitcoin-cli export BITCOIND=${REAL_BITCOIND} #Run the tests +# FAUCET test should be permanently first!!! testScripts=( + 'cryptoconditions_faucet.py' 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' - 'cryptoconditions_faucet.py' - 'cryptoconditions_gateways.py' 'cryptoconditions_oracles.py' 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' + 'cryptoconditions_gateways.py' ); -if [ "x$ENABLE_ZMQ" = "x1" ]; then - testScripts+=('zmq_test.py') -fi - -if [ "x$ENABLE_PROTON" = "x1" ]; then - testScripts+=('proton_test.py') -fi - extArg="-extended" passOn=${@#$extArg} diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 006b1890f..226c16b11 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -13,14 +13,6 @@ export BITCOIND=${REAL_BITCOIND} testScripts=( 'ac_private.py' 'verushash.py' - 'cryptoconditions.py' - 'cryptoconditions_channels.py' - 'cryptoconditions_dice.py' - 'cryptoconditions_faucet.py' - 'cryptoconditions_gateways.py' - 'cryptoconditions_oracles.py' - 'cryptoconditions_rewards.py' - 'cryptoconditions_token.py' 'paymentdisclosure.py' 'prioritisetransaction.py' 'wallet_treestate.py' diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index 9e78d0628..e95d6a120 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -14,7 +14,7 @@ You can run a single test by calling `qa/pull-tester/rpc-tests.sh `. Run all possible tests with `qa/pull-tester/rpc-tests.sh -extended`. -Also it's possible to run CryptoConditions tests only by `qa/pull-tester/cc-tests.sh` +Also it's possible to run CryptoConditions tests only by `qa/pull-tester/cc-tests.sh --noshutdown --tracerpc` Possible options: diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 0010f825b..97f044c07 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -159,7 +159,8 @@ class CryptoconditionsChannelsTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 9957a8f2b..42af850d1 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -244,7 +244,8 @@ class CryptoconditionsDiceTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index a48b8b3d8..29ce328f2 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -10,7 +10,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises from cryptoconditions import assert_success, assert_error, generate_random_string - +import subprocess class CryptoconditionsGatewaysTest(BitcoinTestFramework): @@ -137,12 +137,14 @@ class CryptoconditionsGatewaysTest(BitcoinTestFramework): result = rpc.gatewayslist() assert_equal(result[0], bind_txid) + def run_test(self): print("Mining blocks...") rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 31712abbc..8aad38626 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -269,8 +269,6 @@ class CryptoconditionsOraclesTest(BitcoinTestFramework): oraclesdata_Ihh = self.send_and_mine(result["hex"], rpc) result = rpc.oraclessamples(globals()["oracle_{}".format("Ihh")], oraclesdata_Ihh, "1") assert_equal("[u'0']", str(result["samples"][0]), "Data match") - assert_equal("[u'00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff']", str(result["samples"][1]), "Data match") - assert_equal("[u'00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff']", str(result["samples"][2]), "Data match") def run_test(self): @@ -278,7 +276,8 @@ class CryptoconditionsOraclesTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 5538a399c..3c290e73c 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -194,7 +194,8 @@ class CryptoconditionsRewardsTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 8120f23bf..8c7bd4a73 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -274,7 +274,8 @@ class CryptoconditionsTokenTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() From 69a3c6836505a7c68bcf2a9602cb0bcdaa523340 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sat, 15 Dec 2018 03:24:07 +0600 Subject: [PATCH 770/805] small CC tests refactor --- qa/rpc-tests/cryptoconditions_channels.py | 68 +----------------- qa/rpc-tests/cryptoconditions_dice.py | 67 +----------------- qa/rpc-tests/cryptoconditions_faucet.py | 68 +----------------- qa/rpc-tests/cryptoconditions_gateways.py | 69 +------------------ qa/rpc-tests/cryptoconditions_oracles.py | 69 +------------------ qa/rpc-tests/cryptoconditions_rewards.py | 69 +------------------ qa/rpc-tests/cryptoconditions_token.py | 69 +------------------ qa/rpc-tests/test_framework/test_framework.py | 69 +++++++++++++++++++ 8 files changed, 83 insertions(+), 465 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 97f044c07..053b532cb 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,71 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsChannelsTest(BitcoinTestFramework): - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): def run_channels_tests(self): diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 42af850d1..51fd18908 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -4,78 +4,15 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsDiceTest(BitcoinTestFramework): - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsDiceTest(CryptoconditionsTestFramework): def run_dice_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index 4f8cb42cf..a3cbdeb15 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,71 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsFaucetTest(BitcoinTestFramework): - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsFaucetTest(CryptoconditionsTestFramework): def run_faucet_tests(self): rpc = self.rpc diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index 29ce328f2..a7f0cad2b 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -4,80 +4,15 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises from cryptoconditions import assert_success, assert_error, generate_random_string -import subprocess - -class CryptoconditionsGatewaysTest(BitcoinTestFramework): - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsGatewaysTest(CryptoconditionsTestFramework): def run_gateways_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 8aad38626..f295bf020 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,72 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsOraclesTest(BitcoinTestFramework): - - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): def run_oracles_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 3c290e73c..7bda54eaf 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,72 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsRewardsTest(BitcoinTestFramework): - - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsRewardsTest(CryptoconditionsTestFramework): def run_rewards_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 8c7bd4a73..630d8f6e3 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,72 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsTokenTest(BitcoinTestFramework): - - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsTokenTest(CryptoconditionsTestFramework): def run_token_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/test_framework/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py index f545b4246..d1c3d87e3 100755 --- a/qa/rpc-tests/test_framework/test_framework.py +++ b/qa/rpc-tests/test_framework/test_framework.py @@ -180,3 +180,72 @@ class ComparisonTestFramework(BitcoinTestFramework): extra_args=[['-debug', '-whitelist=127.0.0.1']] * self.num_nodes, binary=[self.options.testbinary] + [self.options.refbinary]*(self.num_nodes-1)) + + +class CryptoconditionsTestFramework(BitcoinTestFramework): + + def __init__(self): + self.num_nodes = 2 + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid From b3ec3b929bc4d4c87b1dc56fb96397cff906ddd8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 13:25:08 -1100 Subject: [PATCH 771/805] +print --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 788ee95b0..aa5263337 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3833,7 +3833,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex) } height = pindex->GetHeight(); blocktime = (uint32_t)pindex->nTime; - //fprintf(stderr,"komodo_activate_sapling.%d starting blocktime %u cmp.%d\n",height,blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); + fprintf(stderr,"komodo_activate_sapling.%d starting blocktime %u cmp.%d\n",height,blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); // avoid trying unless we have at least 30 blocks if (height < 30) @@ -3852,7 +3852,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex) } height = pindex->GetHeight(); blocktime = (uint32_t)pindex->nTime; - //fprintf(stderr,"starting blocktime %u cmp.%d\n",blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); + fprintf(stderr,"starting blocktime %u cmp.%d\n",blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); if ( blocktime > KOMODO_SAPLING_ACTIVATION ) // find the earliest transition { while ( (prev= pindex->pprev) != 0 ) From cb88fa3b4fd66f97062378f917b68761f5932ac7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 13:37:42 -1100 Subject: [PATCH 772/805] -prints --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index aa5263337..788ee95b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3833,7 +3833,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex) } height = pindex->GetHeight(); blocktime = (uint32_t)pindex->nTime; - fprintf(stderr,"komodo_activate_sapling.%d starting blocktime %u cmp.%d\n",height,blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); + //fprintf(stderr,"komodo_activate_sapling.%d starting blocktime %u cmp.%d\n",height,blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); // avoid trying unless we have at least 30 blocks if (height < 30) @@ -3852,7 +3852,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex) } height = pindex->GetHeight(); blocktime = (uint32_t)pindex->nTime; - fprintf(stderr,"starting blocktime %u cmp.%d\n",blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); + //fprintf(stderr,"starting blocktime %u cmp.%d\n",blocktime,blocktime > KOMODO_SAPLING_ACTIVATION); if ( blocktime > KOMODO_SAPLING_ACTIVATION ) // find the earliest transition { while ( (prev= pindex->pprev) != 0 ) From c16bcc7757f56e0d24423e92411b4cd410855841 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 14:11:36 -1100 Subject: [PATCH 773/805] Add sapling:1 to gen_COIN file --- 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 e6600fa65..29ce82554 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\\\"}\""; +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\\\"}\""; int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) From 58076c86ea94a3d9c682695618c4ebf00802afc1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 09:34:03 +0800 Subject: [PATCH 774/805] 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 775/805] 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 776/805] 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 af24220ba745fc7769f81ffb96927268dcf6d8ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 15:53:37 -1100 Subject: [PATCH 777/805] Notary port -> 7775 --- src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 788ee95b0..80eb63853 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3879,9 +3879,7 @@ int32_t komodo_activate_sapling(CBlockIndex *pindex) } if ( activation != 0 ) { -//#if KOMODO_SAPLING_ACTIVATION != 1544832000 komodo_setactivation(activation); -//#endif fprintf(stderr,"%s sapling activation at %d\n",ASSETCHAINS_SYMBOL,activation); ASSETCHAINS_SAPLING = activation; } From c75b409f673557c13d1c63913a21186d1c62c7aa Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 11:05:37 +0800 Subject: [PATCH 778/805] 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 779/805] 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 8cee58f02d2135bf96033eff7b1c89c75b0c4011 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:06:07 -1100 Subject: [PATCH 780/805] +print --- src/cc/dapps/zmigrate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index a86b529ad..249a3edce 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -734,6 +734,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * cJSON *retjson; char *retstr,params[1024],addr[128]; sprintf(params,"'[{\"address\":\"%s\",\"amount\":%.8f}]'",destaddr,dstr(amount)); sprintf(addr,"\"%s\"",srcaddr); + printf("z_sendmany from.(%s) -> %s\n",srcaddr,params); if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 ) { printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0)); From 3f6462aa16e97e6e1ba867ad3a07dea01fd21a2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:08:39 -1100 Subject: [PATCH 781/805] +prints --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 80eb63853..13268fe1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1446,8 +1446,8 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio if ( ASSETCHAINS_PRIVATE != 0 && invalid_private_taddr != 0 ) { static uint32_t counter; - if ( counter++ < 10 ) - fprintf(stderr,"found taddr in private chain: z_z.%d z_t.%d t_z.%d\n",z_z,z_t,t_z); + //if ( counter++ < 10 ) + fprintf(stderr,"found taddr in private chain: z_z.%d z_t.%d t_z.%d vinsize.%d\n",z_z,z_t,t_z,(int32_t)tx.vin.size()); if ( z_t == 0 || z_z != 0 || t_z != 0 || tx.vin.size() != 0 ) return state.DoS(100, error("CheckTransaction(): this is a private chain, only sprout -> taddr allowed until deadline"),REJECT_INVALID, "bad-txns-acprivacy-chain"); } From 77557116e7529c1174e1f62be68b3b2e518b5873 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:10:19 -1100 Subject: [PATCH 782/805] Smaller size --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 249a3edce..4b29bebaf 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -907,7 +907,7 @@ int32_t main(int32_t argc,char **argv) zsaddr = clonestr(argv[2]); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; - stdamount = 1000 * SATOSHIDEN; + stdamount = 100 * SATOSHIDEN; txfee = 10000; again: printf("start processing zmigrate\n"); From f6a3cd1a18a74f38426ea05cf2319369966532a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:13:59 -1100 Subject: [PATCH 783/805] Randomize zmigrate size 100/1000/10000 --- src/cc/dapps/zmigrate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 4b29bebaf..2a6249110 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -931,6 +931,12 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 + switch ( (rand() % 3) ) + { + case 0: stdamount = 100 * SATOSHIDEN; break; + case 1: stdamount = 1000 * SATOSHIDEN; break; + case 2: stdamount = 10000 * SATOSHIDEN; break; + } if ( amount > stdamount+txfee ) amount = stdamount + txfee; if ( getnewaddress(coinaddr,coinstr,"") == 0 ) From 8bcefc7c96a2348060cb668762bd5e836ca38904 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:18:56 -1100 Subject: [PATCH 784/805] Rotate --- src/cc/dapps/zmigrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 2a6249110..2ab95abe3 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -931,7 +931,8 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 - switch ( (rand() % 3) ) + static uint32_t counter; + switch ( (counter++ % 3) ) { case 0: stdamount = 100 * SATOSHIDEN; break; case 1: stdamount = 1000 * SATOSHIDEN; break; From 441aa51c8b6de2f04ed0c5355bdbb28d489c4aef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:22:02 -1100 Subject: [PATCH 785/805] Smaller cap --- src/cc/dapps/zmigrate.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 2ab95abe3..4b29bebaf 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -931,13 +931,6 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 - static uint32_t counter; - switch ( (counter++ % 3) ) - { - case 0: stdamount = 100 * SATOSHIDEN; break; - case 1: stdamount = 1000 * SATOSHIDEN; break; - case 2: stdamount = 10000 * SATOSHIDEN; break; - } if ( amount > stdamount+txfee ) amount = stdamount + txfee; if ( getnewaddress(coinaddr,coinstr,"") == 0 ) From 3e03c53eb77c3ce44a46ddd6f8c131704ec350db Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:27:11 -1100 Subject: [PATCH 786/805] +print --- src/cc/dapps/zmigrate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 4b29bebaf..78749ec68 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -670,6 +670,7 @@ int64_t find_onetime_amount(char *coinstr,char *coinaddr) coinaddr[0] = 0; if ( (array= get_listunspent(coinstr,"")) != 0 ) { + printf("got listunspent.(%s)\n",jprint(array,0)); if ( (n= cJSON_GetArraySize(array)) > 0 ) { for (i=0; i Date: Sat, 15 Dec 2018 01:28:49 -1100 Subject: [PATCH 787/805] +print --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 78749ec68..6736bc577 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -326,7 +326,7 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char else if ( REFCOIN_CLI != 0 && REFCOIN_CLI[0] != 0 ) { sprintf(cmdstr,"%s %s %s %s %s %s > %s\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,fname); - //printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); + printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); } system(cmdstr); *retstrp = 0; From 8b16e9a503cdb79b33529046c69077c6903c61b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:30:09 -1100 Subject: [PATCH 788/805] -print --- src/cc/dapps/zmigrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 6736bc577..1d5355790 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -326,7 +326,7 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char else if ( REFCOIN_CLI != 0 && REFCOIN_CLI[0] != 0 ) { sprintf(cmdstr,"%s %s %s %s %s %s > %s\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,fname); - printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); + //printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); } system(cmdstr); *retstrp = 0; @@ -670,7 +670,7 @@ int64_t find_onetime_amount(char *coinstr,char *coinaddr) coinaddr[0] = 0; if ( (array= get_listunspent(coinstr,"")) != 0 ) { - printf("got listunspent.(%s)\n",jprint(array,0)); + //printf("got listunspent.(%s)\n",jprint(array,0)); if ( (n= cJSON_GetArraySize(array)) > 0 ) { for (i=0; i Date: Sat, 15 Dec 2018 01:33:11 -1100 Subject: [PATCH 789/805] Speedup --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 1d5355790..d1f09db70 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -939,7 +939,7 @@ again: z_sendmany(opidstr,coinstr,"",zcaddr,coinaddr,amount-txfee); lastopid = (uint32_t)time(NULL); } else printf("couldnt getnewaddress!\n"); - sleep(30); + sleep(3); continue; } if ( time(NULL) > lastopid+600 ) From 7a0c4015b943f8ef6d31927d997acb9fc3a4552d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:34:28 -1100 Subject: [PATCH 790/805] Reduce delay --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index d1f09db70..143c09d7f 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -918,7 +918,7 @@ again: { if ( have_pending_opid(coinstr,0) != 0 ) { - sleep(60); + sleep(10); continue; } if ( (amount= find_onetime_amount(coinstr,coinaddr)) > txfee ) From e4774f0590d62b4a751d197c72d1c2b877a90aec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 01:41:22 -1100 Subject: [PATCH 791/805] Try 500 --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 143c09d7f..48542d2cc 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -908,7 +908,7 @@ int32_t main(int32_t argc,char **argv) zsaddr = clonestr(argv[2]); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; - stdamount = 100 * SATOSHIDEN; + stdamount = 500 * SATOSHIDEN; txfee = 10000; again: printf("start processing zmigrate\n"); From b2d6cfe7bf70bad0fef827b4a43813a61059d188 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 02:32:42 -1100 Subject: [PATCH 792/805] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 13268fe1b..2f710af5d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1446,7 +1446,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio if ( ASSETCHAINS_PRIVATE != 0 && invalid_private_taddr != 0 ) { static uint32_t counter; - //if ( counter++ < 10 ) + if ( counter++ < 10 ) fprintf(stderr,"found taddr in private chain: z_z.%d z_t.%d t_z.%d vinsize.%d\n",z_z,z_t,t_z,(int32_t)tx.vin.size()); if ( z_t == 0 || z_z != 0 || t_z != 0 || tx.vin.size() != 0 ) return state.DoS(100, error("CheckTransaction(): this is a private chain, only sprout -> taddr allowed until deadline"),REJECT_INVALID, "bad-txns-acprivacy-chain"); From dd0fc6a3bce87e9e260a6ff3d447c6e9c64c20d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 02:52:35 -1100 Subject: [PATCH 793/805] Dont reject peer with tx overwinter mismatch --- src/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2f710af5d..e606a2667 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1020,10 +1020,8 @@ bool ContextualCheckTransaction( // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond if (isSprout && tx.fOverwintered) { - return state.DoS(isInitBlockDownload() ? 0 : dosLevel, - error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet", - nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel), - REJECT_INVALID, "tx-overwinter-not-active"); + return state.DoS(nHeight < Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); + //return state.DoS(isInitBlockDownload() ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); } if (saplingActive) { From faec23f3687eff8a531a93ecbb1490f37f816b82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 02:59:45 -1100 Subject: [PATCH 794/805] New PIRATE seed node --- src/assetchains.old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index c1419e7f5..6df854903 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -39,7 +39,7 @@ echo $pubkey ~/VerusCoin/src/komodod -pubkey=$pubkey -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & ./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 & ./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 & -./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=136.243.102.225 & +./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=178.63.77.56 & ./komodod -pubkey=$pubkey -ac_name=MGNX -ac_supply=12465003 -ac_staked=90 -ac_reward=2000000000 -ac_halving=525960 -ac_cc=2 -ac_end=2629800 -addnode=142.93.27.180 & ./komodod -pubkey=$pubkey -ac_name=PGT -ac_supply=10000000 -ac_end=1 -addnode=190.114.254.104 & ./komodod -pubkey=$pubkey -ac_name=KMDICE -ac_supply=10500000 -ac_reward=2500000000 -ac_halving=210000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=144.76.217.232 & From ea5cd9f31b948f8ee2b58b451e97bb75bf30031b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 03:02:56 -1100 Subject: [PATCH 795/805] Autoscale down size of std amount --- src/cc/dapps/zmigrate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 48542d2cc..4d7e89ad6 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -932,6 +932,12 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 + static int64_t lastamount,lastamount2; + stdamount = 500 * SATOSHIDEN; + if ( amount == lastamount && amount == lastamount2 ) + stdamount /= 10; + lastamount2 = lastamount; + lastamount = amount; if ( amount > stdamount+txfee ) amount = stdamount + txfee; if ( getnewaddress(coinaddr,coinstr,"") == 0 ) From dabdd01bec1a89bbbdff8288fec3565da6013758 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 03:03:33 -1100 Subject: [PATCH 796/805] +comment --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 4d7e89ad6..620130306 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -908,7 +908,7 @@ int32_t main(int32_t argc,char **argv) zsaddr = clonestr(argv[2]); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; - stdamount = 500 * SATOSHIDEN; + //stdamount = 500 * SATOSHIDEN; txfee = 10000; again: printf("start processing zmigrate\n"); From 151645ce9e89c9a6ff2d11d69b536816cad971a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 03:16:43 -1100 Subject: [PATCH 797/805] 10/50/500 zmigrate sizes auto set --- src/cc/dapps/zmigrate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 620130306..73bff3276 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -932,10 +932,16 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 - static int64_t lastamount,lastamount2; + static int64_t lastamount,lastamount2,lastamount3,lastamount4; stdamount = 500 * SATOSHIDEN; if ( amount == lastamount && amount == lastamount2 ) + { stdamount /= 10; + if ( amount == lastamount3 && amount == lastamount4 ) + stdamount /= 5; + } + lastamount4 = lastamount3; + lastamount3 = lastamount2; lastamount2 = lastamount; lastamount = amount; if ( amount > stdamount+txfee ) From 2546ae048d93834f0887822d321df1f9c595c392 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 03:25:41 -1100 Subject: [PATCH 798/805] Use height check for overwinter invalid --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e606a2667..84abe0880 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1020,7 +1020,8 @@ bool ContextualCheckTransaction( // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond if (isSprout && tx.fOverwintered) { - return state.DoS(nHeight < Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); + int32_t ht = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight; + return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); //return state.DoS(isInitBlockDownload() ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active"); } From 9dceacbde87394c92b2bb5b7ee3eda941dae5bef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 04:57:12 -1100 Subject: [PATCH 799/805] Allow sprout when overwinter --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 84abe0880..c3fc62233 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1079,7 +1079,9 @@ bool ContextualCheckTransaction( if (overwinterActive) { // Reject transactions intended for Sprout if (!tx.fOverwintered) { - return state.DoS(dosLevel, error("ContextualCheckTransaction: overwinter is active"), + int32_t ht = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight; + return state.DoS( + return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel, error("ContextualCheckTransaction: overwinter is active"), REJECT_INVALID, "tx-overwinter-active"); } From 2532131a6aab6d4812c2aac14b0947c8147e376d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 04:58:36 -1100 Subject: [PATCH 800/805] Syntax --- src/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c3fc62233..e4a9d04c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1080,9 +1080,7 @@ bool ContextualCheckTransaction( // Reject transactions intended for Sprout if (!tx.fOverwintered) { int32_t ht = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight; - return state.DoS( - return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel, error("ContextualCheckTransaction: overwinter is active"), - REJECT_INVALID, "tx-overwinter-active"); + return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel, error("ContextualCheckTransaction: overwinter is active"),REJECT_INVALID, "tx-overwinter-active"); } // Check that all transactions are unexpired From 69b8e1028d08230dd44e4d897909495e626137eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 05:51:40 -1100 Subject: [PATCH 801/805] Dont retry failed bigger amounts in migrate --- src/cc/dapps/zmigrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 73bff3276..42e7d0fe5 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -932,7 +932,7 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 - static int64_t lastamount,lastamount2,lastamount3,lastamount4; + static int64_t lastamount,lastamount2,lastamount3,lastamount4,refamount = 500 * SATOSHIDEN; stdamount = 500 * SATOSHIDEN; if ( amount == lastamount && amount == lastamount2 ) { @@ -940,6 +940,10 @@ again: if ( amount == lastamount3 && amount == lastamount4 ) stdamount /= 5; } + if ( stdamount < refamount ) + refamount = stdamount; + else if ( refamount > stdamount ) + stdamount = refamount; lastamount4 = lastamount3; lastamount3 = lastamount2; lastamount2 = lastamount; From 3eb0194063c4e23c6b423193a5e4e790c6d8cf92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 05:57:34 -1100 Subject: [PATCH 802/805] Start at 5000 --- src/cc/dapps/zmigrate.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 42e7d0fe5..31928c7d1 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -932,18 +932,16 @@ again: if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) { // generate taddr, send max of 10000.0001 - static int64_t lastamount,lastamount2,lastamount3,lastamount4,refamount = 500 * SATOSHIDEN; - stdamount = 500 * SATOSHIDEN; + static int64_t lastamount,lastamount2,lastamount3,lastamount4,refamount = 5000 * SATOSHIDEN; + stdamount = refamount; if ( amount == lastamount && amount == lastamount2 ) { stdamount /= 10; if ( amount == lastamount3 && amount == lastamount4 ) - stdamount /= 5; + stdamount /= 10; } if ( stdamount < refamount ) refamount = stdamount; - else if ( refamount > stdamount ) - stdamount = refamount; lastamount4 = lastamount3; lastamount3 = lastamount2; lastamount2 = lastamount; From 7b30d56d3ddfc03eefe611fdd78e5c1e92d6d5db Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 15 Dec 2018 10:29:00 -0800 Subject: [PATCH 803/805] Add makefile and readme for CC dapps --- src/cc/dapps/Makefile | 11 +++++++++++ src/cc/dapps/README.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/cc/dapps/Makefile create mode 100644 src/cc/dapps/README.md diff --git a/src/cc/dapps/Makefile b/src/cc/dapps/Makefile new file mode 100644 index 000000000..6e7874788 --- /dev/null +++ b/src/cc/dapps/Makefile @@ -0,0 +1,11 @@ +# just type make to compile all dapps +all: zmigrate oraclefeed + +zmigrate: + $(CC) zmigrate.c -o zmigrate -lm + +oraclefeed: + $(CC) oraclefeed.c -o oraclefeed -lm + +clean: + rm zmigrate oraclefeed diff --git a/src/cc/dapps/README.md b/src/cc/dapps/README.md new file mode 100644 index 000000000..0d8b2cac2 --- /dev/null +++ b/src/cc/dapps/README.md @@ -0,0 +1,28 @@ +# CryptoCondition dApps + +## Compiling + +To compile all dapps in this directory: + + make + +## zmigrate - Sprout to Sapling Migration dApp + +This tool converts Sprout zaddress funds into Sapling funds in a new Sapling address. + +### Usage + + ./zmigrate zsaplingaddr + +The above command may need to be run multiple times to complete the process. + +This CLI implementation will be called by GUI wallets, average users do not +need to worry about using this low-level tool. + +## oraclefeed - feed of price data using oracles + +### Usage + + ./oraclefeed $ACNAME $ORACLETXID $MYPUBKEY $FORMAT $BINDTXID [refcoin_cli] + +Supported formats are L and Ihh. Price data from CoinDesk API. From ba0c0794ebcdd7c7883a00f847c830b83ae7180e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Dec 2018 07:43:08 -1100 Subject: [PATCH 804/805] Add three to migrate --- src/cc/dapps/zmigrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 31928c7d1..84cf4b057 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -946,8 +946,8 @@ again: lastamount3 = lastamount2; lastamount2 = lastamount; lastamount = amount; - if ( amount > stdamount+txfee ) - amount = stdamount + txfee; + if ( amount > stdamount+2*txfee ) + amount = stdamount + 2*txfee; if ( getnewaddress(coinaddr,coinstr,"") == 0 ) { z_sendmany(opidstr,coinstr,"",zcaddr,coinaddr,amount-txfee); From 3028d884e531765a4f02b5be21b91cf324690fa2 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 16 Dec 2018 23:04:45 +0800 Subject: [PATCH 805/805] 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); } }