File tree Expand file tree Collapse file tree 5 files changed +41
-12
lines changed Expand file tree Collapse file tree 5 files changed +41
-12
lines changed Original file line number Diff line number Diff line change 66#define BITCOIN_INTERFACES_NODE_H
77
88#include < consensus/amount.h>
9- #include < external_signer.h>
109#include < net.h> // For NodeId
1110#include < net_types.h> // For banmap_t
1211#include < netaddress.h> // For Network
@@ -50,6 +49,16 @@ struct BlockAndHeaderTipInfo
5049 double verification_progress;
5150};
5251
52+ // ! External signer interface used by the GUI.
53+ class ExternalSigner
54+ {
55+ public:
56+ virtual ~ExternalSigner () {};
57+
58+ // ! Get signer display name
59+ virtual std::string getName () = 0;
60+ };
61+
5362// ! Top-level interface for a bitcoin node (bitcoind process).
5463class Node
5564{
@@ -111,8 +120,8 @@ class Node
111120 // ! Disconnect node by id.
112121 virtual bool disconnectById (NodeId id) = 0;
113122
114- // ! List external signers
115- virtual std::vector<ExternalSigner> externalSigners () = 0;
123+ // ! Return list of external signers (attached devices which can sign transactions).
124+ virtual std::vector<std::unique_ptr< ExternalSigner>> listExternalSigners () = 0;
116125
117126 // ! Get total bytes recv.
118127 virtual int64_t getTotalBytesRecv () = 0;
Original file line number Diff line number Diff line change @@ -67,6 +67,17 @@ using interfaces::WalletClient;
6767
6868namespace node {
6969namespace {
70+ #ifdef ENABLE_EXTERNAL_SIGNER
71+ class ExternalSignerImpl : public interfaces ::ExternalSigner
72+ {
73+ public:
74+ ExternalSignerImpl (::ExternalSigner signer) : m_signer(std::move(signer)) {}
75+ std::string getName () override { return m_signer.m_name ; }
76+ private:
77+ ::ExternalSigner m_signer;
78+ };
79+ #endif
80+
7081class NodeImpl : public Node
7182{
7283private:
@@ -172,14 +183,18 @@ class NodeImpl : public Node
172183 }
173184 return false ;
174185 }
175- std::vector<ExternalSigner> externalSigners () override
186+ std::vector<std::unique_ptr<interfaces:: ExternalSigner>> listExternalSigners () override
176187 {
177188#ifdef ENABLE_EXTERNAL_SIGNER
178189 std::vector<ExternalSigner> signers = {};
179190 const std::string command = gArgs .GetArg (" -signer" , " " );
180- if (command == " " ) return signers ;
191+ if (command == " " ) return {} ;
181192 ExternalSigner::Enumerate (command, signers, Params ().NetworkIDString ());
182- return signers;
193+ std::vector<std::unique_ptr<interfaces::ExternalSigner>> result;
194+ for (auto & signer : signers) {
195+ result.emplace_back (std::make_unique<ExternalSignerImpl>(std::move (signer)));
196+ }
197+ return result;
183198#else
184199 // This result is indistinguishable from a successful call that returns
185200 // no signers. For the current GUI this doesn't matter, because the wallet
Original file line number Diff line number Diff line change 66#include < config/bitcoin-config.h>
77#endif
88
9- #include < external_signer .h>
9+ #include < interfaces/node .h>
1010#include < qt/createwalletdialog.h>
1111#include < qt/forms/ui_createwalletdialog.h>
1212
@@ -113,7 +113,7 @@ CreateWalletDialog::~CreateWalletDialog()
113113 delete ui;
114114}
115115
116- void CreateWalletDialog::setSigners (const std::vector<ExternalSigner>& signers)
116+ void CreateWalletDialog::setSigners (const std::vector<std::unique_ptr<interfaces:: ExternalSigner> >& signers)
117117{
118118 m_has_signers = !signers.empty ();
119119 if (m_has_signers) {
@@ -126,7 +126,7 @@ void CreateWalletDialog::setSigners(const std::vector<ExternalSigner>& signers)
126126 ui->blank_wallet_checkbox ->setChecked (false );
127127 ui->disable_privkeys_checkbox ->setEnabled (false );
128128 ui->disable_privkeys_checkbox ->setChecked (true );
129- const std::string label = signers[0 ]. m_name ;
129+ const std::string label = signers[0 ]-> getName () ;
130130 ui->wallet_name_line_edit ->setText (QString::fromStdString (label));
131131 ui->buttonBox ->button (QDialogButtonBox::Ok)->setEnabled (true );
132132 } else {
Original file line number Diff line number Diff line change 77
88#include < QDialog>
99
10+ #include < memory>
11+
12+ namespace interfaces {
1013class ExternalSigner ;
14+ } // namespace interfaces
15+
1116class WalletModel ;
1217
1318namespace Ui {
@@ -24,7 +29,7 @@ class CreateWalletDialog : public QDialog
2429 explicit CreateWalletDialog (QWidget* parent);
2530 virtual ~CreateWalletDialog ();
2631
27- void setSigners (const std::vector<ExternalSigner>& signers);
32+ void setSigners (const std::vector<std::unique_ptr<interfaces:: ExternalSigner> >& signers);
2833
2934 QString walletName () const ;
3035 bool isEncryptWalletChecked () const ;
Original file line number Diff line number Diff line change @@ -274,9 +274,9 @@ void CreateWalletActivity::create()
274274{
275275 m_create_wallet_dialog = new CreateWalletDialog (m_parent_widget);
276276
277- std::vector<ExternalSigner> signers;
277+ std::vector<std::unique_ptr<interfaces:: ExternalSigner> > signers;
278278 try {
279- signers = node ().externalSigners ();
279+ signers = node ().listExternalSigners ();
280280 } catch (const std::runtime_error& e) {
281281 QMessageBox::critical (nullptr , tr (" Can't list signers" ), e.what ());
282282 }
You can’t perform that action at this time.
0 commit comments