Merge pull request #43 from StakedChain/mastertest

Mastertest
This commit is contained in:
blackjok3rtt
2018-11-09 20:46:24 +08:00
committed by GitHub
40 changed files with 687 additions and 421 deletions

View File

@@ -9,15 +9,16 @@ This is the official Komodo sourcecode repository based on https://github.com/jl
## Development Resources ## Development Resources
- Komodo Website: [https://komodoplatform.com/](https://komodoplatform.com/) - Komodo Website: [https://komodoplatform.com](https://komodoplatform.com/)
- Komodo Blockexplorer: [https://kmdexplorer.io//](https://https://kmdexplorer.io/) - Komodo Blockexplorer: [https://kmdexplorer.io](https://kmdexplorer.io/)
- Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/) - Komodo Discord: [https://komodoplatform.com/discord](https://komodoplatform.com/discord)
- Forum: [https://forum.komodoplatform.com](https://forum.komodoplatform.com/)
- Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com) - Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com)
- Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home) - Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home)
- Knowledgebase & How-to: [https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages](https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages) - Knowledgebase & How-to: [https://support.komodoplatform.com/en/support/solutions](https://support.komodoplatform.com/en/support/solutions)
- API references: [http://docs.komodoplatform.com/](http://docs.komodoplatform.com/) - API references & Dev Documentation: [https://docs.komodoplatform.com](https://docs.komodoplatform.com/)
- Blog: [http://blog.komodoplatform.com/](http://blog.komodoplatform.com/) - Blog: [https://blog.komodoplatform.com](https://blog.komodoplatform.com/)
- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf) - Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/whitepaper)
- Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0) - Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0)
## List of Komodo Platform Technologies ## List of Komodo Platform Technologies

View File

@@ -246,8 +246,8 @@ obj/build.h: FORCE
libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
# server: zcashd # server: zcashd
libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) -DSERVER
libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DSEVER
libbitcoin_server_a_SOURCES = \ libbitcoin_server_a_SOURCES = \
sendalert.cpp \ sendalert.cpp \
addrman.cpp \ addrman.cpp \

View File

@@ -10,7 +10,6 @@ komodo_test_SOURCES = \
test-komodo/test_coinimport.cpp \ test-komodo/test_coinimport.cpp \
test-komodo/test_eval_bet.cpp \ test-komodo/test_eval_bet.cpp \
test-komodo/test_eval_notarisation.cpp \ test-komodo/test_eval_notarisation.cpp \
test-komodo/test_crosschain.cpp \
test-komodo/test_parse_notarisation.cpp test-komodo/test_parse_notarisation.cpp
komodo_test_CPPFLAGS = $(komodod_CPPFLAGS) komodo_test_CPPFLAGS = $(komodod_CPPFLAGS)

2
src/ac/dion Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
./komodo-cli -ac_name=DION $1 $2 $3 $4 $5 $6

2
src/ac/kmdice Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
./komodo-cli -ac_name=KMDICE $1 $2 $3 $4 $5 $6

2
src/ac/pgt Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6

View File

@@ -57,5 +57,36 @@
"195.201.137.5", "195.201.137.5",
"195.201.20.230" "195.201.20.230"
] ]
},
{
"ac_name": "PGT",
"ac_supply": "10000000",
"ac_end": "1",
"addnode": [
"190.114.254.104"
]
},
{
"ac_name": "KMDICE",
"ac_supply": "10500000",
"ac_reward": "2500000000",
"ac_halving": "210000",
"ac_cc": "2",
"addressindex": "1",
"spentindex": "1",
"addnode": [
"144.76.217.232"
]
},
{
"ac_name": "DION",
"ac_supply": "3900000000",
"ac_reward": "22260000000",
"ac_staked": "100",
"ac_cc": "1",
"ac_end": "4300000000",
"addnode": [
"51.75.124.34"
]
} }
] ]

View File

@@ -41,3 +41,6 @@ echo $pubkey
./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=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=136.243.102.225 &
./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=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 &
./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 &

View File

