Ensure InInstruction data is properly limited

Bitcoin didn't check, assuming data was <= 80 bytes thanks to being in
OP_RETURN. An additional global check has been added.
This commit is contained in:
Luke Parker
2023-03-25 01:36:28 -04:00
parent 6a981dae6e
commit d954e67238
4 changed files with 20 additions and 8 deletions

View File

@@ -53,8 +53,8 @@ impl TryFrom<Vec<u8>> for Address {
EncodedAddress::P2WSH(hash) => {
Payload::WitnessProgram { version: WitnessVersion::V0, program: hash.to_vec() }
}
EncodedAddress::P2TR(hash) => {
Payload::WitnessProgram { version: WitnessVersion::V1, program: hash.to_vec() }
EncodedAddress::P2TR(key) => {
Payload::WitnessProgram { version: WitnessVersion::V1, program: key.to_vec() }
}
},
}))

View File

@@ -27,9 +27,10 @@ pub use balance::*;
mod account;
pub use account::*;
// Monero, our current longest address candidate, has a longest address of featured with payment ID
// 1 (enum) + 1 (flags) + 64 (two keys) + 8 (payment ID) = 74
pub const MAX_ADDRESS_LEN: u32 = 74;
// Monero, our current longest address candidate, has a longest address of featured
// 1 (enum) + 1 (flags) + 64 (two keys) = 66
// When JAMTIS arrives, it'll become 114 bytes
pub const MAX_ADDRESS_LEN: u32 = 128;
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]