uahf: input_index check is back in SignatureHash

This commit is contained in:
Svyatoslav Nikolsky 2017-08-23 13:48:49 +03:00
parent 806bd02fbd
commit 7f14f9b40d
2 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,3 @@
use std::cmp::max;
use hash::H256;
use {Magic, Deployment};

View File

@ -235,10 +235,6 @@ impl TransactionInputSigner {
}
fn signature_hash_witness0(&self, input_index: usize, input_amount: u64, script_pubkey: &Script, sighashtype: u32, sighash: Sighash) -> H256 {
self.signature_hash_fork_id(input_index, input_amount, script_pubkey, sighashtype, sighash)
}
fn signature_hash_fork_id(&self, input_index: usize, input_amount: u64, script_pubkey: &Script, sighashtype: u32, sighash: Sighash) -> H256 {
let hash_prevouts = compute_hash_prevouts(sighash, &self.inputs);
let hash_sequence = compute_hash_sequence(sighash, &self.inputs);
let hash_outputs = compute_hash_outputs(sighash, input_index, &self.outputs);
@ -257,6 +253,18 @@ impl TransactionInputSigner {
let out = stream.out();
dhash256(&out)
}
fn signature_hash_fork_id(&self, input_index: usize, input_amount: u64, script_pubkey: &Script, sighashtype: u32, sighash: Sighash) -> H256 {
if input_index >= self.inputs.len() {
return 1u8.into();
}
if sighash.base == SighashBase::Single && input_index >= self.outputs.len() {
return 1u8.into();
}
self.signature_hash_witness0(input_index, input_amount, script_pubkey, sighashtype, sighash)
}
}
fn compute_hash_prevouts(sighash: Sighash, inputs: &[UnsignedTransactionInput]) -> H256 {