From d89331a720692929c11263db3ee6a384296e5ddd Mon Sep 17 00:00:00 2001 From: antiochp <30642645+antiochp@users.noreply.github.com> Date: Thu, 26 Sep 2019 08:33:33 +0100 Subject: [PATCH] use explicit protocol version (local is not safe) --- impls/src/backends/lmdb.rs | 5 ++--- impls/src/test_framework/testclient.rs | 7 +++---- libwallet/src/api_impl/owner.rs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/impls/src/backends/lmdb.rs b/impls/src/backends/lmdb.rs index 37a995aa..8b1e8ce2 100644 --- a/impls/src/backends/lmdb.rs +++ b/impls/src/backends/lmdb.rs @@ -360,7 +360,7 @@ where .join(filename); let path_buf = Path::new(&path).to_path_buf(); let mut stored_tx = File::create(path_buf)?; - let tx_hex = util::to_hex(ser::ser_vec(tx, ser::ProtocolVersion::local()).unwrap());; + let tx_hex = util::to_hex(ser::ser_vec(tx, ser::ProtocolVersion(1)).unwrap());; stored_tx.write_all(&tx_hex.as_bytes())?; stored_tx.sync_all()?; Ok(()) @@ -380,8 +380,7 @@ where tx_f.read_to_string(&mut content)?; let tx_bin = util::from_hex(content).unwrap(); Ok(Some( - ser::deserialize::(&mut &tx_bin[..], ser::ProtocolVersion::local()) - .unwrap(), + ser::deserialize::(&mut &tx_bin[..], ser::ProtocolVersion(1)).unwrap(), )) } diff --git a/impls/src/test_framework/testclient.rs b/impls/src/test_framework/testclient.rs index 2b4923a4..a441700c 100644 --- a/impls/src/test_framework/testclient.rs +++ b/impls/src/test_framework/testclient.rs @@ -185,10 +185,9 @@ where libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper: tx_bin".to_owned()), )?; - let tx: Transaction = ser::deserialize(&mut &tx_bin[..], ser::ProtocolVersion::local()) - .context(libwallet::ErrorKind::ClientCallback( - "Error parsing TxWrapper: tx".to_owned(), - ))?; + let tx: Transaction = ser::deserialize(&mut &tx_bin[..], ser::ProtocolVersion(1)).context( + libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper: tx".to_owned()), + )?; super::award_block_to_wallet( &self.chain, diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index 4026d747..7f97dbba 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -448,7 +448,7 @@ pub fn post_tx<'a, C>(client: &C, tx: &Transaction, fluff: bool) -> Result<(), E where C: NodeClient + 'a, { - let tx_hex = grin_util::to_hex(ser::ser_vec(tx, ser::ProtocolVersion::local()).unwrap()); + let tx_hex = grin_util::to_hex(ser::ser_vec(tx, ser::ProtocolVersion(1)).unwrap()); let res = client.post_tx(&TxWrapper { tx_hex: tx_hex }, fluff); if let Err(e) = res { error!("api: post_tx: failed with error: {}", e);