From 90ae662e4d29986ec42e9059470138480172dedc Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 24 Aug 2018 18:52:23 -0700 Subject: [PATCH] Fix packet header offset And update transaction offsets to use the same approach as packet.rs. Maybe this should be serialized_size(), but thanks to this GenericArray update, those values are the same. --- src/packet.rs | 2 +- src/transaction.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/packet.rs b/src/packet.rs index ddd24c9de1..5ca3055bc7 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -340,7 +340,7 @@ pub fn to_blobs( } const BLOB_INDEX_END: usize = size_of::(); -const BLOB_ID_END: usize = BLOB_INDEX_END + size_of::() + size_of::(); +const BLOB_ID_END: usize = BLOB_INDEX_END + size_of::(); const BLOB_FLAGS_END: usize = BLOB_ID_END + size_of::(); const BLOB_SIZE_END: usize = BLOB_FLAGS_END + size_of::(); diff --git a/src/transaction.rs b/src/transaction.rs index b894d7ed29..09be5027f7 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -6,10 +6,11 @@ use chrono::prelude::*; use hash::Hash; use payment_plan::{Payment, PaymentPlan, Witness}; use signature::{Keypair, KeypairUtil, Pubkey, Signature}; +use std::mem::size_of; -pub const SIGNED_DATA_OFFSET: usize = 96; +pub const SIGNED_DATA_OFFSET: usize = PUB_KEY_OFFSET + size_of::(); pub const SIG_OFFSET: usize = 0; -pub const PUB_KEY_OFFSET: usize = 64; +pub const PUB_KEY_OFFSET: usize = size_of::(); /// The type of payment plan. Each item must implement the PaymentPlan trait. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]