[#wallet-CWallet-GetKey]
= xref:wallet.adoc[wallet]::xref:wallet/CWallet.adoc[CWallet]::GetKey
:relfileprefix: ../../
:mrdocs:

Find the private key for the given key id from the wallet&apos;s descriptors, if available Returns nullopt when no descriptor has the key or if the wallet is locked&period;

== Synopsis

Declared in `&lt;wallet&sol;wallet&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::optional&lt;CKey&gt;
GetKey(xref:CKeyID.adoc[CKeyID] const& keyid) const;
----

== Return Value

The private key, or nullopt if unavailable&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *keyid*
| The key id to look up&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