@@ -10,6 +10,7 @@
#include "util.h" #include "util.h"
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <stdio.h> #include <stdio.h>
@@ -77,6 +78,8 @@ public:
#include "komodo_notary.h" #include "komodo_notary.h"
#include "notaries_staked.cpp" #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) 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)
{ {

View File

@@ -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 all of the above are the standard bitcoin vout types and there should be plenty of materials about it
Encrypted by a verified device 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. 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 but it gets more interesting
each CC script has an evalcode 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 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
@@ -55,9 +55,11 @@ extern std::string CCerror;
#define SMALLVAL 0.000000000000001 #define SMALLVAL 0.000000000000001
#define MIN_NOTARIZATION_CONFIRMS 2 #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; }; 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; typedef union _bits256 bits256;
#endif
struct CC_utxo struct CC_utxo
{ {
uint256 txid; uint256 txid;
@@ -149,6 +151,7 @@ bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t n
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
std::vector<uint8_t> Mypubkey(); std::vector<uint8_t> Mypubkey();
bool Myprivkey(uint8_t myprivkey[]); bool Myprivkey(uint8_t myprivkey[]);
bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
int64_t CCduration(int32_t &numblocks,uint256 txid); int64_t CCduration(int32_t &numblocks,uint256 txid);
bool isCCTxNotarizedConfirmed(uint256 txid); bool isCCTxNotarizedConfirmed(uint256 txid);
// CCtx // CCtx

View File

@@ -655,7 +655,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK
return(totalinputs); 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,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; 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<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > 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); fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN);
entropytxs = n;
return(totalinputs); return(totalinputs);
} }
@@ -826,7 +827,9 @@ UniValue DiceInfo(uint256 diceid)
result.push_back(Pair("timeoutblocks",timeoutblocks)); result.push_back(Pair("timeoutblocks",timeoutblocks));
cp = CCinit(&C,EVAL_DICE); cp = CCinit(&C,EVAL_DICE);
dicepk = GetUnspendable(cp,0); dicepk = GetUnspendable(cp,0);
funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,diceid); 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); sprintf(numstr,"%.8f",(double)funding/COIN);
result.push_back(Pair("funding",numstr)); result.push_back(Pair("funding",numstr));
return(result); return(result);
@@ -955,7 +958,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet
fprintf(stderr,"%s\n", CCerror.c_str() ); fprintf(stderr,"%s\n", CCerror.c_str() );
return(""); 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 ) if ( myIsutxo_spentinmempool(entropytxid,0) != 0 )
{ {

View File

@@ -164,17 +164,6 @@ bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data)
return true; return true;
} }
/*
* Get MoMoM corresponding to a notarisation tx hash (on assetchain)
*/
bool Eval::GetProofRoot(uint256 kmdNotarisationHash, uint256 &momom) const
{
std::pair<uint256,NotarisationData> out;
if (!GetNextBacknotarisation(kmdNotarisationHash, out)) return false;
momom = out.second.MoMoM;
return true;
}
uint32_t Eval::GetAssetchainsCC() const uint32_t Eval::GetAssetchainsCC() const
{ {

View File

@@ -103,7 +103,6 @@ public:
virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const; virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const;
virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const; virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const;
virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const; virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const;
virtual bool GetProofRoot(uint256 kmdNotarisationHash, uint256 &momom) const;
virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const; virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
virtual uint32_t GetAssetchainsCC() const; virtual uint32_t GetAssetchainsCC() const;
virtual std::string GetAssetchainsSymbol() const; virtual std::string GetAssetchainsSymbol() const;

View File

@@ -16,6 +16,7 @@
#include "cc/eval.h" #include "cc/eval.h"
#include "cc/utils.h" #include "cc/utils.h"
#include "importcoin.h" #include "importcoin.h"
#include "crosschain.h"
#include "primitives/transaction.h" #include "primitives/transaction.h"
@@ -75,14 +76,8 @@ bool Eval::ImportCoin(const std::vector<uint8_t> params, const CTransaction &imp
// Check proof confirms existance of burnTx // Check proof confirms existance of burnTx
{ {
uint256 momom, target; uint256 target = proof.second.Exec(burnTx.GetHash());
if (!GetProofRoot(proof.first, momom)) if (!CheckMoMoM(proof.first, target))
return Invalid("coudnt-load-momom");
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()))
return Invalid("momom-check-fail"); return Invalid("momom-check-fail");
} }

View File

@@ -20,6 +20,7 @@
#include "version.h" #include "version.h"
/* /*
* Serialisation boilerplate * Serialisation boilerplate
*/ */

View File

@@ -103,8 +103,9 @@ template <typename IsTarget>
int ScanNotarisationsFromHeight(int nHeight, const IsTarget f, Notarisation &found) int ScanNotarisationsFromHeight(int nHeight, const IsTarget f, Notarisation &found)
{ {
int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height()); int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height());
int start = std::max(nHeight, 1);
for (int h=nHeight; h<limit; h++) { for (int h=start; h<limit; h++) {
NotarisationsInBlock notarisations; NotarisationsInBlock notarisations;
if (!GetBlockNotarisations(*chainActive[h]->phashBlock, notarisations)) if (!GetBlockNotarisations(*chainActive[h]->phashBlock, notarisations))
@@ -255,6 +256,38 @@ bool GetNextBacknotarisation(uint256 kmdNotarisationTxid, Notarisation &out)
} }
bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom)
{
/*
* Given a notarisation hash and an MoMoM. Backnotarisations may arrive out of order
* or multiple in the same block. So dereference the notarisation hash to the corresponding
* backnotarisation and scan around the kmdheight to see if the MoMoM is a match.
* This is a sledgehammer approach...
*/
Notarisation bn;
if (!GetBackNotarisation(kmdNotarisationHash, bn))
return false;
// Need to get block height of that backnotarisation
EvalRef eval;
CBlockIndex block;
CTransaction tx;
if (!eval->GetTxConfirmed(bn.first, tx, block)){
fprintf(stderr, "Can't get height of backnotarisation, this should not happen\n");
return false;
}
Notarisation nota;
auto checkMoMoM = [&](Notarisation &nota) {
return nota.second.MoMoM == momom;
};
return (bool) ScanNotarisationsFromHeight(block.nHeight-100, checkMoMoM, nota);
}
/* /*
* On assetchain * On assetchain
* in: txid * in: txid

View File

@@ -27,7 +27,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
void CompleteImportTransaction(CTransaction &importTx); void CompleteImportTransaction(CTransaction &importTx);
/* On assetchain */ /* On assetchain */
bool GetNextBacknotarisation(uint256 txid, std::pair<uint256,NotarisationData> &bn); bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom);
#endif /* CROSSCHAIN_H */ #endif /* CROSSCHAIN_H */

2
src/fiat/dion Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
./komodo-cli -ac_name=DION $1 $2 $3 $4 $5 $6

2
src/fiat/kmdice Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
./komodo-cli -ac_name=KMDICE $1 $2 $3 $4 $5 $6

2
src/fiat/pgt Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6

View File

@@ -797,6 +797,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys
void komodo_connectblock(CBlockIndex *pindex,CBlock& block) void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
{ {
static int32_t hwmheight; static int32_t hwmheight;
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; 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; 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; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count;
@@ -809,6 +811,26 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
return; return;
} }
//fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); //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 && NOTARY_PUBKEY33[0] != 0 )
{
if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 )
{
IS_KOMODO_NOTARY = 0;
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);
}
}
}
lastStakedEra = staked_era;
}
numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime()); numnotaries = komodo_notaries(pubkeys,pindex->nHeight,pindex->GetBlockTime());
calc_rmd160_sha256(rmd160,pubkeys[0],33); calc_rmd160_sha256(rmd160,pubkeys[0],33);
if ( pindex->nHeight > hwmheight ) if ( pindex->nHeight > hwmheight )
@@ -831,9 +853,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
txn_count = block.vtx.size(); txn_count = block.vtx.size();
for (i=0; i<txn_count; i++) for (i=0; i<txn_count; i++)
{ {
if ((is_STAKED(ASSETCHAINS_SYMBOL) != 0) && (STAKED_era(pindex->GetBlockTime()) == 0)) { if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 && staked_era == 0 ) {
printf("ERA 0 SKIP %s\n",ASSETCHAINS_SYMBOL); // in era gap no point checking any invlaid notarisations.
continue; break;
} }
txhash = block.vtx[i].GetHash(); txhash = block.vtx[i].GetHash();
numvouts = block.vtx[i].vout.size(); numvouts = block.vtx[i].vout.size();

View File

@@ -29,9 +29,8 @@ uint64_t komodo_paxtotal();
int32_t komodo_longestchain(); int32_t komodo_longestchain();
uint64_t komodo_maxallowed(int32_t baseid); uint64_t komodo_maxallowed(int32_t baseid);
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
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_ELECTION_GAP 2000 //((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100)
#define KOMODO_ASSETCHAIN_MAXLEN 65 #define KOMODO_ASSETCHAIN_MAXLEN 65
@@ -45,17 +44,18 @@ struct komodo_state KOMODO_STATES[34];
#define _COINBASE_MATURITY 100 #define _COINBASE_MATURITY 100
int COINBASE_MATURITY = _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,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,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
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,ASSETCHAINS_TXPOW;
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; 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];
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1;
uint32_t ASSETCHAINS_MAGIC = 2387029918; uint32_t ASSETCHAINS_MAGIC = 2387029918;
uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; 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; uint32_t KOMODO_INITDONE;
char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; char KMDUSERPASS[8192],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;

