|
5 | 5 | #include <interfaces/wallet.h> |
6 | 6 |
|
7 | 7 | #include <amount.h> |
| 8 | +#include <chainparams.h> |
| 9 | +#include <external_signer.h> |
8 | 10 | #include <interfaces/chain.h> |
9 | 11 | #include <interfaces/handler.h> |
10 | 12 | #include <policy/fees.h> |
@@ -500,6 +502,16 @@ class WalletImpl : public Wallet |
500 | 502 | std::shared_ptr<CWallet> m_wallet; |
501 | 503 | }; |
502 | 504 |
|
| 505 | +class ExternalSignerImpl : public interfaces::ExternalSigner |
| 506 | +{ |
| 507 | +public: |
| 508 | +#ifdef ENABLE_EXTERNAL_SIGNER |
| 509 | + ExternalSignerImpl(::ExternalSigner signer) : m_signer(std::move(signer)) {} |
| 510 | + std::string getName() override { return m_signer.m_name; } |
| 511 | + ::ExternalSigner m_signer; |
| 512 | +#endif |
| 513 | +}; |
| 514 | + |
503 | 515 | class WalletClientImpl : public WalletClient |
504 | 516 | { |
505 | 517 | public: |
@@ -559,6 +571,28 @@ class WalletClientImpl : public WalletClient |
559 | 571 | } |
560 | 572 | return paths; |
561 | 573 | } |
| 574 | + std::vector<std::unique_ptr<interfaces::ExternalSigner>> listExternalSigners() override |
| 575 | + { |
| 576 | +#ifdef ENABLE_EXTERNAL_SIGNER |
| 577 | + const std::string command = gArgs.GetArg("-signer", ""); |
| 578 | + if (command == "") return {}; |
| 579 | + std::vector<::ExternalSigner> signers; |
| 580 | + ExternalSigner::Enumerate(command, signers, Params().NetworkIDString()); |
| 581 | + std::vector<std::unique_ptr<interfaces::ExternalSigner>> result; |
| 582 | + for (auto& signer : signers) { |
| 583 | + result.emplace_back(std::make_unique<ExternalSignerImpl>(std::move(signer))); |
| 584 | + } |
| 585 | + return result; |
| 586 | +#else |
| 587 | + // This result is indistinguishable from a successful call that returns |
| 588 | + // no signers. For the current GUI this doesn't matter, because the wallet |
| 589 | + // creation dialog disables the external signer checkbox in both |
| 590 | + // cases. The return type could be changed to std::optional<std::vector> |
| 591 | + // (or something that also includes error messages) if this distinction |
| 592 | + // becomes important. |
| 593 | + return {}; |
| 594 | +#endif // ENABLE_EXTERNAL_SIGNER |
| 595 | + } |
562 | 596 | std::vector<std::unique_ptr<Wallet>> getWallets() override |
563 | 597 | { |
564 | 598 | std::vector<std::unique_ptr<Wallet>> wallets; |
|
0 commit comments