<p>I have created a key from using <a href="http://cryptocoinjs.com/modules/currency/coinstring/" rel="nofollow noreferrer">coinstring</a>, and then imported it into my wallet. Then I ran:</p>

<pre><code>bitcoin-cli signrawtransactionwithkey "$rawtxhex" "[\"$mykey$\"]"
</code></pre>

<p>But it results in:</p>

<pre><code>Unable to sign input, invalid stack size (possibly missing key)
</code></pre>

<p>Any ideas? My <code>mykey</code> is not actually a variable, I am hardcoding it in my specific case so I know it is present.</p>

CC BY-SA 4.0
2019-10-28T15:32:22.377Z
What type of address did you make from the private key?
Ava Chow
CC BY-SA 4.0
2019-10-28T15:44:46.887Z
@AndrewChow what do you mean? I just pasted the private key directly in that command.
Lance Pollard
CC BY-SA 4.0
2019-10-28T15:59:26.537Z
Before you can sign a transaction with a private key, you need to send Bitcoin to an address that is controlled by that private key. What type of address did you send to? P2PKH? Segwit? Something else?
Ava Chow
CC BY-SA 4.0
2019-10-28T18:01:40.493Z
@AndrewChow can you please direct me to some documentation, I am not sure what you're talking about. How can I send bitcoin to an address if creating a transaction requires signing something with the key in the first place?
Lance Pollard
CC BY-SA 4.0
2019-10-28T22:07:18.890Z
You don't need to sign anything with the key first to send to an address controlled by it. You need to sign the transaction when you are trying to SPEND those coins. Receiving coins on an address does not require the private key at all except to produce the address in the first place.
Ava Chow
CC BY-SA 4.0
2019-10-28T22:08:17.290Z
Can you post what `$rawtxhex` is? How did you create it?
Ava Chow
<transactions><wallet><private-key><signature>
Getting Error "Unable to sign input, invalid stack size (possibly missing key)"
Lance Pollard
# Getting Error "Unable to sign input, invalid stack size (possibly missing key)"

(Asked by: username_0 on 2019-10-28)

I have created a key from using [coinstring](http://cryptocoinjs.com/modules/currency/coinstring/), and then imported it into my wallet. Then I ran:

```
bitcoin-cli signrawtransactionwithkey "$rawtxhex" "[\"$mykey$\"]"

```

But it results in:

```
Unable to sign input, invalid stack size (possibly missing key)

```

Any ideas? My `mykey` is not actually a variable, I am hardcoding it in my specific case so I know it is present.

**Tags:** transactions, wallet, private-key, signature

> **Comments:**
> **username_1**: What type of address did you make from the private key?  
> **username_0**: @AndrewChow what do you mean? I just pasted the private key directly in that command.  
> **username_1**: Before you can sign a transaction with a private key, you need to send Bitcoin to an address that is controlled by that private key. What type of address did you send to? P2PKH? Segwit? Something else?  
> **username_0**: @AndrewChow can you please direct me to some documentation, I am not sure what you're talking about. How can I send bitcoin to an address if creating a transaction requires signing something with the key in the first place?  
> **username_1**: You don't need to sign anything with the key first to send to an address controlled by it. You need to sign the transaction when you are trying to SPEND those coins. Receiving coins on an address does not require the private key at all except to produce the address in the first place.  
> **username_1**: Can you post what `$rawtxhex` is? How did you create it?  

---

## 0 answers

