0

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

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.

2
  • 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
1

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; 

while(notfound){
    var eachPK = fromXprv(myxprv,0,index);
    var details = wif2Address(eachPK);
    if(outputaddr===details.p2wpkh){
        notfound = false;
        return "found";
    } else {
        index++;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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