Change GetMetadata to use unique_ptr<CKeyMetadata>
Summary: Backport of Core PR16528 [31/43] : https://github.com/bitcoin/bitcoin/pull/16528/commits/8b9603bd0b443e2f7984eb72bf2e21cf02af0bcb
Test Plan:
ninja all check-all
Reviewers: #bitcoin_abc, Fabien, majcosta
Reviewed By: #bitcoin_abc, Fabien, majcosta
Differential Revision: https://reviews.bitcoinabc.org/D8453