transaction: reject transactions with Segwit byte set but no witnesses

This commit is contained in:
Andrew Poelstra 2018-08-24 00:14:14 +00:00
parent d1d3b3fb02
commit f0221fb79b
1 changed files with 10 additions and 6 deletions

View File

@ -408,12 +408,16 @@ impl<D: SimpleDecoder> ConsensusDecodable<D> for Transaction {
for txin in input.iter_mut() { for txin in input.iter_mut() {
txin.witness = ConsensusDecodable::consensus_decode(d)?; txin.witness = ConsensusDecodable::consensus_decode(d)?;
} }
Ok(Transaction { if !input.is_empty() && input.iter().all(|input| input.witness.is_empty()) {
version: version, Err(serialize::Error::ParseFailed("witness flag set but no witnesses present"))
input: input, } else {
output: output, Ok(Transaction {
lock_time: ConsensusDecodable::consensus_decode(d)?, version: version,
}) input: input,
output: output,
lock_time: ConsensusDecodable::consensus_decode(d)?,
})
}
} }
// We don't support anything else // We don't support anything else
x => { x => {