mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
wallet: fix importdescriptor silent fail
This commit is contained in:
parent
711ddce943
commit
538be4219a
3 changed files with 16 additions and 2 deletions
|
@ -1522,7 +1522,9 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
|
||||||
// Need to ExpandPrivate to check if private keys are available for all pubkeys
|
// Need to ExpandPrivate to check if private keys are available for all pubkeys
|
||||||
FlatSigningProvider expand_keys;
|
FlatSigningProvider expand_keys;
|
||||||
std::vector<CScript> scripts;
|
std::vector<CScript> scripts;
|
||||||
parsed_desc->Expand(0, keys, scripts, expand_keys);
|
if (!parsed_desc->Expand(0, keys, scripts, expand_keys)) {
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot expand descriptor. Probably because of hardened derivations without private keys provided");
|
||||||
|
}
|
||||||
parsed_desc->ExpandPrivate(0, keys, expand_keys);
|
parsed_desc->ExpandPrivate(0, keys, expand_keys);
|
||||||
|
|
||||||
// Check if all private keys are provided
|
// Check if all private keys are provided
|
||||||
|
|
|
@ -4555,7 +4555,10 @@ ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const Flat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top up key pool, the manager will generate new scriptPubKeys internally
|
// Top up key pool, the manager will generate new scriptPubKeys internally
|
||||||
new_spk_man->TopUp();
|
if (!new_spk_man->TopUp()) {
|
||||||
|
WalletLogPrintf("Could not top up scriptPubKeys\n");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply the label if necessary
|
// Apply the label if necessary
|
||||||
// Note: we disable labels for ranged descriptors
|
// Note: we disable labels for ranged descriptors
|
||||||
|
|
|
@ -207,6 +207,15 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||||
success=False,
|
success=False,
|
||||||
error_code=-4,
|
error_code=-4,
|
||||||
error_message='Cannot import private keys to a wallet with private keys disabled')
|
error_message='Cannot import private keys to a wallet with private keys disabled')
|
||||||
|
|
||||||
|
self.log.info("Should not import a descriptor with hardened derivations when private keys are disabled")
|
||||||
|
self.test_importdesc({"desc": descsum_create("wpkh(" + xpub + "/1h/*)"),
|
||||||
|
"timestamp": "now",
|
||||||
|
"range": 1},
|
||||||
|
success=False,
|
||||||
|
error_code=-4,
|
||||||
|
error_message='Cannot expand descriptor. Probably because of hardened derivations without private keys provided')
|
||||||
|
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
test_address(w1,
|
test_address(w1,
|
||||||
address,
|
address,
|
||||||
|
|
Loading…
Add table
Reference in a new issue