Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Previous output's pubkey script is not included in the data that the Bob signs. #1272

Closed
Kangmo opened this Issue Apr 2, 2016 · 2 comments

Comments

Projects
None yet
3 participants

Kangmo commented Apr 2, 2016

Source File: _includes/devdoc/guide_transactions.md

As illustrated in the figure above, the data Bob signs includes the txid and output index of the previous transaction, the previous output’s pubkey script, the pubkey script Bob creates which will let the next recipient spend this transaction’s output, and the amount of satoshis to spend to the next recipient.

=> The previous output's pubkey script is not included in the data Bob signs. But the current transaction points to the previous output with the outpoint(tx hash & vout).

=> Need to remove 'the previous output's pubkey script' from the 'data Blob signs'.

@wbnns wbnns self-assigned this Dec 9, 2016

@wbnns wbnns added the Under Review label Jan 31, 2017

Kexkey commented Feb 8, 2017 edited

The guide is correct.

The previous output's pubkey script is actually included in the data Bob signs. The fact that it's not a mandatory parameter to signrawtransaction is where it's confusing; when the previous transaction is in the UTXO set, bitcoind is able to get it from there (or the mempool). But when the previous transaction has not been broadcasted yet, bitcoind has no way to get it -- you have to supply it. In this particular case, it is important to sign the good pubkey script and because it is not broadcasted (maybe you got the other data from the previous payer which could be dishonest and used a pubkey script that pays to himself), the only way to be sure you are spending the input you think you are spending is by providing the pubkey script, which forces you to verify it (and make sure the not-yet-broadcasted transaction pays the output to you).

See https://bitcoin.org/en/developer-examples#offline-signing where it says:

"In the other raw transaction subsections above, the previous output was part of the UTXO set known to the wallet, so the wallet was able to use the txid and output index number to find the previous pubkey script and insert it automatically.

In this case, you’re spending an output which is unknown to the wallet, so it can’t automatically insert the previous pubkey script."

...

"Successfully sign the transaction by providing the previous pubkey script and other required input data."

Contributor

wbnns commented Feb 8, 2017

@Kangmo Thank you for raising this and thank you to @Kexkey for clarifying. 👍

@wbnns wbnns closed this Feb 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment