diff options
author | Sjors Provoost <sjors@sprovoost.nl> | 2021-12-08 18:10:06 +0700 |
---|---|---|
committer | Sjors Provoost <sjors@sprovoost.nl> | 2021-12-21 11:45:28 +0700 |
commit | c9a77e227eecf357c7dd550efb8c1827bb99a5de (patch) | |
tree | 217d180d81c08709d2c7a890680a096016e219a6 /src/qt/receivecoinsdialog.cpp | |
parent | 56113daef4830cad1af3c00f6b3c447c9e2a8e05 (diff) |
gui: address type dropdown, add bech32m
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
Diffstat (limited to 'src/qt/receivecoinsdialog.cpp')
-rw-r--r-- | src/qt/receivecoinsdialog.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
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()) |