mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-28 14:59:22 +01:00
Merge bitcoin/bitcoin#31603: descriptor: check whitespace in keys within fragments
21e9d39a37docs: add release notes for 31603 (brunoerg)a8b548d75dtest: `getdescriptorinfo`/`importdescriptors` with whitespace in pubkeys (brunoerg)c7afca3d62test: descriptor: check whitespace into keys (brunoerg)cb722a3ceadescriptor: check whitespace in ParsePubkeyInner (brunoerg)50856695eftest: fix descriptors in `ismine_tests` (brunoerg) Pull request description: Currently, we successfully parse descriptors which contains spaces in the beginning or end of the public/private key within a fragment (e.g. `pk( KEY)`, `pk(KEY )` or `pk( KEY )`). I have noticed that one of the reasons is that the `DecodeBase58` function simply ignore these whitespaces. This PR changes the `ParsePubkeyInner ` to reject pubkeys that contain a whitespace at the beginning and/or at the end. We will only check the whitespace in some RPCs (e.g. `importdescriptors`), but an already imported descriptor won't be affected by this check, especially because we store descriptors from `ToString`. For context: https://github.com/brunoerg/bitcoinfuzz/issues/72 ACKs for top commit: rkrux: tACK21e9d39a37darosior: re-ACK21e9d39a37sipa: utACK21e9d39a37Tree-SHA512: 54f48a89a235517e5cdc29a46dceeb7dabbee93c7616a166288ff3f90131808eb0ece43b0797a11fe827a5f7bd51d65e3e75c16789b0a42020934cabb684cc8f
This commit is contained in:
@@ -406,7 +406,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// scriptPubKey multisig - Descriptor
|
||||
{
|
||||
CWallet keystore(chain.get(), "", CreateMockableWalletDatabase());
|
||||
std::string desc_str = "multi(2, " + EncodeSecret(uncompressedKey) + ", " + EncodeSecret(keys[1]) + ")";
|
||||
std::string desc_str = "multi(2," + EncodeSecret(uncompressedKey) + "," + EncodeSecret(keys[1]) + ")";
|
||||
|
||||
auto spk_manager = CreateDescriptor(keystore, desc_str, true);
|
||||
|
||||
@@ -442,7 +442,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
{
|
||||
CWallet keystore(chain.get(), "", CreateMockableWalletDatabase());
|
||||
|
||||
std::string desc_str = "sh(multi(2, " + EncodeSecret(uncompressedKey) + ", " + EncodeSecret(keys[1]) + "))";
|
||||
std::string desc_str = "sh(multi(2," + EncodeSecret(uncompressedKey) + "," + EncodeSecret(keys[1]) + "))";
|
||||
|
||||
auto spk_manager = CreateDescriptor(keystore, desc_str, true);
|
||||
|
||||
@@ -485,7 +485,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
{
|
||||
CWallet keystore(chain.get(), "", CreateMockableWalletDatabase());
|
||||
|
||||
std::string desc_str = "wsh(multi(2, " + EncodeSecret(keys[0]) + ", " + EncodeSecret(keys[1]) + "))";
|
||||
std::string desc_str = "wsh(multi(2," + EncodeSecret(keys[0]) + "," + EncodeSecret(keys[1]) + "))";
|
||||
|
||||
auto spk_manager = CreateDescriptor(keystore, desc_str, true);
|
||||
|
||||
@@ -528,7 +528,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
{
|
||||
CWallet keystore(chain.get(), "", CreateMockableWalletDatabase());
|
||||
|
||||
std::string desc_str = "wsh(multi(2, " + EncodeSecret(uncompressedKey) + ", " + EncodeSecret(keys[1]) + "))";
|
||||
std::string desc_str = "wsh(multi(2," + EncodeSecret(uncompressedKey) + "," + EncodeSecret(keys[1]) + "))";
|
||||
|
||||
auto spk_manager = CreateDescriptor(keystore, desc_str, false);
|
||||
BOOST_CHECK_EQUAL(spk_manager, nullptr);
|
||||
@@ -568,7 +568,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
{
|
||||
CWallet keystore(chain.get(), "", CreateMockableWalletDatabase());
|
||||
|
||||
std::string desc_str = "sh(wsh(multi(2, " + EncodeSecret(keys[0]) + ", " + EncodeSecret(keys[1]) + ")))";
|
||||
std::string desc_str = "sh(wsh(multi(2," + EncodeSecret(keys[0]) + "," + EncodeSecret(keys[1]) + ")))";
|
||||
|
||||
auto spk_manager = CreateDescriptor(keystore, desc_str, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user