-
Notifications
You must be signed in to change notification settings - Fork 302
Address type dropdown, add Taproot (Receive tab) #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe replace "wallets" with "services" or "third-party services" or "third-party wallets". Otherwise the user might get confused into thinking that an old wallet.dat can't generate this, which is not true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if they're more likely to think of an upgrade scenario than about receiving coins from another wallet they have? "third-party" is a bit of an tech industry term, and probably doesn't translate well. Paging @jonatack. ("other, old, wallets" is more clear perhaps, though maybe not pretty) |
||
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()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,6 +461,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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this special case needed? Wouldn't it return nullptr below? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe not, but since legacy wallets don't have descriptors, it does seem cleaner. |
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a check (like the one for taproot)?
Locally, I am getting:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you manually created a wallet without a
pkh()
descriptor? We could add checks for the existence of each output type to the interface and then remove them from the dropdown. However, if someone manually creates a wallet, they would also understand the error message, and it might even better than a missing item?