Skip to content

Commit fc5da52

Browse files
committed
wallet: add GetExternalSigner()
1 parent 259f52c commit fc5da52

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/wallet/external_signer_scriptpubkeyman.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ bool ExternalSignerScriptPubKeyMan::SetupDescriptor(std::unique_ptr<Descriptor>
3333
return true;
3434
}
3535

36+
ExternalSigner ExternalSignerScriptPubKeyMan::GetExternalSigner() {
37+
const std::string command = gArgs.GetArg("-signer", "");
38+
if (command == "") throw std::runtime_error(std::string(__func__) + ": restart bitcoind with -signer=<cmd>");
39+
std::vector<ExternalSigner> signers;
40+
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
41+
if (signers.empty()) throw std::runtime_error(std::string(__func__) + ": No external signers found");
42+
// TODO: add fingerprint argument in case of multiple signers
43+
return signers[0];
44+
}
45+
3646
#endif

src/wallet/wallet.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3573,6 +3573,19 @@ void ReserveDestination::ReturnDestination()
35733573
address = CNoDestination();
35743574
}
35753575

3576+
#ifdef ENABLE_EXTERNAL_SIGNER
3577+
ExternalSigner CWallet::GetExternalSigner()
3578+
{
3579+
const std::string command = gArgs.GetArg("-signer", "");
3580+
if (command == "") throw std::runtime_error(std::string(__func__) + ": restart bitcoind with -signer=<cmd>");
3581+
std::vector<ExternalSigner> signers;
3582+
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
3583+
if (signers.empty()) throw std::runtime_error(std::string(__func__) + ": No external signers found");
3584+
// TODO: add fingerprint argument in case of multiple signers
3585+
return signers[0];
3586+
}
3587+
#endif
3588+
35763589
void CWallet::LockCoin(const COutPoint& output)
35773590
{
35783591
AssertLockHeld(cs_wallet);

src/wallet/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
839839

840840
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool separate_coins, const CFeeRate& effective_feerate, const CFeeRate& long_term_feerate, const CoinEligibilityFilter& filter, bool positive_only) const;
841841

842+
#ifdef ENABLE_EXTERNAL_SIGNER
843+
ExternalSigner GetExternalSigner() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
844+
#endif
842845
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
843846
void LockCoin(const COutPoint& output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
844847
void UnlockCoin(const COutPoint& output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);

0 commit comments

Comments
 (0)