View File

@@ -22,9 +22,6 @@
#define KOMODO_MAINNET_START 178999 #define KOMODO_MAINNET_START 178999
//extern const char *notaries_STAKED[][2];
//extern const int num_notaries_STAKED;
const char *Notaries_genesis[][2] = const char *Notaries_genesis[][2] =
{ {
{ "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
@@ -207,15 +204,13 @@ const char *Notaries_elected1[][2] =
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) 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 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; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 )
timestamp = komodo_heightstamp(height); timestamp = komodo_heightstamp(height);
else if ( ASSETCHAINS_SYMBOL[0] == 0 ) 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 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 (is_STAKED(ASSETCHAINS_SYMBOL) == 0)
{ {
@@ -226,8 +221,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if ( did0 == 0 ) if ( did0 == 0 )
{ {
n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
for (i=0; i<n0; i++) for (i=0; i<n0; i++) {
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
}
did0 = 1; did0 = 1;
} }
memcpy(pubkeys,elected_pubkeys0,n0 * 33); memcpy(pubkeys,elected_pubkeys0,n0 * 33);
@@ -240,8 +236,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if ( did1 == 0 ) if ( did1 == 0 )
{ {
n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1)); n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
for (i=0; i<n1; i++) for (i=0; i<n1; i++) {
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
}
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1); fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1);
did1 = 1; did1 = 1;
@@ -252,74 +249,16 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
} }
} }
else 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) if (timestamp != 0)
{
staked_era = STAKED_era(timestamp);
if (staked_era == 1)
{ {
if (didstaked1 == 0) int32_t staked_era; int8_t numSN;
{ uint8_t staked_pubkeys[64][33];
ns1 = num_notaries_STAKED1; staked_era = STAKED_era(timestamp);
for (i=0; i<ns1; i++) numSN = numStakedNotaries(staked_pubkeys,staked_era);
decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); memcpy(pubkeys,staked_pubkeys,numSN * 33);
didstaked1 = 1; return(numSN);
didstaked2 = 0;
didstaked3 = 0;
didstaked4 = 0;
printf("%s IS A STAKED CHAIN and is era 1 \n",ASSETCHAINS_SYMBOL);
}
memcpy(pubkeys,staked_pubkeys1,ns1 * 33);
return(ns1);
} else if (staked_era == 2)
{
if (didstaked2 == 0)
{
ns2 = num_notaries_STAKED2;
for (i=0; i<ns2; i++)
decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]);
didstaked2 = 1;
didstaked3 = 0;
didstaked4 = 0;
printf("%s IS A STAKED CHAIN and is era 2 \n",ASSETCHAINS_SYMBOL);
}
memcpy(pubkeys,staked_pubkeys2,ns2 * 33);
return(ns2);
} else if (staked_era == 3)
{
if (didstaked3 == 0)
{
ns3 = num_notaries_STAKED3;
for (i=0; i<ns3; i++)
decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]);
didstaked3 = 1;
didstaked4 = 0;
printf("%s IS A STAKED CHAIN and is era 3 \n",ASSETCHAINS_SYMBOL);
}
memcpy(pubkeys,staked_pubkeys3,ns3 * 33);
return(ns3);
} else if (staked_era == 4)
{
if (didstaked4 == 0)
{
ns4 = num_notaries_STAKED4;
for (i=0; i<ns4; i++)
decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]);
didstaked4 = 1;
printf("%s IS A STAKED CHAIN and is era 4 \n",ASSETCHAINS_SYMBOL);
}
memcpy(pubkeys,staked_pubkeys4,ns4 * 33);
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.
//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);
} }
}
} }
htind = height / KOMODO_ELECTION_GAP; htind = height / KOMODO_ELECTION_GAP;

View File

@@ -47,10 +47,11 @@
#define KOMODO_KVBINARY 2 #define KOMODO_KVBINARY 2
#define KOMODO_KVDURATION 1440 #define KOMODO_KVDURATION 1440
#define KOMODO_ASSETCHAIN_MAXLEN 65 #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; }; 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; 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; }; 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; typedef union _bits320 bits320;

View File

@@ -1479,6 +1479,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\\\"}\""; 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\\\"}\"";
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp)
{ {
int32_t i,notaryid; int32_t i,notaryid;
@@ -1504,7 +1505,14 @@ void komodo_args(char *argv0)
extern int64_t MAX_MONEY; extern int64_t MAX_MONEY;
extern const char *Notaries_elected1[][2]; 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; 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_KOMODO_NOTARY = GetBoolArg("-notary", false);
IS_STAKED_NOTARY = GetArg("-stakednotary", -1);
if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) {
fprintf(stderr, "Cannot be STAKED and KMD notary at the same time!\n");
exit(0);
}
MIN_RECV_SATS = GetArg("-mintxvalue",-1);
WHITELIST_ADDRESS = GetArg("-whitelistaddress","");
if ( GetBoolArg("-gen", false) != 0 ) if ( GetBoolArg("-gen", false) != 0 )
KOMODO_MININGTHREADS = GetArg("-genproclimit",1); KOMODO_MININGTHREADS = GetArg("-genproclimit",1);
else KOMODO_MININGTHREADS = -1; else KOMODO_MININGTHREADS = -1;
@@ -1512,7 +1520,7 @@ void komodo_args(char *argv0)
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n"); fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
DONATION_PUBKEY = GetArg("-donation", ""); DONATION_PUBKEY = GetArg("-donation", "");
NOTARY_PUBKEY = GetArg("-pubkey", ""); NOTARY_PUBKEY = GetArg("-pubkey", "");
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
{ {
USE_EXTERNAL_PUBKEY = 1; USE_EXTERNAL_PUBKEY = 1;
if ( IS_KOMODO_NOTARY == 0 ) if ( IS_KOMODO_NOTARY == 0 )
@@ -1521,13 +1529,13 @@ void komodo_args(char *argv0)
if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 ) if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 )
{ {
IS_KOMODO_NOTARY = 1; IS_KOMODO_NOTARY = 1;
IS_STAKED_NOTARY = -1;
fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]);
break; break;
} }
} }
//KOMODO_PAX = 1; }
} //else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name","");
name = GetArg("-ac_name","");
if ( argv0 != 0 ) if ( argv0 != 0 )
{ {
len = (int32_t)strlen(argv0); len = (int32_t)strlen(argv0);
@@ -1606,7 +1614,7 @@ void komodo_args(char *argv0)
ASSETCHAINS_SUPPLY = 1000000; ASSETCHAINS_SUPPLY = 1000000;
printf("ASSETCHAINS_STREAM is set with no supply, setting supply at 1,000,000 coins. \n"); 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 || ASSETCHAINS_TXPOW != 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 || ASSETCHAINS_TXPOW != 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]); 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; extraptr = extrabuf;

