Skip to content

Commit 157ea7c

Browse files
committed
wallet: add external_signer flag
1 parent f3e6ce7 commit 157ea7c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/wallet/wallet.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::strin
259259
wallet_creation_flags |= WALLET_FLAG_BLANK_WALLET;
260260
}
261261

262+
// Private keys must be disabled for an external signer wallet
263+
if ((wallet_creation_flags & WALLET_FLAG_EXTERNAL_SIGNER) && !(wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
264+
error = Untranslated("Private keys must be disabled when using an external signer");
265+
status = DatabaseStatus::FAILED_CREATE;
266+
return nullptr;
267+
}
268+
269+
// Descriptor support must be enabled for an external signer wallet
270+
if ((wallet_creation_flags & WALLET_FLAG_EXTERNAL_SIGNER) && !(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) {
271+
error = Untranslated("Descriptor support must be enabled when using an external signer");
272+
status = DatabaseStatus::FAILED_CREATE;
273+
return nullptr;
274+
}
275+
262276
// Wallet::Verify will check if we're trying to create a wallet with a duplicate name.
263277
std::unique_ptr<WalletDatabase> database = MakeWalletDatabase(name, options, status, error);
264278
if (!database) {

src/wallet/wallet.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ static constexpr uint64_t KNOWN_WALLET_FLAGS =
115115
| WALLET_FLAG_BLANK_WALLET
116116
| WALLET_FLAG_KEY_ORIGIN_METADATA
117117
| WALLET_FLAG_DISABLE_PRIVATE_KEYS
118-
| WALLET_FLAG_DESCRIPTORS;
118+
| WALLET_FLAG_DESCRIPTORS
119+
| WALLET_FLAG_EXTERNAL_SIGNER;
119120

120121
static constexpr uint64_t MUTABLE_WALLET_FLAGS =
121122
WALLET_FLAG_AVOID_REUSE;
@@ -126,6 +127,7 @@ static const std::map<std::string,WalletFlags> WALLET_FLAG_MAP{
126127
{"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
127128
{"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
128129
{"descriptor_wallet", WALLET_FLAG_DESCRIPTORS},
130+
{"external_signer", WALLET_FLAG_EXTERNAL_SIGNER}
129131
};
130132

131133
extern const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS;

src/wallet/walletutil.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ enum WalletFlags : uint64_t {
6060

6161
//! Indicate that this wallet supports DescriptorScriptPubKeyMan
6262
WALLET_FLAG_DESCRIPTORS = (1ULL << 34),
63+
64+
//! Indicates that the wallet needs an external signer
65+
WALLET_FLAG_EXTERNAL_SIGNER = (1ULL << 35),
6366
};
6467

6568
//! Get the path of the wallet directory.

0 commit comments

Comments
 (0)