Commit Graph

34 Commits

Author SHA1 Message Date
Jack Grigg 7b005aaa7a Expand `CppStream` to cover all `Stream`-like C++ types
In its existing usage, `CppStream` was only used in a context where the
C++ `READWRITE` macro was being called with a `CDataStream`. However, in
other contexts the macro can be called with various other types with a
stream-like interface. Since we can't expose C++ templates across the
`cxx` bridge (or FFI generally), we instead turn `CppStream` into an
enum that covers all of the stream-like types we may want to use.
2023-04-06 21:30:38 +00:00
Kris Nuttycombe 192804a081 Merge branch 'version-5.4.0' into 'master' 2023-01-30 21:19:54 -07:00
Jack Grigg 908675b5b9 rust: Add `cxx` version of `RustStream` 2023-01-24 04:15:09 +00:00
Kris Nuttycombe 3cec519ce4 scripted-diff: Update Zcash copyrights to 2023
-BEGIN VERIFY SCRIPT-
for party in "The Zcash developers" "The Bitcoin Core developers" "Bitcoin Developers"; do
  sed -i"" -e "s#Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? $party#Copyright (c) \1-2023 $party#" COPYING
  sed -i"" -e "s#\(.*\)\([0-9]\{4\}\)\(-[0-9]\{4\}\)\, $party#\1\2-2023, $party#" contrib/debian/copyright
done

sed -i"" -e "s/define(_COPYRIGHT_YEAR, [0-9]\{4\})/define(_COPYRIGHT_YEAR, 2023)/" configure.ac
sed -i"" -e "s/#define COPYRIGHT_YEAR [0-9]\{4\}/#define COPYRIGHT_YEAR 2023/" src/clientversion.h

git grep "^// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2023 The Zcash developers#" {}
-END VERIFY SCRIPT-
2023-01-23 11:31:54 -07:00
Kris Nuttycombe 28040f9ce4 scripted-diff: Add 2016-2022 copyright headers for files added/modified in 2016
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM bitcoin-v0.11.2..94f427a211bb337200c29a1e19be0f5ad2f171b0 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2016-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:23:09 -06:00
Homu bad7f7eadb Auto merge of #5202 - str4d:5022-tx-v5, r=str4d
v5 transaction format

Includes a new wrapper that enables passing C++ streams across to Rust.

Closes zcash/zcash#5022.
2021-06-12 17:59:44 +00:00
Wladimir J. van der Laan 1fca92ae03 streams: Remove special cases for ancient MSVC
Quite sure that we haven't supported MSVC 6.0 for ages (MSC_VER 1300 is
>= MSVC++ 7.0) but with the C++11 switch we can be sure.

(cherry picked from commit a2141e415aed26bab756220d8707b5fb33e6fef8)
2021-06-11 21:34:43 +01:00
Wladimir J. van der Laan 336d0e3be5 streams: Add data() method to CDataStream
Analogous to c++11 vector data().

(cherry picked from commit af4c44ce59aa643b3e03eaa121ec075f524227a5)
2021-06-11 21:34:43 +01:00
Jack Grigg e6dd9550e1 rust: Enable C++ streams to be passed into Rust code 2021-06-10 22:11:41 +01:00
Daira Hopwood fb8dd9d458 CBufferedFile: use eof() method rather than feof(src) in error message.
Co-authored-by: Jack Grigg <jack@z.cash>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-08-26 13:20:20 +01:00
Daira Hopwood 6c20de21b9 CBufferedFile: assert that Fill() is only called when nReadPos == nSrcPos, and simplify based on that assumption.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-08-26 13:20:20 +01:00
Alfredo Garcia 868691020e Add null check to feof.
Co-authored-by: Jack Grigg <jack@z.cash>
Co-authored-by: Ying Tong Lai <yingtong@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-08-26 13:19:01 +01:00
Larry Ruane 75251cb2bc util: CBufferedFile fixes 2020-03-02 18:03:46 -07:00
Daira Hopwood bc909a7a7f Replace http with https: in links to the MIT license.
Also change MIT/X11 to just MIT, since no distinction was intended.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-07-18 15:26:01 +01:00
Homu 2d1a3cf8f5 Auto merge of #3183 - bitcartel:least_authority_issue_d, r=str4d
Closes #3182 - Least Authority Issue D

