Address comments from code review.
This commit is contained in:
parent
8cf43d255f
commit
ba3ff42e13
|
@ -96,7 +96,7 @@ impl FromStr for ZcashAddress {
|
|||
.map(|kind| ZcashAddress { kind, net });
|
||||
};
|
||||
|
||||
// If it's not valid Bech32 or Base58Check, it's not a Zcash address.
|
||||
// If it's not valid Bech32, Bech32m, or Base58Check, it's not a Zcash address.
|
||||
Err(ParseError::NotZcash)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,15 +102,15 @@ impl Typecode {
|
|||
/// An error while attempting to parse a string as a Zcash address.
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ParseError {
|
||||
/// The unified address contains both P2PKH and P2SH items.
|
||||
/// The unified container contains both P2PKH and P2SH items.
|
||||
BothP2phkAndP2sh,
|
||||
/// The unified address contains a duplicated typecode.
|
||||
/// The unified container contains a duplicated typecode.
|
||||
DuplicateTypecode(Typecode),
|
||||
/// The parsed typecode exceeds the maximum allowed CompactSize value.
|
||||
InvalidTypecodeValue(u64),
|
||||
/// The string is an invalid encoding.
|
||||
InvalidEncoding(String),
|
||||
/// The unified address only contains transparent items.
|
||||
/// The unified container only contains transparent items.
|
||||
OnlyTransparent,
|
||||
}
|
||||
|
||||
|
@ -179,14 +179,14 @@ pub(crate) mod private {
|
|||
|
||||
fn write_raw_encoding<W: Write>(&self, mut writer: W) {
|
||||
for item in &self.items() {
|
||||
let addr = item.data();
|
||||
let data = item.data();
|
||||
CompactSize::write(
|
||||
&mut writer,
|
||||
<u32>::from(item.typecode()).try_into().unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
CompactSize::write(&mut writer, addr.len()).unwrap();
|
||||
writer.write_all(addr).unwrap();
|
||||
CompactSize::write(&mut writer, data.len()).unwrap();
|
||||
writer.write_all(data).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ pub(crate) mod private {
|
|||
let buf = cursor.get_ref();
|
||||
if (buf.len() as u64) < addr_end {
|
||||
return Err(ParseError::InvalidEncoding(format!(
|
||||
"Truncated: unable to read {} bytes of address data",
|
||||
"Truncated: unable to read {} bytes of item data",
|
||||
length
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ mod tests {
|
|||
fn padding() {
|
||||
// The test cases below use `Address(vec![Receiver::Orchard([1; 43])])` as base.
|
||||
|
||||
// Invalid padding ([0xff; 16] instead of [b'u', 0x00, 0x00, 0x00...])
|
||||
// Invalid padding ([0xff; 16] instead of [0x75, 0x00, 0x00, 0x00...])
|
||||
let invalid_padding = [
|
||||
0xe6, 0x59, 0xd1, 0xed, 0xf7, 0x4b, 0xe3, 0x5e, 0x5a, 0x54, 0x0e, 0x41, 0x5d, 0x2f,
|
||||
0x0c, 0x0d, 0x33, 0x42, 0xbd, 0xbe, 0x9f, 0x82, 0x62, 0x01, 0xc1, 0x1b, 0xd4, 0x1e,
|
||||
|
|
Loading…
Reference in New Issue