I have created a key from using 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.

  • What type of address did you make from the private key?
    – Andrew Chow
    Oct 28 '19 at 15:32
  • @AndrewChow what do you mean? I just pasted the private key directly in that command. Oct 28 '19 at 15:44
  • 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?
    – Andrew Chow
    Oct 28 '19 at 15:59
  • @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? Oct 28 '19 at 18:01
  • 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.
    – Andrew Chow
    Oct 28 '19 at 22:07

Your Answer

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

Browse other questions tagged or ask your own question.