Prevent undefined behaviour when null pointer is passed in as parameter to function

Includes a backport of bitcoin/bitcoin#10250.
2018-05-03 16:39:10 -07:00
Simon 54a872f0fa Fix undefined behaviour, calling memcpy with NULL pointer.
Identified as part of audit: Least Authority, Issue D.
2018-04-30 16:41:02 -07:00
Pieter Wuille 1878f3a759 Fix some empty vector references
streams.h has some methods that can be tricked into dereferencing
null pointers or end() iterators. Fix this.
2018-04-18 21:31:14 -07:00
Jack Grigg b7e75b17af
Implement basic Sapling v4 transaction parser
Details of Sapling datatypes will be filled in later; for now, they are treated
as binary blobs.

Includes code cherry-picked from upstream commit:
    7030d9eb47254499bba14f1c00abc6bf493efd91
    BIP144: Serialization, hashes, relay (sender side)
2018-04-19 05:01:47 +01:00
Pieter Wuille 242f1421db
Get rid of nType and nVersion
Remove the nType and nVersion as parameters to all serialization methods
and functions. There is only one place where it's read and has an impact
(in CAddress), and even there it does not impact any of the recursively
invoked serializers.

Instead, the few places that need nType or nVersion are changed to read
it directly from the stream object, through GetType() and GetVersion()
methods which are added to all stream classes.
2018-04-17 13:09:28 +01:00
Pieter Wuille b8a6579366
Make GetSerializeSize a wrapper on top of CSizeComputer
Given that in default GetSerializeSize implementations created by
ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid
of the specialized GetSerializeSize methods everywhere, and just use
CSizeComputer. This removes a lot of code which isn't actually used
anywhere.

For CCompactSize and CVarInt this actually removes a more efficient
size computing algorithm, which is brought back in a later commit.
2018-04-16 07:38:38 -06:00
Pieter Wuille 7f4acac433
Make nType and nVersion private and sometimes const
Make the various stream implementations' nType and nVersion private
and const (except in CDataStream where we really need a setter).
2018-04-16 07:38:37 -06:00
Pieter Wuille 1315591c85
Make streams' read and write return void
The stream implementations had two cascading layers (the upper one
with operator<< and operator>>, and a lower one with read and write).
The lower layer's functions are never cascaded (nor should they, as
they should only be used from the higher layer), so make them return
void instead.
2018-04-16 07:38:37 -06:00
Pieter Wuille 670a7686a6
Remove unused ReadVersion and WriteVersion
CDataStream and CAutoFile had a ReadVersion and WriteVersion method
that was never used. Remove them.
2018-04-16 07:38:37 -06:00
Cory Fields d1c9ef8606
serialization: teach serializers variadics
Also add a variadic CDataStream ctor for ease-of-use.
2018-04-16 07:38:37 -06:00
Pavel Janík f0e9019223
Prevent -Wshadow warnings with gcc versions 4.8.5, 5.3.1 and 6.2.1.
Zcash: partial (ignoring src/test/script_tests.cpp due to merge conflicts)
2017-03-25 20:25:56 +13:00
Patrick Strateman e9d221e764 CDataStream::ignore Throw exception instead of assert on negative nSize.
Previously disk corruption would cause an assert instead of an exception.
2016-10-20 22:59:50 -07:00
Pieter Wuille f588c5edd6 Fix OOM bug: UTXO entries with invalid script length 2016-10-20 22:59:50 -07:00
Jack Grigg 6bffc46a87 Implement CSecureDataStream for streaming CKeyingMaterial 2016-09-28 13:44:53 +13:00
Cory Fields d7d187e8a4 allocators: split allocators and pagelocker
Pagelocker is only needed for secure (usually wallet) operations, so don't make
the zero-after-free allocator depend on it.
2015-03-20 12:23:44 +01:00
Cory Fields 1630219d90 openssl: abstract out OPENSSL_cleanse
This makes it easier for us to replace it if desired, since it's now only in
one spot. Also, it avoids the openssl include from allocators.h, which
essentially forced openssl to be included from every compilation unit.
2015-02-15 11:34:02 -05:00
Pavel Janík 5262fde0ec Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Michael Ford 78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Cory Fields fa7361907a boost: split stream classes out of serialize.h
serialization now has no dependencies.
2014-10-22 15:21:06 -04:00