Skip to content

Commit a6a7947

Browse files
committed
Add "Create wallet if missing" option to the GUI
bwt-dev/bwt#76
1 parent dfdf807 commit a6a7947

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Add instructions and utility script for using the Electrum AppImage (#2)
44

5+
- Add "Create wallet if missing" option to the GUI (https://github.com/bwt-dev/bwt/issues/76)
6+
57
- Fix multi-signature wallet detection
68

79
## 0.2.1 - 2021-01-14

src/bwt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ def __init__(self, parent, config, name):
3636
self.enabled = config.get('bwt_enabled')
3737
self.bitcoind_url = config.get('bwt_bitcoind_url', default_bitcoind_url())
3838
self.bitcoind_dir = config.get('bwt_bitcoind_dir', default_bitcoind_dir())
39-
self.bitcoind_wallet = config.get('bwt_bitcoind_wallet')
4039
self.bitcoind_auth = config.get('bwt_bitcoind_auth', config.get('bwt_bitcoind_cred'))
40+
self.bitcoind_wallet = config.get('bwt_bitcoind_wallet')
41+
self.create_wallet_if_missing = config.get('bwt_create_wallet_if_missing', False)
4142
self.rescan_since = config.get('bwt_rescan_since', 'all')
4243
self.custom_opt = config.get('bwt_custom_opt')
4344
self.socket_path = config.get('bwt_socket_path', default_socket_path())
@@ -71,6 +72,9 @@ def start(self):
7172
if self.bitcoind_wallet:
7273
args.extend([ '--bitcoind-wallet', self.bitcoind_wallet ])
7374

75+
if self.create_wallet_if_missing:
76+
args.extend([ '--create-wallet-if-missing' ])
77+
7478
if self.socket_path:
7579
args.extend([ '--unix-listener-path', self.socket_path ])
7680

src/qt.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from PyQt5.QtCore import Qt, QObject, pyqtSignal
55
from PyQt5.QtGui import QTextOption
6-
from PyQt5.QtWidgets import QSizePolicy, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QTextEdit, QComboBox, QPushButton, QFormLayout
6+
from PyQt5.QtWidgets import QSizePolicy, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QTextEdit, QComboBox, QPushButton, QFormLayout, QCheckBox
77

88
from electrum.i18n import _
99
from electrum.plugin import hook
@@ -66,7 +66,11 @@ def settings_dialog(self, window):
6666
form.addRow('', helptext(_('Used for reading the cookie file. Ignored if auth is set.'), False))
6767

6868
wallet_e = input(self.bitcoind_wallet, 150)
69-
form.addRow(_('Wallet:'), wallet_e)
69+
wallet_ch = checkbox('Create if missing', self.create_wallet_if_missing)
70+
wallet_hbox = QHBoxLayout()
71+
wallet_hbox.addWidget(wallet_e)
72+
wallet_hbox.addWidget(wallet_ch)
73+
form.addRow(_('Wallet:'), wallet_hbox)
7074
form.addRow('', helptext(_('For use with multi-wallet. Leave blank to use the default wallet.'), False))
7175

7276

@@ -115,6 +119,7 @@ def save_config_and_run():
115119
self.bitcoind_dir = str(dir_e.text())
116120
self.bitcoind_auth = str(auth_e.text())
117121
self.bitcoind_wallet = str(wallet_e.text())
122+
self.create_wallet_if_missing = wallet_ch.isChecked()
118123
self.rescan_since = get_rescan_value(rescan_c, rescan_e)
119124
self.custom_opt = str(custom_opt_e.text())
120125
self.verbose = verbose_c.currentIndex()
@@ -124,6 +129,7 @@ def save_config_and_run():
124129
self.config.set_key('bwt_bitcoind_dir', self.bitcoind_dir)
125130
self.config.set_key('bwt_bitcoind_auth', self.bitcoind_auth)
126131
self.config.set_key('bwt_bitcoind_wallet', self.bitcoind_wallet)
132+
self.config.set_key('bwt_create_wallet_if_missing', self.create_wallet_if_missing)
127133
self.config.set_key('bwt_rescan_since', self.rescan_since)
128134
self.config.set_key('bwt_custom_opt', self.custom_opt)
129135
self.config.set_key('bwt_verbose', self.verbose)
@@ -179,6 +185,11 @@ def helptext(text, wrap=True):
179185
l.setStyleSheet('QLabel { color: #aaa; font-size: 0.9em }')
180186
return l
181187

188+
def checkbox(text, selected=False):
189+
ch = QCheckBox(text)
190+
ch.setChecked(selected)
191+
return ch
192+
182193
def show_log(log_t, level, pkg, msg):
183194
scrollbar = log_t.verticalScrollBar()
184195
wasOnBottom = scrollbar.value() >= scrollbar.maximum() - 5

0 commit comments

Comments
 (0)