transaction: reject transactions with Segwit byte set but no witnesses
This commit is contained in:
parent
d1d3b3fb02
commit
f0221fb79b
|
@ -408,6 +408,9 @@ 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)?;
|
||||||
}
|
}
|
||||||
|
if !input.is_empty() && input.iter().all(|input| input.witness.is_empty()) {
|
||||||
|
Err(serialize::Error::ParseFailed("witness flag set but no witnesses present"))
|
||||||
|
} else {
|
||||||
Ok(Transaction {
|
Ok(Transaction {
|
||||||
version: version,
|
version: version,
|
||||||
input: input,
|
input: input,
|
||||||
|
@ -415,6 +418,7 @@ impl<D: SimpleDecoder> ConsensusDecodable<D> for Transaction {
|
||||||
lock_time: ConsensusDecodable::consensus_decode(d)?,
|
lock_time: ConsensusDecodable::consensus_decode(d)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// We don't support anything else
|
// We don't support anything else
|
||||||
x => {
|
x => {
|
||||||
Err(serialize::Error::UnsupportedSegwitFlag(x))
|
Err(serialize::Error::UnsupportedSegwitFlag(x))
|
||||||
|
|
Loading…
Reference in New Issue