Skip to content

Commit

Permalink
Merge 63b5dfa into merged_master (Bitcoin PR bitcoin-core/gui#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
delta1 committed Jun 14, 2023
2 parents b8c1d97 + 63b5dfa commit 8886cea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
4 changes: 4 additions & 0 deletions doc/release-notes-gui-459.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ class Wallet
// Return whether private keys enabled.
virtual bool privateKeysDisabled() = 0;

// Return whether the wallet contains a Taproot scriptPubKeyMan
virtual bool taprootEnabled() = 0;

// Return whether wallet uses an external signer.
virtual bool hasExternalSigner() = 0;

Expand Down
10 changes: 2 additions & 8 deletions src/qt/forms/receivecoinsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="useBech32">
<widget class="QComboBox" name="addressType">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -211,12 +211,6 @@
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Native segwit addresses (aka Blech32) 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>
</property>
<property name="text">
<string>Generate native segwit (Bech32) address</string>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -366,7 +360,7 @@
<tabstops>
<tabstop>reqLabel</tabstop>
<tabstop>reqAmount</tabstop>
<tabstop>useBech32</tabstop>
<tabstop>addressType</tabstop>
<tabstop>reqMessage</tabstop>
<tabstop>receiveButton</tabstop>
<tabstop>clearButton</tabstop>
Expand Down
26 changes: 13 additions & 13 deletions src/qt/receivecoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,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.
Expand Down Expand Up @@ -150,15 +158,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())
Expand Down
5 changes: 5 additions & 0 deletions src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ class WalletImpl : public Wallet
bool canGetAddresses() override { return m_wallet->CanGetAddresses(); }
bool hasExternalSigner() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER); }
bool privateKeysDisabled() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); }
bool taprootEnabled() override {
if (m_wallet->IsLegacy()) return false;
auto spk_man = m_wallet->GetScriptPubKeyMan(OutputType::BECH32M, /*internal=*/false);
return spk_man != nullptr;
}
OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; }
CAmount getDefaultMaxTxFee() override { return m_wallet->m_default_max_tx_fee; }
void remove() override
Expand Down

0 comments on commit 8886cea

Please sign in to comment.