View File

@@ -1045,25 +1045,39 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,
} }
} }
extern char NOTARYADDRS[64][36];
extern uint8_t NUM_NOTARIES;
int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only
{ {
static int32_t didinit; static char notaryaddrs[17 + 1][64]; if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 )
int32_t i; {
if ( didinit == 0 ) if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) {
{ for (int32_t i=0; i<=NUM_NOTARIES; i++)
uint8_t pubkey33[33]; if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 )
for (i=0; i<=17; i++) return(1);
{ }
if ( i < 17 ) }
decode_hex(pubkey33,33,(char *)notaries_STAKED1[i][1]); else
else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); {
pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64];
} int32_t i;
didinit = 1; if ( didinit == 0 )
} {
for (i=0; i<=17; i++) 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 ) if ( strcmp(coinaddr,notaryaddrs[i]) == 0 )
return(1); return(1);
}
return(0); return(0);
} }
@@ -1217,6 +1231,24 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
} }
} }
if ( ASSETCHAINS_TXPOW != 0 && tx.vjoinsplit.size() == 0 )
{
// genesis coinbase 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
uint256 txid = tx.GetHash();
if ( ((ASSETCHAINS_TXPOW & 2) != 0 && iscoinbase != 0) || ((ASSETCHAINS_TXPOW & 1) != 0 && iscoinbase == 0) )
{
if ( ((uint8_t *)&txid)[0] != 0 || ((uint8_t *)&txid)[31] != 0 )
{
uint256 genesistxid = uint256S("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
if ( txid != genesistxid )
{
fprintf(stderr,"private chain iscoinbase.%d invalid txpow.%d txid.%s\n",iscoinbase,ASSETCHAINS_TXPOW,txid.GetHex().c_str());
return state.DoS(100, error("CheckTransaction(): this is a txpow chain, must have 0x00 ends"),REJECT_INVALID, "bad-txns-actxpow-chain");
}
}
}
}
// Ensure input values do not exceed MAX_MONEY // Ensure input values do not exceed MAX_MONEY
// We have not resolved the txin values at this stage, // We have not resolved the txin values at this stage,
// but we do know what the joinsplits claim to add // but we do know what the joinsplits claim to add

View File

@@ -180,11 +180,11 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals);
/** Unregister a network node */ /** Unregister a network node */
void UnregisterNodeSignals(CNodeSignals& nodeSignals); void UnregisterNodeSignals(CNodeSignals& nodeSignals);
/** /**
* Process an incoming block. This only returns after the best known valid * 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 * block is made active. Note that it does not, however, guarantee that the
* specific block passed to it has been checked for validity! * 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[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] 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. * @param[in] pblock The block we want to process.
@@ -640,7 +640,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
/** /**
* Check transaction inputs, and make sure any * Check transaction inputs, and make sure any
* pay-to-script-hash transactions are evaluating IsStandard scripts * pay-to-script-hash transactions are evaluating IsStandard scripts
* *
* Why bother? To avoid denial-of-service attacks; an attacker * Why bother? To avoid denial-of-service attacks; an attacker
* can submit a standard HASH... OP_EQUAL transaction, * can submit a standard HASH... OP_EQUAL transaction,
* which will get accepted into blocks. The redemption * which will get accepted into blocks. The redemption
@@ -649,14 +649,14 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
* DUP CHECKSIG DROP ... repeated 100 times... OP_1 * DUP CHECKSIG DROP ... repeated 100 times... OP_1
*/ */
/** /**
* Check for standard transaction types * Check for standard transaction types
* @param[in] mapInputs Map of previous transactions that have outputs we're spending * @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @return True if all inputs (scriptSigs) use only standard transaction forms * @return True if all inputs (scriptSigs) use only standard transaction forms
*/ */
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, uint32_t consensusBranchId); bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, uint32_t consensusBranchId);
/** /**
* Count ECDSA signature operations the old-fashioned (pre-0.6) way * Count ECDSA signature operations the old-fashioned (pre-0.6) way
* @return number of sigops this transaction's outputs will produce when spent * @return number of sigops this transaction's outputs will produce when spent
* @see CTransaction::FetchInputs * @see CTransaction::FetchInputs
@@ -665,7 +665,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx);
/** /**
* Count ECDSA signature operations in pay-to-script-hash inputs. * Count ECDSA signature operations in pay-to-script-hash inputs.
* *
* @param[in] mapInputs Map of previous transactions that have outputs we're spending * @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 * @return maximum number of sigops required to validate this transaction's inputs
* @see CTransaction::FetchInputs * @see CTransaction::FetchInputs
@@ -732,9 +732,9 @@ bool IsExpiredTx(const CTransaction &tx, int nBlockHeight);
*/ */
bool CheckFinalTx(const CTransaction &tx, int flags = -1); bool CheckFinalTx(const CTransaction &tx, int flags = -1);
/** /**
* Closure representing one script verification * 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 class CScriptCheck
{ {
@@ -916,6 +916,8 @@ extern CBlockTreeDB *pblocktree;
*/ */
int GetSpendHeight(const CCoinsViewCache& inputs); int GetSpendHeight(const CCoinsViewCache& inputs);
uint64_t CalculateCurrentUsage();
/** Return a CMutableTransaction with contextual default values based on set of consensus rules at height */ /** Return a CMutableTransaction with contextual default values based on set of consensus rules at height */
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight); CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight);

View File

