mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 14:45:08 +01:00
rpc: add external_signer option to createwallet
This commit is contained in:
parent
2700f09c41
commit
2655197e1c
@ -183,6 +183,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "createwallet", 4, "avoid_reuse"},
|
||||
{ "createwallet", 5, "descriptors"},
|
||||
{ "createwallet", 6, "load_on_startup"},
|
||||
{ "createwallet", 7, "external_signer"},
|
||||
{ "loadwallet", 1, "load_on_startup"},
|
||||
{ "unloadwallet", 1, "load_on_startup"},
|
||||
{ "getnodeaddresses", 0, "count"},
|
||||
|
@ -2726,6 +2726,7 @@ static RPCHelpMan createwallet()
|
||||
{"avoid_reuse", RPCArg::Type::BOOL, /* default */ "false", "Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
|
||||
{"descriptors", RPCArg::Type::BOOL, /* default */ "false", "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
|
||||
{"load_on_startup", RPCArg::Type::BOOL, /* default */ "null", "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
|
||||
{"external_signer", RPCArg::Type::BOOL, /* default */ "false", "Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true."},
|
||||
},
|
||||
RPCResult{
|
||||
RPCResult::Type::OBJ, "", "",
|
||||
@ -2770,6 +2771,13 @@ static RPCHelpMan createwallet()
|
||||
flags |= WALLET_FLAG_DESCRIPTORS;
|
||||
warnings.emplace_back(Untranslated("Wallet is an experimental descriptor wallet"));
|
||||
}
|
||||
if (!request.params[7].isNull() && request.params[7].get_bool()) {
|
||||
#ifdef ENABLE_EXTERNAL_SIGNER
|
||||
flags |= WALLET_FLAG_EXTERNAL_SIGNER;
|
||||
#else
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Configure with --enable-external-signer to use this");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_BDB
|
||||
if (!(flags & WALLET_FLAG_DESCRIPTORS)) {
|
||||
|
@ -678,10 +678,10 @@ class RPCOverloadWrapper():
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.rpc, name)
|
||||
|
||||
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase='', avoid_reuse=None, descriptors=None, load_on_startup=None):
|
||||
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase='', avoid_reuse=None, descriptors=None, load_on_startup=None, external_signer=None):
|
||||
if descriptors is None:
|
||||
descriptors = self.descriptors
|
||||
return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup)
|
||||
return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup, external_signer)
|
||||
|
||||
def importprivkey(self, privkey, label=None, rescan=None):
|
||||
wallet_info = self.getwalletinfo()
|
||||
|
@ -70,8 +70,15 @@ class SignerTest(BitcoinTestFramework):
|
||||
)
|
||||
self.clear_mock_result(self.nodes[1])
|
||||
|
||||
# Create new wallets with private keys disabled:
|
||||
self.nodes[1].createwallet(wallet_name='hww', disable_private_keys=True, descriptors=True)
|
||||
# Create new wallets for an external signer.
|
||||
# disable_private_keys and descriptors must be true:
|
||||
assert_raises_rpc_error(-4, "Private keys must be disabled when using an external signer", self.nodes[1].createwallet, wallet_name='not_hww', disable_private_keys=False, descriptors=True, external_signer=True)
|
||||
if self.is_bdb_compiled():
|
||||
assert_raises_rpc_error(-4, "Descriptor support must be enabled when using an external signer", self.nodes[1].createwallet, wallet_name='not_hww', disable_private_keys=True, descriptors=False, external_signer=True)
|
||||
else:
|
||||
assert_raises_rpc_error(-4, "Compiled without bdb support (required for legacy wallets)", self.nodes[1].createwallet, wallet_name='not_hww', disable_private_keys=True, descriptors=False, external_signer=True)
|
||||
|
||||
self.nodes[1].createwallet(wallet_name='hww', disable_private_keys=True, descriptors=True, external_signer=True)
|
||||
hww = self.nodes[1].get_wallet_rpc('hww')
|
||||
|
||||
result = hww.enumeratesigners()
|
||||
|
Loading…
Reference in New Issue
Block a user