Add code comment for emtpy input
The line of code `let mut have_witness = self.input.is_empty();` is puzzling if one does not know _why_ we serialize in BIP141 style when there are no inputs. Add a code comment to save devs spending time trying to work out _why_ this is correct.
This commit is contained in:
parent
6a0ec1ac47
commit
f02b3a8472
|
@ -588,6 +588,8 @@ impl Encodable for Transaction {
|
|||
) -> Result<usize, io::Error> {
|
||||
let mut len = 0;
|
||||
len += self.version.consensus_encode(&mut s)?;
|
||||
// To avoid serialization ambiguity, no inputs means we use BIP141 serialization (see
|
||||
// `Transaction` docs for full explanation).
|
||||
let mut have_witness = self.input.is_empty();
|
||||
for input in &self.input {
|
||||
if !input.witness.is_empty() {
|
||||
|
|
Loading…
Reference in New Issue