The `dumpwallet` RPC command throws an error at the signet node and stops it.
~~This does not happen in mainnet or testnet, where the command worked successfully in my tests..~~
Originally this error was only happening on signet, but it also happened on testnet after it worked successfully for a while.

**Expected behavior**

The RPC `dumpwallet` command is expected to return a success message and create the dump file that contains the private keys.

**Actual behavior**

The command returns an error on client side (`bitcoin-cli`):
`error: timeout on transient error: Could not connect to the server 127.0.0.1:38332 (error code 1 - "EOF reached")
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.`

And it throws an error at the signet node and stops it.

```
POTENTIAL DEADLOCK DETECTED
Previous lock order was:
  'cs_wallet' in wallet/wallet.cpp:2860 (in thread 'httpworker.1')
  (2) '::cs_main' in node/interfaces.cpp:687 (in thread 'httpworker.1')
  'm_node.mempool->cs' in node/interfaces.cpp:687 (in thread 'httpworker.1')
  'cs_wallet' in wallet/wallet.cpp:1204 (in thread 'httpworker.1')
  (1) 'cs_KeyStore' in script/signingprovider.cpp:165 (in thread 'httpworker.1')
Current lock order is:
  'wallet.cs_wallet' in wallet/rpcdump.cpp:743 (in thread 'httpworker.3')
  (1) 'spk_man.cs_KeyStore' in wallet/rpcdump.cpp:743 (in thread 'httpworker.3')
  (1) 'spk_man->cs_KeyStore' in wallet/wallet.cpp:2303 (in thread 'httpworker.3')
  (2) 'cs_main' in node/interfaces.cpp:493 (in thread 'httpworker.3')
Assertion failed: detected inconsistent lock order for 'cs_main' in node/interfaces.cpp:493 (in thread 'httpworker.3'), details in debug log.
Aborted (core dumped)
```

**To reproduce**

Start the node on signet mode:
`bitcoind -signet`

And dump an existing wallet:
`bitcoin-cli -signet -rpcwallet="legacy_wallet_01" dumpwallet "filename"`

**System information**

The bitcoin node was compiled from master (commit: `df2b5dadfb2dc21b05e5a60b71987fb5b96201f5`)
Ubuntu 20.04, 8 CPUs, 12 GiB RAM and SSD.

return nuptr;
        }
        waetInstance->m_default_max_tx_fee = nMaxFee;
    }
    if (chain && chain->relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) {
        warnings.push_back(AmountHighWarn("-minrelaytxfee") + Untranslated(" ") +
                           _("The waet wi avoid paying less than the minimum relay fee."));
    }
    waetInstance->m_confirm_target = gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
    waetInstance->m_spend_zero_conf_change = gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
    waetInstance->m_signal_rbf = gArgs.GetBoolArg("-waetrbf", DEFAULT_WALLET_RBF);
    waetInstance->WaetLogPrintf("Waet completed loading in %15dms\n", GetTimeMiis() - nStart);
    // Try to top up keypool. No-op if the waet is locked.
    waetInstance->TopUpKeyPool();
    LOCK(waetInstance->cs_waet);
    if (chain && !AttachChain(waetInstance, *chain, error, warnings)) {
        return nuptr;
    }
    {
        LOCK(cs_waets);
        auto& load_waet : g_load_waet_fns) {
            load_waet(interfaces::MakeWaet(waetInstance));
        }
    }
    waetInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-waetbroadcast", DEFAULT_WALLETBROADCAST));
    {
        waetInstance->WaetLogPrintf("setKeyPool.size() = %u\n",      waetInstance->GetKeyPoolSize());
        waetInstance->WaetLogPrintf("mapWaet.size() = %u\n",       waetInstance->mapWaet.size());
        waetInstance->WaetLogPrintf("m_address_book.size() = %u\n",  waetInstance->m_address_book.size());
    }