Multiwallet qt #2184

pull CodeShark wants to merge 39 commits into bitcoin:master from CodeShark:multiwallet-qt changing 37 files +2519 −779
  1. CodeShark commented at 7:20 pm on January 16, 2013: contributor
    Added ability to load/unload multiple wallets dynamically in bitcoin-qt
  2. Added multiple wallet support
    =============================
    
    A new global structure called pWalletMap has been added. Upon initialization, multiple wallets can be loaded.
    
    A new CWallet* parameter has been added to the RPC functions. Functions which do not use a wallet simply ignore it. In addition, a new field has been added to CRPCCommand that tells us whether or not the function uses a wallet.
    
    Two new RPC methods have been added:
      1) listwallets - Returns an array containing wallet names.
      2) usewallet - Prefix existing wallet RPC calls with usewallet <walletname> to use a particular wallet. If no wallet is specified, the default wallet is used.
        example: bitcoind usewallet foo listreceivedbyaddress 0 true
    
    TODO:
      1) Get wallet names from bitcoin.conf in init.cpp.
      2) Change help RPC so that the message does not depend on wallet state (i.e. walletpassphrase RPC call)
    71c63e3636
  3. Added CWallet* parameter to RPC test suite and a CWalletMap instance to test_bitcoin.cpp 4a6b0e290b
  4. Fixed RPC issues detected by test suite. 158ce39274
  5. Added loading of wallet names and files from -usewallet arguments
    =================================================================
    
    You can now specify additional wallets in the config file or via command line arguments:
    
    	usewallet=foo
    
    or
    
    	bitcoind -usewallet=foo
    
    A default wallet called "default" in the RPC and using file "wallet.dat" is always loaded, as to not break compatibility with the master branch. Therefore, additional wallets should neither be called "default" nor "wallet" nor anything else that might conflict with other filenames in the .bitcoin directory.
    
    The wallet will be stored in a file called foo.dat. If the wallet doesn't yet exist, it will be created the first time bitcoind is run.
    
    TODO: Ensure filename collisions cannot occur. Perhaps allow the wallet files to be arbitrarily named rather than tied to their identifier.
    1b640c143f
  6. TxMemPool::accept() calls SyncWithWallets(), so all mempool transactions are synched automatically without having to call SyncWithWallets() explicitly. This is important when sending between two wallets in a single bitcoind instance so that the receiving wallet is alerted of the transaction immediately.
    Removed calls to SyncWithWallets() in ProcessMessage() since SyncWithWallets() is already called by tx.AcceptToMemoryPool().
    
    SyncWithWallets() is still called explicitly from CBlock::ConnectBlock() since the transaction never goes through the mempool in this case.
    1cdf18b85b
  7. Modified getinfo RPC call to return an array of wallets 27fa196cb8
  8. Removed dependency on wallet encryption state for getting help on RPC methods. Help always returns usage info now. 93e6b809eb
  9. usewallet now checks whether method is valid. 0f815bf909
  10. Fixed LOCK to lock appropriate wallet. 924f088620
  11. Fixed wallet load time indicator. fa1c80863d
  12. Moved wallet detail information out of getinfo and put it in listwallets. getinfo now just shows how many wallets are loaded. b0cae87871
  13. Moved code for locking a wallet automatically at a certain time from rpcwallet.cpp into CCryptoKeyStore class.
    TODO:
      Encapsulate the thread spawning and make the call nonblocking.
      Give each thread a unique name.
    2b31fdfef9
  14. Dynamic loading and unloading of wallets.
    New Changes:
      - Moved LoadWallet out of init.cpp and into CWalletMap class.
      - Added new RPC methods: loadwallet and unloadwallet.
    
    TODO:
      - Clean up I/O in CWalletMap::LoadWallet - debug, error, and UI output functions.
      - Make sure wallet loading and unloading are thread-safe.
      - Save wallets to bitcoin.conf automatically.
    1b51a7f7bd
  15. New naming scheme for wallets. Checks for valid character set. CWalletMap now handles unregistration of wallets from main.
    Added linker option to makefiles for boost_regex.
    3fd110a6f7
  16. More load options at startup.
    If at least one -usewallet parameter is given, it will use those parameters to determine which wallets to load at startup.
    If no -usewallet parameters are given, it searches the data directory for files named wallet-<walletname>.dat.
    
    Also added -nousewallet parameters which override either -usewallet or the data directory.
    9d201cfaf9
  17. Thread-safe CWalletMap. 2256d1d7f7
  18. Using GetWallet instead of pWalletMap->wallets.find 3f5d692883
  19. Using GetWallet instead of pWalletMap->wallets.find 629ca2fc5c
  20. Merge branch 'multiwallet' of 108.60.150.142:../gitrepos/bitcoin into multiwallet 55d301c7f7
  21. Moved RPC type conversion for usewallet to RPCConvertValues function. ebf85b17aa
  22. Fixed usewallet params. 74228a2228
  23. Added preprocessor directive for boost filesystem v2 vs v3. ec0cc4bfcb
  24. Better encapsulation on WalletMap class, moved critical section locks to within the class methods themselves and out of bitcoinrpc.cpp, wallet unload locks on individual wallet rather than all wallets. 7348f78bc7
  25. Checking for CDB exceptions upon loading wallet. d21a960ef4
  26. Added unload methods for wallet db and call to unload in ~CWallet(). f409a6d413
  27. Fixed test_bitcoin issue. 6215e532f0
  28. Added locks on setpwalletRegistered functions. d8b0cf104d
  29. Added ReacceptWalletTransactions() registered wallet function in main rather than iterating through the wallet map in init. 3d15116f3c
  30. Added -lboost_regex to bitcoin-qt.pro. aa93b315d4
  31. Made wallet pointers in CWalletMap boost::shared_ptr<CWallet>. e0f3cbe20a
  32. Removed pwalletMain. Using pWalletMap->GetDefaultWallet() instead. eba5579499
  33. Renamed CWalletMap CWalletManager and pWalletMap pWalletManager. 6f3e40b96f
  34. Added Timer 3944f1d061
  35. Integrated timer with wallet. 64a9b45640
  36. Added wallet unloading tracers. Let rpcmining methods use nondefault wallet. a240960a0d
  37. Changed the way unlock time displays in listwallets. 41f561cad6
  38. Made wallet unlock timestamp UTC. 5bb560f24b
  39. laanwj commented at 8:22 pm on January 16, 2013: member

    Nice!

    It’s a huge pull request though; will take some time to look at it.

    BTW: seems there is a merge problem?

  40. in src/init.cpp: in 3393032282 outdated
    866@@ -793,88 +867,13 @@ bool AppInit2()
    867         return false;
    868     }
    869 
    870-    // ********************************************************* Step 8: load wallet
    871+    // ********************************************************* Step 8: load wallets
    872+    
    873+    uiInterface.InitMessage(_("Loading wallets..."));
    874+    printf("Loading wallets...\n");
    


    Diapolo commented at 8:37 pm on January 16, 2013:
    Not needed anymore.
  41. in src/net.cpp: in 3393032282 outdated
    1930@@ -1931,7 +1931,14 @@ void StartNode(void* parg)
    1931         printf("Error; NewThread(ThreadDumpAddress) failed\n");
    1932 
    1933     // Generate coins in the background
    1934-    GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain);
    1935+    try
    


    Diapolo commented at 8:39 pm on January 16, 2013:
    This seems unrelated to Qt wallets?

    CodeShark commented at 5:21 am on January 17, 2013:
    Sorry, this was a holdover from one of the last commits of the bitcoind multiwallet and it was too much of a pain to do a clean rebase and fix it all.

    CodeShark commented at 6:47 am on January 19, 2013:
    Once I finish merging the original multiwallet with bitcoin/bitcoin master, I’ll merge this all in as well cleanly.
  42. in src/qt/bitcoin.cpp: in 3393032282 outdated
    236+                
    237+                // Create wallet models for each wallet and add it.
    238+                BOOST_FOREACH(const wallet_map::value_type& item, pWalletManager->GetWalletMap())
    239+                {
    240+                    QString name(item.first.c_str());
    241+                    if (name == "") name = "~Default";
    


    Diapolo commented at 8:50 pm on January 16, 2013:
    name.isEmpty() would be more Qt style :).

    CodeShark commented at 5:23 am on January 17, 2013:
    Yeah, it’s interesting having to code in two completely different styles - having two entirely separate classes of containers. But at least it’s easy to convert between them. :)
  43. in src/qt/bitcoin.cpp: in 3393032282 outdated
    257@@ -250,7 +258,7 @@ int main(int argc, char *argv[])
    258 
    259                 window.hide();
    260                 window.setClientModel(0);
    261-                window.setWalletModel(0);
    262+                                
    


    Diapolo commented at 8:51 pm on January 16, 2013:
    Orphan tabs / spaces.
  44. in bitcoin-qt.pro: in 3393032282 outdated
    21@@ -22,10 +22,10 @@ UI_DIR = build
    22 
    23 # use: qmake "RELEASE=1"
    24 contains(RELEASE, 1) {
    25-    # Mac: compile for maximum compatibility (10.5, 32-bit)
    26-    macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
    27-    macx:QMAKE_CFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
    28-    macx:QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
    29+    # Mac: compile for compatibility and performance (10.6, 64-bit)
    


    Diapolo commented at 8:54 pm on January 16, 2013:
    Is this related to Qt wallets? @gavinandresen Should take a look at this changes. I thought we still are after 10.5 compatibility.

    CodeShark commented at 6:48 am on January 19, 2013:
    I added this because of build issues I was having on Mountain Lion.
  45. in src/qt/bitcoingui.cpp: in 3393032282 outdated
    770              tr("Date: %1\n"
    771                 "Amount: %2\n"
    772                 "Type: %3\n"
    773                 "Address: %4\n")
    774                   .arg(date)
    775-                  .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true))
    


    Diapolo commented at 8:55 pm on January 16, 2013:
    Why do you think it’s better to pass unit instead of that query here?

    CodeShark commented at 5:24 am on January 17, 2013:
    this is so that the gui controller can make comparisons and perform arithmetic without having to worry about formatting - for instance, determining whether it is positive or negative. However, if the only comparison it needs to make is whether it’s positive or negative, an alternative is to use an extra parameter to specify the sign.
  46. in src/qt/bitcoingui.cpp: in 3393032282 outdated
    786+    if (!clientModel || !walletManager) return;
    787 
    788-    exportAction->setEnabled(false);
    789-    disconnect(exportAction, SIGNAL(triggered()), 0, 0);
    790-}
    791+    QString dataDir = GetDataDir().string().c_str();
    


    Diapolo commented at 8:56 pm on January 16, 2013:
    QString::fromStdString(GetDataDir().string()) seems safer.
  47. in src/qt/bitcoingui.cpp: in 3393032282 outdated
    832-    disconnect(exportAction, SIGNAL(triggered()), 0, 0);
    833+    std::ostringstream err;
    834+    std::string walletName;
    835+    if (!walletManager->LoadWalletFromFile(walletFile.toStdString(), walletName, err))
    836+    {
    837+        QMessageBox errBox;
    


    Diapolo commented at 8:57 pm on January 16, 2013:
    You should use the .message() function for this IMHO.
  48. in src/qt/bitcoingui.cpp: in 3393032282 outdated
    437+    return;
    438+}
    439+
    440+bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
    441+{
    442+    if (!walletStack->addWalletView(name, walletModel)) return false;
    


    Diapolo commented at 9:14 pm on January 16, 2013:
    Just my opinion perhaps, but when reading through, I find these returns hard to catch and would prefer a newline with indentation.
  49. in src/qt/bitcoingui.cpp: in 3393032282 outdated
    799-
    800-    exportAction->setEnabled(true);
    801-    disconnect(exportAction, SIGNAL(triggered()), 0, 0);
    802-    connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked()));
    803-}
    804+    if (walletFile == "") return;
    


    Diapolo commented at 9:18 pm on January 16, 2013:
    .isEmpty()
  50. in src/keystore.cpp: in 3393032282 outdated
    76@@ -77,12 +77,10 @@ bool CCryptoKeyStore::Lock()
    77 {
    78     if (!SetCrypted())
    79         return false;
    80-
    


    Diapolo commented at 9:19 pm on January 16, 2013:
    Unrelated change.
  51. in src/qt/walletstack.h: in 3393032282 outdated
    41+    Q_OBJECT
    42+public:
    43+    explicit WalletStack(QWidget *parent = 0);
    44+    ~WalletStack();
    45+
    46+    void setBitcoinGUI(BitcoinGUI *gui) { this->gui = gui; }
    


    Diapolo commented at 9:23 pm on January 16, 2013:
    What if gui is undefined?

    laanwj commented at 9:26 pm on January 16, 2013:
    No problem right? It would just set the gui field to 0. What else would you expect to do here?

    Diapolo commented at 9:41 pm on January 16, 2013:
    You are correct.
  52. in src/qt/walletstack.h: in 3393032282 outdated
    43+    explicit WalletStack(QWidget *parent = 0);
    44+    ~WalletStack();
    45+
    46+    void setBitcoinGUI(BitcoinGUI *gui) { this->gui = gui; }
    47+    
    48+    void setClientModel(ClientModel *clientModel) { this->clientModel = clientModel; }
    


    Diapolo commented at 9:23 pm on January 16, 2013:
    Same question as above.

    laanwj commented at 9:28 pm on January 16, 2013:
    No problem either. In the implementation methods it’s checking for clientModel to be 0 before using it, as it should. Am I missing something?

    Diapolo commented at 9:40 pm on January 16, 2013:
    No, I did :). No problem then! It was just a (too) quick review.
  53. in src/wallet.cpp: in 3393032282 outdated
    1830@@ -1804,3 +1831,362 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts)
    1831     }
    1832 }
    1833 
    1834+// TODO: Remove these functions
    


    Diapolo commented at 9:44 pm on January 16, 2013:
    What is your vision for these?

    CodeShark commented at 5:41 am on January 17, 2013:
    Well, this section definitely needs to be cleaned up a LOT. But ultimately I envision a registration API, where the wallet can operate entirely as a service without having to know a thing about the UI. Apps that make use of it will query it for status (balance, history, contact info, accounts, etc…), ask the wallet manager to create new wallets or load existing wallets from different locations or save them to different locations, ask it to send transactions on its behalf, and subscribe callback handlers to be alerted when things happen.
  54. CodeShark commented at 5:48 am on January 17, 2013: contributor
    The merge is actually not that horrible…
  55. Merged multiwallet(5bb560f) with master. 5f429b8c70
  56. Merged multiwallet-qt (3cfab72) with multiwallet (5f429b8). 18ad19fbde
  57. BitcoinPullTester commented at 2:59 am on January 24, 2013: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/227637f431b1994d0d87b66993129fd4a1e0a0e1 for binaries and test log.
  58. BitcoinPullTester commented at 9:58 pm on September 16, 2013: none

    Automatic sanity-testing: FAILED MERGE, see http://jenkins.bluematt.me/pull-tester/18ad19fbde0688645f52e26ae545da2849d7c9b4 for test log.

    This pull does not merge cleanly onto current master This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  59. Diapolo commented at 6:06 am on September 17, 2013: none
    Needs a rebase to keep up with autotools.
  60. CodeShark commented at 8:35 am on September 17, 2013: contributor
    Actually, I accidentally pushed this - I am no longer supporting this branch and will close the pull request.
  61. CodeShark closed this on Sep 17, 2013

  62. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

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: 2024-11-17 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me