Skip to content

Commit cf2c0b6

Browse files
committed
Support P2WPKH and P2SH-P2WPKH in dumpprivkey
1 parent 37c03d3 commit cf2c0b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/wallet/rpcdump.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,12 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
578578
if (!IsValidDestination(dest)) {
579579
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
580580
}
581-
const CKeyID *keyID = boost::get<CKeyID>(&dest);
582-
if (!keyID) {
581+
auto keyid = GetKeyForDestination(*pwallet, dest);
582+
if (keyid.IsNull()) {
583583
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
584584
}
585585
CKey vchSecret;
586-
if (!pwallet->GetKey(*keyID, vchSecret)) {
586+
if (!pwallet->GetKey(keyid, vchSecret)) {
587587
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
588588
}
589589
return CBitcoinSecret(vchSecret).ToString();

0 commit comments

Comments
 (0)