Skip to content

Commit 0e365bf

Browse files
committed
[gui] display address on external signer
1 parent b36fd6b commit 0e365bf

File tree

7 files changed

+38
-0
lines changed

7 files changed

+38
-0
lines changed

src/interfaces/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ class WalletImpl : public Wallet
448448
unsigned int getConfirmTarget() override { return m_wallet->m_confirm_target; }
449449
bool hdEnabled() override { return m_wallet->IsHDEnabled(); }
450450
bool canGetAddresses() override { return m_wallet->CanGetAddresses(); }
451+
bool hasExternalSigner() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER); }
451452
bool privateKeysDisabled() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); }
452453
OutputType getDefaultAddressType() override { return m_wallet->m_default_address_type; }
453454
CAmount getDefaultMaxTxFee() override { return m_wallet->m_default_max_tx_fee; }

src/interfaces/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ class Wallet
258258
// Return whether private keys enabled.
259259
virtual bool privateKeysDisabled() = 0;
260260

261+
// Return whether wallet uses an external signer.
262+
virtual bool hasExternalSigner() = 0;
263+
261264
// Get default address type.
262265
virtual OutputType getDefaultAddressType() = 0;
263266

src/qt/forms/receiverequestdialog.ui

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@
254254
</property>
255255
</widget>
256256
</item>
257+
<item>
258+
<widget class="QPushButton" name="btnVerify">
259+
<property name="text">
260+
<string>&amp;Verify</string>
261+
</property>
262+
<property name="toolTip">
263+
<string>Verify this address on e.g. a hardware wallet screen</string>
264+
</property>
265+
<property name="autoDefault">
266+
<bool>false</bool>
267+
</property>
268+
</widget>
269+
</item>
257270
<item>
258271
<widget class="QPushButton" name="btnSaveAs">
259272
<property name="text">

src/qt/receiverequestdialog.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info)
8989
ui->wallet_tag->hide();
9090
ui->wallet_content->hide();
9191
}
92+
93+
ui->btnVerify->setVisible(this->model->wallet().hasExternalSigner());
9294
}
9395

9496
void ReceiveRequestDialog::updateDisplayUnit()
@@ -106,3 +108,8 @@ void ReceiveRequestDialog::on_btnCopyAddress_clicked()
106108
{
107109
GUIUtil::setClipboard(info.address);
108110
}
111+
112+
void ReceiveRequestDialog::on_btnVerify_clicked()
113+
{
114+
model->displayAddress(info.address.toStdString());
115+
}

src/qt/receiverequestdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ReceiveRequestDialog : public QDialog
2929
private Q_SLOTS:
3030
void on_btnCopyURI_clicked();
3131
void on_btnCopyAddress_clicked();
32+
void on_btnVerify_clicked();
3233
void updateDisplayUnit();
3334

3435
private:

src/qt/walletmodel.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,18 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
563563
return true;
564564
}
565565

566+
bool WalletModel::displayAddress(std::string sAddress)
567+
{
568+
CTxDestination dest = DecodeDestination(sAddress);
569+
bool res = false;
570+
try {
571+
res = m_wallet->displayAddress(dest);
572+
} catch (const ExternalSignerException& e) {
573+
QMessageBox::critical(nullptr, tr("Can't display address"), e.what());
574+
}
575+
return res;
576+
}
577+
566578
bool WalletModel::isWalletEnabled()
567579
{
568580
return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);

src/qt/walletmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class WalletModel : public QObject
139139
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest);
140140

141141
bool bumpFee(uint256 hash, uint256& new_hash);
142+
bool displayAddress(std::string sAddress);
142143

143144
static bool isWalletEnabled();
144145

0 commit comments

Comments
 (0)