<p>No, you need the private key that the address in question was derived from.</p>
<p>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.</p>

CC BY-SA 4.0
2021-03-11T21:21:00.920Z
is there a way to recover the required private key using the xpriv key?
Marko
CC BY-SA 4.0
2021-03-12T04:31:04.477Z
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
CC BY-SA 4.0
2021-03-11T19:26:47.447Z
2021-03-11T19:26:47.447Z
chytrik
<p>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.</p>
<p>For example, if you know the output address you want to spend from you could write a script that loops through each private key.</p>
<p>Psuedo code:</p>
<pre><code>var myxprv = &quot;xprv1234....&quot;;
var outputaddr = &quot;bc1wqSomeAddress....&quot;;
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 &quot;found&quot;;
    } else {
        index++;
    }
}
</code></pre>

CC BY-SA 4.0
2021-03-12T03:35:08.363Z
2021-03-12T03:35:08.363Z
m1xolyd1an
<p>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?</p>

<private-key><p2wpkh>
Spending transaction output with only xpriv key
Marko
# Spending transaction output with only xpriv key

(Asked by: username_0 on 2021-03-11)

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?

**Tags:** private-key, p2wpkh


---

## 2 answers

### Answer by username_1 on 2021-03-11. Score: 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.

> **Comments:**
> **username_0**: is there a way to recover the required private key using the xpriv key?  
> **username_1**: 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.  

---

### Answer by username_2 on 2021-03-12. Score: 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++;
    }
}

```


---

