Skip to content
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

UI external signer support (e.g. hardware wallet) #4

Merged
merged 7 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ class Wallet
// Return whether private keys enabled.
virtual bool privateKeysDisabled() = 0;

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

// Get default address type.
virtual OutputType getDefaultAddressType() = 0;

Expand Down
13 changes: 13 additions & 0 deletions src/qt/forms/receiverequestdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,19 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnVerify">
<property name="text">
<string>&amp;Verify</string>
</property>
<property name="toolTip">
<string>Verify this address on e.g. a hardware wallet screen</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSaveAs">
<property name="text">
Expand Down
6 changes: 6 additions & 0 deletions src/qt/receiverequestdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info)
ui->wallet_tag->hide();
ui->wallet_content->hide();
}

ui->btnVerify->setVisible(this->model->wallet().hasExternalSigner());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

62ac119

nit, drop this->.


connect(ui->btnVerify, &QPushButton::clicked, [this] {
model->displayAddress(info.address.toStdString());
});
}

void ReceiveRequestDialog::updateDisplayUnit()
Expand Down
12 changes: 12 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
return true;
}

bool WalletModel::displayAddress(std::string sAddress)
{
CTxDestination dest = DecodeDestination(sAddress);
bool res = false;
try {
res = m_wallet->displayAddress(dest);
} catch (const std::runtime_error& e) {
QMessageBox::critical(nullptr, tr("Can't display address"), e.what());
}
return res;
}

bool WalletModel::isWalletEnabled()
{
return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class WalletModel : public QObject
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest);

bool bumpFee(uint256 hash, uint256& new_hash);
bool displayAddress(std::string sAddress);

static bool isWalletEnabled();

Expand Down
1 change: 1 addition & 0 deletions src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ class WalletImpl : public Wallet
unsigned int getConfirmTarget() override { return m_wallet->m_confirm_target; }
bool hdEnabled() override { return m_wallet->IsHDEnabled(); }
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); }
OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; }
CAmount getDefaultMaxTxFee() override { return m_wallet->m_default_max_tx_fee; }
Expand Down