def open_wallet(self, filename): directory, basename = os.path.split(filename) dbenv = self.get_dbenv_handle(directory) uid = bsddb_read_file_uid(filename) if uid in dbenv.open_file_uids: raise Exception("Multiple wallets with the same uid unsupported in the same directory.") wallet_db = BSDDBWalletDatabase(dbenv, basename) wallet = Wallet(wallet_db, self.clientparams.runmode) wallet.open() account = WalletAccount(self.log, basename, wallet, self.blockchain) TransactionPublisher(self.node, account) self.account_set.add_account(account) self.account_infos[account] = (dbenv, directory, basename) #add uid last in case something went wrong before dbenv.open_file_uids.add(uid)
def new_wallet(self, filename, passphrase): directory, basename = os.path.split(filename) dbenv = self.get_dbenv_handle(directory) wallet_db = BSDDBWalletDatabase(dbenv, basename) wallet_db.create() wallet = Wallet(wallet_db, self.clientparams.runmode) wallet.create(passphrase) #add file uid to list dbenv.open_file_uids.add(bsddb_read_file_uid(filename)) account = WalletAccount(self.log, basename, wallet, self.blockchain) TransactionPublisher(self.node, account) self.account_set.add_account(account) self.account_infos[account] = (dbenv, directory, basename)
def open_wallet(self, filename): directory, basename = os.path.split(filename) dbenv = self.get_dbenv_handle(directory) uid = bsddb_read_file_uid(filename) if uid in dbenv.open_file_uids: raise Exception( "Multiple wallets with the same uid unsupported in the same directory." ) wallet_db = BSDDBWalletDatabase(dbenv, basename) wallet = Wallet(wallet_db, self.clientparams.runmode) wallet.open() account = WalletAccount(self.log, basename, wallet, self.blockchain) TransactionPublisher(self.node, account) self.account_set.add_account(account) self.account_infos[account] = (dbenv, directory, basename) #add uid last in case something went wrong before dbenv.open_file_uids.add(uid)
def close_wallet(self, account): dbenv, directory, basename = self.account_infos[account] uid = bsddb_read_file_uid(os.path.join(directory, basename)) dbenv.open_file_uids.remove(uid) self.account_set.remove_account(account) del self.account_infos[account]