1

I've been reading up about raw transactions on bitcoin.org and there are two examples Simple and Complex.

What I can't tell from the information provided is if it necessary to sign each of the inputs separately, or whether you can just sign the entire tx with one.

So two examples:

  1. Input 1 came from address A and input 2 came from address A.
  2. Input 1 came from address B and input 2 came from address C.

For example 1, my assumption is that I could just use

bitcoin-cli signrawtransaction RAW_TX

but for example 2 I would have to use

 bitcoin-cli signrawtransaction RAW_TX [] ["ADDR_B_PRIVATE_KEY"]
 bitcoin-cli signrawtransaction PARTLY_SIGNED_RAW_TX [] ["$ADDR_B_PRIVATE_KEY"]
2

Do i need to sign each input in a raw transaction?

Technically, yes. But software like Bitcoin Core Client signs all inputs where the private keys are known. And of course, leave unsigned/untouched all other inputs.

1

You can just use

bitcoin-cli signrawtransaction RAW_TX

if the private keys of all inputs of that transaction are in your Bitcoin Core (or bitcoind).

  • And what if the keys are not imported (but known anyway)? How should it be added as a argument? a list with each key, all in the same order as the outputs ? – Alex Jan 4 '18 at 22:56
  • @FeedTheWeb Do this for each key: importprivkey PRIVKEY "" false Don't forget to type false, and.the order doesn't matter. If this doesn't work, do a rescan after adding each key (but probably it won't be needed.) If you have lots of keys, I may write you a little piece of code that reads the PrivKeys from a file and imports them. – MCCCS Jan 5 '18 at 4:20
  • And if I don't want to import/rescan (because it takes forever), the syntax should be bitcoin-cli signrawtransaction RAW_TX [] ["PRIVKEY1", "PRIVKEY2"] , right? – Alex Jan 5 '18 at 11:40
  • @FeedTheWeb No, importprivkey PRIVKEY "" false won't rescan, because the last argument is rescan?, false. And you're right, you don't need to importprivkey, your command is correct. – MCCCS Jan 5 '18 at 12:35

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.