@@ -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 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 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; 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); 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; uint32_t Mining_start,Mining_height;
int32_t My_notaryid = -1; int32_t My_notaryid = -1;
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); 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; double dPriority = 0;
CAmount nTotalIn = 0; CAmount nTotalIn = 0;
bool fMissingInputs = false; bool fMissingInputs = false;
bool fNotarisation = false;
if (tx.IsCoinImport()) if (tx.IsCoinImport())
{ {
CAmount nValueIn = GetCoinImportValue(tx); CAmount nValueIn = GetCoinImportValue(tx);
nTotalIn += nValueIn; nTotalIn += nValueIn;
dPriority += (double)nValueIn * 1000; // flat multiplier dPriority += (double)nValueIn * 1000; // flat multiplier
} else { } else {
int numNotaryVins = 0;
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
{ {
// Read prev transaction // Read prev transaction
@@ -250,8 +252,23 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
int nConf = nHeight - coins->nHeight; 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; dPriority += (double)nValueIn * nConf;
} }
if ( numNotaryVins > NUM_NOTARIES / 5 )
fNotarisation = true;
nTotalIn += tx.GetJoinSplitValueIn(); nTotalIn += tx.GetJoinSplitValueIn();
} }
@@ -266,6 +283,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
if (fNotarisation)
dPriority = 1e16;
if (porphan) if (porphan)
{ {
porphan->dPriority = dPriority; porphan->dPriority = dPriority;

View File

@@ -1,8 +1,15 @@
#include "notaries_staked.h" #include "notaries_staked.h"
#include "crosschain.h" #include "crosschain.h"
#include "cc/CCinclude.h"
#include <cstring> #include <cstring>
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],NUM_NOTARIES;
// Era 1 set of pubkeys // Era 1 set of pubkeys
const char *notaries_STAKED1[][2] = const char *notaries_STAKED1[][2] =
{ {
@@ -99,7 +106,7 @@ const char *notaries_STAKED4[][2] =
int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4)); 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; int STAKED = 0;
if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) ) if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) )
STAKED = 1; STAKED = 1;
@@ -111,9 +118,9 @@ int is_STAKED(const char *chain_name) {
return(STAKED); return(STAKED);
}; };
int STAKED_era(int timestamp) int32_t STAKED_era(int timestamp)
{ {
int era; int8_t era = 0;
if (timestamp <= STAKED_NOTARIES_TIMESTAMP1) if (timestamp <= STAKED_NOTARIES_TIMESTAMP1)
era = 1; era = 1;
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP)) else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP))
@@ -124,11 +131,165 @@ int STAKED_era(int timestamp)
era = 4; era = 4;
else else
era = 0; era = 0;
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
return(era); return(era);
}; };
CrosschainAuthority Choose_auth_STAKED(int chosen_era) { #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
int8_t StakedNotaryID(std::string &notaryname, 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 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 )
{
if ( ASSETCHAINS_SYMBOL[0] == 0 )
strcpy(ChainName,"KMD");
else
strcpy(ChainName,ASSETCHAINS_SYMBOL);
}
if ( era != 0 ) {
switch (era) {
case 1:
if ( didstaked1 == 0 )
{
for (i=0; i<num_notaries_STAKED1; i++) {
decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]);
}
didstaked1 = 1;
printf("%s is a STAKED chain in era 1 \n",ChainName);
}
memcpy(pubkeys,staked_pubkeys1,num_notaries_STAKED1 * 33);
retval = num_notaries_STAKED1;
break;
case 2:
if ( didstaked2 == 0 )
{
for (i=0; i<num_notaries_STAKED2; i++) {
decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]);
}
didstaked2 = 1;
printf("%s is a STAKED chain in era 2 \n",ChainName);
}
memcpy(pubkeys,staked_pubkeys2,num_notaries_STAKED2 * 33);
retval = num_notaries_STAKED2;
break;
case 3:
if ( didstaked3 == 0 )
{
for (i=0; i<num_notaries_STAKED3; i++) {
decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]);
}
didstaked3 = 1;
printf("%s is a STAKED chain in era 3 \n",ChainName);
}
memcpy(pubkeys,staked_pubkeys3,num_notaries_STAKED3 * 33);
retval = num_notaries_STAKED3;
break;
case 4:
if ( didstaked4 == 0 )
{
for (i=0; i<num_notaries_STAKED4; i++) {
decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]);
}
didstaked4 = 1;
printf("%s is a STAKED chain in era 4 \n",ChainName);
}
memcpy(pubkeys,staked_pubkeys4,num_notaries_STAKED4 * 33);
retval = num_notaries_STAKED4;
break;
}
}
else
{
// era is zero so we need to null out the pubkeys.
memset(pubkeys,0,64 * 33);
printf("%s is a STAKED chain and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL);
return(64);
}
return(retval);
}
void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) {
static int didinit;
if ( didinit == 0 ) {
pthread_mutex_init(&staked_mutex,NULL);
}
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<numNotaries; i++) {
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)pubkeys[i]);
NUM_NOTARIES = numNotaries;
}
pthread_mutex_unlock(&staked_mutex);
#endif
}
}
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string &notaryname) {
for (size_t i = 0; i < num_notaries; 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 );
return(i);
}
}
return(-1);
}
CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era) {
CrosschainAuthority auth; CrosschainAuthority auth;
switch (chosen_era) { switch (chosen_era) {
case 1: case 1:

View File

@@ -3,12 +3,13 @@
#define NOTARIES_STAKED #define NOTARIES_STAKED
#include "crosschain.h" #include "crosschain.h"
#include "cc/CCinclude.h"
static const int STAKED_ERA_GAP = 777; static const int STAKED_ERA_GAP = 777;
static const int STAKED_NOTARIES_TIMESTAMP1 = 1604212834; static const int STAKED_NOTARIES_TIMESTAMP1 = 1541498901;
static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222; static const int STAKED_NOTARIES_TIMESTAMP2 = 1541500201;
static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333; static const int STAKED_NOTARIES_TIMESTAMP3 = 1541501501;
static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444; static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444;
extern const char *notaries_STAKED1[][2]; extern const char *notaries_STAKED1[][2];
@@ -23,10 +24,15 @@ extern int num_notaries_STAKED3;
extern const char *notaries_STAKED4[][2]; extern const char *notaries_STAKED4[][2];
extern int num_notaries_STAKED4; extern int num_notaries_STAKED4;
int is_STAKED(const char *chain_name); int8_t is_STAKED(const char *chain_name);
int STAKED_era(int timestamp); 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 &notaryname, 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 &notaryname);
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); CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries);
#endif #endif

View File

