I had the idea that walletinit.h/.c is kind of the multiwallet interface (wallet manager). The functions we have there (DeleteWallets(), VerifyWallets(), ShutdownWallets();, etc.) sounded for me after vpwallets belongs there…
IMO, the multiwallet map should ideally not sit within the objects (CWallet) implementation.
TheBlueMatt
commented at 10:15 pm on December 3, 2017:
Tend to agree with @jonasschnelli here, though I agree the barrier isn’t exactly clear (yet). Ideally we’d move more towards clarifying the interface here - making CWallet less and less aware of all the things around it (including other wallets). @sipa thoughts here?
jnewbery
commented at 10:30 am on July 7, 2017:
member
This overlaps significantly with #10762. Not sure how I should ask for review. Perhaps find out which one people think is the priority? Or I could split the walletinit.cpp commits into their own PR.
in
src/wallet/rpcwallet.cpp:2997
in
72c37457cdoutdated
On further thought, I think I prefer the names attachwallet and detachwallet. That gives a bit more distinction from the dump/import RPCs and makes a stronger implication that the new .dat file is being loaded and attached as a separate wallet.
promag
commented at 10:43 am on July 7, 2017:
member
@jnewbery IMO this one should rebase on the other.
jnewbery
commented at 10:46 am on July 7, 2017:
member
IMO this one should rebase on the other.
Makes logical sense. Downside is that the other is a more significant change, so may take longer to get merged.
promag
commented at 10:54 am on July 7, 2017:
member
If this really depends on that work then there’s no other way than waiting. The other downside is that the other commits will show up here too.
jnewbery
commented at 3:09 pm on July 7, 2017:
member
I’ve changed the PR sequence, so this will now depend on #10767. If I get positive concept feedbac on #10767 I’ll rebase this on top of it.
For now, I’m still just looking for concept feedback.
jnewbery force-pushed
on Aug 28, 2017
jnewbery
commented at 9:21 pm on August 28, 2017:
member
Rebased on #10767 . Reviewers, please review #10767 first.
jnewbery force-pushed
on Aug 30, 2017
MarcoFalke referenced this in commit
791a0e6dda
on Sep 7, 2017
jnewbery force-pushed
on Sep 11, 2017
jnewbery
commented at 4:31 pm on September 11, 2017:
member
Rebased now that #10767 is merged. Still a work in progress. PR text updated.
jnewbery force-pushed
on Sep 15, 2017
jnewbery force-pushed
on Sep 15, 2017
jnewbery force-pushed
on Sep 15, 2017
jnewbery renamed this:
[WIP] [wallet] dynamic loading/unloading of wallets
[wallet] dynamic loading/unloading of wallets
on Sep 15, 2017
jnewbery force-pushed
on Sep 20, 2017
jnewbery
commented at 2:16 pm on September 20, 2017:
member
Bad automatic merge of the testcase. Re-merged manually.
jnewbery
commented at 4:51 pm on September 20, 2017:
member
Manual rebase fixed the test bug. Travis now passes.
promag
commented at 9:08 am on September 21, 2017:
Missing spaces after ,?
in
src/wallet/init.cpp:198
in
6c5b84119doutdated
192- for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
193- if (boost::filesystem::path(walletFile).filename() != walletFile) {
194- return InitError(strprintf(_("Error loading wallet %s. -wallet parameter must only specify a filename (not a path)."), walletFile));
195- }
196+ // -salvagewallet can only be used when loading a single wallet
197+ bool salvage_wallet = gArgs.GetBoolArg("-salvagewallet", false) && wallet_files.size() <= 1;
promag
commented at 9:39 am on September 21, 2017:
Throw an error if -salvagewallet and there are multiple wallets?
jnewbery
commented at 1:44 pm on September 21, 2017:
Sounds like a sensible change in behaviour. I think it’s beyond the scope of this PR.
ryanofsky
commented at 6:05 pm on December 20, 2017:
It looks like WalletParameterInteraction is already throwing an error in this case. I think it would be better to drop the comment and wallet_files check here. If you’d prefer to keep the check, I think the comment should be something clearer like “// parameter interaction code should have thrown an error if -salvagewallet was enabled with more than wallet file, so the wallet_files size check here should have no effect.”
promag
commented at 9:45 am on September 21, 2017:
Why not just LOCK(cs_wallets) too?
jnewbery
commented at 1:44 pm on September 21, 2017:
Because I’d prefer to avoid recursive locking if possible.
promag
commented at 9:30 pm on September 21, 2017:
Just curious, why?
TheBlueMatt
commented at 10:13 pm on December 3, 2017:
Yes, definitely. cs_wallets is locked before cs_main in global lock order, so putting it too many places is just asking for trouble, IMO.
promag
commented at 9:51 am on September 21, 2017:
member
Quick review. All touched code could be updated as per dev notes.
Most importantly, With the LOCK(cs_wallets) it will be impossible to have concurrent RPC to different wallets, not to mention to the same wallet. Is this expected behavior? - I’m assuming there is a thread pool for RPC.
jnewbery
commented at 1:43 pm on September 21, 2017:
member
Regarding the locking: Yes, I’ve implemented this as a mutex for now, which as you point out would limit wallet RPCs to be single-threaded. I’d like to update this to be something a bit better before v0.16. Suggestions are either a shared mutex or (suggested by @theuni) a version of the decay pointers in #10738. The problem with using a shared mutex is that C++ doesn’t have a standard library shared mutex until C++14 (std::shared_timed_mutex) so I’d either have to use boost::shared_mutex or roll my own.
(apologies - I thought I’d already written a note in this PR explaining this, but I must have failed to hit send!)
For now, I think review of this PR with the mutex is helpful, and I’ll change it around to use a shared_mutex later.
laanwj added this to the "Blockers" column in a project
luke-jr
commented at 8:03 pm on September 21, 2017:
member
This seems to ignore the whole issue of long-term wallet references, and probably locks cs_wallets too long.
laanwj added this to the milestone 0.16.0
on Sep 28, 2017
laanwj
commented at 6:44 am on September 28, 2017:
member
Adding 0.16.0 milestone, I think this should be merged after 0.15.1 to prevent extra rebasing in the wallet code when porting back to 0.15.1.
in
src/wallet/rpcwallet.cpp:2725
in
e188d00eceoutdated
kallewoof
commented at 3:59 am on October 4, 2017:
Ugh, passwords on prompts leaves the password as plaintext in shell history etc. Can’t really be fixed for HTTP-RPC I guess, but CLI could probably take a bool to mean “prompt me for password”.
in
src/wallet/rpcwallet.cpp:2668
in
6c5b84119doutdated
2665+ "openwallet \"filename\" (\"passphrase\")\n"
2666 "\nOpens a wallet from a wallet.dat file.\n"
2667+ "\nUse the passphrase argument to unlock an encrypted wallet while opening.\n"
2668 "\nArguments:\n"
2669 "1. \"filename\" (string, required) The wallet.dat file\n"
2670+ "2. \"passphrase\" (string, optional) The wallet.dat file\n"
kallewoof
commented at 4:00 am on October 4, 2017:
Description is wrong.
kallewoof
commented at 4:03 am on October 4, 2017:
member
utACK6c5b84119d1ffa547bf094b28ca602bdaf07c21a
promag
commented at 2:31 pm on October 11, 2017:
member
Needs rebase.
The openwallet should rescan?
fanquake added this to the "In progress" column in a project
Sjors
commented at 3:56 pm on November 20, 2017:
member
Concept ACK.
I was able to use openwallet and closewallet.
I wonder how this interacts with #11383. E.g. I’m guessing the UI wouldn’t pick up on this (not a big issue). I can try once both are rebased.
It would be nice if bitcoin-cli -rpcwallet=X would open X if it’s not open yet, maybe close it when done (future PR).
Should there be a separate RPC for creating a new wallet or should that be done using openwallet? (my initial thoughts are that there should be a separate RPC)
I would prefer it if openwallet fails for wallets that don’t exist, rather than creating a new wallet. I understand it makes sense for bitcoind -wallet to create a new one, because that’s what a new user would expect, but I don’t think that’s needed for openwallet.
promag
commented at 4:29 pm on November 20, 2017:
member
@Sjors this PR must be rebased with #11383 (probably when that gets merged).
TheBlueMatt
commented at 4:01 pm on December 5, 2017:
This is redundant now, no?
in
src/wallet/wallet.h:1084
in
2e774d8912outdated
1079@@ -1080,6 +1080,9 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
1080 /** Mark a transaction as replaced by another transaction (e.g., BIP 125). */
1081 bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
10821083+ //! Verify wallet naming and perform salvage on the wallet if required
1084+ static bool VerifyWallet(std::string walletFile, bool salvage_wallet);
TheBlueMatt
commented at 4:08 pm on December 5, 2017:
nit: I’d rather not make this a static CWallet member. wallet.cpp is already plenty big and the stuff that it does seems more external db-related stuff and less wallet-related stuff. Ideally it’d be nice to more clearly separate the DB stuff from the wallet logic itself by pulling things like the DB-related stuff out of CreateWalletFromFile.
ryanofsky
commented at 6:28 pm on December 20, 2017:
In commit “add CDBEnv::Shutdown() function”
I think this method should start with if (!fDbEnvInit) return; similar to the Flush method so shutdown code can be simple for callers (no need for -disablewallet check).
ryanofsky
commented at 6:31 pm on December 20, 2017:
In commit “add CDBEnv::Shutdown() function”
Maybe AssertLockHeld(cs_db)
in
src/wallet/wallet.cpp:3763
in
b3f0973d92outdated
3760+bool CWallet::VerifyWallet(std::string walletFile, bool salvage_wallet, std::string& strError)
3761 {
3762 if (boost::filesystem::path(walletFile).filename() != walletFile) {
3763- return InitError(strprintf(_("Error loading wallet %s. wallet parameter must only specify a filename (not a path)."), walletFile));
3764+ strError = strprintf(_("Error loading wallet %s. wallet parameter must only specify a filename (not a path)."), walletFile);
3765+ return InitError(strError);
ryanofsky
commented at 6:39 pm on December 20, 2017:
It might be better to drop thee InitError calls here and let callers VerifyWallet callers invoke it. Otherwise calls to open wallets via RPC could trigger GUI message boxes and maybe hang.
ryanofsky
commented at 7:49 pm on December 20, 2017:
member
Maybe mark work in progress due to unresolved locking issues.
It’s not clear to me that exclusively locking cs_wallets is really that much worse than current behavior, since most current RPCs seem to acquire locks for a long time and effectively be single threaded. But it would be good to avoid this.
It might be straightforward to fix by making vpwallets hold shared pointers, and by releasing the cs_wallets lock except when accessing vpwallets. I don’t think there is any need for strong_ptrs because there should be no reason to care what threads wallets are closed on.
Using a shared lock as a substitute for shared pointers seems a little kludgy to me since it would just be speeding up overbroad cs_wallets locks instead of removing them, and would it would still block operations on unrelated wallets when any wallet was being opened or closed.
Verify and Flush refactoring commits in this PR seem like they might be useful changes on their own, and could maybe be pulled out into separate PRs to simplify this one.
jnewbery renamed this:
[wallet] dynamic loading/unloading of wallets
[WIP] [wallet] dynamic loading/unloading of wallets
on Dec 20, 2017
wtogami
commented at 9:03 am on December 30, 2017:
contributor
Needs rebase
Should there be a separate RPC for creating a new wallet or should that be done using openwallet? (my initial thoughts are that there should be a separate RPC)
I suggest there should be a new RPC command to create new wallets. Aside from least surprise, there is more than one type of wallet that the user could want created.
jonasschnelli
commented at 7:22 am on January 4, 2018:
contributor
Needs rebase and issues (@ryanofsky) addressed.
laanwj removed this from the milestone 0.16.0
on Jan 11, 2018
laanwj added this to the milestone 0.17.0
on Jan 11, 2018
laanwj removed this from the "Blockers" column in a project
achow101
commented at 4:13 am on February 14, 2018:
member
Closing the wallet that is in use by qt (the one at vpwallets[0] will result in a crash. So additional handling for Qt stuff is needed.
jnewbery
commented at 8:15 pm on April 10, 2018:
member
I plan to pick this up again in the next few days. it requires:
rebasing on top of all the recent wallet refactors
addressing the locking issues (potentially pulling in #11402)
considering how this interacts with multiwallet in the GUI #12610
Sjors
commented at 10:40 am on April 11, 2018:
member
considering how this interacts with multiwallet in the GUI
A good enough first step would be if the dropdowns update when wallets are loaded / unloaded through the console. Adding UI to load and unload wallets can be a followup PR.
jnewbery
commented at 9:28 pm on April 12, 2018:
member
015:26< wumpus>#topic dynamic wallet load/unload (promag) 115:26< Randolf> Ack. 215:26< promag>not sure what you guys think
315:26< instagibbs_> what's the controversy in this topic :) 415:27< jonasschnelli> [#10740](/bitcoin-bitcoin/10740/) 515:27< sipa> it should happen, duh
615:27< gribble> [#10740](/bitcoin-bitcoin/10740/) | [WIP] [wallet] dynamic loading/unloading of wallets by jnewbery · Pull Request [#10740](/bitcoin-bitcoin/10740/) · bitcoin/bitcoin · GitHub 715:27< wumpus> seems like something we want to have at some point... 815:27< promag> but I think luke agrees that wallet management should be with shared pointers
915:27< sipa> how and when is another :)
1015:27< luke-jr> indeed, using names just asks for chaos with runtime-changing wallets
1115:28< promag> please read [#11402](/bitcoin-bitcoin/11402/) for some reasons to switch1215:28< gribble> [#11402](/bitcoin-bitcoin/11402/) | Use shared pointer for wallet instances by promag · Pull Request [#11402](/bitcoin-bitcoin/11402/) · bitcoin/bitcoin · GitHub1315:28< jonasschnelli> IMO 10740 can't create wallets, IMO first step would be to add a createwallet RPC call1415:29< jonasschnelli> the whole creation/configuration setup if flawed since multiwallet
1515:29< jonasschnelli> stuff like -keypool should be per wallet
1615:29< jnewbery> jonasschnelli: you think createwallet should go in*before* load/unload?1715:29< jonasschnelli>and persisted in the wallet file (as configuration section)
1815:29< jonasschnelli> jnewbery: not sure,.. just thinking
1915:30< jnewbery> seems reasonable to me
2015:30< jonasschnelli> createwallet could also *not* load the wallet in the first step (not ideal, but maybe reduces complexity)
2115:30< sipa> that seems strange... you could create a new wallet at run time but not use it?2215:30< jonasschnelli> sipa: createwallet could also directly load/use the wallet
2315:30< jnewbery> I think createwallet would also load the new wallet, no?2415:30< promag> create implies loading
2515:30< luke-jr> sipa: iow, 0 to 1 only.2615:31< sipa> jonasschnelli: well then you need to have loading functionality first!2715:31< sipa>andif you have it, why not expose it
2815:31< jonasschnelli> sipa: yes. That's a point.2915:31< jnewbery> createwallet could also be done by bitcoin-wallet-tool3015:32< jnewbery> (#8745)3115:32< gribble> [#8745](/bitcoin-bitcoin/8745/) | [PoC] Add wallet inspection and modification tool "bitcoin-wallet-tool" by jonasschnelli · Pull Request [#8745](/bitcoin-bitcoin/8745/) · bitcoin/bitcoin · GitHub3215:32< jonasschnelli> Yes. Would be possible...3315:32< jonasschnelli> I just think the create-during-startup approach is not good
3415:33< promag> also related [#10973](/bitcoin-bitcoin/10973/)3515:33< jnewbery> jonasschnelli: I agree
3615:33< gribble> [#10973](/bitcoin-bitcoin/10973/) | Refactor: separate wallet from node by ryanofsky · Pull Request [#10973](/bitcoin-bitcoin/10973/) · bitcoin/bitcoin · GitHub3715:33< sipa> jonasschnelli: agree
3815:33< jonasschnelli> And as a first step I though createwallet would make sense.. but not loading it seems after a strange use-case3915:33< luke-jr> load -> create -> unload
4015:33< jonasschnelli> but a nice first code/impl. step
4115:33< luke-jr> unload is the complex part tbh
4215:33< jnewbery> luke-jr: agree
4315:34< jonasschnelli> Agree with luke-jr. Maybe split unload away from the existing PR jnewbery ?4415:34< jnewbery> yes
4515:34< jnewbery> I intend to pick up 10740 again soon, rebase and rework it
4615:34< promag> consider the use case: 1) rpc rescan wallet 2) in parallel unload wallet - should 2) wait for1) ?4715:34< luke-jr> probably
4815:35< jonasschnelli> Great. Dynamic loading/creating is a nice feature that we probably want for0.17!4915:35< promag> luke-jr: andif the unload is from the UI?5015:35< jnewbery> promag: do you consider 11402 a prereq for load/unload? What about just load?5115:36< jonasschnelli> the wallet-tool is IMO orthogonal to wallet creation
5215:36< jonasschnelli>*via RPC
5315:36< luke-jr> promag: probably the same
5415:36< promag> jnewbery: IMHO for both
5515:36< jonasschnelli> RPC seems to be a must, wallet-tool can be a better place to create some sorts of wallets (or inspect it), .. like encrypted wallets
5615:36< luke-jr> promag: at least initially
5715:37< jnewbery> promag: want to rebase and put on high priority for review then, if you consider it a blocker?5815:37< promag> luke-jr: my point is that it should not block, you request the unload and go on, when the wallet is not used anymore it gets unloaded
5915:38< jonasschnelli> [#11402](/bitcoin-bitcoin/11402/)6015:38< gribble> [#11402](/bitcoin-bitcoin/11402/) | Use shared pointer for wallet instances by promag · Pull Request [#11402](/bitcoin-bitcoin/11402/) · bitcoin/bitcoin · GitHub6115:38< luke-jr> promag: you mean leave the wallet loaded, but invisible? that seems worst outcome IMO
6215:38< luke-jr> user may unload and just shut off the PC
6315:38< wumpus> the unload should probably be in two stages: after requesting it, RPC and the GUI lose access to it. Then it waits for current operations tofinish. Then the thing really gets delted.6415:38< luke-jr> yes
6515:38< promag> luke-jr: then the application will wait for wallets to unload
6615:38< jnewbery> I don't think we need to worry about unload at this stage. First step is add load functionality, then createwallet functionality6715:38< luke-jr>and make it visible to the user in the meantime
6815:39< luke-jr> jnewbery: +16915:39< promag> wumpus: right, hence shared pointers
I should reduce the scope of this PR to just a loadwallet RPC. A createwallet RPC should come next, followed by unloadwallet. (unloadwallet is where most of the difficulties are).
jnewbery renamed this:
[WIP] [wallet] dynamic loading/unloading of wallets
[WIP] [wallet] `loadwallet` RPC - load wallet at runtime
on Apr 18, 2018
jnewbery
commented at 9:03 pm on April 18, 2018:
member
Updated PR text since this PR is now only for loading wallets (not creating or unloading).
Original text also had the following motivation:
Main motivation for this was the fact that several wallet parameters are actions for individual wallet load/creation, rather than properties of the wallet component. Examples are -salvagewallet, -rescan, -usehd and -upgradewallet. Continuing with that config/loading model is difficult in a multi-wallet world - how can users run those actions on individual wallets when loading multiple wallets? This PR offers a solution: individual wallets can be loaded at run-time, and RPC parameters can be passed in to carry out the various wallet-loading actions. Note that none of those load actions are yet implemented in this PR, but can easily be added.
jnewbery force-pushed
on Apr 18, 2018
jnewbery
commented at 9:06 pm on April 18, 2018:
member
Overhauled this PR to just contain the loadwallet functionality.
It is built on @promag’s PR #13017. Please review that first.
This also needs the cs_wallets locking functionality from #11402 to be thread-safe.
I’ll rebase once those PRs are merged. I’ve pushed the branch now in case anyone wants to do early review.
promag
commented at 9:11 pm on April 18, 2018:
member
@jnewbery Nice. BTW I was thinking creating a different PR to just make #13017 thread safe.
jnewbery
commented at 9:13 pm on April 18, 2018:
member
I was thinking creating a different PR to just make #13017 thread safe.
Great. I’ll keep an eye out and rebase on top of that when it’s ready.
in
src/wallet/rpcwallet.cpp:2910
in
d667f8b82eoutdated
Should call CWallet::postInitProcess instead? Otherwise MaybeCompactWalletDB is not called if the daemon is launched without wallets.
jnewbery renamed this:
[WIP] [wallet] `loadwallet` RPC - load wallet at runtime
[wallet] `loadwallet` RPC - load wallet at runtime
on Apr 19, 2018
jnewbery force-pushed
on Apr 19, 2018
jnewbery
commented at 9:54 pm on April 19, 2018:
member
Thanks for the review @promag - I’ve done as you suggested and called CWallet::postInitProcess(). Because rpc doesn’t have the CScheduler reference when loading the wallet, I had to change the WalletInit::Start() function to always schedule background wallet flushes, even when started with no wallets (ie -nowallet). Note that when started with -disablewallet, the entire wallet module is disabled and it’s not possible to load wallets later.
I’ve also rebased on [#13028 rebased on master].
Removed the [WIP] tag since I think this implementation is now complete and ready for review.
in
src/wallet/wallet.h:748
in
1faccae15doutdated
744@@ -747,6 +745,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
745 const CBlockIndex* m_last_block_processed = nullptr;
746747 public:
748+ static std::atomic<bool> fFlushScheduled;
0for (CWallet*pwallet : GetWallets()) {
1// Add wallet transactions that aren't already in a block to mempool
2// Do this here as mempool requires genesis block to be loaded
3 pwallet->ReacceptWalletTransactions();
4}
5..
in
src/wallet/init.cpp:332
in
1faccae15doutdated
324@@ -324,7 +325,12 @@ bool WalletInit::Open() const
325 void WalletInit::Start(CScheduler& scheduler) const
326 {
327 for (CWallet* pwallet : GetWallets()) {
328- pwallet->postInitProcess(scheduler);
329+ pwallet->postInitProcess();
330+ }
331+
332+ // Run a thread to flush wallet periodically
333+ if (!CWallet::fFlushScheduled.exchange(true)) {
I’m going to leave this function here for now. It seems reasonable to have a postInitProcess() step for loading wallets, even if it is only doing one thing.
This makes the diff smaller, and we can always remove postInitProcess() later if it really is unnecessary.
promag
commented at 1:09 am on April 20, 2018:
member
I had to change the WalletInit::Start() function to always schedule background wallet flushes
Much better out of CWallet IMO.
jonasschnelli
commented at 11:51 am on April 23, 2018:
contributor
Needs rebase again.
jnewbery force-pushed
on Apr 23, 2018
jnewbery
commented at 4:44 pm on April 23, 2018:
member
Yes - if there are multiple wallets loaded, you need to send the RPC request to the correct wallet endpoint. Look at TestNode’s get_wallet_rpc() method.
conscott
commented at 6:20 am on April 27, 2018:
contributor
Test ACK0569d2cd1324304ba2d78d1299454126c9d82b51 - just left a small test nit
promag
commented at 9:10 am on April 27, 2018:
member
@conscott thanks for the review, mind review #13028 too (this is rebased on that one)?
laanwj referenced this in commit
783bb6455e
on Apr 30, 2018
jnewbery force-pushed
on Apr 30, 2018
jnewbery
commented at 3:59 pm on April 30, 2018:
member
Updated test following @conscott’s suggestion and rebased on master to get #13028
in
doc/release-notes-pr10740.md:4
in
5423e5899aoutdated
0@@ -0,0 +1,6 @@
1+Dynamic loading of wallets
2+--------------------------
3+
4+Previously, wallets could only be loaded at startup, by specifying `-wallet` parameters on the command line or in the bitcoin.conf file. It is now possible to load wallets dynamically at runtime by calling the `loadwallet` RPC. The wallet file/directory must be located in the `walletdir` directory in order to be loaded.
Is this fine or should the outputs be the same?
Should it be possible to specify an absolute path if it’s in the walletdir?
jnewbery
commented at 10:12 pm on May 2, 2018:
member
Is this fine or should the outputs be the same?
Should it be possible to specify an absolute path if it’s in the walletdir?
I think that question is orthogonal to this PR. As you’ve noted, this is pre-existing behaviour and is exhibited when specifying wallet names on the command line or .conf file. This behaviour was specified in the PR that introduced external wallet files (here: #11687 (review)).
Can we save discussion on whether that’s the best behaviour for outside this PR?
jnewbery force-pushed
on May 2, 2018
promag
commented at 10:21 pm on May 2, 2018:
member
Release notes LGTM.
Tested ACKa395059 (previously tested 2d67656).
Can we save discussion on whether that’s the best behaviour for outside this PR?
Absolutely!
conscott
commented at 9:11 am on May 3, 2018:
contributor
Maybe some help messages noting that certain config options still apply here - eg if you started with something like zapwallettxes, upgradewallet, rescan, etc it will take the same action for newly-loaded wallets here.
TheBlueMatt
commented at 3:47 pm on May 7, 2018:
member
Should probably fix the various memory leaks in CreateWalletFromFile first - we didnt really use to care cause it would just persist through operation, now we do.
promag
commented at 3:59 pm on May 7, 2018:
member
Should probably fix the various memory leaks in CreateWalletFromFile first - we didnt really use to care cause it would just persist through operation, now we do.
@TheBlueMatt#13063 fixes that.
TheBlueMatt
commented at 4:04 pm on May 7, 2018:
member
#13063 seems overkill for this issue, we could just use a unique_ptr within CreateWalletFromFile.
Should probably fix the various memory leaks in CreateWalletFromFile
first - we didnt really use to care cause it would just persist through
operation, now we do.
promag
commented at 4:16 pm on May 7, 2018:
member
@TheBlueMatt Then you mean #12647. Either way it’s something that can be fixed in another PR.
TheBlueMatt
commented at 4:43 pm on May 7, 2018:
member
@promag it can be fixed in another PR, but that would have to be merged before this one. Its really no big deal on master, but with an RPC that allows you to create arbitrary memory leaks, that’s not great…
jnewbery
commented at 9:15 pm on May 7, 2018:
member
Should probably fix the various memory leaks in CreateWalletFromFile first - we didnt really use to care cause it would just persist through operation, now we do.
I’ve added the minimal fix from here: #12647 (review) to address the memory lead. @promag - that conflicts with your shared pointer PR, but it should be trivial for you to rebase that.
jnewbery force-pushed
on May 7, 2018
in
src/wallet/rpcwallet.cpp:3030
in
fc45f748caoutdated
Yes, certainly. What I’d prefer, ideally, is to just call this wallet_instance and use this smart pointer everywhere instead of CWallet* walletInstance = temp_wallet.get().
But this is fine, it’s no longer scary.
ok, I’ll change it if I need to update the branch for another reason.
laanwj
commented at 2:15 pm on May 9, 2018:
member
Looks overall good to me. Some small comments.
jnewbery force-pushed
on May 9, 2018
laanwj
commented at 5:32 pm on May 9, 2018:
member
utACK5ef858bfed2438746db0ba096ff3c98755603cb8
in
src/wallet/wallet.cpp:4016
in
dffe989059outdated
3971+ "or (for backwards compatibility) the name of an existing data file in -walletdir (%s)"),
3972+ wallet_file, GetWalletDir()));
3973+ }
3974+
3975+ // Make sure that the wallet path doesn't clash with an existing wallet path
3976+ std::set<fs::path> wallet_paths;
commit: [wallet] Fix potential memory leak in CreateWalletFromFile
This isn’t a complete fix because there are still early returns with errors in the rescan logic below. I believe it is safe to move the RegisterValidationInterface call to the bottom of the function as I argued in #12647 because cs_main gets locked on line 4135.
This isn’t a complete fix because there are still early returns with errors in the rescan logic below. I believe it is safe to move the RegisterValidationInterface call to the bottom of the function as I argued in #12647 because cs_main gets locked on line 4135.
jimpo’s right, f8c81def4f5f88074348890a613c1006824b1b5d[wallet] Fix potential memory leak in CreateWalletFromFile isn’t currently a complete fix for all memory leaks. Also, his suggestion to move RegisterValidationInterface and fix more leaks should be ok because of the cs_main lock. If you want to make that change, I would just add a comment above the RegisterValidationInterface call that says, “it is safe to register for notifications after rescanning (no notifications will be missed) because cs_main is held during the entire scan.” Only downside to this change is that if in the future we do optimize the rescan to not hold cs_main the entire time, it could introduce a bug where notifications are missed after the rescan completes.
Other options:
Just drop this commit and deal with memory leaks in a separate PR.
Just add a comment above the temp_wallet.release() call in this commit noting that walletInstance will be leaked if there is an error and the code below returns nullptr.
Get rid of temp_wallet, and make walletInstance a unique ptr. Return walletInstance.release() on the last line of this function. Add UnregisterValidationInterface(walletInstance.get()) calls below where nullptr is returned.
laanwj
commented at 5:37 am on May 14, 2018:
member
This seems very near ready for merge except for @jimpo’s nits.
[wallet] Fix potential memory leak in CreateWalletFromFile
Fix proposed by ryanofsky in
https://github.com/bitcoin/bitcoin/pull/12647#discussion_r174875670
59b87a27ef
[wallet] setup wallet background flushing in WalletInit directly
WalletInit::Start calls postInitProcess() for each wallet. Previously
each call to postInitProcess() would attempt to schedule wallet
background flushing.
Just start wallet background flushing once from WalletInit::Start().
470316c3bf
jnewbery force-pushed
on May 15, 2018
jnewbery
commented at 5:46 pm on May 15, 2018:
member
jimpo
commented at 7:40 pm on May 15, 2018:
contributor
Sorry, one more thing then I’ll ACK.
[wallet] Add CWallet::Verify function
This allows a single wallet to be verified. Prior to this commit, all
wallets were verified together by the WalletInit::Verify() function at
start-up.
Individual wallet verification will be done when loading wallets
dynamically at runtime.
e0e90db07b
[wallet] Pass error message back from CWallet::Verify()
Pass an error message back from CWallet::Verify(), and call
InitError/InitWarning from WalletInit::Verify().
This means that we can call CWallet::Verify() independently from
WalletInit and not have InitErrors printed to stdout. It also means that
the error can be reported to the user if dynamic wallet load fails.
876eb64680
[wallet] [rpc] Add loadwallet RPC
The new `loadwallet` RPC method allows an existing wallet to be loaded
dynamically at runtime.
`unloadwallet` and `createwallet` are not implemented. Notably,
`loadwallet` can only be used to load existing wallets, not to create a
new wallet.
5d152601e9
[wallet] [tests] Test loadwallet
Add testcases to wallet_multiwallet.py to test the new `loadwallet` RPC
method.
a46aeb6901
[docs] Add release notes for `loadwallet` RPC.cd53981b3d
jnewbery force-pushed
on May 16, 2018
jimpo
commented at 6:36 pm on May 16, 2018:
contributor
ACKcd53981
laanwj merged this
on May 16, 2018
laanwj closed this
on May 16, 2018
laanwj referenced this in commit
4cfe17c338
on May 16, 2018
jnewbery deleted the branch
on May 16, 2018
laanwj removed this from the "Blockers" column in a project
fanquake moved this from the "In progress" to the "Done" column in a project
PastaPastaPasta referenced this in commit
358c4db77a
on Dec 22, 2019
PastaPastaPasta referenced this in commit
6c4c334350
on Jan 2, 2020
PastaPastaPasta referenced this in commit
54e52012c2
on Jan 4, 2020
PastaPastaPasta referenced this in commit
02e1fecfbd
on Jan 4, 2020
PastaPastaPasta referenced this in commit
6ef89566e0
on Jan 10, 2020
PastaPastaPasta referenced this in commit
25d98e2bdd
on Jan 10, 2020
PastaPastaPasta referenced this in commit
99ccb6ebdd
on Jan 10, 2020
PastaPastaPasta referenced this in commit
f6f455db81
on Jan 12, 2020
PastaPastaPasta referenced this in commit
a3386a3fda
on Apr 14, 2020
PastaPastaPasta referenced this in commit
96dc3027bf
on Apr 14, 2020
PastaPastaPasta referenced this in commit
3333dee99c
on Apr 14, 2020
PastaPastaPasta referenced this in commit
10182d0444
on Apr 14, 2020
PastaPastaPasta referenced this in commit
e4b122fbf7
on Apr 14, 2020
PastaPastaPasta referenced this in commit
44159fe3cf
on Apr 15, 2020
PastaPastaPasta referenced this in commit
a5c5c591d2
on Apr 15, 2020
PastaPastaPasta referenced this in commit
5d02fa540e
on Apr 15, 2020
PastaPastaPasta referenced this in commit
bdf4fb3cfc
on Apr 15, 2020
PastaPastaPasta referenced this in commit
d9706ddeb5
on Apr 15, 2020
PastaPastaPasta referenced this in commit
ee0f3f2592
on Apr 15, 2020
PastaPastaPasta referenced this in commit
93248e49d4
on Apr 15, 2020
PastaPastaPasta referenced this in commit
494bb74077
on Apr 15, 2020
PastaPastaPasta referenced this in commit
95af923340
on Apr 15, 2020
PastaPastaPasta referenced this in commit
41c3831fb9
on Apr 15, 2020
PastaPastaPasta referenced this in commit
918f0978cb
on Apr 15, 2020
PastaPastaPasta referenced this in commit
c0c46932d5
on Apr 15, 2020
PastaPastaPasta referenced this in commit
a7f55b3442
on Apr 15, 2020
PastaPastaPasta referenced this in commit
a762ac80f5
on Apr 15, 2020
PastaPastaPasta referenced this in commit
37954f4062
on Apr 15, 2020
PastaPastaPasta referenced this in commit
79e49511b1
on Apr 15, 2020
PastaPastaPasta referenced this in commit
91cd6c3510
on Apr 15, 2020
PastaPastaPasta referenced this in commit
af06fb5cd6
on Apr 16, 2020
PastaPastaPasta referenced this in commit
63d6252ca7
on Apr 16, 2020
PastaPastaPasta referenced this in commit
5f7934ed52
on Apr 16, 2020
PastaPastaPasta referenced this in commit
1217f87cb7
on Apr 16, 2020
PastaPastaPasta referenced this in commit
7657f30980
on Apr 16, 2020
PastaPastaPasta referenced this in commit
0a31408dec
on Apr 16, 2020
PastaPastaPasta referenced this in commit
2d8a3d1295
on Apr 26, 2020
PastaPastaPasta referenced this in commit
ab7fecc81e
on Apr 26, 2020
PastaPastaPasta referenced this in commit
b512b8922d
on Apr 26, 2020
PastaPastaPasta referenced this in commit
35fa9feec2
on May 10, 2020
PastaPastaPasta referenced this in commit
fcde41dda2
on May 10, 2020
PastaPastaPasta referenced this in commit
41460518df
on May 10, 2020
PastaPastaPasta referenced this in commit
84af55906c
on May 10, 2020
PastaPastaPasta referenced this in commit
3d73de3381
on May 10, 2020
PastaPastaPasta referenced this in commit
53670a2b9f
on May 10, 2020
PastaPastaPasta referenced this in commit
8ebbdfe805
on May 10, 2020
ckti referenced this in commit
1bc9245138
on Mar 28, 2021
ckti referenced this in commit
ea688a5fbd
on Mar 28, 2021
ckti referenced this in commit
40977a0c5e
on Mar 28, 2021
gades referenced this in commit
4d034dc8cd
on Jun 30, 2021
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2025-05-13 09:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me