mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-14 23:37:51 +02:00
rpc: Fix for duplicate external signers case
In case of multiple external signers, with some duplicates, de-duplicate them: keep one signer per fingerprint, and keep all non-duplicates as well. Add a new test check.
This commit is contained in:
@@ -53,7 +53,7 @@ bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalS
|
||||
for (const ExternalSigner& signer : signers) {
|
||||
if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate = true;
|
||||
}
|
||||
if (duplicate) break;
|
||||
if (duplicate) continue;
|
||||
std::string name;
|
||||
const UniValue& model_field = signer.find_value("model");
|
||||
if (model_field.isStr() && model_field.getValStr() != "") {
|
||||
|
||||
@@ -72,6 +72,19 @@ class RPCSignerTest(BitcoinTestFramework):
|
||||
)
|
||||
self.clear_mock_result(self.nodes[1])
|
||||
|
||||
# Duplicate fingerprints
|
||||
self.set_mock_result(self.nodes[1],
|
||||
'0 ['
|
||||
'{"fingerprint": "00000001", "type": "trezor", "model": "trezor_t"}, '
|
||||
'{"fingerprint": "00000001", "type": "trezor", "model": "trezor_t"}, '
|
||||
'{"fingerprint": "00000002", "type": "trezor", "model": "trezor_one"}'
|
||||
']')
|
||||
assert_equal(self.nodes[1].enumeratesigners(), {"signers": [
|
||||
{"fingerprint": "00000001", "name": "trezor_t"},
|
||||
{"fingerprint": "00000002", "name": "trezor_one"},
|
||||
]})
|
||||
self.clear_mock_result(self.nodes[1])
|
||||
|
||||
assert_equal({'fingerprint': '00000001', 'name': 'trezor_t'} in self.nodes[1].enumeratesigners()['signers'], True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user