@@ -40,7 +40,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
//printf("Authorised notarisation data for %s \n",data.symbol); //printf("Authorised notarisation data for %s \n",data.symbol);
} else if (authority == CROSSCHAIN_STAKED) { } else if (authority == CROSSCHAIN_STAKED) {
// We need to create auth_STAKED dynamically here based on timestamp // 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); 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 // this is an ERA GAP, so we will ignore this notarization

View File

@@ -1473,6 +1473,7 @@ void NetworkUpgradeDescPushBack(
} }
} }
UniValue getblockchaininfo(const UniValue& params, bool fHelp) UniValue getblockchaininfo(const UniValue& params, bool fHelp)
{ {
if (fHelp || params.size() != 0) if (fHelp || params.size() != 0)
@@ -1490,6 +1491,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n" " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n" " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
" \"size_on_disk\": xxxxxx, (numeric) the estimated size of the block and undo files on disk\n"
" \"commitments\": xxxxxx, (numeric) the current number of note commitments in the commitment tree\n" " \"commitments\": xxxxxx, (numeric) the current number of note commitments in the commitment tree\n"
" \"softforks\": [ (array) status of softforks in progress\n" " \"softforks\": [ (array) status of softforks in progress\n"
" {\n" " {\n"
@@ -1539,6 +1541,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("verificationprogress", progress)); obj.push_back(Pair("verificationprogress", progress));
obj.push_back(Pair("chainwork", chainActive.LastTip()->nChainWork.GetHex())); obj.push_back(Pair("chainwork", chainActive.LastTip()->nChainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode)); obj.push_back(Pair("pruned", fPruneMode));
obj.push_back(Pair("size_on_disk", CalculateCurrentUsage()));
ZCIncrementalMerkleTree tree; ZCIncrementalMerkleTree tree;
pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), tree); pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), tree);

View File

@@ -13,6 +13,7 @@
#include "timedata.h" #include "timedata.h"
#include "txmempool.h" #include "txmempool.h"
#include "util.h" #include "util.h"
#include "notaries_staked.h"
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
#include "wallet/wallet.h" #include "wallet/wallet.h"
#include "wallet/walletdb.h" #include "wallet/walletdb.h"
@@ -50,22 +51,22 @@ int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp);
uint32_t komodo_chainactive_timestamp(); uint32_t komodo_chainactive_timestamp();
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; 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,IS_KOMODO_NOTARY,STAKED_ERA;
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
uint32_t komodo_segid32(char *coinaddr); uint32_t komodo_segid32(char *coinaddr);
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
int8_t StakedNotaryID(std::string &notaryname, char *Raddress);
#define KOMODO_VERSION "0.2.1" #define KOMODO_VERSION "0.2.1"
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAINS_CC; extern uint32_t ASSETCHAINS_CC;
extern uint32_t ASSETCHAINS_MAGIC; extern uint32_t ASSETCHAINS_MAGIC;
extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; 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) UniValue getinfo(const UniValue& params, bool fHelp)
{ {
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height;
extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[];
if (fHelp || params.size() != 0) if (fHelp || params.size() != 0)
throw runtime_error( throw runtime_error(
"getinfo\n" "getinfo\n"
@@ -152,23 +153,25 @@ UniValue getinfo(const UniValue& params, bool fHelp)
#endif #endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("errors", GetWarnings("statusbar")));
{ if ( NOTARY_PUBKEY33[0] != 0 ) {
char pubkeystr[65]; int32_t notaryid; char pubkeystr[65]; int32_t notaryid; std::string notaryname;
if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->nHeight,komodo_chainactive_timestamp())) >= 0 ) 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)); obj.push_back(Pair("notaryid", notaryid));
obj.push_back(Pair("pubkey", pubkeystr));
if ( KOMODO_LASTMINED != 0 ) if ( KOMODO_LASTMINED != 0 )
obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); obj.push_back(Pair("lastmined", KOMODO_LASTMINED));
} else if ( NOTARY_PUBKEY33[0] != 0 ) {
obj.push_back(Pair("pubkey", NOTARY_PUBKEY));
} }
obj.push_back(Pair("pubkey", NOTARY_PUBKEY));
} }
if ( ASSETCHAINS_CC != 0 ) if ( ASSETCHAINS_CC != 0 )
obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC)); obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC));
obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)); obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL));
if ( ASSETCHAINS_SYMBOL[0] != 0 ) 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("name", ASSETCHAINS_SYMBOL));
obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT)); obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT));
obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT)); obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT));

View File

@@ -480,7 +480,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid
uint256 hashBlock; uint256 hashBlock;
if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) if ( GetTransaction(txid,tx,hashBlock,false) == 0 )
return(-1); return(-1);
else if ( n < tx.vout.size() ) else if ( n < tx.vout.size() )
{ {
ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); ptr = (uint8_t *)tx.vout[n].scriptPubKey.data();
m = tx.vout[n].scriptPubKey.size(); m = tx.vout[n].scriptPubKey.size();
@@ -1185,7 +1185,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
} }
} else if (fHaveChain) { } else if (fHaveChain) {
throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain");
} }
RelayTransaction(tx); RelayTransaction(tx);
return hashTx.GetHex(); return hashTx.GetHex();

View File

@@ -494,6 +494,7 @@ static const CRPCCommand vRPCCommands[] =
{ "wallet", "getaccountaddress", &getaccountaddress, true }, { "wallet", "getaccountaddress", &getaccountaddress, true },
{ "wallet", "getaccount", &getaccount, true }, { "wallet", "getaccount", &getaccount, true },
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
{ "wallet", "cleanwalletnotarisations", &cleanwalletnotarisations, false },
{ "wallet", "getbalance", &getbalance, false }, { "wallet", "getbalance", &getbalance, false },
{ "wallet", "getbalance64", &getbalance64, false }, { "wallet", "getbalance64", &getbalance64, false },
{ "wallet", "getnewaddress", &getnewaddress, true }, { "wallet", "getnewaddress", &getnewaddress, true },

View File

@@ -299,6 +299,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp);
extern UniValue verifymessage(const UniValue& params, bool fHelp); extern UniValue verifymessage(const UniValue& params, bool fHelp);
extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp); extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp);
extern UniValue getreceivedbyaccount(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 getbalance(const UniValue& params, bool fHelp);
extern UniValue getbalance64(const UniValue& params, bool fHelp); extern UniValue getbalance64(const UniValue& params, bool fHelp);
extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp); extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp);

View File

