Skip to content

Commit ad47fb8

Browse files
committed
Merge bitcoin-core#416: Add RPC setting
bd5c826 gui: add RPC setting (Sjors Provoost) Pull request description: RPC access is disabled by default for the GUI. With the proliferation of third party desktop applications that use the Bitcoin Core RPC (e.g. Specter Desktop, Sparrow and Wasabi), this PR makes them slight easier to configure. It's no longer required to find and edit `bitcoin.conf` to add `server=1` to it. <img width="447" alt="Schermafbeelding 2021-09-02 om 14 25 58" src="https://user-images.githubusercontent.com/10217/131844201-be3b49a8-ae88-47e6-8992-e95ee6b70f69.png"> ACKs for top commit: hebasto: ACK bd5c826, tested on Linux Mint 20.2 (Qt 5.12.8): shaavan: reACK bd5c826 promag: Code review ACK bd5c826. Just minor fixes to the .ui form since last review. Tree-SHA512: ab377e2358826096b499013bc3a864b7b63dff9859e96041e93ff0897d2319a35e8b3adcfb8df5f83274466c83d040d4ea18c546699421425c835e6f42562ae0
2 parents ccc4b91 + bd5c826 commit ad47fb8

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<string>Automatically start %1 after logging in to the system.</string>
3434
</property>
3535
<property name="text">
36-
<string>&amp;Start %1 on system login</string>
36+
<string>Start %1 on system &amp;login</string>
3737
</property>
3838
</widget>
3939
</item>
@@ -179,13 +179,23 @@
179179
<property name="sizeHint" stdset="0">
180180
<size>
181181
<width>40</width>
182-
<height>20</height>
182+
<height>40</height>
183183
</size>
184184
</property>
185185
</spacer>
186186
</item>
187187
</layout>
188188
</item>
189+
<item>
190+
<widget class="QCheckBox" name="enableServer">
191+
<property name="toolTip">
192+
<string extracomment="Tooltip text for Options window setting that enables the RPC server.">This allows you or a third party tool to communicate with the node through command-line and JSON-RPC commands.</string>
193+
</property>
194+
<property name="text">
195+
<string extracomment="An Options window setting to enable the RPC server.">Enable RPC &amp;server</string>
196+
</property>
197+
</widget>
198+
</item>
189199
<item>
190200
<spacer name="verticalSpacer_Main">
191201
<property name="orientation">

src/qt/optionsdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
210210
connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
211211
/* Network */
212212
connect(ui->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
213+
connect(ui->enableServer, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
213214
connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
214215
connect(ui->connectSocksTor, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
215216
/* Display */
@@ -246,6 +247,7 @@ void OptionsDialog::setMapper()
246247
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
247248
mapper->addMapping(ui->mapPortNatpmp, OptionsModel::MapPortNatpmp);
248249
mapper->addMapping(ui->allowIncoming, OptionsModel::Listen);
250+
mapper->addMapping(ui->enableServer, OptionsModel::Server);
249251

250252
mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse);
251253
mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP);

src/qt/optionsmodel.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ void OptionsModel::Init(bool resetSettings)
149149
if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
150150
addOverriddenOption("-listen");
151151

152+
if (!settings.contains("server")) {
153+
settings.setValue("server", false);
154+
}
155+
if (!gArgs.SoftSetBoolArg("-server", settings.value("server").toBool())) {
156+
addOverriddenOption("-server");
157+
}
158+
152159
if (!settings.contains("fUseProxy"))
153160
settings.setValue("fUseProxy", false);
154161
if (!settings.contains("addrProxy"))
@@ -363,6 +370,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
363370
return settings.value("nThreadsScriptVerif");
364371
case Listen:
365372
return settings.value("fListen");
373+
case Server:
374+
return settings.value("server");
366375
default:
367376
return QVariant();
368377
}
@@ -528,6 +537,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
528537
setRestartRequired(true);
529538
}
530539
break;
540+
case Server:
541+
if (settings.value("server") != value) {
542+
settings.setValue("server", value);
543+
setRestartRequired(true);
544+
}
545+
break;
531546
default:
532547
break;
533548
}

src/qt/optionsmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class OptionsModel : public QAbstractListModel
6969
ExternalSignerPath, // QString
7070
SpendZeroConfChange, // bool
7171
Listen, // bool
72+
Server, // bool
7273
OptionIDRowCount,
7374
};
7475

0 commit comments

Comments
 (0)