Skip to content

Commit c9a77e2

Browse files
Sjorspromag
andcommitted
gui: address type dropdown, add bech32m
Co-authored-by: João Barbosa <[email protected]>
1 parent 56113da commit c9a77e2

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

doc/release-notes-gui-459.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GUI changes
2+
-----------
3+
4+
- The Bech32 checkbox has been replaced with a dropdown for all address types, including the new Bech32m (BIP-350) standard for Taproot enabled wallets.

src/qt/forms/receivecoinsdialog.ui

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
</widget>
196196
</item>
197197
<item>
198-
<widget class="QCheckBox" name="useBech32">
198+
<widget class="QComboBox" name="addressType">
199199
<property name="sizePolicy">
200200
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
201201
<horstretch>0</horstretch>
@@ -211,12 +211,6 @@
211211
<property name="focusPolicy">
212212
<enum>Qt::StrongFocus</enum>
213213
</property>
214-
<property name="toolTip">
215-
<string>Native segwit addresses (aka Bech32 or BIP-173) reduce your transaction fees later on and offer better protection against typos, but old wallets don't support them. When unchecked, an address compatible with older wallets will be created instead.</string>
216-
</property>
217-
<property name="text">
218-
<string>Generate native segwit (Bech32) address</string>
219-
</property>
220214
</widget>
221215
</item>
222216
<item>
@@ -366,7 +360,7 @@
366360
<tabstops>
367361
<tabstop>reqLabel</tabstop>
368362
<tabstop>reqAmount</tabstop>
369-
<tabstop>useBech32</tabstop>
363+
<tabstop>addressType</tabstop>
370364
<tabstop>reqMessage</tabstop>
371365
<tabstop>receiveButton</tabstop>
372366
<tabstop>clearButton</tabstop>

src/qt/receivecoinsdialog.cpp

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

90-
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
91-
ui->useBech32->setCheckState(Qt::Checked);
92-
} else {
93-
ui->useBech32->setCheckState(Qt::Unchecked);
90+
// Populate address type dropdown and select default
91+
auto add_address_type = [&](OutputType type, const QString& text, const QString& tooltip) {
92+
const auto index = ui->addressType->count();
93+
ui->addressType->addItem(text, (int) type);
94+
ui->addressType->setItemData(index, tooltip, Qt::ToolTipRole);
95+
if (model->wallet().getDefaultAddressType() == type) ui->addressType->setCurrentIndex(index);
96+
};
97+
add_address_type(OutputType::LEGACY, "Base58 (Legacy)", "Not recommended due to higher fees and less protection against typos.");
98+
add_address_type(OutputType::P2SH_SEGWIT, "Base58 (P2SH-SegWit)", "Generates an address compatible with older wallets.");
99+
add_address_type(OutputType::BECH32, "Bech32 (SegWit)", "Generates a native segwit address (BIP-173). Some old wallets don't support it.");
100+
if (model->wallet().taprootEnabled()) {
101+
add_address_type(OutputType::BECH32M, "Bech32m (Taproot)", "Bech32m (BIP-350) is an upgrade to Bech32, wallet support is still limited.");
94102
}
95103

96104
// Set the button to be enabled or disabled based on whether the wallet can give out new addresses.
@@ -144,15 +152,7 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
144152
QString address;
145153
QString label = ui->reqLabel->text();
146154
/* Generate new receiving address */
147-
OutputType address_type;
148-
if (ui->useBech32->isChecked()) {
149-
address_type = OutputType::BECH32;
150-
} else {
151-
address_type = model->wallet().getDefaultAddressType();
152-
if (address_type == OutputType::BECH32) {
153-
address_type = OutputType::P2SH_SEGWIT;
154-
}
155-
}
155+
const OutputType address_type = (OutputType)ui->addressType->currentData().toInt();
156156
address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, label, "", address_type);
157157

158158
switch(model->getAddressTableModel()->getEditStatus())

0 commit comments

Comments
 (0)