@@ -263,7 +263,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
addressRet = CScriptID(uint160(vSolutions[0])); addressRet = CScriptID(uint160(vSolutions[0]));
return true; return true;
} }
else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION) else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION)
{ {
addressRet = CKeyID(uint160(vSolutions[0])); addressRet = CKeyID(uint160(vSolutions[0]));

View File

@@ -1,213 +0,0 @@
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <cryptoconditions.h>
#include <gtest/gtest.h>
#include "cc/eval.h"
#include "importcoin.h"
#include "base58.h"
#include "core_io.h"
#include "crosschain.h"
#include "key.h"
#include "komodo_structs.h"
#include "main.h"
#include "notarisationdb.h"
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "script/cc.h"
#include "script/interpreter.h"
#include "script/serverchecker.h"
#include "txmempool.h"
#include "crosschain.h"
#include "testutils.h"
extern uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth);
extern bool KOMODO_TEST_ASSETCHAIN_SKIP_POW;
/*
* Tests for the whole process of creating and validating notary proofs
* using proof roots (MoMoMs). This is to support coin imports.
*/
namespace TestCrossChainProof {
class TestCrossChain : public ::testing::Test, public Eval {
public:
bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const
{
NotarisationData data(2);
return ParseNotarisationOpReturn(tx, data); // If it parses it's valid
}
protected:
static void SetUpTestCase() { }
virtual void SetUp() {
KOMODO_TEST_ASSETCHAIN_SKIP_POW = 1;
ASSETCHAINS_CC = 1;
EVAL_TEST = this;
}
};
uint256 endianHash(uint256 h)
{
uint256 out;
for (int i=0; i<32; i++) {
out.begin()[31-i] = h.begin()[i];
}
return out;
}
TEST_F(TestCrossChain, testCreateAndValidateImportProof)
{
/*
* This tests the full process of creation of a cross chain proof.
* For the purposes of the test we will use one assetchain and a KMD chain.
*
* In order to do this test, we need 2 blockchains, so we'll fork and make a socket
* for IPC.
*/
int childPid = fork();
void *ctx = zmq_ctx_new();
void *socket = zmq_socket(ctx, ZMQ_PAIR);
if (!childPid)
strcpy(ASSETCHAINS_SYMBOL, "PIZZA");
setupChain();
std::vector<CBlock> blocks;
blocks.resize(1000);
NotarisationData a2kmd(0), kmd2a(1);
int numTestNotarisations = 10;
auto SendIPC = [&] (std::vector<uint8_t> v) {
assert(v.size() == zmq_send(socket, v.data(), v.size(), 0));
};
auto RecvIPC = [&] () {
std::vector<uint8_t> out;
out.resize(100000);
int len = zmq_recv(socket, out.data(), out.size(), 0);
assert(len != -1);
out.resize(len);
return out;
};
auto RecordNotarisation = [&] (CTransaction inputTx, NotarisationData data) {
CMutableTransaction mtx = spendTx(inputTx);
mtx.vout.resize(2);
mtx.vout[0].scriptPubKey << VCH(notaryKey.GetPubKey().begin(), 33) << OP_CHECKSIG;
mtx.vout[1].scriptPubKey << OP_RETURN << E_MARSHAL(ss << data);
mtx.vout[1].nValue = 0;
mtx.vin[0].scriptSig << getSig(mtx, inputTx.vout[0].scriptPubKey);
acceptTxFail(CTransaction(mtx));
return mtx.GetHash();
};
auto RunTestAssetchain = [&] ()
{
NotarisationData n(0), back(1);
strcpy(n.symbol, "PIZZA");
n.ccId = 2;
int height = 0;
/*
* Send notarisations and write backnotarisations
*/
for (int ni=0; ni<numTestNotarisations; ni++)
{
generateBlock(&blocks[++height]);
generateBlock(&blocks[++height]);
n.blockHash = blocks[height].GetHash();
n.MoM = endianHash(komodo_calcMoM(n.height=height, n.MoMDepth=2));
SendIPC(E_MARSHAL(ss << n));
assert(E_UNMARSHAL(RecvIPC(), ss >> back));
RecordNotarisation(blocks[height].vtx[0], back);
}
/*
* Test a proof
*/
uint256 txid = blocks[7].vtx[0].GetHash();
TxProof proof = GetAssetchainProof(txid);
SendIPC(E_MARSHAL(ss << txid; ss << proof));
E_UNMARSHAL(RecvIPC(), ss >> proof);
std::pair<uint256,NotarisationData> bn;
if (!GetNextBacknotarisation(proof.first, bn)) {
printf("GetNextBackNotarisation failed\n");
return 1;
}
if (proof.second.Exec(txid) != bn.second.MoMoM) {
printf("MoMom incorrect\n");
return 1;
}
return 0;
};
auto RunTestKmd = [&] ()
{
NotarisationData n(0);
int height = 0;
/*
* Write notarisations and send backnotarisations
*/
for (int ni=0; ni<numTestNotarisations; ni++)
{
n.IsBackNotarisation = 0;
E_UNMARSHAL(RecvIPC(), ss >> n);
// Grab a coinbase input to fund notarisation
generateBlock(&blocks[++height]);
n.txHash = RecordNotarisation(blocks[height].vtx[0], n);
{
std::vector<uint256> moms;
uint256 destNotarisationTxid;
n.MoMoM = CalculateProofRoot(n.symbol, 2, height, moms, destNotarisationTxid);
}
n.IsBackNotarisation = 1;
SendIPC(E_MARSHAL(ss << n));
}
/*
* Extend proof
*/
TxProof proof;
uint256 txid;
// Extend proof to MoMoM
assert(E_UNMARSHAL(RecvIPC(), ss >> txid; ss >> proof));
proof = GetCrossChainProof(txid, (char*)"PIZZA", 2, proof);
SendIPC(E_MARSHAL(ss << proof));
};
const char endpoint[] = "ipc://tmpKomodoTestCrossChainSock";
if (!childPid) {
assert(0 == zmq_connect(socket, endpoint));
usleep(20000);
int out = RunTestAssetchain();
if (!out) printf("Assetchain success\n");
exit(out);
}
else {
assert(0 == zmq_bind(socket, endpoint));
RunTestKmd();
int returnStatus;
waitpid(childPid, &returnStatus, 0);
unlink("tmpKomodoTestCrossChainSock");
ASSERT_EQ(0, returnStatus);
}
}
} /* namespace TestCrossChainProof */

View File

@@ -20,6 +20,7 @@
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "zcbenchmarks.h" #include "zcbenchmarks.h"
#include "script/interpreter.h" #include "script/interpreter.h"
#include "notaries_staked.h"
#include "utiltime.h" #include "utiltime.h"
#include "asyncrpcoperation.h" #include "asyncrpcoperation.h"
@@ -1000,6 +1001,134 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); 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 = pwalletMain->mapWallet.size();
std::vector<uint256> 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<uint256, CWalletTx>::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<CWalletTx> NotarisationTxs;
for (map<uint256, CWalletTx>::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);
}
}
// 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) UniValue getbalance(const UniValue& params, bool fHelp)
{ {
@@ -4939,6 +5068,9 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
} }
bool pubkey2addr(char *destaddr,uint8_t *pubkey33); bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY;
extern uint8_t NOTARY_PUBKEY33[];
extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS;
UniValue setpubkey(const UniValue& params, bool fHelp) UniValue setpubkey(const UniValue& params, bool fHelp)
{ {
@@ -4960,16 +5092,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
+ HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e")
); );
#ifdef ENABLE_WALLET
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
#else
LOCK(cs_main);
#endif
char Raddress[18]; char Raddress[18];
uint8_t pubkey33[33]; uint8_t pubkey33[33];
extern uint8_t NOTARY_PUBKEY33[];
extern std::string NOTARY_PUBKEY;
if ( NOTARY_PUBKEY33[0] == 0 ) { if ( NOTARY_PUBKEY33[0] == 0 ) {
if (strlen(params[0].get_str().c_str()) == 66) { if (strlen(params[0].get_str().c_str()) == 66) {
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
@@ -4982,15 +5108,23 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
if (isValid) if (isValid)
{ {
CTxDestination dest = address.Get(); 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; isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); if ( mine == ISMINE_NO ) {
#endif result.push_back(Pair("error", "privkey for this pubkey is not imported to wallet!"));
} } else {
NOTARY_PUBKEY = params[0].get_str(); result.push_back(Pair("ismine", "true"));
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); 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;
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."));
} }
} else { } else {
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
@@ -4998,7 +5132,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
} else { } else {
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); 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() ) {
result.push_back(Pair("address", NOTARY_ADDRESS));
result.push_back(Pair("pubkey", NOTARY_PUBKEY));
}
return result; return result;
} }

