-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core14 changes #846
Core14 changes #846
Conversation
This pull request introduces 1 alert when merging ea35dc7 into 1a5763f - view on LGTM.com new alerts:
|
ea35dc7
to
73edfd7
Compare
06352af
to
320fbde
Compare
This pull request introduces 1 alert when merging 5e75d24 into e44462b - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging b9128f3 into c156819 - view on LGTM.com new alerts:
|
0b00090
to
0045c3b
Compare
src/wallet/wallet.h
Outdated
@@ -751,6 +750,8 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface | |||
MasterKeyMap mapMasterKeys; | |||
unsigned int nMasterKeyMaxID; | |||
|
|||
CHDMintWallet* zwallet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause memory leak on some places due to it re-assign this without freeing the previos value. Better to to use std::unique_ptr
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value will not be reassigned within the same instance ever, but a unique_ptr
is better anyway. Updated, please take a look
1757a53
to
8b4221e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This pull request fixes 1 alert when merging bf6d3b6 into 3de577b - view on LGTM.com fixed alerts:
|
support - Make CWalletDB a member of CHDMintWallet to avoid constant creation of wallet database file
bf6d3b6
to
a7a6d1c
Compare
@levonpetrosyan93 @ultimaweapon rebased, some issues so had to make a new commit. please re-review. |
src/wallet/wallet.cpp
Outdated
@@ -102,7 +102,7 @@ struct CompareByAmount | |||
|
|||
static void EnsureMintWalletAvailable() | |||
{ | |||
if (!zwalletMain) { | |||
if (!pwalletMain->zwallet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to ensure pwalletMain
is not null here
src/wallet/wallet.cpp
Outdated
@@ -175,7 +175,7 @@ CPubKey CWallet::GetKeyFromKeypath(uint32_t nChange, uint32_t nChild) { | |||
return pubkey; | |||
} | |||
|
|||
CPubKey CWallet::GenerateNewKey(uint32_t nChange) | |||
CPubKey CWallet::GenerateNewKey(uint32_t nChange, bool nWriteChain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you start boolean variables with n
? In bitcoin it's f
to denote variable as a "flag"
src/wallet/rpcwallet.cpp
Outdated
@@ -84,7 +84,7 @@ bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException) | |||
|
|||
void EnsureSigmaWalletIsAvailable() | |||
{ | |||
if (!zwalletMain) { | |||
if (!pwalletMain->zwallet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check pwalletMain
for null
src/hdmint/wallet.cpp
Outdated
@@ -521,7 +520,7 @@ CKeyID CHDMintWallet::GetMintSeedID(int32_t nCount){ | |||
* @param seedId (optional) seedId of the key to use for mint generation. | |||
* @return sucess | |||
*/ | |||
bool CHDMintWallet::CreateMintSeed(uint512& mintSeed, const int32_t& nCount, CKeyID& seedId) | |||
bool CHDMintWallet::CreateMintSeed(CWalletDB& walletdb, uint512& mintSeed, const int32_t& nCount, CKeyID& seedId, bool nWriteChain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nWriteChain
-> fWriteChain
src/wallet/sigmaspendbuilder.cpp
Outdated
@@ -168,13 +168,14 @@ CAmount SigmaSpendBuilder::GetChanges(std::vector<CTxOut>& outputs, CAmount amou | |||
auto params = sigma::Params::get_default(); | |||
|
|||
CHDMint hdMint; | |||
CWalletDB walletdb(pwalletMain->strWalletFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect in multiple wallets scenario. You need to pass CWalletDB
object reference to GetChanges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can obtain wallet file name from CWallet
object and use it to create CWalletDB
src/wallet/rpcwallet.cpp
Outdated
@@ -84,7 +84,7 @@ bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException) | |||
|
|||
void EnsureSigmaWalletIsAvailable() | |||
{ | |||
if (!pwalletMain->zwallet) { | |||
if (!pwalletMain && !pwalletMain->zwallet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
||, not &&
src/wallet/wallet.cpp
Outdated
@@ -102,7 +102,7 @@ struct CompareByAmount | |||
|
|||
static void EnsureMintWalletAvailable() | |||
{ | |||
if (!pwalletMain->zwallet) { | |||
if (!pwalletMain && !pwalletMain->zwallet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& -> ||
e0ff003
to
149e41b
Compare
make CHDMintWallet a member of CWallet (to better handle multiple wallet architecture in core 14)
Mac test optimisations:
CHDMintWallet
, pass as reference where possiblesome HDMint code cleanup