walletpassphrase(…)
null
dumpwallet Test
Only legacy wallets are supported by this command (code -4)
And no indication is given as to how to do it for "newer" or non-legacy wallets. So in addition to backing up wallet.dat, how do I export the private keys?
Legacy refer to wallets based on the key-based architecture. As to BC 26.0.0 it creates wallets the skeleton of which is descriptor based. That is why you got that "code -4 " message when run dumpwallet command. To get list of private keys run
listdescriptors true
where true is boolean value for ( private ) argument of this function.
The output will show you "Array of descriptor objects (sorted by descriptor string representation)"
Each listed descriptor from this array will contain a field relevant to private key.
Setting "true" is mandatory value for ( private ) argument as on default it equals to "false" which results in descriptor for public keys rather than private one.
listdescriptors (26.0.0 RPC): https://bitcoincore.org/en/doc/26.0.0/rpc/wallet/listdescriptors/