Skip to content

Commit 575e4e4

Browse files
committed
[gui] wallet client: get external signer list
1 parent 0e365bf commit 575e4e4

File tree

6 files changed

+44
-3
lines changed

6 files changed

+44
-3
lines changed

src/interfaces/wallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ class WalletClientImpl : public WalletClient
572572
return HandleLoadWallet(std::move(fn));
573573
}
574574

575+
ExternalSignerList ExternalSigners() override
576+
{
577+
return ListExternalSigners();
578+
}
579+
575580
WalletContext m_context;
576581
const std::vector<std::string> m_wallet_filenames;
577582
std::vector<std::unique_ptr<Handler>> m_rpc_handlers;

src/interfaces/wallet.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ class Wallet
312312
//! Wallet chain client that in addition to having chain client methods for
313313
//! starting up, shutting down, and registering RPCs, also has additional
314314
//! methods (called by the GUI) to load and create wallets.
315+
typedef std::vector<std::pair<std::string, std::string>> ExternalSignerList; // TODO: figure out where to define this
316+
315317
class WalletClient : public ChainClient
316318
{
317319
public:
@@ -335,6 +337,9 @@ class WalletClient : public ChainClient
335337
//! loaded at startup or by RPC.
336338
using LoadWalletFn = std::function<void(std::unique_ptr<Wallet> wallet)>;
337339
virtual std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) = 0;
340+
341+
//! List external signers
342+
virtual ExternalSignerList ExternalSigners() = 0;
338343
};
339344

340345
//! Information about one wallet address.

src/qt/walletcontroller.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ void CreateWalletActivity::finish()
281281

282282
void CreateWalletActivity::create()
283283
{
284+
// Check for external signers
285+
286+
284287
m_create_wallet_dialog = new CreateWalletDialog(m_parent_widget);
285288
m_create_wallet_dialog->setWindowModality(Qt::ApplicationModal);
286289
m_create_wallet_dialog->show();

src/wallet/wallet.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <wallet/coinselection.h>
2323
#include <wallet/crypter.h>
2424
#include <wallet/scriptpubkeyman.h>
25-
#include <wallet/externalsigner.h>
2625
#include <wallet/walletdb.h>
2726
#include <wallet/walletutil.h>
2827

@@ -96,8 +95,6 @@ constexpr CAmount DEFAULT_TRANSACTION_MAXFEE{COIN / 10};
9695
constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
9796
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
9897
constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
99-
//! -signer default
100-
static const std::string DEFAULT_EXTERNAL_SIGNER = "";
10198
//! Pre-calculated constants for input size estimation in *virtual size*
10299
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
103100

@@ -619,6 +616,7 @@ struct CoinSelectionParams
619616
CoinSelectionParams() {}
620617
};
621618

619+
typedef std::vector<std::pair<std::string, std::string>> ExternalSignerList;
622620
class WalletRescanReserver; //forward declarations for ScanForWalletTransactions/RescanFromTime
623621
/**
624622
* A CWallet maintains a set of transactions and balances, and provides the ability to create new transactions.

src/wallet/walletutil.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <wallet/walletutil.h>
66

7+
#include <chainparams.h>
78
#include <logging.h>
89
#include <util/system.h>
910

@@ -91,3 +92,21 @@ std::vector<fs::path> ListWalletDir()
9192

9293
return paths;
9394
}
95+
96+
ExternalSignerList ListExternalSigners()
97+
{
98+
ExternalSignerList result = {};
99+
#ifdef ENABLE_EXTERNAL_SIGNER
100+
const std::string command = gArgs.GetArg("-signer", DEFAULT_EXTERNAL_SIGNER);
101+
if (command == "") return result;
102+
std::string chain = gArgs.GetChainName();
103+
const bool mainnet = chain == CBaseChainParams::MAIN;
104+
std::vector<ExternalSigner> signers;
105+
ExternalSigner::Enumerate(command, signers, mainnet, /* ignore_errors */ false);
106+
if (signers.empty()) return {};
107+
for (ExternalSigner signer : signers) {
108+
result.push_back(make_pair(signer.m_fingerprint, signer.m_name));
109+
}
110+
#endif
111+
return result;
112+
}

src/wallet/walletutil.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
#include <fs.h>
99
#include <script/descriptor.h>
10+
#include <wallet/externalsigner.h>
1011

1112
#include <vector>
1213

14+
//! -signer default
15+
static const std::string DEFAULT_EXTERNAL_SIGNER = "";
16+
1317
/** (client) version numbers for particular wallet features */
1418
enum WalletFeature
1519
{
@@ -70,6 +74,13 @@ fs::path GetWalletDir();
7074
//! Get wallets in wallet directory.
7175
std::vector<fs::path> ListWalletDir();
7276

77+
typedef std::vector<std::pair<std::string, std::string>> ExternalSignerList; // TODO: figure out where to define this
78+
/**
79+
* Calls enumerate if -signer is configured and returns a list of signer
80+
* fingerpints and names. Otherwise returns an empty list.
81+
*/
82+
ExternalSignerList ListExternalSigners();
83+
7384
/** Descriptor with some wallet metadata */
7485
class WalletDescriptor
7586
{

0 commit comments

Comments
 (0)