Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ned.ryerson on June 03, 2014, 03:27:30 PM



Title: How does signrawtransaction know which private key to use?
Post by: ned.ryerson on June 03, 2014, 03:27:30 PM
It only has a previous output (hash and vout index) but nothing to tell it which address that output was for, so how can it choose the correct private key to sign the transaction?


Title: Re: How does signrawtransaction know which private key to use?
Post by: piotr_n on June 03, 2014, 03:39:48 PM
hash and vout index refer to a UTXO record containing a spend script. the spend script refers to a public address, upon which a private key can be matched.


Title: Re: How does signrawtransaction know which private key to use?
Post by: ned.ryerson on June 03, 2014, 03:43:14 PM
hash and vout index refer to a UTXO record containing a spend script. the spend script refers to a public address, upon which a private key can be matched.
But if you're offline (and no blockchain access), how can it get the UTXO?


Title: Re: How does signrawtransaction know which private key to use?
Post by: gmaxwell on June 03, 2014, 03:48:57 PM
But if you're offline (and no blockchain access), how can it get the UTXO?
It can't in that case, thats why it has an optional scriptpubkey argument.