From c9a77e227eecf357c7dd550efb8c1827bb99a5de Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Wed, 8 Dec 2021 18:10:06 +0700 Subject: [PATCH] gui: address type dropdown, add bech32m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Barbosa --- doc/release-notes-gui-459.md | 4 ++++ src/qt/forms/receivecoinsdialog.ui | 10 ++-------- src/qt/receivecoinsdialog.cpp | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 doc/release-notes-gui-459.md diff --git a/doc/release-notes-gui-459.md b/doc/release-notes-gui-459.md new file mode 100644 index 0000000000..b590ac5d45 --- /dev/null +++ b/doc/release-notes-gui-459.md @@ -0,0 +1,4 @@ +GUI changes +----------- + +- The Bech32 checkbox has been replaced with a dropdown for all address types, including the new Bech32m (BIP-350) standard for Taproot enabled wallets. diff --git a/src/qt/forms/receivecoinsdialog.ui b/src/qt/forms/receivecoinsdialog.ui index 06d39426c9..4b2c3ed434 100644 --- a/src/qt/forms/receivecoinsdialog.ui +++ b/src/qt/forms/receivecoinsdialog.ui @@ -195,7 +195,7 @@ - + 0 @@ -211,12 +211,6 @@ Qt::StrongFocus - - 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. - - - Generate native segwit (Bech32) address - @@ -366,7 +360,7 @@ reqLabel reqAmount - useBech32 + addressType reqMessage receiveButton clearButton diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index d47ee95826..0d859a8253 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -87,10 +87,18 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model) &QItemSelectionModel::selectionChanged, this, &ReceiveCoinsDialog::recentRequestsView_selectionChanged); - if (model->wallet().getDefaultAddressType() == OutputType::BECH32) { - ui->useBech32->setCheckState(Qt::Checked); - } else { - ui->useBech32->setCheckState(Qt::Unchecked); + // Populate address type dropdown and select default + auto add_address_type = [&](OutputType type, const QString& text, const QString& tooltip) { + const auto index = ui->addressType->count(); + ui->addressType->addItem(text, (int) type); + ui->addressType->setItemData(index, tooltip, Qt::ToolTipRole); + if (model->wallet().getDefaultAddressType() == type) ui->addressType->setCurrentIndex(index); + }; + add_address_type(OutputType::LEGACY, "Base58 (Legacy)", "Not recommended due to higher fees and less protection against typos."); + add_address_type(OutputType::P2SH_SEGWIT, "Base58 (P2SH-SegWit)", "Generates an address compatible with older wallets."); + add_address_type(OutputType::BECH32, "Bech32 (SegWit)", "Generates a native segwit address (BIP-173). Some old wallets don't support it."); + if (model->wallet().taprootEnabled()) { + add_address_type(OutputType::BECH32M, "Bech32m (Taproot)", "Bech32m (BIP-350) is an upgrade to Bech32, wallet support is still limited."); } // 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() QString address; QString label = ui->reqLabel->text(); /* Generate new receiving address */ - OutputType address_type; - if (ui->useBech32->isChecked()) { - address_type = OutputType::BECH32; - } else { - address_type = model->wallet().getDefaultAddressType(); - if (address_type == OutputType::BECH32) { - address_type = OutputType::P2SH_SEGWIT; - } - } + const OutputType address_type = (OutputType)ui->addressType->currentData().toInt(); address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, label, "", address_type); switch(model->getAddressTableModel()->getEditStatus())