@@ -214,7 +214,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std:
214
214
}
215
215
216
216
chain.initMessage (_ (" Loading wallet..." ).translated );
217
- std::shared_ptr<CWallet> wallet = CWallet::Create (chain, name, std::move (database), options.create_flags , error, warnings);
217
+ std::shared_ptr<CWallet> wallet = CWallet::Create (& chain, name, std::move (database), options.create_flags , error, warnings);
218
218
if (!wallet) {
219
219
error = Untranslated (" Wallet loading failed." ) + Untranslated (" " ) + error;
220
220
status = DatabaseStatus::FAILED_LOAD;
@@ -294,7 +294,7 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::strin
294
294
295
295
// Make the wallet
296
296
chain.initMessage (_ (" Loading wallet..." ).translated );
297
- std::shared_ptr<CWallet> wallet = CWallet::Create (chain, name, std::move (database), wallet_creation_flags, error, warnings);
297
+ std::shared_ptr<CWallet> wallet = CWallet::Create (& chain, name, std::move (database), wallet_creation_flags, error, warnings);
298
298
if (!wallet) {
299
299
error = Untranslated (" Wallet creation failed." ) + Untranslated (" " ) + error;
300
300
status = DatabaseStatus::FAILED_CREATE;
@@ -3885,14 +3885,14 @@ std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, cons
3885
3885
return MakeDatabase (wallet_path, options, status, error_string);
3886
3886
}
3887
3887
3888
- std::shared_ptr<CWallet> CWallet::Create (interfaces::Chain& chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
3888
+ std::shared_ptr<CWallet> CWallet::Create (interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
3889
3889
{
3890
3890
const std::string& walletFile = database->Filename ();
3891
3891
3892
3892
int64_t nStart = GetTimeMillis ();
3893
3893
// TODO: Can't use std::make_shared because we need a custom deleter but
3894
3894
// should be possible to use std::allocate_shared.
3895
- std::shared_ptr<CWallet> walletInstance (new CWallet (& chain, name, std::move (database)), ReleaseWallet);
3895
+ std::shared_ptr<CWallet> walletInstance (new CWallet (chain, name, std::move (database)), ReleaseWallet);
3896
3896
DBErrors nLoadWalletRet = walletInstance->LoadWallet ();
3897
3897
if (nLoadWalletRet != DBErrors::LOAD_OK) {
3898
3898
if (nLoadWalletRet == DBErrors::CORRUPT) {
@@ -3952,7 +3952,9 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
3952
3952
}
3953
3953
}
3954
3954
3955
- walletInstance->chainStateFlushed (chain.getTipLocator ());
3955
+ if (chain) {
3956
+ walletInstance->chainStateFlushed (chain->getTipLocator ());
3957
+ }
3956
3958
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
3957
3959
// Make it impossible to disable private keys after creation
3958
3960
error = strprintf (_ (" Error loading %s: Private keys can only be disabled during creation" ), walletFile);
@@ -4049,9 +4051,9 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4049
4051
_ (" This is the transaction fee you will pay if you send a transaction." ));
4050
4052
}
4051
4053
walletInstance->m_pay_tx_fee = CFeeRate (nFeePerK, 1000 );
4052
- if (walletInstance->m_pay_tx_fee < chain. relayMinFee ()) {
4054
+ if (chain && walletInstance->m_pay_tx_fee < chain-> relayMinFee ()) {
4053
4055
error = strprintf (_ (" Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)" ),
4054
- gArgs .GetArg (" -paytxfee" , " " ), chain. relayMinFee ().ToString ());
4056
+ gArgs .GetArg (" -paytxfee" , " " ), chain-> relayMinFee ().ToString ());
4055
4057
return nullptr ;
4056
4058
}
4057
4059
}
@@ -4065,15 +4067,15 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4065
4067
if (nMaxFee > HIGH_MAX_TX_FEE) {
4066
4068
warnings.push_back (_ (" -maxtxfee is set very high! Fees this large could be paid on a single transaction." ));
4067
4069
}
4068
- if (CFeeRate (nMaxFee, 1000 ) < chain. relayMinFee ()) {
4070
+ if (chain && CFeeRate (nMaxFee, 1000 ) < chain-> relayMinFee ()) {
4069
4071
error = strprintf (_ (" Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)" ),
4070
- gArgs .GetArg (" -maxtxfee" , " " ), chain. relayMinFee ().ToString ());
4072
+ gArgs .GetArg (" -maxtxfee" , " " ), chain-> relayMinFee ().ToString ());
4071
4073
return nullptr ;
4072
4074
}
4073
4075
walletInstance->m_default_max_tx_fee = nMaxFee;
4074
4076
}
4075
4077
4076
- if (chain. relayMinFee ().GetFeePerK () > HIGH_TX_FEE_PER_KB) {
4078
+ if (chain && chain-> relayMinFee ().GetFeePerK () > HIGH_TX_FEE_PER_KB) {
4077
4079
warnings.push_back (AmountHighWarn (" -minrelaytxfee" ) + Untranslated (" " ) +
4078
4080
_ (" The wallet will avoid paying less than the minimum relay fee." ));
4079
4081
}
@@ -4089,7 +4091,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
4089
4091
4090
4092
LOCK (walletInstance->cs_wallet );
4091
4093
4092
- if (!AttachChain (walletInstance, chain, error, warnings)) {
4094
+ if (chain && !AttachChain (walletInstance, * chain, error, warnings)) {
4093
4095
return nullptr ;
4094
4096
}
4095
4097
0 commit comments