bitcoin::consensus::encode
pub fn serialize<T: Encodable + ?Sized>(data: &T) -> Vec<u8>
Encode an object into a vector