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 6
6
#define BITCOIN_INTERFACES_NODE_H
7
7
8
8
#include < consensus/amount.h>
9
- #include < external_signer.h>
10
9
#include < net.h> // For NodeId
11
10
#include < net_types.h> // For banmap_t
12
11
#include < netaddress.h> // For Network
@@ -50,6 +49,16 @@ struct BlockAndHeaderTipInfo
50
49
double verification_progress;
51
50
};
52
51
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
+
53
62
// ! Top-level interface for a bitcoin node (bitcoind process).
54
63
class Node
55
64
{
@@ -111,8 +120,8 @@ class Node
111
120
// ! Disconnect node by id.
112
121
virtual bool disconnectById (NodeId id) = 0;
113
122
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;
116
125
117
126
// ! Get total bytes recv.
118
127
virtual int64_t getTotalBytesRecv () = 0;
Original file line number Diff line number Diff line change @@ -67,6 +67,17 @@ using interfaces::WalletClient;
67
67
68
68
namespace node {
69
69
namespace {
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
+
70
81
class NodeImpl : public Node
71
82
{
72
83
private:
@@ -172,14 +183,18 @@ class NodeImpl : public Node
172
183
}
173
184
return false ;
174
185
}
175
- std::vector<ExternalSigner> externalSigners () override
186
+ std::vector<std::unique_ptr<interfaces:: ExternalSigner>> listExternalSigners () override
176
187
{
177
188
#ifdef ENABLE_EXTERNAL_SIGNER
178
189
std::vector<ExternalSigner> signers = {};
179
190
const std::string command = gArgs .GetArg (" -signer" , " " );
180
- if (command == " " ) return signers ;
191
+ if (command == " " ) return {} ;
181
192
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;
183
198
#else
184
199
// This result is indistinguishable from a successful call that returns
185
200
// no signers. For the current GUI this doesn't matter, because the wallet
Original file line number Diff line number Diff line change 6
6
#include < config/bitcoin-config.h>
7
7
#endif
8
8
9
- #include < external_signer .h>
9
+ #include < interfaces/node .h>
10
10
#include < qt/createwalletdialog.h>
11
11
#include < qt/forms/ui_createwalletdialog.h>
12
12
@@ -113,7 +113,7 @@ CreateWalletDialog::~CreateWalletDialog()
113
113
delete ui;
114
114
}
115
115
116
- void CreateWalletDialog::setSigners (const std::vector<ExternalSigner>& signers)
116
+ void CreateWalletDialog::setSigners (const std::vector<std::unique_ptr<interfaces:: ExternalSigner> >& signers)
117
117
{
118
118
m_has_signers = !signers.empty ();
119
119
if (m_has_signers) {
@@ -126,7 +126,7 @@ void CreateWalletDialog::setSigners(const std::vector<ExternalSigner>& signers)
126
126
ui->blank_wallet_checkbox ->setChecked (false );
127
127
ui->disable_privkeys_checkbox ->setEnabled (false );
128
128
ui->disable_privkeys_checkbox ->setChecked (true );
129
- const std::string label = signers[0 ]. m_name ;
129
+ const std::string label = signers[0 ]-> getName () ;
130
130
ui->wallet_name_line_edit ->setText (QString::fromStdString (label));
131
131
ui->buttonBox ->button (QDialogButtonBox::Ok)->setEnabled (true );
132
132
} else {
Original file line number Diff line number Diff line change 7
7
8
8
#include < QDialog>
9
9
10
+ #include < memory>
11
+
12
+ namespace interfaces {
10
13
class ExternalSigner ;
14
+ } // namespace interfaces
15
+
11
16
class WalletModel ;
12
17
13
18
namespace Ui {
@@ -24,7 +29,7 @@ class CreateWalletDialog : public QDialog
24
29
explicit CreateWalletDialog (QWidget* parent);
25
30
virtual ~CreateWalletDialog ();
26
31
27
- void setSigners (const std::vector<ExternalSigner>& signers);
32
+ void setSigners (const std::vector<std::unique_ptr<interfaces:: ExternalSigner> >& signers);
28
33
29
34
QString walletName () const ;
30
35
bool isEncryptWalletChecked () const ;
Original file line number Diff line number Diff line change @@ -274,9 +274,9 @@ void CreateWalletActivity::create()
274
274
{
275
275
m_create_wallet_dialog = new CreateWalletDialog (m_parent_widget);
276
276
277
- std::vector<ExternalSigner> signers;
277
+ std::vector<std::unique_ptr<interfaces:: ExternalSigner> > signers;
278
278
try {
279
- signers = node ().externalSigners ();
279
+ signers = node ().listExternalSigners ();
280
280
} catch (const std::runtime_error& e) {
281
281
QMessageBox::critical (nullptr , tr (" Can't list signers" ), e.what ());
282
282
}
You can’t perform that action at this time.
0 commit comments