GetExternalSigner(): fail if multiple signers are found
If there are multiple external signers, `GetExternalSigner()` will just pick the first one in the list. If the user has two or more hardware wallets connected at the same time, he might not notice this. This PR adds a check and fails with suitable message.
This commit is contained in:
1 parent
8c61374ba7
commit
292b1a3e9c
7 files changed
+54
-7
No files matched your search
@@ -32,6 +32,13 @@ class WalletSignerTest(BitcoinTestFramework):
|
||||
else:
|
||||
return path
|
||||
|
||||
def mock_multi_signers_path(self):
|
||||
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'multi_signers.py')
|
||||
if platform.system() == "Windows":
|
||||
return "py " + path
|
||||
else:
|
||||
return path
|
||||
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
# The experimental syscall sandbox feature (-sandbox) is not compatible with -signer (which
|
||||
@@ -58,6 +65,8 @@ class WalletSignerTest(BitcoinTestFramework):
|
||||
self.test_valid_signer()
|
||||
self.restart_node(1, [f"-signer={self.mock_invalid_signer_path()}", "-keypool=10"])
|
||||
self.test_invalid_signer()
|
||||
self.restart_node(1, [f"-signer={self.mock_multi_signers_path()}", "-keypool=10"])
|
||||
self.test_multiple_signers()
|
||||
|
||||
def test_valid_signer(self):
|
||||
self.log.debug(f"-signer={self.mock_signer_path()}")
|
||||
@@ -212,5 +221,11 @@ class WalletSignerTest(BitcoinTestFramework):
|
||||
self.log.info('Test invalid external signer')
|
||||
assert_raises_rpc_error(-1, "Invalid descriptor", self.nodes[1].createwallet, wallet_name='hww_invalid', disable_private_keys=True, descriptors=True, external_signer=True)
|
||||
|
||||
def test_multiple_signers(self):
|
||||
self.log.debug(f"-signer={self.mock_multi_signers_path()}")
|
||||
self.log.info('Test multiple external signers')
|
||||
|
||||
assert_raises_rpc_error(-1, "GetExternalSigner: More than one external signer found", self.nodes[1].createwallet, wallet_name='multi_hww', disable_private_keys=True, descriptors=True, external_signer=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletSignerTest().main()
|
||||
Reference in new issue
Block a user