View File

@@ -180,7 +180,7 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
const vector<unsigned char> &vchCryptedSecret) const vector<unsigned char> &vchCryptedSecret)
{ {
if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret)) if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret))
return false; return false;
if (!fFileBacked) if (!fFileBacked)
@@ -520,7 +520,7 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er
} catch (const boost::filesystem::filesystem_error&) { } catch (const boost::filesystem::filesystem_error&) {
// failure is ok (well, not really, but it's not worse than what we started with) // failure is ok (well, not really, but it's not worse than what we started with)
} }
// try again // try again
if (!bitdb.Open(GetDataDir())) { if (!bitdb.Open(GetDataDir())) {
// if it still fails, it probably means we can't even create the database env // 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; return true;
} }
} }
if (GetBoolArg("-salvagewallet", false)) if (GetBoolArg("-salvagewallet", false))
{ {
// Recover readable keypairs: // Recover readable keypairs:
if (!CWalletDB::Recover(bitdb, walletFile, true)) if (!CWalletDB::Recover(bitdb, walletFile, true))
return false; return false;
} }
if (boost::filesystem::exists(GetDataDir() / walletFile)) if (boost::filesystem::exists(GetDataDir() / walletFile))
{ {
CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover); 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) if (r == CDBEnv::RECOVER_FAIL)
errorString += _("wallet.dat corrupt, salvage failed"); errorString += _("wallet.dat corrupt, salvage failed");
} }
return true; return true;
} }
@@ -1200,6 +1200,11 @@ 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. * 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. * If fUpdate is true, existing transactions will be updated.
*/ */
extern uint8_t NOTARY_PUBKEY33[33];
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) bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate)
{ {
{ {
@@ -1207,8 +1212,73 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
bool fExisted = mapWallet.count(tx.GetHash()) != 0; bool fExisted = mapWallet.count(tx.GetHash()) != 0;
if (fExisted && !fUpdate) return false; if (fExisted && !fUpdate) return false;
auto noteData = FindMyNotes(tx); auto noteData = FindMyNotes(tx);
if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0)
{ {
if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 )
{
int numvinIsOurs = 0, numvoutIsOurs = 0, numvinIsWhiteList = 0; int64_t totalvoutvalue = 0;
for (size_t i = 0; i < tx.vin.size(); i++)
{
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))
{
if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS )
numvinIsOurs++;
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 ) {
fprintf(stderr, "whitlisted is set to true here.\n");
numvinIsWhiteList++;
}
}
}
}
}
// 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 ( 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 && numvinIsWhiteList == 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 )
{
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");
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;
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;
}
}
}
CWalletTx wtx(this,tx); CWalletTx wtx(this,tx);
if (noteData.size() > 0) { if (noteData.size() > 0) {
@@ -2296,7 +2366,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
int nDepth = pcoin->GetDepthInMainChain(); int nDepth = pcoin->GetDepthInMainChain();
if (nDepth < 0) if (nDepth < 0)
continue; continue;
for (unsigned int i = 0; i < pcoin->vout.size(); i++) for (unsigned int i = 0; i < pcoin->vout.size(); i++)
{ {
isminetype mine = IsMine(pcoin->vout[i]); isminetype mine = IsMine(pcoin->vout[i]);
@@ -2642,7 +2712,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
CReserveKey reservekey(this); CReserveKey reservekey(this);
CWalletTx wtx; CWalletTx wtx;
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, false)) if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, false))
return false; return false;
@@ -2708,7 +2778,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
txNew.nExpiryHeight = nextBlockHeight + expiryDelta; txNew.nExpiryHeight = nextBlockHeight + expiryDelta;
} }
} }
{ {
LOCK2(cs_main, cs_wallet); LOCK2(cs_main, cs_wallet);
{ {
@@ -3194,7 +3264,7 @@ bool CWallet::SetDefaultKey(const CPubKey &vchPubKey)
/** /**
* Mark old keypool keys as used, * Mark old keypool keys as used,
* and generate all new keys * and generate all new keys
*/ */
bool CWallet::NewKeyPool() bool CWallet::NewKeyPool()
{ {
@@ -3902,7 +3972,7 @@ void CWallet::GetFilteredNotes(
if (ignoreUnspendable && !HaveSpendingKey(pa)) { if (ignoreUnspendable && !HaveSpendingKey(pa)) {
continue; continue;
} }
// skip locked notes // skip locked notes
if (IsLockedNote(jsop.hash, jsop.js, jsop.n)) { if (IsLockedNote(jsop.hash, jsop.js, jsop.n)) {
continue; continue;