Is it possible to spend a P2WPKH transaction output, with only knowing the xpriv key and not knowing the specific private key that corresponds to the public key of the transaction?

2 Answers 2


No, you need the private key that the address in question was derived from.

There is no mechanism for the wider network to determine that an address was derived from a private key, that was derived from a specific xpriv. The transaction signature must be created using the private key that is related to the address in question.

  • is there a way to recover the required private key using the xpriv key?
    – Marko
    Mar 11, 2021 at 21:21
  • Yes, the xpriv key is the piece of information needed to derive the child priv keys in question. You just need to know which derivation path to take; there are a few different standard paths used by most wallets.
    – chytrik
    Mar 12, 2021 at 4:31

The extended private key (xprv) can derive all the individual WIF private keys associated with that HD account. So technically it is possible to parse through the xprv keychain until you find the individual WIF private key that corresponds with the output you want to spend from.

For example, if you know the output address you want to spend from you could write a script that loops through each private key.

Psuedo code:

var myxprv = "xprv1234....";
var outputaddr = "bc1wqSomeAddress....";
var notfound = true;
var index = 0; 

    var eachPK = fromXprv(myxprv,0,index);
    var details = wif2Address(eachPK);
        notfound = false;
        return "found";
    } else {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.