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

Retrieve the particular key if it is available&period; Returns nullopt if the key is not in the wallet, or if the wallet is locked&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;requires&lowbar;capability(0x7f94fd519208), requires&lowbar;capability(0x7f95058b93a8), requires&lowbar;capability(0x7f94f1e44168), requires&lowbar;capability(0x7f9505cb2e88), requires&lowbar;capability(0x7f94f23e4688), requires&lowbar;capability(0x7f94fd840dc8)&rsqb;&rsqb;
std::optional&lt;CKey&gt;
GetKey(xref:CKeyID.adoc[CKeyID] const& keyid) const;
----

== Return Value

The private key, or nullopt if it is unavailable or the wallet is locked&period;

== Parameters

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


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