Skip to content

Commit f04337e

Browse files
committed
gui: add taproot checkbox
1 parent 3caa616 commit f04337e

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

src/qt/forms/receivecoinsdialog.ui

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,31 @@
219219
</property>
220220
</widget>
221221
</item>
222+
<item>
223+
<widget class="QCheckBox" name="useTaproot">
224+
<property name="sizePolicy">
225+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
226+
<horstretch>0</horstretch>
227+
<verstretch>0</verstretch>
228+
</sizepolicy>
229+
</property>
230+
<property name="maximumSize">
231+
<size>
232+
<width>1000</width>
233+
<height>16777215</height>
234+
</size>
235+
</property>
236+
<property name="focusPolicy">
237+
<enum>Qt::StrongFocus</enum>
238+
</property>
239+
<property name="toolTip">
240+
<string>Although the addresses (Bech32m or BIP-350) in Taproot look very similiar to Bech32 addresses, some wallets are not yet able to send to them.</string>
241+
</property>
242+
<property name="text">
243+
<string>Use Taproot</string>
244+
</property>
245+
</widget>
246+
</item>
222247
<item>
223248
<spacer name="horizontalSpacer_3">
224249
<property name="orientation">

src/qt/receivecoinsdialog.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,23 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
8787
&QItemSelectionModel::selectionChanged, this,
8888
&ReceiveCoinsDialog::recentRequestsView_selectionChanged);
8989

90-
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
90+
const OutputType address_type = model->wallet().getDefaultAddressType();
91+
if (address_type == OutputType::BECH32 || address_type == OutputType::BECH32M) {
9192
ui->useBech32->setCheckState(Qt::Checked);
9293
} else {
9394
ui->useBech32->setCheckState(Qt::Unchecked);
9495
}
9596

97+
ui->useTaproot->setVisible(model->wallet().taprootEnabled());
98+
99+
// Enable/disable Taproot checkbox depending on bech32 choice
100+
connect(ui->useBech32, &QCheckBox::toggled, [this](bool checked) {
101+
ui->useTaproot->setEnabled(checked);
102+
if (!checked) {
103+
ui->useTaproot->setChecked(false);
104+
}
105+
});
106+
96107
// Set the button to be enabled or disabled based on whether the wallet can give out new addresses.
97108
ui->receiveButton->setEnabled(model->wallet().canGetAddresses());
98109

@@ -146,10 +157,10 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
146157
/* Generate new receiving address */
147158
OutputType address_type;
148159
if (ui->useBech32->isChecked()) {
149-
address_type = OutputType::BECH32;
160+
address_type = ui->useTaproot->isChecked() ? OutputType::BECH32M : OutputType::BECH32;
150161
} else {
151162
address_type = model->wallet().getDefaultAddressType();
152-
if (address_type == OutputType::BECH32) {
163+
if (address_type == OutputType::BECH32 || address_type == OutputType::BECH32M) {
153164
address_type = OutputType::P2SH_SEGWIT;
154165
}
155166
}

0 commit comments

Comments
 (0)